added option to control agi script output

added new database field agi_output to servers table
added configurable AGI output option to call_log AGI scripts

git-svn-id: svn://192.168.202.10@172 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
mattf
2006-08-15 15:40:19 +00:00
parent ee479d83b8
commit 583c694f6c
6 changed files with 162 additions and 113 deletions
+72 -55
View File
@@ -1,6 +1,6 @@
#!/usr/bin/perl
#
# call_log.agi version 0.9 *DBI-version*
# call_log.agi version 0.10 *DBI-version*
#
# runs at the beginning and ending of every external call made and received
#
@@ -24,10 +24,10 @@
# 60622-0956 - Altered log for Zap client phones for consistent output
# 60718-1638 - changed to use DBI-DBD::mysql
# - changed to use /etc/astguiclient.conf for configs
# 60815-1023 - 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 = 'call_log.agi';
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
$year = ($year + 1900);
@@ -42,7 +42,6 @@ $now_date_epoch = time();
$now_date = "$year-$mon-$mday $hour:$min:$sec";
# default path to astguiclient configuration file:
$PATHconf = '/etc/astguiclient.conf';
@@ -81,20 +80,42 @@ 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;
$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++;
}
@@ -143,16 +164,12 @@ 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+(.*)$/)
{
@@ -190,16 +207,15 @@ while(<STDIN>) {
## until here.
}
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 ($V) {print STDERR "AGI Environment Dump: |$unique_id|$channel|$extension|$type|$callerid|\n";}
if ($AGILOG) {$agi_string = "AGI Variables: |$unique_id|$channel|$extension|$type|$callerid|"; &agi_output;}
if ( ($extension =~ /h/i) && (length($extension) < 3)) {$stage = 'END';}
else {$stage = 'START';}
@@ -207,13 +223,7 @@ else {$stage = 'START';}
### call start stage
if ($stage =~ /START/)
{
use DBI;
$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 ($V) {print STDERR "\nCALL STARTED\n";}
if ($M) {print STDERR "+++++ CALL LOG START : |$unique_id|$channel|$extension|$type|$callerid|$now_date\n";}
if ($AGILOG) {$agi_string = "+++++ CALL LOG START : $now_date"; &agi_output;}
if ($channel =~ /^SIP/) {$channel =~ s/-.*//gi;}
if ($channel =~ /^IAX2/) {$channel =~ s/\/\d+$//gi;}
@@ -222,15 +232,14 @@ if ($stage =~ /START/)
$channel_line = $channel;
$channel_line =~ s/^Zap\///gi;
$stmtA = "SELECT count(*) FROM phones where server_ip='$server_ip' and extension='$channel_line' and protocol='Zap';";
$stmtA = "SELECT count(*) FROM phones where server_ip='$VARserver_ip' and extension='$channel_line' and protocol='Zap';";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
@aryA = $sthA->fetchrow_array;
if($DB){print STDERR $aryA[0]," NEW Actions to send on server $server_ip $endless_loop\n";}
$is_client_phone = "$aryA[0]";
if ($AGILOG) {$agi_string = "Local Zap phone: $aryA[0]|$channel_line|"; &agi_output;}
$sthA->finish();
if ($V) {print STDERR "$is_client_phone|$channel_line|\n";}
if ($is_client_phone < 1)
{
@@ -262,9 +271,9 @@ if ($stage =~ /START/)
$extension = $SIP_ext;
}
$stmtA = "INSERT INTO call_log (uniqueid,channel,channel_group,type,server_ip,extension,number_dialed,start_time,start_epoch,end_time,end_epoch,length_in_sec,length_in_min,caller_code) values('$unique_id','$channel','$channel_group','$type','$server_ip','$extension','$number_dialed','$now_date','$now_date_epoch','','','','','$callerid')";
$stmtA = "INSERT INTO call_log (uniqueid,channel,channel_group,type,server_ip,extension,number_dialed,start_time,start_epoch,end_time,end_epoch,length_in_sec,length_in_min,caller_code) values('$unique_id','$channel','$channel_group','$type','$VARserver_ip','$extension','$number_dialed','$now_date','$now_date_epoch','','','','','$callerid')";
if ($V) {print STDERR "\n|$stmtA|\n";}
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
$affected_rows = $dbhA->do($stmtA);
$dbhA->disconnect();
@@ -274,15 +283,7 @@ if ($stage =~ /START/)
### call end stage
else
{
if ($V) {print STDERR "\nCALL HUNG UP\n";}
use DBI;
$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 ($V) {print STDERR "\nCONNECTED\n";}
if ($AGILOG) {$agi_string = "|CALL HUNG UP|"; &agi_output;}
### get uniqueid and start_epoch from the call_log table
$stmtA = "SELECT uniqueid,start_epoch FROM call_log where uniqueid='$unique_id';";
@@ -294,7 +295,7 @@ else
{
@aryA = $sthA->fetchrow_array;
$start_time = "$aryA[1]";
if ($V) {print STDERR $aryA[0],"|", $aryA[1],"\n";}
if ($AGILOG) {$agi_string = "|$aryA[0]|$aryA[1]|"; &agi_output;}
$rec_count++;
}
$sthA->finish();
@@ -305,20 +306,20 @@ else
$length_in_min = ($length_in_sec / 60);
$length_in_min = sprintf("%8.2f", $length_in_min);
if ($V) {print STDERR "\nQUERY done: start time = $start_time | sec: $length_in_sec | min: $length_in_min |\n";}
if ($AGILOG) {$agi_string = "QUERY done: start time = $start_time | sec: $length_in_sec | min: $length_in_min |"; &agi_output;}
$stmtA = "UPDATE call_log set end_time='$now_date',end_epoch='$now_date_epoch',length_in_sec=$length_in_sec,length_in_min='$length_in_min' where uniqueid='$unique_id'";
if ($V) {print STDERR "\n|$stmtA|\n";}
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
$affected_rows = $dbhA->do($stmtA);
}
$stmtA = "DELETE from live_inbound where uniqueid='$unique_id' and server_ip='$server_ip'";
if ($V) {print STDERR "\n|$stmtA|\n";}
$stmtA = "DELETE from live_inbound where uniqueid='$unique_id' and server_ip='$VARserver_ip'";
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
$affected_rows = $dbhA->do($stmtA);
##### BEGIN Park Log entry check and update #####
$stmtA = "SELECT UNIX_TIMESTAMP(parked_time),UNIX_TIMESTAMP(grab_time) FROM park_log where uniqueid='$unique_id' and server_ip='$server_ip' LIMIT 1;";
$stmtA = "SELECT UNIX_TIMESTAMP(parked_time),UNIX_TIMESTAMP(grab_time) FROM park_log where uniqueid='$unique_id' and server_ip='$VARserver_ip' LIMIT 1;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
@@ -328,14 +329,14 @@ else
@aryA = $sthA->fetchrow_array;
$parked_time = "$aryA[0]";
$grab_time = "$aryA[1]";
if ($V) {print STDERR $aryA[0],"|", $aryA[1],"\n";}
if ($AGILOG) {$agi_string = "|$aryA[0]|$aryA[1]|"; &agi_output;}
$rec_count++;
}
$sthA->finish();
if ($rec_count)
{
print STDERR "*****Entry found for $unique_id-$server_ip in park_log: $parked_time|$grab_time\n";
if ($AGILOG) {$agi_string = "*****Entry found for $unique_id-$VARserver_ip in park_log: $parked_time|$grab_time"; &agi_output;}
if ($parked_time > $grab_time)
{
$parked_sec=($now_date_epoch - $parked_time);
@@ -347,16 +348,32 @@ else
$parked_sec=($grab_time - $parked_time);
}
$stmtA = "UPDATE park_log set status='HUNGUP',hangup_time='$now_date',parked_sec='$parked_sec',talked_sec='$talked_sec' where uniqueid='$unique_id' and server_ip='$server_ip'";
$stmtA = "UPDATE park_log set status='HUNGUP',hangup_time='$now_date',parked_sec='$parked_sec',talked_sec='$talked_sec' where uniqueid='$unique_id' and server_ip='$VARserver_ip'";
$affected_rows = $dbhA->do($stmtA);
}
# else {print STDERR "*****No entry found for $unique_id-$server_ip in park_log\n";}
##### END Park Log entry check and update #####
$dbhA->disconnect();
if ($M) {print STDERR "+++++ CALL LOG HUNGUP: |$unique_id|$channel|$extension|$now_date|min: $length_in_min|\n";}
if ($AGILOG) {$agi_string = "+++++ CALL LOG HUNGUP: |$unique_id|$channel|$extension|$now_date|min: $length_in_min|"; &agi_output;}
}
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='';
}
+70 -52
View File
@@ -1,6 +1,6 @@
#!/usr/bin/perl
#
# call_log.agi version 0.7 *DBI-version*
# call_log.agi version 0.8 *DBI-version*
#
# runs at the beginning and ending of every external call made and received
#
@@ -22,10 +22,10 @@
# 60622-0957 - Altered log for Zap client phones for consistent output
# 60718-1638 - changed to use DBI-DBD::mysql
# - changed to use /etc/astguiclient.conf for configs
# 60815-1023 - 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 = 'call_logCID.agi';
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
$year = ($year + 1900);
@@ -40,8 +40,6 @@ $now_date_epoch = time();
$now_date = "$year-$mon-$mday $hour:$min:$sec";
# default path to astguiclient configuration file:
$PATHconf = '/etc/astguiclient.conf';
@@ -80,22 +78,42 @@ 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;
$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)
@@ -145,7 +163,7 @@ $|=1;
while(<STDIN>) {
chomp;
last unless length($_);
if ($V)
if ($AGILOG)
{
if (/^agi_(\w+)\:\s+(.*)$/)
{
@@ -181,16 +199,13 @@ 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";}
}
}
foreach $i (sort keys %AGI)
{
if ($AGILOG) {$agi_string = " -- $i = $AGI{$i}"; &agi_output;}
}
if ($V) {print STDERR "AGI Environment Dump: |$unique_id|$channel|$extension|$type|$callerid|\n";}
if ( ($extension =~ /h/i) && (length($extension) < 3)) {$stage = 'END';}
else {$stage = 'START';}
@@ -198,13 +213,7 @@ else {$stage = 'START';}
### call start stage
if ($stage =~ /START/)
{
use DBI;
$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 ($V) {print STDERR "\nCALL STARTED\n";}
if ($M) {print STDERR "+++++ CALL LOG START : |$unique_id|$channel|$extension|$type|$callerid|$now_date\n";}
if ($AGILOG) {$agi_string = "+++++ CALL LOG START : $now_date"; &agi_output;}
$is_client_phone = 0;
if ($channel =~ /^SIP/) {$channel =~ s/-.*//gi;}
@@ -214,15 +223,14 @@ if ($stage =~ /START/)
$channel_line = $channel;
$channel_line =~ s/^Zap\///gi;
$stmtA = "SELECT count(*) FROM phones where server_ip='$server_ip' and extension='$channel_line' and protocol='Zap';";
$stmtA = "SELECT count(*) FROM phones where server_ip='$VARserver_ip' and extension='$channel_line' and protocol='Zap';";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
@aryA = $sthA->fetchrow_array;
if($DB){print STDERR $aryA[0]," NEW Actions to send on server $server_ip $endless_loop\n";}
$is_client_phone = "$aryA[0]";
if ($AGILOG) {$agi_string = "Local Zap phone: $aryA[0]|$channel_line|"; &agi_output;}
$sthA->finish();
if ($V) {print STDERR "$is_client_phone|$channel_line|\n";}
if ($is_client_phone < 1)
{
@@ -254,9 +262,9 @@ if ($stage =~ /START/)
$extension = $SIP_ext;
}
$stmtA = "INSERT INTO call_log (uniqueid,channel,channel_group,type,server_ip,extension,number_dialed,start_time,start_epoch,end_time,end_epoch,length_in_sec,length_in_min,caller_code) values('$unique_id','$channel','$channel_group','$type','$server_ip','$extension','$number_dialed','$now_date','$now_date_epoch','','','','','$calleridname')";
$stmtA = "INSERT INTO call_log (uniqueid,channel,channel_group,type,server_ip,extension,number_dialed,start_time,start_epoch,end_time,end_epoch,length_in_sec,length_in_min,caller_code) values('$unique_id','$channel','$channel_group','$type','$VARserver_ip','$extension','$number_dialed','$now_date','$now_date_epoch','','','','','$calleridname')";
if ($V) {print STDERR "\n|$stmtA|\n";}
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
$affected_rows = $dbhA->do($stmtA);
$dbhA->disconnect();
@@ -266,15 +274,7 @@ if ($stage =~ /START/)
### call end stage
else
{
if ($V) {print STDERR "\nCALL HUNG UP\n";}
use DBI;
$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 ($V) {print STDERR "\nCONNECTED\n";}
if ($AGILOG) {$agi_string = "|CALL HUNG UP|"; &agi_output;}
### get uniqueid and start_epoch from the call_log table
$stmtA = "SELECT uniqueid,start_epoch FROM call_log where uniqueid='$unique_id';";
@@ -286,7 +286,7 @@ else
{
@aryA = $sthA->fetchrow_array;
$start_time = "$aryA[1]";
if ($V) {print STDERR $aryA[0],"|", $aryA[1],"\n";}
if ($AGILOG) {$agi_string = "|$aryA[0]|$aryA[1]|"; &agi_output;}
$rec_count++;
}
$sthA->finish();
@@ -297,20 +297,20 @@ else
$length_in_min = ($length_in_sec / 60);
$length_in_min = sprintf("%8.2f", $length_in_min);
if ($V) {print STDERR "\nQUERY done: start time = $start_time | sec: $length_in_sec | min: $length_in_min |\n";}
if ($AGILOG) {$agi_string = "QUERY done: start time = $start_time | sec: $length_in_sec | min: $length_in_min |"; &agi_output;}
$stmtA = "UPDATE call_log set end_time='$now_date',end_epoch='$now_date_epoch',length_in_sec=$length_in_sec,length_in_min='$length_in_min' where uniqueid='$unique_id'";
if ($V) {print STDERR "\n|$stmtA|\n";}
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
$affected_rows = $dbhA->do($stmtA);
}
$stmtA = "DELETE from live_inbound where uniqueid='$unique_id' and server_ip='$server_ip'";
if ($V) {print STDERR "\n|$stmtA|\n";}
$stmtA = "DELETE from live_inbound where uniqueid='$unique_id' and server_ip='$VARserver_ip'";
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
$affected_rows = $dbhA->do($stmtA);
##### BEGIN Park Log entry check and update #####
$stmtA = "SELECT UNIX_TIMESTAMP(parked_time),UNIX_TIMESTAMP(grab_time) FROM park_log where uniqueid='$unique_id' and server_ip='$server_ip' LIMIT 1;";
$stmtA = "SELECT UNIX_TIMESTAMP(parked_time),UNIX_TIMESTAMP(grab_time) FROM park_log where uniqueid='$unique_id' and server_ip='$VARserver_ip' LIMIT 1;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
@@ -320,14 +320,14 @@ else
@aryA = $sthA->fetchrow_array;
$parked_time = "$aryA[0]";
$grab_time = "$aryA[1]";
if ($V) {print STDERR $aryA[0],"|", $aryA[1],"\n";}
if ($AGILOG) {$agi_string = "|$aryA[0]|$aryA[1]|"; &agi_output;}
$rec_count++;
}
$sthA->finish();
if ($rec_count)
{
print STDERR "*****Entry found for $unique_id-$server_ip in park_log: $parked_time|$grab_time\n";
if ($AGILOG) {$agi_string = "*****Entry found for $unique_id-$VARserver_ip in park_log: $parked_time|$grab_time"; &agi_output;}
if ($parked_time > $grab_time)
{
$parked_sec=($now_date_epoch - $parked_time);
@@ -339,16 +339,34 @@ else
$parked_sec=($grab_time - $parked_time);
}
$stmtA = "UPDATE park_log set status='HUNGUP',hangup_time='$now_date',parked_sec='$parked_sec',talked_sec='$talked_sec' where uniqueid='$unique_id' and server_ip='$server_ip'";
$stmtA = "UPDATE park_log set status='HUNGUP',hangup_time='$now_date',parked_sec='$parked_sec',talked_sec='$talked_sec' where uniqueid='$unique_id' and server_ip='$VARserver_ip'";
$affected_rows = $dbhA->do($stmtA);
}
# else {print STDERR "*****No entry found for $unique_id-$server_ip in park_log\n";}
# else {print STDERR "*****No entry found for $unique_id-$VARserver_ip in park_log\n";}
##### END Park Log entry check and update #####
$dbhA->disconnect();
if ($M) {print STDERR "+++++ CALL LOG HUNGUP: |$unique_id|$channel|$extension|$now_date|min: $length_in_min|\n";}
if ($AGILOG) {$agi_string = "+++++ CALL LOG HUNGUP: |$unique_id|$channel|$extension|$now_date|min: $length_in_min|"; &agi_output;}
}
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='';
}
@@ -87,7 +87,8 @@ voicemail_dump_exten VARCHAR(20) NOT NULL default '85026666666666',
answer_transfer_agent VARCHAR(20) NOT NULL default '8365',
ext_context VARCHAR(20) NOT NULL default 'default',
sys_perf_log ENUM('Y','N') default 'N',
vd_server_logs ENUM('Y','N') default 'Y'
vd_server_logs ENUM('Y','N') default 'Y',
agi_output ENUM('NONE','STDERR','FILE','BOTH') default 'FILE'
);
+1
View File
@@ -1,2 +1,3 @@
ALTER TABLE servers ADD sys_perf_log ENUM('Y','N') default 'N';
ALTER TABLE servers ADD vd_server_logs ENUM('Y','N') default 'Y';
ALTER TABLE servers ADD agi_output ENUM('NONE','STDERR','FILE','BOTH') default 'FILE';
@@ -3,6 +3,7 @@
If you want to allow Consultative Transfers, a fronter to a closer, you can place CXFER as one of the number-to-dial presets and the proper dialstring will be sent to do a Local Consultative Transfer, then the agent can just LEAVE-3WAY-CALL and move on to their next call. If you want to allow Blind transfers of customers to a VICIDIAL AGI script for logging or an IVR, then place AXFER in the number-to-dial field. You can also specify an custom extension after the AXFER or CXFER, for instance if you want to do Internal Consultative transfers instead of Local you would put CXFER90009 in the number-to-dial field||
System Performance -<\/B> Setting this option to Y will enable logging of system performance stats for the server machine including system load, system processes and Asterisk channels in use. Default is N||
Server Logs -<\/B> Setting this option to Y will enable logging of all VICIDIAL related scripts to their text log files. Setting this to N will stop writing logs to files for these processes, also the screen logging of asterisk will be disabled if this is set to N when Asterisk is started. Default is Y||
AGI Output -<\/B> Setting this option to NONE will disable output from all VICIDIAL related AGI scripts. Setting this to STDERR will send the AGI output to the Asterisk CLI. Setting this to FILE will send the output to a file in the logs directory. Setting this to BOTH will send output to both the Asterisk CLI and a log file. Default is FILE
############################################################ CLIENT
+13 -2
View File
@@ -17,10 +17,11 @@
# 60620-1243 - Added variable filtering to eliminate SQL injection attack threat
# 60814-1402 - Added off-hour gmt values (India, Australia, etc...)
# 60814-1540 - Added system performance logging and script logging options
# 60815-1016 - Added agi output option
#
$version = '2.0.1';
$build = '60814-1540';
$build = '60815-1016';
require("dbconnect.php");
@@ -203,6 +204,8 @@ if (isset($_GET["sys_perf_log"])) {$sys_perf_log=$_GET["sys_perf_log"];}
elseif (isset($_POST["sys_perf_log"])) {$sys_perf_log=$_POST["sys_perf_log"];}
if (isset($_GET["vd_server_logs"])) {$vd_server_logs=$_GET["vd_server_logs"];}
elseif (isset($_POST["vd_server_logs"])) {$vd_server_logs=$_POST["vd_server_logs"];}
if (isset($_GET["agi_output"])) {$agi_output=$_GET["agi_output"];}
elseif (isset($_POST["agi_output"])) {$agi_output=$_POST["agi_output"];}
##### BEGIN VARIABLE FILTERING FOR SECURITY #####
@@ -292,6 +295,7 @@ $server_id = ereg_replace("[^-\_0-9a-zA-Z]","",$server_id);
$old_server_id = ereg_replace("[^-\_0-9a-zA-Z]","",$old_server_id);
$ext_context = ereg_replace("[^-\_0-9a-zA-Z]","",$ext_context);
$CoNfIrM = ereg_replace("[^-\_0-9a-zA-Z]","",$CoNfIrM);
$agi_output = ereg_replace("[^-\_0-9a-zA-Z]","",$agi_output);
### ALPHA-NUMERIC and spaces dots, commas, dashes, underscores
$phone_type = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$phone_type);
@@ -874,6 +878,11 @@ echo "<TABLE WIDTH=98% BGCOLOR=#E6E6E6 cellpadding=2 cellspacing=0><TR><TD ALIGN
<BR>
<B>Server Logs -</B> Setting this option to Y will enable logging of all VICIDIAL related scripts to their text log files. Setting this to N will stop writing logs to files for these processes, also the screen logging of asterisk will be disabled if this is set to N when Asterisk is started. Default is Y.
<BR>
<A NAME="servers-agi_output">
<BR>
<B>AGI Output -</B> Setting this option to NONE will disable output from all VICIDIAL related AGI scripts. Setting this to STDERR will send the AGI output to the Asterisk CLI. Setting this to FILE will send the output to a file in the logs directory. Setting this to BOTH will send output to both the Asterisk CLI and a log file. Default is FILE.
<BR><BR><BR><BR>
@@ -1311,6 +1320,7 @@ echo "<tr bgcolor=#B6D3FC><td align=right>VICIDIAL AD extension: </td><td align=
echo "<tr bgcolor=#B6D3FC><td align=right>Default Context: </td><td align=left><input type=text name=ext_context size=20 maxlength=20 value=\"$row[16]\">$NWB#servers-ext_context$NWE</td></tr>\n";
echo "<tr bgcolor=#B6D3FC><td align=right>System Performance: </td><td align=left><select size=1 name=sys_perf_log><option>Y</option><option>N</option><option selected>$row[17]</option></select>$NWB#servers-sys_perf_log$NWE</td></tr>\n";
echo "<tr bgcolor=#B6D3FC><td align=right>Server Logs: </td><td align=left><select size=1 name=vd_server_logs><option>Y</option><option>N</option><option selected>$row[18]</option></select>$NWB#servers-vd_server_logs$NWE</td></tr>\n";
echo "<tr bgcolor=#B6D3FC><td align=right>AGI Output: </td><td align=left><select size=1 name=agi_output><option>NONE</option><option>STDERR</option><option>FILE</option><option>BOTH</option><option selected>$row[19]</option></select>$NWB#servers-agi_output$NWE</td></tr>\n";
echo "<tr bgcolor=#B6D3FC><td align=center colspan=2><input type=submit name=submit VALUE=SUBMIT></td></tr>\n";
echo "</TABLE></center>\n";
@@ -1529,7 +1539,7 @@ if ($ADD==41)
{
echo "<br>SERVER MODIFIED: $server_ip\n";
$stmt="UPDATE servers set server_id='$server_id',server_description='$server_description',server_ip='$server_ip',active='$active',asterisk_version='$asterisk_version', max_vicidial_trunks='$max_vicidial_trunks', telnet_host='$telnet_host', telnet_port='$telnet_port', ASTmgrUSERNAME='$ASTmgrUSERNAME', ASTmgrSECRET='$ASTmgrSECRET', ASTmgrUSERNAMEupdate='$ASTmgrUSERNAMEupdate', ASTmgrUSERNAMElisten='$ASTmgrUSERNAMElisten', ASTmgrUSERNAMEsend='$ASTmgrUSERNAMEsend', local_gmt='$local_gmt', voicemail_dump_exten='$voicemail_dump_exten', answer_transfer_agent='$answer_transfer_agent', ext_context='$ext_context', sys_perf_log='$sys_perf_log', vd_server_logs='$vd_server_logs' where server_id='$old_server_id';";
$stmt="UPDATE servers set server_id='$server_id',server_description='$server_description',server_ip='$server_ip',active='$active',asterisk_version='$asterisk_version', max_vicidial_trunks='$max_vicidial_trunks', telnet_host='$telnet_host', telnet_port='$telnet_port', ASTmgrUSERNAME='$ASTmgrUSERNAME', ASTmgrSECRET='$ASTmgrSECRET', ASTmgrUSERNAMEupdate='$ASTmgrUSERNAMEupdate', ASTmgrUSERNAMElisten='$ASTmgrUSERNAMElisten', ASTmgrUSERNAMEsend='$ASTmgrUSERNAMEsend', local_gmt='$local_gmt', voicemail_dump_exten='$voicemail_dump_exten', answer_transfer_agent='$answer_transfer_agent', ext_context='$ext_context', sys_perf_log='$sys_perf_log', vd_server_logs='$vd_server_logs', agi_output='$agi_output' where server_id='$old_server_id';";
$rslt=mysql_query($stmt, $link);
}
}
@@ -1563,6 +1573,7 @@ echo "<tr bgcolor=#B6D3FC><td align=right>VICIDIAL AD extension: </td><td align=
echo "<tr bgcolor=#B6D3FC><td align=right>Default Context: </td><td align=left><input type=text name=ext_context size=20 maxlength=20 value=\"$row[16]\">$NWB#servers-ext_context$NWE</td></tr>\n";
echo "<tr bgcolor=#B6D3FC><td align=right>System Performance: </td><td align=left><select size=1 name=sys_perf_log><option>Y</option><option>N</option><option selected>$row[17]</option></select>$NWB#servers-sys_perf_log$NWE</td></tr>\n";
echo "<tr bgcolor=#B6D3FC><td align=right>Server Logs: </td><td align=left><select size=1 name=vd_server_logs><option>Y</option><option>N</option><option selected>$row[18]</option></select>$NWB#servers-vd_server_logs$NWE</td></tr>\n";
echo "<tr bgcolor=#B6D3FC><td align=right>AGI Output: </td><td align=left><select size=1 name=agi_output><option>NONE</option><option>STDERR</option><option>FILE</option><option>BOTH</option><option selected>$row[19]</option></select>$NWB#servers-agi_output$NWE</td></tr>\n";
echo "<tr bgcolor=#B6D3FC><td align=center colspan=2><input type=submit name=submit VALUE=SUBMIT></td></tr>\n";
echo "</TABLE></center>\n";