diff -Naur astcc.old/astcc.agi astcc.new/astcc.agi --- astcc.old/astcc.agi 2004-10-01 22:48:25.000000000 -0400 +++ astcc.new/astcc.agi 2005-01-07 19:40:27.243323223 -0500 @@ -357,6 +357,47 @@ return; } +sub checkexpired() { + my ($cardno) = @_; + my $carddata = &getcard($cardno); + return if ($carddata->{expiration} < 1); + $sth = $dbh->prepare("SELECT NOW()+0"); + $sth->execute; + my ($now) = $sth->fetchrow_array; + $sth->finish; + if ($now > $carddata->{expiration}) { + if ($quiet < 5 ) { + $AGI->stream_file("your"); + $AGI->stream_file("card-number"); + $AGI->stream_file("has-expired"); + $AGI->stream_file("vm-goodbye"); + } + exit(0); + } + return; +} + +sub setfirstuse() { + my ($cardno) = @_; + my $carddata = &getcard($cardno); + if ($carddata->{firstuse} < 1) { + $dbh->do("UPDATE cards SET firstuse=NULL WHERE number=" . + $dbh->quote($carddata->{number})); + } + &setexpiration($cardno); + return; +} + +sub setexpiration() { + my ($cardno) = @_; + if ($config{'expirationdaysafteruse'}) { + my $carddata = &getcard($cardno); + $dbh->do("UPDATE cards SET expiration= DATE_ADD('$carddata->{firstuse}', INTERVAL $config{'expirationdaysafteruse'} day) WHERE number=" . + $dbh->quote($carddata->{number})); + } + return; +} + sub setinuse() { my ($cardno, $inuse) = @_; my $carddata = &getcard($cardno); @@ -440,6 +481,7 @@ # # At this point we have a valid card number. # +&checkexpired($carddata->{number}); &checkinuse($carddata->{number}); &setinuse($carddata->{number}, 1); @@ -553,6 +595,7 @@ exit(0); } +&setfirstuse($carddata->{number}); my @trunks = split(/:/, $numdata->{trunks}); foreach $trunk (@trunks) { $res = &trytrunk($trunk, $phoneno, $maxmins);