Modified agi-VDADlisten_DTMF.agi script to work with /etc/astguiclient.conf and DBI
git-svn-id: svn://192.168.202.10@103 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
+60
-17
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/perl
|
||||
#
|
||||
# agi-VDADlisten_DTMF.agi version 0.1
|
||||
# agi-VDADlisten_DTMF.agi version 0.2 *DBI-version*
|
||||
#
|
||||
# To be initiated by an agent so during a call. Agent will click a PIN NUMBER
|
||||
# link on a web form webpage that will Originate a new call to this script
|
||||
@@ -23,6 +23,13 @@
|
||||
#
|
||||
# Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
|
||||
#
|
||||
# changes:
|
||||
# 60206-1434 first build
|
||||
# 60207-1205 - added database records entries/modifications
|
||||
# 60207-1507 - added ability to send AMs to campaign-defined message to leave
|
||||
# 60731-1536 - changed to use DBI-DBD::mysql
|
||||
# - changed to use /etc/astguiclient.conf for configs
|
||||
#
|
||||
|
||||
$V = 1; # set to 1 for verbose mode
|
||||
$M = 1; # set to 1 for 2 line messages mode
|
||||
@@ -36,10 +43,50 @@ $product_code = 'ABC';
|
||||
$user = '1234';
|
||||
$pin = '0';
|
||||
|
||||
### Make sure this file is in a path or put the absolute path to it
|
||||
require("/home/cron/AST_SERVER_conf.pl"); # local configuration file
|
||||
# default path to astguiclient configuration file:
|
||||
$PATHconf = '/etc/astguiclient.conf';
|
||||
|
||||
use Net::MySQL;
|
||||
open(conf, "$PATHconf") || die "can't open $PATHconf: $!\n";
|
||||
@conf = <conf>;
|
||||
close(conf);
|
||||
$i=0;
|
||||
foreach(@conf)
|
||||
{
|
||||
$line = $conf[$i];
|
||||
$line =~ s/ |>|\n|\r|\t|\#.*|;.*//gi;
|
||||
if ( ($line =~ /^PATHhome/) && ($CLIhome < 1) )
|
||||
{$PATHhome = $line; $PATHhome =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^PATHlogs/) && ($CLIlogs < 1) )
|
||||
{$PATHlogs = $line; $PATHlogs =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^PATHagi/) && ($CLIagi < 1) )
|
||||
{$PATHagi = $line; $PATHagi =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^PATHweb/) && ($CLIweb < 1) )
|
||||
{$PATHweb = $line; $PATHweb =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^PATHsounds/) && ($CLIsounds < 1) )
|
||||
{$PATHsounds = $line; $PATHsounds =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^PATHmonitor/) && ($CLImonitor < 1) )
|
||||
{$PATHmonitor = $line; $PATHmonitor =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^VARserver_ip/) && ($CLIserver_ip < 1) )
|
||||
{$VARserver_ip = $line; $VARserver_ip =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^VARDB_server/) && ($CLIDB_server < 1) )
|
||||
{$VARDB_server = $line; $VARDB_server =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^VARDB_database/) && ($CLIDB_database < 1) )
|
||||
{$VARDB_database = $line; $VARDB_database =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^VARDB_user/) && ($CLIDB_user < 1) )
|
||||
{$VARDB_user = $line; $VARDB_user =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^VARDB_pass/) && ($CLIDB_pass < 1) )
|
||||
{$VARDB_pass = $line; $VARDB_pass =~ s/.*=//gi;}
|
||||
if ( ($line =~ /^VARDB_port/) && ($CLIDB_port < 1) )
|
||||
{$VARDB_port = $line; $VARDB_port =~ s/.*=//gi;}
|
||||
$i++;
|
||||
}
|
||||
|
||||
# Customized Variables
|
||||
$server_ip = $VARserver_ip; # Asterisk server IP
|
||||
|
||||
if (!$VARDB_port) {$VARDB_port='3306';}
|
||||
|
||||
use DBI;
|
||||
use Asterisk::AGI;
|
||||
$AGI = new Asterisk::AGI;
|
||||
|
||||
@@ -130,26 +177,22 @@ while(<STDIN>) {
|
||||
|
||||
&enter_pin_number;
|
||||
|
||||
if (!$DB_port) {$DB_port='3306';}
|
||||
|
||||
my $dbhA = Net::MySQL->new(hostname=>"$DB_server", database=>"$DB_database", user=>"$DB_user", password=>"$DB_pass", port => "$DB_port") or die "Couldn't connect to database: $DB_server - $DB_database\n";
|
||||
$dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass")
|
||||
or die "Couldn't connect to database: " . DBI->errstr;
|
||||
|
||||
if (length($pin) < 4) {$AGI->stream_file('buzz');}
|
||||
else {$AGI->stream_file('ding');}
|
||||
|
||||
### insert a record into the vicidial_list_pins table
|
||||
$stmtA = "INSERT INTO vicidial_list_pins (entry_time,phone_number,lead_id,campaign_id,product_code,user,digits) values('$SQLdate','$phone_number','$lead_id','$campaign_id','$product_code','$user','$pin');";
|
||||
$dbhA->query($stmtA);
|
||||
$dbhA->query("select LAST_INSERT_ID() LIMIT 1;");
|
||||
if ($dbhA->has_selected_record)
|
||||
{
|
||||
$iterA=$dbhA->create_record_iterator;
|
||||
while ($recordA = $iterA->each)
|
||||
{$insert_pin_id = "$recordA->[0]";}
|
||||
}
|
||||
if($M){print STDERR "\n|$stmtA|$insert_pin_id|\n";}
|
||||
|
||||
$dbhA->close;
|
||||
$affected_rows = $dbhA->do($stmtA);
|
||||
|
||||
$insert_pin_id = $dbhA->{'mysql_insertid'};
|
||||
|
||||
if($M){print STDERR "\n|$stmtA|$insert_pin_id|$affected_rows|\n";}
|
||||
|
||||
$dbhA->disconnect();
|
||||
|
||||
exit;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user