[Asterisk-cvs] astcc astcc.agi,1.11,1.12

markster at lists.digium.com markster at lists.digium.com
Sat Mar 12 00:56:28 CST 2005


Update of /usr/cvsroot/astcc
In directory mongoose.digium.com:/tmp/cvs-serv17408

Modified Files:
	astcc.agi 
Log Message:
Allow expiration checking (bug #3269)


Index: astcc.agi
===================================================================
RCS file: /usr/cvsroot/astcc/astcc.agi,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- astcc.agi	2 Oct 2004 02:48:25 -0000	1.11
+++ astcc.agi	12 Mar 2005 06:52:38 -0000	1.12
@@ -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);




More information about the svn-commits mailing list