[Asterisk-Users] DISA and AGI: authenticate by caller ID?
Matthew Simpson
matthew at txlink.net
Thu Jul 1 10:08:56 MST 2004
I'm having trouble getting an AGI exec command to spawn app_disa. The
script executes properly, but does not spawn DISA. The CLI gives no helpful
clues. Am I doing the exec incorrectly?
I want to have a way to authenticate callers to the extension by Caller
ID... if their caller ID is in my database and set to active, they can call
out. [like a calling card but auth'd by CID instead of PIN].
Here is my dialplan:
1234, 1, agi(ldusers.agi)
1234, 2, Hangup
Here is my code:
#!/usr/bin/perl
#
use Asterisk::AGI;
use DBI;
$db = "dbname";
$host = "hostname";
$port = "3306";
$userid = "dbuser";
$password = "dpasswd";
$connectionInfo = "DBI:mysql:database=$db;$host:$port";
$dbh = DBI->connect($connectionInfo,$userid,$password);
$AGI = new Asterisk::AGI;
my %input = $AGI->ReadParse();
$AGI->answer();
if (my $callerid = $input{'callerid'}) {
$AGI->say_digits($callerid);
$query = "SELECT active FROM cids WHERE cid=$callerid"; #
active should be 1 if the caller ID is found and set active
$sth = $dbh->prepare($query);
$sth->execute();
$sth->bind_columns(undef, \$active);
$sth->fetch();
if($active)
$AGI->exec('DISA','no-password|disa');
}
$AGI->hangup();
exit;
More information about the asterisk-users
mailing list