changed VD_amd and park_CID to use AGI output options from servers table
git-svn-id: svn://192.168.202.10@174 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/perl
|
||||
#
|
||||
# VD_amd.agi version 0.4 *DBI-version*
|
||||
# VD_amd.agi version 0.5 *DBI-version*
|
||||
#
|
||||
# NOTE: This script is only needed with app_amd enabled systems
|
||||
#
|
||||
@@ -27,14 +27,26 @@
|
||||
# 60207-1507 added ability to send AMs to campaign-defined message to leave
|
||||
# 60731-1407 - changed to use DBI-DBD::mysql
|
||||
# - changed to use /etc/astguiclient.conf for configs
|
||||
# 60815-1310 - added output options check from database
|
||||
#
|
||||
|
||||
$script = 'VD_amd.agi';
|
||||
|
||||
$V = 0; # set to 1 for verbose mode
|
||||
$M = 0; # set to 1 for 2 line messages mode
|
||||
$A = 1; # set to 1 for AMD output messages mode
|
||||
$AMD_LOG = 1; # set to 1 for logfile
|
||||
|
||||
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
|
||||
$year = ($year + 1900);
|
||||
$mon++;
|
||||
if ($mon < 10) {$mon = "0$mon";}
|
||||
if ($mday < 10) {$mday = "0$mday";}
|
||||
if ($hour < 10) {$Fhour = "0$hour";}
|
||||
if ($min < 10) {$min = "0$min";}
|
||||
if ($sec < 10) {$sec = "0$sec";}
|
||||
|
||||
$now_date_epoch = time();
|
||||
$now_date = "$year-$mon-$mday $hour:$min:$sec";
|
||||
|
||||
# default path to astguiclient configuration file:
|
||||
$PATHconf = '/etc/astguiclient.conf';
|
||||
|
||||
@@ -73,42 +85,45 @@ foreach(@conf)
|
||||
$i++;
|
||||
}
|
||||
|
||||
# Customized Variables
|
||||
$server_ip = $VARserver_ip; # Asterisk server IP
|
||||
|
||||
if (!$VARDB_port) {$VARDB_port='3306';}
|
||||
if (!$AGILOGfile) {$AGILOGfile = "$PATHlogs/agiout.$year-$mon-$mday";}
|
||||
|
||||
use DBI;
|
||||
use Asterisk::AGI;
|
||||
$AGI = new Asterisk::AGI;
|
||||
|
||||
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
|
||||
$year = ($year + 1900);
|
||||
$mon++;
|
||||
if ($mon < 10) {$mon = "0$mon";}
|
||||
if ($mday < 10) {$mday = "0$mday";}
|
||||
if ($hour < 10) {$Fhour = "0$hour";}
|
||||
if ($min < 10) {$min = "0$min";}
|
||||
if ($sec < 10) {$sec = "0$sec";}
|
||||
|
||||
$dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass")
|
||||
or die "Couldn't connect to database: " . DBI->errstr;
|
||||
|
||||
$now_date_epoch = time();
|
||||
$now_date = "$year-$mon-$mday $hour:$min:$sec";
|
||||
$start_time=$now_date;
|
||||
$CIDdate = "$mon$mday$hour$min$sec";
|
||||
$tsSQLdate = "$year$mon$mday$hour$min$sec";
|
||||
$SQLdate = "$year-$mon-$mday $hour:$min:$sec";
|
||||
$SQLdateBEGIN = $SQLdate;
|
||||
### Grab Server values from the database
|
||||
$stmtA = "SELECT agi_output FROM servers where server_ip = '$VARserver_ip';";
|
||||
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
|
||||
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
|
||||
$sthArows=$sthA->rows;
|
||||
$rec_count=0;
|
||||
while ($sthArows > $rec_count)
|
||||
{
|
||||
$AGILOG = '0';
|
||||
@aryA = $sthA->fetchrow_array;
|
||||
$DBagi_output = "$aryA[0]";
|
||||
if ($DBagi_output =~ /STDERR/) {$AGILOG = '1';}
|
||||
if ($DBagi_output =~ /FILE/) {$AGILOG = '2';}
|
||||
if ($DBagi_output =~ /BOTH/) {$AGILOG = '3';}
|
||||
$rec_count++;
|
||||
}
|
||||
$sthA->finish();
|
||||
|
||||
|
||||
### begin parsing run-time options ###
|
||||
if (length($ARGV[0])>1)
|
||||
{
|
||||
if ($V) {print STDERR "Perl Environment Dump:\n";}
|
||||
if ($AGILOG) {$agi_string = "Perl Environment Dump:"; &agi_output;}
|
||||
$i=0;
|
||||
while ($#ARGV >= $i)
|
||||
{
|
||||
$args = "$args $ARGV[$i]";
|
||||
if ($V) {print STDERR "$i|$ARGV[$i]|\n";}
|
||||
if ($AGILOG) {$agi_string = "$i|$ARGV[$i]"; &agi_output;}
|
||||
$i++;
|
||||
}
|
||||
|
||||
@@ -142,17 +157,14 @@ if ($V) {print STDERR "Perl Environment Dump:\n";}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($V) {print "no command line options set\n";}
|
||||
}
|
||||
|
||||
|
||||
$|=1;
|
||||
while(<STDIN>)
|
||||
{
|
||||
chomp;
|
||||
last unless length($_);
|
||||
if ($V)
|
||||
if ($AGILOG)
|
||||
{
|
||||
if (/^agi_(\w+)\:\s+(.*)$/)
|
||||
{
|
||||
@@ -191,35 +203,32 @@ if ( (
|
||||
}
|
||||
|
||||
|
||||
if ($V)
|
||||
{
|
||||
if ($AGILOG) {$agi_string = "AGI Environment Dump:"; &agi_output;}
|
||||
|
||||
if ($V) {print STDERR "AGI Environment Dump:\n";}
|
||||
foreach $i (sort keys %AGI) {
|
||||
if ($V) {print STDERR " -- $i = $AGI{$i}\n";}
|
||||
}
|
||||
foreach $i (sort keys %AGI)
|
||||
{
|
||||
if ($AGILOG) {$agi_string = " -- $i = $AGI{$i}"; &agi_output;}
|
||||
}
|
||||
|
||||
if ($AGILOG) {$agi_string = "AGI Variables: |$unique_id|$channel|$extension|$type|$callerid|"; &agi_output;}
|
||||
|
||||
|
||||
$VDADcampaign='';
|
||||
$VDADphone='';
|
||||
$VDADphone_code='';
|
||||
|
||||
if ($V) {print STDERR "AGI Environment Dump: |$unique_id|$channel|$extension|$type|$callerid|$calleridname|$priority|\n";}
|
||||
|
||||
|
||||
$callerid =~ s/\"//gi;
|
||||
$CIDlead_id = $callerid;
|
||||
$CIDlead_id = substr($CIDlead_id, 11, 9);
|
||||
$CIDlead_id = ($CIDlead_id + 0);
|
||||
$VD_lead_id = $CIDlead_id;
|
||||
|
||||
if ($V) {print STDERR "\nVD_amd : $callerid $channel $priority\n";}
|
||||
if ($M) {print STDERR "+++++ VD amd START : |$unique_id|$channel|$extension|$type|$callerid|$CIDlead_id|$now_date|$AST_ver|$priority|$calleridname|\n";}
|
||||
if ($AGILOG) {$agi_string = "+++++ VD amd START : |$CIDlead_id|$now_date|$AST_ver|$priority|$calleridname|"; &agi_output;}
|
||||
|
||||
|
||||
if ( ($channel =~ /Local/i) && ($AST_ver !~ /^1\.0\.8|^1\.0\.9/) )
|
||||
{
|
||||
if ($M) {print STDERR "+++++ VDAD START LOCAL CHANNEL: EXITING- $priority\n";}
|
||||
if ($AGILOG) {$agi_string = "+++++ VDAD START LOCAL CHANNEL: EXITING- $priority"; &agi_output;}
|
||||
if ($priority > 2) {sleep(1);}
|
||||
exit;
|
||||
}
|
||||
@@ -229,7 +238,10 @@ exit;
|
||||
$AMDSTATUS = $AGI->get_variable(AMDSTATUS);
|
||||
$AMDCAUSE = $AGI->get_variable(AMDCAUSE);
|
||||
|
||||
if ($A) {print STDERR "AAAAA AMD results: |$AMDSTATUS|$AMDCAUSE|\n";}
|
||||
if ($A)
|
||||
{
|
||||
if ($AGILOG) {$agi_string = "AAAAA AMD results: |$AMDSTATUS|$AMDCAUSE|"; &agi_output;}
|
||||
}
|
||||
|
||||
# AAAAA AMD results: |AMD_PERSON|AMD_HUMAN-300-300|
|
||||
# AAAAA AMD results: |AMD_MACHINE|AMD_LONGGREETING-1500-1500|
|
||||
@@ -248,7 +260,10 @@ if ($AMD_LOG)
|
||||
########## AMD says it's a person so exit and go on to transfer scripts ##########
|
||||
if ($AMDSTATUS =~ /PERSON|NOTSURE|HANGUP/)
|
||||
{
|
||||
if ($A) {print STDERR " AMD exiting\n";}
|
||||
if ($A)
|
||||
{
|
||||
if ($AGILOG) {$agi_string = " AMD exiting"; &agi_output;}
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
@@ -258,13 +273,10 @@ else
|
||||
########## AMD says it's a machine so modify statuses and hangup call ##########
|
||||
########## something will go here later for leaving a message on AMs ##########
|
||||
|
||||
$dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass")
|
||||
or die "Couldn't connect to database: " . DBI->errstr;
|
||||
|
||||
|
||||
########## FIND ext_context from the servers table ##########
|
||||
$stmtA = "SELECT ext_context FROM servers where server_ip = '$server_ip';";
|
||||
if($M){print STDERR "\n\n|$stmtA|\n";}
|
||||
$stmtA = "SELECT ext_context FROM servers where server_ip = '$VARserver_ip';";
|
||||
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
|
||||
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
|
||||
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
|
||||
$sthArows=$sthA->rows;
|
||||
@@ -281,7 +293,7 @@ $sthA->finish();
|
||||
|
||||
########## FIND vicidial_auto_calls record ##########
|
||||
$stmtA = "SELECT campaign_id,phone_code,phone_number FROM vicidial_auto_calls where callerid='$callerid' order by auto_call_id desc limit 1;";
|
||||
if($M){print STDERR "\n\n|$stmtA|\n";}
|
||||
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
|
||||
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
|
||||
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
|
||||
$sthArows=$sthA->rows;
|
||||
@@ -299,18 +311,18 @@ $sthA->finish();
|
||||
|
||||
########## UPDATE vicidial_list ##########
|
||||
$stmtA = "UPDATE vicidial_list set status='A' where lead_id = '$VD_lead_id';";
|
||||
if($M){print STDERR "\n\n|$stmtA|\n";}
|
||||
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
|
||||
$affected_rows = $dbhA->do($stmtA);
|
||||
if ($M) {print STDERR "-- VDAD vicidial_list update: |$affected_rows|$VD_lead_id\n";}
|
||||
if ($AGILOG) {$agi_string = "-- VDAD vicidial_list update: |$affected_rows|$VD_lead_id"; &agi_output;}
|
||||
|
||||
########## DELETE vicidial_auto_calls entry ##########
|
||||
$stmtA = "DELETE FROM vicidial_auto_calls where callerid='$callerid' order by auto_call_id desc limit 1;";
|
||||
$affected_rows = $dbhA->do($stmtA);
|
||||
if ($M) {print STDERR "-- VDAC record deleted: |$affected_rows| |$VD_lead_id|$uniqueid|$VD_callerid|$server_ip\n";}
|
||||
if ($AGILOG) {$agi_string = "-- VDAC record deleted: |$affected_rows| |$VD_lead_id|$uniqueid|$VD_callerid"; &agi_output;}
|
||||
|
||||
########## FIND AND UPDATE vicidial_log ##########
|
||||
$stmtA = "SELECT start_epoch FROM vicidial_log where uniqueid='$uniqueid' and lead_id='$VD_lead_id' order by call_date desc limit 1;";
|
||||
if($M){print STDERR "\n\n|$stmtA|\n";}
|
||||
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
|
||||
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
|
||||
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
|
||||
$sthArows=$sthA->rows;
|
||||
@@ -325,25 +337,25 @@ $sthA->finish();
|
||||
|
||||
if (!$epc_countCUSTDATA)
|
||||
{
|
||||
if($M){print STDERR "\nVD amd: no VDL record found: $uniqueid $calleridname $VD_lead_id $uniqueid\n";}
|
||||
if ($AGILOG) {$agi_string = "no VDL record found: $uniqueid $calleridname $VD_lead_id $uniqueid"; &agi_output;}
|
||||
$end_epoch = ($now_date_epoch + 3);
|
||||
$stmtA = "INSERT INTO vicidial_log (uniqueid,lead_id,campaign_id,call_date,start_epoch,status,phone_code,phone_number,user,processed,length_in_sec,end_epoch) values('$uniqueid','$VD_lead_id','$VD_campaign_id','$now_date','$now_date_epoch','A','$VD_phone_code','$VD_phone_number','VDAD','N','3','$end_epoch')";
|
||||
if($M){print STDERR "\n|$stmtA|\n";}
|
||||
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
|
||||
$affected_rows = $dbhA->do($stmtA);
|
||||
}
|
||||
else
|
||||
{
|
||||
$VD_seconds = ($now_date_epoch - $VD_start_epoch);
|
||||
$stmtA = "UPDATE vicidial_log set status='A',end_epoch='$now_date_epoch',length_in_sec='$VD_seconds' where uniqueid='$uniqueid' and lead_id='$VD_lead_id' order by call_date desc limit 1;";
|
||||
if($M){print STDERR "\n\n|$stmtA|\n";}
|
||||
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
|
||||
$affected_rows = $dbhA->do($stmtA);
|
||||
if ($M) {print STDERR "-- VDAD vicidial_log update: |$affected_rows|$uniqueid|\n";}
|
||||
if ($AGILOG) {$agi_string = "-- VDAD vicidial_log update: |$affected_rows|$uniqueid|"; &agi_output;}
|
||||
}
|
||||
|
||||
|
||||
### Grab vmail forward message values from the database
|
||||
$stmtA = "SELECT am_message_exten,amd_send_to_vmx FROM vicidial_campaigns where campaign_id = '$VD_campaign_id';";
|
||||
if($M){print STDERR "\n\n|$stmtA|\n";}
|
||||
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
|
||||
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
|
||||
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
|
||||
$sthArows=$sthA->rows;
|
||||
@@ -357,21 +369,21 @@ while ($sthArows > $epc_countCUSTDATA)
|
||||
}
|
||||
$sthA->finish();
|
||||
|
||||
if ($M) {print STDERR "-- AMD campaign values: |$VD_campaign_id|$DB_am_message_exten|$DB_amd_send_to_vmx|\n";}
|
||||
if ($AGILOG) {$agi_string = "-- AMD campaign values: |$VD_campaign_id|$DB_am_message_exten|$DB_amd_send_to_vmx|"; &agi_output;}
|
||||
|
||||
if ( ($DB_amd_send_to_vmx =~ /Y/) && (length($DB_am_message_exten) > 0) )
|
||||
{
|
||||
$stmtA = "UPDATE vicidial_log set status='AM' where uniqueid='$uniqueid' and lead_id='$VD_lead_id' order by call_date desc limit 1;";
|
||||
if($M){print STDERR "\n\n|$stmtA|\n";}
|
||||
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
|
||||
$affected_rows = $dbhA->do($stmtA);
|
||||
if ($M) {print STDERR "-- VDAD vicidial_log AM update: |$affected_rows|$uniqueid|\n";}
|
||||
if ($AGILOG) {$agi_string = "-- VDAD vicidial_log AM update: |$affected_rows|$uniqueid|"; &agi_output;}
|
||||
|
||||
$stmtA = "UPDATE vicidial_list set status='AM' where lead_id='$VD_lead_id';";
|
||||
if($M){print STDERR "\n\n|$stmtA|\n";}
|
||||
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
|
||||
$affected_rows = $dbhA->do($stmtA);
|
||||
if ($M) {print STDERR "-- VDAD vicidial_list AM update: |$affected_rows|$uniqueid|\n";}
|
||||
if ($AGILOG) {$agi_string = "-- VDAD vicidial_list AM update: |$affected_rows|$uniqueid|"; &agi_output;}
|
||||
|
||||
print STDERR "\nexiting the AMD app, transferring call to $DB_am_message_exten";
|
||||
if ($AGILOG) {$agi_string = "exiting the AMD app, transferring call to $DB_am_message_exten"; &agi_output;}
|
||||
print "SET CONTEXT $ext_context\n";
|
||||
checkresult($result);
|
||||
print "SET EXTENSION $DB_am_message_exten\n";
|
||||
@@ -414,3 +426,20 @@ sub checkresult {
|
||||
$fail++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sub agi_output
|
||||
{
|
||||
if ($AGILOG >=2)
|
||||
{
|
||||
### open the log file for writing ###
|
||||
open(Lout, ">>$AGILOGfile")
|
||||
|| die "Can't open $AGILOGfile: $!\n";
|
||||
print Lout "$now_date|$script|$agi_string\n";
|
||||
close(Lout);
|
||||
}
|
||||
### send to STDERR writing ###
|
||||
if ( ($AGILOG == '1') || ($AGILOG == '3') )
|
||||
{print STDERR "$now_date|$script|$agi_string\n";}
|
||||
$agi_string='';
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/perl
|
||||
#
|
||||
# park_CID.agi version 0.2 *DBI-version*
|
||||
# park_CID.agi version 0.3 *DBI-version*
|
||||
#
|
||||
# runs before the park extension to populate the parked_channels entry with the channel's callerid
|
||||
#
|
||||
@@ -17,10 +17,21 @@
|
||||
# changes:
|
||||
# 60731-1423 - changed to use DBI-DBD::mysql
|
||||
# - changed to use /etc/astguiclient.conf for configs
|
||||
# 60815-1256 - added output options check from database
|
||||
#
|
||||
|
||||
$V = 0; # set to 1 for verbose mode
|
||||
$M = 1; # set to 1 for 2 line messages mode
|
||||
$script = 'park_CID.agi';
|
||||
|
||||
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
|
||||
$year = ($year + 1900);
|
||||
$mon++;
|
||||
if ($mon < 10) {$mon = "0$mon";}
|
||||
if ($mday < 10) {$mday = "0$mday";}
|
||||
if ($hour < 10) {$Fhour = "0$hour";}
|
||||
if ($min < 10) {$min = "0$min";}
|
||||
if ($sec < 10) {$sec = "0$sec";}
|
||||
$now_date_epoch = time();
|
||||
$now_date = "$year-$mon-$mday $hour:$min:$sec";
|
||||
|
||||
# default path to astguiclient configuration file:
|
||||
$PATHconf = '/etc/astguiclient.conf';
|
||||
@@ -60,36 +71,43 @@ foreach(@conf)
|
||||
$i++;
|
||||
}
|
||||
|
||||
# Customized Variables
|
||||
$server_ip = $VARserver_ip; # Asterisk server IP
|
||||
|
||||
if (!$VARDB_port) {$VARDB_port='3306';}
|
||||
if (!$AGILOGfile) {$AGILOGfile = "$PATHlogs/agiout.$year-$mon-$mday";}
|
||||
|
||||
use DBI;
|
||||
|
||||
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
|
||||
$year = ($year + 1900);
|
||||
$mon++;
|
||||
if ($mon < 10) {$mon = "0$mon";}
|
||||
if ($mday < 10) {$mday = "0$mday";}
|
||||
if ($hour < 10) {$Fhour = "0$hour";}
|
||||
if ($min < 10) {$min = "0$min";}
|
||||
if ($sec < 10) {$sec = "0$sec";}
|
||||
|
||||
$now_date_epoch = time();
|
||||
$now_date = "$year-$mon-$mday $hour:$min:$sec";
|
||||
$dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass")
|
||||
or die "Couldn't connect to database: " . DBI->errstr;
|
||||
|
||||
### Grab Server values from the database
|
||||
$stmtA = "SELECT agi_output FROM servers where server_ip = '$VARserver_ip';";
|
||||
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
|
||||
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
|
||||
$sthArows=$sthA->rows;
|
||||
$rec_count=0;
|
||||
while ($sthArows > $rec_count)
|
||||
{
|
||||
$AGILOG = '0';
|
||||
@aryA = $sthA->fetchrow_array;
|
||||
$DBagi_output = "$aryA[0]";
|
||||
if ($DBagi_output =~ /STDERR/) {$AGILOG = '1';}
|
||||
if ($DBagi_output =~ /FILE/) {$AGILOG = '2';}
|
||||
if ($DBagi_output =~ /BOTH/) {$AGILOG = '3';}
|
||||
$rec_count++;
|
||||
}
|
||||
$sthA->finish();
|
||||
|
||||
|
||||
### begin parsing run-time options ###
|
||||
if (length($ARGV[0])>1)
|
||||
{
|
||||
if ($V) {print STDERR "Perl Environment Dump:\n";}
|
||||
if ($AGILOG) {$agi_string = "Perl Environment Dump:"; &agi_output;}
|
||||
$i=0;
|
||||
while ($#ARGV >= $i)
|
||||
{
|
||||
$args = "$args $ARGV[$i]";
|
||||
if ($V) {print STDERR "$i|$ARGV[$i]|\n";}
|
||||
if ($AGILOG) {$agi_string = "$i|$ARGV[$i]"; &agi_output;}
|
||||
$i++;
|
||||
}
|
||||
if ($args =~ />| |\"/i)
|
||||
@@ -130,16 +148,13 @@ if ($V) {print STDERR "Perl Environment Dump:\n";}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($V) {print "no command line options set\n";}
|
||||
}
|
||||
|
||||
|
||||
$|=1;
|
||||
while(<STDIN>) {
|
||||
chomp;
|
||||
last unless length($_);
|
||||
if ($V)
|
||||
if ($AGILOG)
|
||||
{
|
||||
if (/^agi_(\w+)\:\s+(.*)$/)
|
||||
{
|
||||
@@ -172,35 +187,43 @@ while(<STDIN>) {
|
||||
}
|
||||
}
|
||||
|
||||
if ($V)
|
||||
{
|
||||
if ($AGILOG) {$agi_string = "AGI Environment Dump:"; &agi_output;}
|
||||
|
||||
if ($V) {print STDERR "AGI Environment Dump:\n";}
|
||||
foreach $i (sort keys %AGI) {
|
||||
if ($V) {print STDERR " -- $i = $AGI{$i}\n";}
|
||||
}
|
||||
}
|
||||
|
||||
if ($V) {print STDERR "AGI Environment Dump: |$unique_id|$channel|$extension|$type|$callerid|\n";}
|
||||
foreach $i (sort keys %AGI)
|
||||
{
|
||||
if ($AGILOG) {$agi_string = " -- $i = $AGI{$i}"; &agi_output;}
|
||||
}
|
||||
|
||||
|
||||
if ($V) {print STDERR "\nCALL BEING PARKED\n";}
|
||||
if ($M) {print STDERR "+++++ CALL PARK START : |$unique_id|$channel|$extension|$type|$callerid|$now_date\n";}
|
||||
if ($AGILOG) {$agi_string = "AGI Variables: |$unique_id|$channel|$extension|$type|$callerid|"; &agi_output;}
|
||||
|
||||
if ($AGILOG) {$agi_string = "CALL BEING PARKED"; &agi_output;}
|
||||
|
||||
|
||||
$dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass")
|
||||
or die "Couldn't connect to database: " . DBI->errstr;
|
||||
|
||||
|
||||
$stmtA = "UPDATE parked_channels set channel_group='$callerid' where server_ip='$server_ip' and channel='$channel';";
|
||||
if ($V) {print STDERR "\n|$stmtA|\n";}
|
||||
$stmtA = "UPDATE parked_channels set channel_group='$callerid' where server_ip='$VARserver_ip' and channel='$channel';";
|
||||
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
|
||||
$affected_rows = $dbhA->do($stmtA);
|
||||
if ($M) {print STDERR "-- Park record updated: |$affected_rows| |$callerid|$channel|$server_ip\n";}
|
||||
if ($AGILOG) {$agi_string = "-- Park record updated: |$affected_rows| |$callerid|$channel|$VARserver_ip"; &agi_output;}
|
||||
|
||||
$dbhA->disconnect();
|
||||
|
||||
|
||||
|
||||
if ($V) {print STDERR "\nAll Done Exiting:\n";}
|
||||
|
||||
exit;
|
||||
|
||||
|
||||
|
||||
sub agi_output
|
||||
{
|
||||
if ($AGILOG >=2)
|
||||
{
|
||||
### open the log file for writing ###
|
||||
open(Lout, ">>$AGILOGfile")
|
||||
|| die "Can't open $AGILOGfile: $!\n";
|
||||
print Lout "$now_date|$script|$agi_string\n";
|
||||
close(Lout);
|
||||
}
|
||||
### send to STDERR writing ###
|
||||
if ( ($AGILOG == '1') || ($AGILOG == '3') )
|
||||
{print STDERR "$now_date|$script|$agi_string\n";}
|
||||
$agi_string='';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user