comment cleanup and removal of depricated call_park AGI scripts
git-svn-id: svn://192.168.202.10@136 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
@@ -1,224 +0,0 @@
|
||||
#!/usr/bin/perl
|
||||
#
|
||||
# call_park.agi
|
||||
#
|
||||
# runs when a call is to be parked for pickup of customer service
|
||||
#
|
||||
# You need to put lines similar to those below in your extensions.conf file:
|
||||
#
|
||||
# ;inbound calls:
|
||||
# exten => 101,1,AGI(call_park.agi,IN_800_TPP_CS-----8775154104-----Inbound TPP 800 CS-----park-----HANGUP----------)
|
||||
#
|
||||
#
|
||||
# Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
|
||||
#
|
||||
|
||||
$V = 1; # set to 1 for verbose mode
|
||||
$M = 1; # set to 1 for 2 line messages mode
|
||||
|
||||
### 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
|
||||
|
||||
|
||||
($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";
|
||||
|
||||
|
||||
|
||||
### begin parsing run-time options ###
|
||||
if (length($ARGV[0])>1)
|
||||
{
|
||||
if ($V) {print STDERR "Perl Environment Dump:\n";}
|
||||
$i=0;
|
||||
while ($#ARGV >= $i)
|
||||
{
|
||||
$args = "$args $ARGV[$i]";
|
||||
if ($V) {print STDERR "$i|$ARGV[$i]|\n";}
|
||||
$i++;
|
||||
}
|
||||
|
||||
### list of command-line array arguments:
|
||||
@ARGV_vars = split(/-----/, $ARGV[0]);
|
||||
|
||||
$channel_group = $ARGV_vars[0];
|
||||
$inbound_number = $ARGV_vars[1];
|
||||
$parked_by = $ARGV_vars[2];
|
||||
$park_extension = $ARGV_vars[3];
|
||||
$status = $ARGV_vars[4];
|
||||
$comment_d = $ARGV_vars[5];
|
||||
$comment_e = $ARGV_vars[6];
|
||||
|
||||
|
||||
if ($args =~ /--help/i)
|
||||
{
|
||||
print "allowed run time options:\n [-q] = quiet\n [-t] = test\n [-debug] = verbose debug messages\n\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($args =~ /-V/i)
|
||||
{
|
||||
$V=1;
|
||||
}
|
||||
if ($args =~ /-debug/i)
|
||||
{
|
||||
$DG=1;
|
||||
}
|
||||
if ($args =~ /-dbAVS/i)
|
||||
{
|
||||
$DGA=1;
|
||||
}
|
||||
if ($args =~ /-q/i)
|
||||
{
|
||||
$q=1;
|
||||
$Q=1;
|
||||
}
|
||||
if ($args =~ /-t/i)
|
||||
{
|
||||
$TEST=1;
|
||||
$T=1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($V) {print "no command line options set\n";}
|
||||
}
|
||||
|
||||
$|=1;
|
||||
while(<STDIN>) {
|
||||
chomp;
|
||||
last unless length($_);
|
||||
if ($V)
|
||||
{
|
||||
if (/^agi_(\w+)\:\s+(.*)$/)
|
||||
{
|
||||
$AGI{$1} = $2;
|
||||
}
|
||||
}
|
||||
|
||||
if (/^agi_uniqueid\:\s+(.*)$/) {$unique_id = $1;}
|
||||
if (/^agi_channel\:\s+(.*)$/) {$channel = $1;}
|
||||
if (/^agi_extension\:\s+(.*)$/) {$extension = $1;}
|
||||
if (/^agi_type\:\s+(.*)$/) {$type = $1;}
|
||||
if (/^agi_callerid\:\s+(.*)$/) {$callerid = $1;}
|
||||
if (/^agi_calleridname\:\s+(.*)$/) {$calleridname = $1;}
|
||||
if ( (!$callerid) or ($callerid =~ /unknown/) )
|
||||
{$callerid = $calleridname;}
|
||||
|
||||
### allow for ANI being sent with the DNIS "*3125551212*9999*"
|
||||
if ($extension =~ /^\*\d\d\d\d\d\d\d\d\d\d\*/)
|
||||
{
|
||||
$callerid = $extension;
|
||||
$callerid =~ s/\*\d\d\d\d\*$//gi;
|
||||
$callerid =~ s/\*\d\d\d\d$//gi;
|
||||
$callerid =~ s/^\*//gi;
|
||||
$extension =~ s/^\*\d\d\d\d\d\d\d\d\d\d\*//gi;
|
||||
$extension =~ s/\*$//gi;
|
||||
|
||||
### set the callerid if sent with DNIS
|
||||
print "SET CALLERID $callerid\n";
|
||||
checkresult($result);
|
||||
}
|
||||
}
|
||||
|
||||
if ($V)
|
||||
{
|
||||
|
||||
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";}
|
||||
|
||||
if ($extension =~ /h/i) {$stage = 'END';}
|
||||
else {$stage = 'START';}
|
||||
|
||||
### call start stage
|
||||
if ($status !~ /HANGUP/)
|
||||
{
|
||||
|
||||
if ($V) {print STDERR "\nCALL PARK STARTED\n";}
|
||||
if ($M) {print STDERR "+++++ CALL PARK START : |$unique_id|$channel|$extension|$type|$callerid|$now_date\n";}
|
||||
|
||||
if ($channel =~ /^SIP/) {$channel =~ s/-.*//gi;}
|
||||
# if ($channel =~ /^Zap\//) {$channel =~ s/-\d$//gi;}
|
||||
|
||||
use Net::MySQL;
|
||||
|
||||
if (!$DB_port) {$DB_port='3306';}
|
||||
|
||||
my $mysql = 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";
|
||||
|
||||
|
||||
$stmtA = "INSERT INTO parked_channels (channel,server_ip,channel_group,extension,parked_by,parked_time) values('$channel','$server_ip','$channel_group','$park_extension','$callerid','$now_date')";
|
||||
if ($V) {print STDERR "\n|$stmtA|\n";}
|
||||
$mysql->query($stmtA) or die "Couldn't execute query:\n";
|
||||
|
||||
|
||||
$stmtA = "INSERT INTO park_log (uniqueid,status,channel,server_ip,parked_time,channel_group) values('$unique_id','PARKED','$channel','$server_ip','$now_date','$channel_group')";
|
||||
if ($V) {print STDERR "\n|$stmtA|\n";}
|
||||
$mysql->query($stmtA) or die "Couldn't execute query:\n";
|
||||
|
||||
$mysql->close;
|
||||
}
|
||||
|
||||
|
||||
### call end stage
|
||||
else
|
||||
{
|
||||
|
||||
if ($V) {print STDERR "\nCALL INBOUND HUNG UP\n";}
|
||||
|
||||
use Net::MySQL;
|
||||
|
||||
if (!$DB_port) {$DB_port='3306';}
|
||||
|
||||
my $dbh = 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";
|
||||
|
||||
|
||||
if ($V) {print STDERR "\nCONNECTED: deleting parked_channels record for $unique_id on $server_ip\n";}
|
||||
|
||||
$stmtA = "DELETE from parked_channels where channel='$channel' and server_ip='$server_ip'";
|
||||
$dbh->query($stmtA) or die "Couldn't execute query:\n";
|
||||
$dbh->close;
|
||||
|
||||
|
||||
if ($M) {print STDERR "+++++ CALL PARK HUNGUP: |$unique_id|\n";}
|
||||
}
|
||||
if ($V) {print STDERR "\nAll Done Call Park Exiting:\n";}
|
||||
|
||||
exit;
|
||||
|
||||
|
||||
|
||||
|
||||
sub checkresult {
|
||||
my ($res) = @_;
|
||||
my $retval;
|
||||
$tests++;
|
||||
chomp $res;
|
||||
if ($res =~ /^200/) {
|
||||
$res =~ /result=(-?\d+)/;
|
||||
if (!length($1)) {
|
||||
print STDERR "FAIL ($res)\n";
|
||||
$fail++;
|
||||
} else {
|
||||
print STDERR "PASS ($1)\n";
|
||||
$pass++;
|
||||
}
|
||||
} else {
|
||||
print STDERR "FAIL (unexpected result '$res')\n";
|
||||
$fail++;
|
||||
}
|
||||
}
|
||||
@@ -1,223 +0,0 @@
|
||||
#!/usr/bin/perl
|
||||
#
|
||||
# call_park.agi
|
||||
#
|
||||
# runs when a call is to be parked for pickup of customer service
|
||||
#
|
||||
# You need to put lines similar to those below in your extensions.conf file:
|
||||
#
|
||||
# ;inbound calls:
|
||||
# exten => 101,1,AGI(call_park.agi,IN_800_TPP_CS-----8775154104-----Inbound TPP 800 CS-----park-----HANGUP----------)
|
||||
#
|
||||
#
|
||||
# Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
|
||||
#
|
||||
|
||||
$V = 1; # set to 1 for verbose mode
|
||||
$M = 1; # set to 1 for 2 line messages mode
|
||||
|
||||
### 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
|
||||
|
||||
|
||||
($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";
|
||||
|
||||
|
||||
|
||||
### begin parsing run-time options ###
|
||||
if (length($ARGV[0])>1)
|
||||
{
|
||||
if ($V) {print STDERR "Perl Environment Dump:\n";}
|
||||
$i=0;
|
||||
while ($#ARGV >= $i)
|
||||
{
|
||||
$args = "$args $ARGV[$i]";
|
||||
if ($V) {print STDERR "$i|$ARGV[$i]|\n";}
|
||||
$i++;
|
||||
}
|
||||
|
||||
### list of command-line array arguments:
|
||||
@ARGV_vars = split(/-----/, $ARGV[0]);
|
||||
|
||||
$channel_group = $ARGV_vars[0];
|
||||
$inbound_number = $ARGV_vars[1];
|
||||
$parked_by = $ARGV_vars[2];
|
||||
$park_extension = $ARGV_vars[3];
|
||||
$status = $ARGV_vars[4];
|
||||
$comment_d = $ARGV_vars[5];
|
||||
$comment_e = $ARGV_vars[6];
|
||||
|
||||
|
||||
if ($args =~ /--help/i)
|
||||
{
|
||||
print "allowed run time options:\n [-q] = quiet\n [-t] = test\n [-debug] = verbose debug messages\n\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($args =~ /-V/i)
|
||||
{
|
||||
$V=1;
|
||||
}
|
||||
if ($args =~ /-debug/i)
|
||||
{
|
||||
$DG=1;
|
||||
}
|
||||
if ($args =~ /-dbAVS/i)
|
||||
{
|
||||
$DGA=1;
|
||||
}
|
||||
if ($args =~ /-q/i)
|
||||
{
|
||||
$q=1;
|
||||
$Q=1;
|
||||
}
|
||||
if ($args =~ /-t/i)
|
||||
{
|
||||
$TEST=1;
|
||||
$T=1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($V) {print "no command line options set\n";}
|
||||
}
|
||||
|
||||
$|=1;
|
||||
while(<STDIN>) {
|
||||
chomp;
|
||||
last unless length($_);
|
||||
if ($V)
|
||||
{
|
||||
if (/^agi_(\w+)\:\s+(.*)$/)
|
||||
{
|
||||
$AGI{$1} = $2;
|
||||
}
|
||||
}
|
||||
|
||||
if (/^agi_uniqueid\:\s+(.*)$/) {$unique_id = $1;}
|
||||
if (/^agi_channel\:\s+(.*)$/) {$channel = $1;}
|
||||
if (/^agi_extension\:\s+(.*)$/) {$extension = $1;}
|
||||
if (/^agi_type\:\s+(.*)$/) {$type = $1;}
|
||||
if (/^agi_callerid\:\s+(.*)$/) {$callerid = $1;}
|
||||
if (/^agi_calleridname\:\s+(.*)$/) {$calleridname = $1;}
|
||||
if ( (!$callerid) or ($callerid =~ /unknown/) )
|
||||
{$callerid = $calleridname;}
|
||||
|
||||
### allow for ANI being sent with the DNIS "*3125551212*9999*"
|
||||
if ($extension =~ /^\*\d\d\d\d\d\d\d\d\d\d\*/)
|
||||
{
|
||||
$callerid = $extension;
|
||||
$callerid =~ s/\*\d\d\d\d\*$//gi;
|
||||
$callerid =~ s/\*\d\d\d\d$//gi;
|
||||
$callerid =~ s/^\*//gi;
|
||||
$extension =~ s/^\*\d\d\d\d\d\d\d\d\d\d\*//gi;
|
||||
$extension =~ s/\*$//gi;
|
||||
|
||||
### set the callerid if sent with DNIS
|
||||
print "SET CALLERID $callerid\n";
|
||||
checkresult($result);
|
||||
}
|
||||
}
|
||||
|
||||
if ($V)
|
||||
{
|
||||
|
||||
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";}
|
||||
|
||||
if ($extension =~ /h/i) {$stage = 'END';}
|
||||
else {$stage = 'START';}
|
||||
|
||||
### call start stage
|
||||
if ($status !~ /HANGUP/)
|
||||
{
|
||||
|
||||
if ($V) {print STDERR "\nCALL PARK STARTED\n";}
|
||||
if ($M) {print STDERR "+++++ CALL PARK START : |$unique_id|$channel|$extension|$type|$callerid|$now_date\n";}
|
||||
|
||||
if ($channel =~ /^SIP/) {$channel =~ s/-.*//gi;}
|
||||
# if ($channel =~ /^Zap\//) {$channel =~ s/-\d$//gi;}
|
||||
if (length($callerid)<10) {$callerid = $parked_by;}
|
||||
|
||||
use Net::MySQL;
|
||||
|
||||
if (!$DB_port) {$DB_port='3306';}
|
||||
|
||||
my $mysql = 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";
|
||||
|
||||
$stmtA = "INSERT INTO parked_channels (channel,server_ip,channel_group,extension,parked_by,parked_time) values('$channel','$server_ip','$channel_group','$park_extension','$callerid','$now_date')";
|
||||
if ($V) {print STDERR "\n|$stmtA|\n";}
|
||||
$mysql->query($stmtA) or die "Couldn't execute query:\n";
|
||||
|
||||
|
||||
$stmtA = "INSERT INTO park_log (uniqueid,status,channel,server_ip,parked_time,channel_group) values('$unique_id','PARKED','$channel','$server_ip','$now_date','$channel_group')";
|
||||
if ($V) {print STDERR "\n|$stmtA|\n";}
|
||||
$mysql->query($stmtA) or die "Couldn't execute query:\n";
|
||||
|
||||
$mysql->close;
|
||||
}
|
||||
|
||||
|
||||
### call end stage
|
||||
else
|
||||
{
|
||||
|
||||
if ($V) {print STDERR "\nCALL INBOUND HUNG UP\n";}
|
||||
|
||||
use Net::MySQL;
|
||||
|
||||
if (!$DB_port) {$DB_port='3306';}
|
||||
|
||||
my $dbh = 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";
|
||||
|
||||
if ($V) {print STDERR "\nCONNECTED: deleting parked_channels record for $unique_id on $server_ip\n";}
|
||||
|
||||
$stmtA = "DELETE from parked_channels where channel='$channel' and server_ip='$server_ip'";
|
||||
$dbh->query($stmtA) or die "Couldn't execute query:\n";
|
||||
$dbh->close;
|
||||
|
||||
|
||||
if ($M) {print STDERR "+++++ CALL PARK HUNGUP: |$unique_id|\n";}
|
||||
}
|
||||
if ($V) {print STDERR "\nAll Done Call Park Exiting:\n";}
|
||||
|
||||
exit;
|
||||
|
||||
|
||||
|
||||
|
||||
sub checkresult {
|
||||
my ($res) = @_;
|
||||
my $retval;
|
||||
$tests++;
|
||||
chomp $res;
|
||||
if ($res =~ /^200/) {
|
||||
$res =~ /result=(-?\d+)/;
|
||||
if (!length($1)) {
|
||||
print STDERR "FAIL ($res)\n";
|
||||
$fail++;
|
||||
} else {
|
||||
print STDERR "PASS ($1)\n";
|
||||
$pass++;
|
||||
}
|
||||
} else {
|
||||
print STDERR "FAIL (unexpected result '$res')\n";
|
||||
$fail++;
|
||||
}
|
||||
}
|
||||
@@ -1,230 +0,0 @@
|
||||
#!/usr/bin/perl
|
||||
#
|
||||
# call_park_I.agi
|
||||
#
|
||||
# runs when a call is to be parked for pickup of customer service
|
||||
# This version is for calls send from one server to another over Crossover PRI T
|
||||
#
|
||||
# You need to put lines similar to those below in your extensions.conf file:
|
||||
#
|
||||
# ;inbound calls:
|
||||
#exten => _90009.,1,AGI(call_park_I.agi,${EXTEN})
|
||||
#exten => _90009.,2,Answer ; Answer the line
|
||||
#exten => _90009.,3,Playback(park) ; Play a welcome message & music
|
||||
#exten => _90009.,4,AGI(call_park_I.agi,HANGUP-----${EXTEN})
|
||||
#
|
||||
#
|
||||
# Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
|
||||
#
|
||||
|
||||
$V = 1; # set to 1 for verbose mode
|
||||
$M = 1; # set to 1 for 2 line messages mode
|
||||
|
||||
### 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
|
||||
|
||||
|
||||
($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";
|
||||
|
||||
|
||||
|
||||
### begin parsing run-time options ###
|
||||
if (length($ARGV[0])>1)
|
||||
{
|
||||
if ($V) {print STDERR "Perl Environment Dump:\n";}
|
||||
$i=0;
|
||||
while ($#ARGV >= $i)
|
||||
{
|
||||
$args = "$args $ARGV[$i]";
|
||||
if ($V) {print STDERR "$i|$ARGV[$i]|\n";}
|
||||
$i++;
|
||||
}
|
||||
|
||||
### list of command-line array arguments:
|
||||
@ARGV_vars = split(/-----/, $ARGV[0]);
|
||||
$status = $ARGV_vars[1];
|
||||
|
||||
|
||||
if ($args =~ /--help/i)
|
||||
{
|
||||
print "allowed run time options:\n [-q] = quiet\n [-t] = test\n [-debug] = verbose debug messages\n\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($args =~ /-V/i)
|
||||
{
|
||||
$V=1;
|
||||
}
|
||||
if ($args =~ /-debug/i)
|
||||
{
|
||||
$DG=1;
|
||||
}
|
||||
if ($args =~ /-dbAVS/i)
|
||||
{
|
||||
$DGA=1;
|
||||
}
|
||||
if ($args =~ /-q/i)
|
||||
{
|
||||
$q=1;
|
||||
$Q=1;
|
||||
}
|
||||
if ($args =~ /-t/i)
|
||||
{
|
||||
$TEST=1;
|
||||
$T=1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($V) {print "no command line options set\n";}
|
||||
}
|
||||
|
||||
use Asterisk::AGI;
|
||||
$AGI = new Asterisk::AGI;
|
||||
|
||||
$|=1;
|
||||
while(<STDIN>) {
|
||||
chomp;
|
||||
last unless length($_);
|
||||
if ($V)
|
||||
{
|
||||
if (/^agi_(\w+)\:\s+(.*)$/)
|
||||
{
|
||||
$AGI{$1} = $2;
|
||||
}
|
||||
}
|
||||
|
||||
if (/^agi_uniqueid\:\s+(.*)$/) {$unique_id = $1;}
|
||||
if (/^agi_channel\:\s+(.*)$/) {$channel = $1;}
|
||||
if (/^agi_extension\:\s+(.*)$/) {$extension = $1;}
|
||||
if (/^agi_type\:\s+(.*)$/) {$type = $1;}
|
||||
if (/^agi_callerid\:\s+(.*)$/) {$callerid = $1;}
|
||||
if (/^agi_calleridname\:\s+(.*)$/) {$calleridname = $1;}
|
||||
if ( (!$callerid) or ($callerid =~ /unknown/) )
|
||||
{$callerid = $calleridname;}
|
||||
|
||||
### allow for internal PRI transfer data string "90009*CL_uk3survy_*8301*10000123*universal***"
|
||||
if ($extension =~ /^900\d\d\*/)
|
||||
{
|
||||
@EXT_vars = split(/\*/, $extension);
|
||||
|
||||
$referring_extension = $EXT_vars[0]; # initial extension sent
|
||||
$channel_group = $EXT_vars[1]; # name of the parked group
|
||||
$inbound_number = $EXT_vars[2]; # extension to send call to after parsing
|
||||
$parked_by = $EXT_vars[3]; # leadID
|
||||
$park_extension = $EXT_vars[4]; # filename of the on-hold music file
|
||||
$comment_d = $EXT_vars[5]; # N/A
|
||||
$comment_e = $EXT_vars[6]; # N/A
|
||||
|
||||
### set the callerid to the filename of the audio for on-hold
|
||||
print "SET CALLERID $park_extension\n";
|
||||
checkresult($result);
|
||||
print STDERR "callerID changed: $park_extension\n";
|
||||
}
|
||||
}
|
||||
|
||||
if ($V)
|
||||
{
|
||||
|
||||
if ($V) {print STDERR "AGI Environment Dump:\n";}
|
||||
foreach $i (sort keys %AGI) {
|
||||
if ($V) {print STDERR " -- $i = $AGI{$i}\n";}
|
||||
}
|
||||
}
|
||||
|
||||
$AGI->stream_file('beep');
|
||||
|
||||
if ($V) {print STDERR "AGI Environment Dump: |$unique_id|$channel|$extension|$type|$callerid|\n";}
|
||||
|
||||
if ( ($extension =~ /h/i) && (length($extension) < 4)) {$stage = 'END';}
|
||||
else {$stage = 'START';}
|
||||
|
||||
### call start stage
|
||||
if ($status !~ /HANGUP/)
|
||||
{
|
||||
|
||||
if ($V) {print STDERR "\nCALL PARK STARTED\n";}
|
||||
if ($M) {print STDERR "+++++ CALL PARK START : |$unique_id|$channel|$extension|$type|$callerid-$pin|$now_date\n";}
|
||||
|
||||
if ($channel =~ /^SIP/) {$channel =~ s/-.*//gi;}
|
||||
# if ($channel =~ /^Zap\//) {$channel =~ s/-\d$//gi;}
|
||||
|
||||
use Net::MySQL;
|
||||
|
||||
if (!$DB_port) {$DB_port='3306';}
|
||||
|
||||
my $mysql = 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";
|
||||
|
||||
$stmtA = "INSERT INTO parked_channels (channel,server_ip,channel_group,extension,parked_by,parked_time) values('$channel','$server_ip','$channel_group','$park_extension','$parked_by','$now_date')";
|
||||
if ($V) {print STDERR "\n|$stmtA|\n";}
|
||||
$mysql->query($stmtA) or die "Couldn't execute query:\n";
|
||||
|
||||
|
||||
$stmtA = "INSERT INTO park_log (uniqueid,status,channel,server_ip,parked_time,channel_group) values('$unique_id','PARKED','$channel','$server_ip','$now_date','$channel_group')";
|
||||
if ($V) {print STDERR "\n|$stmtA|\n";}
|
||||
$mysql->query($stmtA) or die "Couldn't execute query:\n";
|
||||
|
||||
|
||||
$mysql->close;
|
||||
}
|
||||
|
||||
|
||||
### call end stage
|
||||
else
|
||||
{
|
||||
|
||||
if ($V) {print STDERR "\nCALL INBOUND HUNG UP\n";}
|
||||
|
||||
use Net::MySQL;
|
||||
|
||||
if (!$DB_port) {$DB_port='3306';}
|
||||
|
||||
my $dbh = 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";
|
||||
|
||||
if ($V) {print STDERR "\nCONNECTED: deleting parked_channels record for $unique_id on $server_ip\n";}
|
||||
|
||||
$stmtA = "DELETE from parked_channels where channel='$channel' and server_ip='$server_ip'";
|
||||
$dbh->query($stmtA) or die "Couldn't execute query:\n";
|
||||
$dbh->close;
|
||||
|
||||
|
||||
if ($M) {print STDERR "+++++ CALL PARK HUNGUP: |$unique_id|\n";}
|
||||
}
|
||||
if ($V) {print STDERR "\nAll Done Call Park Exiting:\n";}
|
||||
|
||||
exit;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
sub checkresult {
|
||||
my ($res) = @_;
|
||||
my $retval;
|
||||
$tests++;
|
||||
chomp $res;
|
||||
if ($res =~ /^200/) {
|
||||
$res =~ /result=(-?\d+)/;
|
||||
if (!length($1)) {
|
||||
print STDERR "FAIL ($res)\n";
|
||||
$fail++;
|
||||
} else {
|
||||
print STDERR "PASS ($1)\n";
|
||||
$pass++;
|
||||
}
|
||||
} else {
|
||||
print STDERR "FAIL (unexpected result '$res')\n";
|
||||
$fail++;
|
||||
}
|
||||
}
|
||||
@@ -1,307 +0,0 @@
|
||||
#!/usr/bin/perl
|
||||
#
|
||||
# call_park_L.agi
|
||||
#
|
||||
# runs when a call is to be parked for pickup of customer service
|
||||
#
|
||||
# You need to put lines similar to those below in your extensions.conf file:
|
||||
#
|
||||
# ;inbound calls:
|
||||
# exten => 101,1,AGI(call_park_L.agi,IN_800_TPP_CS-----8775154104-----Inbound TPP 800 CS-----park-----HANGUP----------)
|
||||
#
|
||||
#
|
||||
# Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
|
||||
#
|
||||
|
||||
$V = 1; # set to 1 for verbose mode
|
||||
$M = 1; # set to 1 for 2 line messages mode
|
||||
|
||||
### 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
|
||||
|
||||
|
||||
($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";
|
||||
|
||||
|
||||
|
||||
### begin parsing run-time options ###
|
||||
if (length($ARGV[0])>1)
|
||||
{
|
||||
if ($V) {print STDERR "Perl Environment Dump:\n";}
|
||||
$i=0;
|
||||
while ($#ARGV >= $i)
|
||||
{
|
||||
$args = "$args $ARGV[$i]";
|
||||
if ($V) {print STDERR "$i|$ARGV[$i]|\n";}
|
||||
$i++;
|
||||
}
|
||||
|
||||
### list of command-line array arguments:
|
||||
@ARGV_vars = split(/-----/, $ARGV[0]);
|
||||
|
||||
$channel_group = $ARGV_vars[0];
|
||||
$inbound_number = $ARGV_vars[1];
|
||||
$parked_by = $ARGV_vars[2];
|
||||
$park_extension = $ARGV_vars[3];
|
||||
$status = $ARGV_vars[4];
|
||||
$comment_d = $ARGV_vars[5];
|
||||
$comment_e = $ARGV_vars[6];
|
||||
|
||||
|
||||
if ($args =~ /--help/i)
|
||||
{
|
||||
print "allowed run time options:\n [-q] = quiet\n [-t] = test\n [-debug] = verbose debug messages\n\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($args =~ /-V/i)
|
||||
{
|
||||
$V=1;
|
||||
}
|
||||
if ($args =~ /-debug/i)
|
||||
{
|
||||
$DG=1;
|
||||
}
|
||||
if ($args =~ /-dbAVS/i)
|
||||
{
|
||||
$DGA=1;
|
||||
}
|
||||
if ($args =~ /-q/i)
|
||||
{
|
||||
$q=1;
|
||||
$Q=1;
|
||||
}
|
||||
if ($args =~ /-t/i)
|
||||
{
|
||||
$TEST=1;
|
||||
$T=1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($V) {print "no command line options set\n";}
|
||||
}
|
||||
|
||||
use Asterisk::AGI;
|
||||
$AGI = new Asterisk::AGI;
|
||||
|
||||
$|=1;
|
||||
while(<STDIN>) {
|
||||
chomp;
|
||||
last unless length($_);
|
||||
if ($V)
|
||||
{
|
||||
if (/^agi_(\w+)\:\s+(.*)$/)
|
||||
{
|
||||
$AGI{$1} = $2;
|
||||
}
|
||||
}
|
||||
|
||||
if (/^agi_uniqueid\:\s+(.*)$/) {$unique_id = $1;}
|
||||
if (/^agi_channel\:\s+(.*)$/) {$channel = $1;}
|
||||
if (/^agi_extension\:\s+(.*)$/) {$extension = $1;}
|
||||
if (/^agi_type\:\s+(.*)$/) {$type = $1;}
|
||||
if (/^agi_callerid\:\s+(.*)$/) {$callerid = $1;}
|
||||
if (/^agi_calleridname\:\s+(.*)$/) {$calleridname = $1;}
|
||||
if ( (!$callerid) or ($callerid =~ /unknown/) )
|
||||
{$callerid = $calleridname;}
|
||||
|
||||
### allow for ANI being sent with the DNIS "*3125551212*9999*"
|
||||
if ($extension =~ /^\*\d\d\d\d\d\d\d\d\d\d\*/)
|
||||
{
|
||||
$callerid = $extension;
|
||||
$callerid =~ s/\*\d\d\d\d\*$//gi;
|
||||
$callerid =~ s/\*\d\d\d\d$//gi;
|
||||
$callerid =~ s/^\*//gi;
|
||||
$extension =~ s/^\*\d\d\d\d\d\d\d\d\d\d\*//gi;
|
||||
$extension =~ s/\*$//gi;
|
||||
|
||||
### set the callerid if sent with DNIS
|
||||
print "SET CALLERID $callerid\n";
|
||||
checkresult($result);
|
||||
}
|
||||
}
|
||||
|
||||
if ($V)
|
||||
{
|
||||
|
||||
if ($V) {print STDERR "AGI Environment Dump:\n";}
|
||||
foreach $i (sort keys %AGI) {
|
||||
if ($V) {print STDERR " -- $i = $AGI{$i}\n";}
|
||||
}
|
||||
}
|
||||
|
||||
$AGI->stream_file('beep');
|
||||
|
||||
if ($V) {print STDERR "AGI Environment Dump: |$unique_id|$channel|$extension|$type|$callerid|\n";}
|
||||
|
||||
if ($extension =~ /h/i) {$stage = 'END';}
|
||||
else {$stage = 'START';}
|
||||
|
||||
### call start stage
|
||||
if ($status !~ /HANGUP/)
|
||||
{
|
||||
|
||||
if ($V) {print STDERR "\nCALL PARK STARTED\n";}
|
||||
|
||||
&enter_pin_number;
|
||||
|
||||
if ($M) {print STDERR "+++++ CALL PARK START : |$unique_id|$channel|$extension|$type|$callerid-$pin|$now_date\n";}
|
||||
|
||||
if ($channel =~ /^SIP/) {$channel =~ s/-.*//gi;}
|
||||
# if ($channel =~ /^Zap\//) {$channel =~ s/-\d$//gi;}
|
||||
if (length($callerid)<10) {$callerid = $parked_by;}
|
||||
if (length($pin)>0) {$callerid = ($pin + 0);}
|
||||
|
||||
use Net::MySQL;
|
||||
|
||||
if (!$DB_port) {$DB_port='3306';}
|
||||
|
||||
my $mysql = 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";
|
||||
|
||||
$stmtA = "INSERT INTO parked_channels (channel,server_ip,channel_group,extension,parked_by,parked_time) values('$channel','$server_ip','$channel_group','$park_extension','$callerid','$now_date')";
|
||||
if ($V) {print STDERR "\n|$stmtA|\n";}
|
||||
$mysql->query($stmtA) or die "Couldn't execute query:\n";
|
||||
|
||||
|
||||
$stmtA = "INSERT INTO park_log (uniqueid,status,channel,server_ip,parked_time,channel_group) values('$unique_id','PARKED','$channel','$server_ip','$now_date','$channel_group')";
|
||||
if ($V) {print STDERR "\n|$stmtA|\n";}
|
||||
$mysql->query($stmtA) or die "Couldn't execute query:\n";
|
||||
|
||||
|
||||
$mysql->close;
|
||||
}
|
||||
|
||||
|
||||
### call end stage
|
||||
else
|
||||
{
|
||||
|
||||
if ($V) {print STDERR "\nCALL INBOUND HUNG UP\n";}
|
||||
|
||||
use Net::MySQL;
|
||||
|
||||
if (!$DB_port) {$DB_port='3306';}
|
||||
|
||||
my $dbh = 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";
|
||||
|
||||
if ($V) {print STDERR "\nCONNECTED: deleting parked_channels record for $unique_id on $server_ip\n";}
|
||||
|
||||
$stmtA = "DELETE from parked_channels where channel='$channel' and server_ip='$server_ip'";
|
||||
$dbh->query($stmtA) or die "Couldn't execute query:\n";
|
||||
$dbh->close;
|
||||
|
||||
|
||||
if ($M) {print STDERR "+++++ CALL PARK HUNGUP: |$unique_id|\n";}
|
||||
}
|
||||
if ($V) {print STDERR "\nAll Done Call Park Exiting:\n";}
|
||||
|
||||
exit;
|
||||
|
||||
|
||||
|
||||
|
||||
sub enter_pin_number
|
||||
{
|
||||
# please enter the pin number followed by the pound key
|
||||
|
||||
$interrupt_digit='';
|
||||
undef $interrupt_digit;
|
||||
|
||||
$interrupt_digit = $AGI->stream_file('four_digit_id','123456789');
|
||||
|
||||
print STDERR "interrupt_digit |$interrupt_digit|\n";
|
||||
|
||||
$digits_being_entered=1;
|
||||
$totalDTMF='';
|
||||
if ($interrupt_digit > 1)
|
||||
{
|
||||
if ($interrupt_digit == 48) {$interrupt_digit=0;}
|
||||
if ($interrupt_digit == 49) {$interrupt_digit=1;}
|
||||
if ($interrupt_digit == 50) {$interrupt_digit=2;}
|
||||
if ($interrupt_digit == 51) {$interrupt_digit=3;}
|
||||
if ($interrupt_digit == 52) {$interrupt_digit=4;}
|
||||
if ($interrupt_digit == 53) {$interrupt_digit=5;}
|
||||
if ($interrupt_digit == 54) {$interrupt_digit=6;}
|
||||
if ($interrupt_digit == 55) {$interrupt_digit=7;}
|
||||
if ($interrupt_digit == 56) {$interrupt_digit=8;}
|
||||
if ($interrupt_digit == 57) {$interrupt_digit=9;}
|
||||
|
||||
$totalDTMF=$interrupt_digit;
|
||||
}
|
||||
|
||||
$digit_loop_counter=0;
|
||||
#while ( ($digits_being_entered) && ($digit_loop_counter < 20) )
|
||||
# {
|
||||
# $digit = chr($AGI->wait_for_digit('30000')); # wait 30 seconds for input or until the pound key is pressed
|
||||
# if ($digit =~ /\d/)
|
||||
# {
|
||||
# $totalDTMF = "$totalDTMF$digit";
|
||||
# print STDERR "digit |$digit| TotalDTMF |$totalDTMF|\n";
|
||||
# $AGI->say_digits("$digit");
|
||||
# undef $digit;
|
||||
# }
|
||||
# else
|
||||
# {
|
||||
# $digits_being_entered=0;
|
||||
# }
|
||||
#
|
||||
# $digit_loop_counter++;
|
||||
# }
|
||||
|
||||
while ( ($digit_loop_counter < 9) )
|
||||
{
|
||||
$digit = chr($AGI->wait_for_digit('10000')); # wait 10 seconds for input or until the pound key is pressed
|
||||
if ($digit =~ /\d/)
|
||||
{
|
||||
$totalDTMF = "$totalDTMF$digit";
|
||||
print STDERR "digit |$digit| TotalDTMF |$totalDTMF|\n";
|
||||
# $AGI->say_digits("$digit");
|
||||
undef $digit;
|
||||
}
|
||||
else
|
||||
{
|
||||
$digit_loop_counter=9;
|
||||
}
|
||||
|
||||
$digit_loop_counter++;
|
||||
}
|
||||
|
||||
$totalDTMF =~ s/\D//gi;
|
||||
$pin = $totalDTMF;
|
||||
if ($totalDTMF) {print STDERR "digit |$digit| TotalDTMF |$totalDTMF|\n";}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
sub checkresult {
|
||||
my ($res) = @_;
|
||||
my $retval;
|
||||
$tests++;
|
||||
chomp $res;
|
||||
if ($res =~ /^200/) {
|
||||
$res =~ /result=(-?\d+)/;
|
||||
if (!length($1)) {
|
||||
print STDERR "FAIL ($res)\n";
|
||||
$fail++;
|
||||
} else {
|
||||
print STDERR "PASS ($1)\n";
|
||||
$pass++;
|
||||
}
|
||||
} else {
|
||||
print STDERR "FAIL (unexpected result '$res')\n";
|
||||
$fail++;
|
||||
}
|
||||
}
|
||||
@@ -1,307 +0,0 @@
|
||||
#!/usr/bin/perl
|
||||
#
|
||||
# call_park.agi
|
||||
#
|
||||
# runs when a call is to be parked for pickup of customer service
|
||||
#
|
||||
# You need to put lines similar to those below in your extensions.conf file:
|
||||
#
|
||||
# ;inbound calls:
|
||||
# exten => 101,1,AGI(call_park.agi,IN_800_TPP_CS-----8775154104-----Inbound TPP 800 CS-----park-----HANGUP----------)
|
||||
#
|
||||
#
|
||||
# Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
|
||||
#
|
||||
|
||||
$V = 1; # set to 1 for verbose mode
|
||||
$M = 1; # set to 1 for 2 line messages mode
|
||||
|
||||
### 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
|
||||
|
||||
|
||||
($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";
|
||||
|
||||
|
||||
|
||||
### begin parsing run-time options ###
|
||||
if (length($ARGV[0])>1)
|
||||
{
|
||||
if ($V) {print STDERR "Perl Environment Dump:\n";}
|
||||
$i=0;
|
||||
while ($#ARGV >= $i)
|
||||
{
|
||||
$args = "$args $ARGV[$i]";
|
||||
if ($V) {print STDERR "$i|$ARGV[$i]|\n";}
|
||||
$i++;
|
||||
}
|
||||
|
||||
### list of command-line array arguments:
|
||||
@ARGV_vars = split(/-----/, $ARGV[0]);
|
||||
|
||||
$channel_group = $ARGV_vars[0];
|
||||
$inbound_number = $ARGV_vars[1];
|
||||
$parked_by = $ARGV_vars[2];
|
||||
$park_extension = $ARGV_vars[3];
|
||||
$status = $ARGV_vars[4];
|
||||
$comment_d = $ARGV_vars[5];
|
||||
$comment_e = $ARGV_vars[6];
|
||||
|
||||
|
||||
if ($args =~ /--help/i)
|
||||
{
|
||||
print "allowed run time options:\n [-q] = quiet\n [-t] = test\n [-debug] = verbose debug messages\n\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($args =~ /-V/i)
|
||||
{
|
||||
$V=1;
|
||||
}
|
||||
if ($args =~ /-debug/i)
|
||||
{
|
||||
$DG=1;
|
||||
}
|
||||
if ($args =~ /-dbAVS/i)
|
||||
{
|
||||
$DGA=1;
|
||||
}
|
||||
if ($args =~ /-q/i)
|
||||
{
|
||||
$q=1;
|
||||
$Q=1;
|
||||
}
|
||||
if ($args =~ /-t/i)
|
||||
{
|
||||
$TEST=1;
|
||||
$T=1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($V) {print "no command line options set\n";}
|
||||
}
|
||||
|
||||
use Asterisk::AGI;
|
||||
$AGI = new Asterisk::AGI;
|
||||
|
||||
$|=1;
|
||||
while(<STDIN>) {
|
||||
chomp;
|
||||
last unless length($_);
|
||||
if ($V)
|
||||
{
|
||||
if (/^agi_(\w+)\:\s+(.*)$/)
|
||||
{
|
||||
$AGI{$1} = $2;
|
||||
}
|
||||
}
|
||||
|
||||
if (/^agi_uniqueid\:\s+(.*)$/) {$unique_id = $1;}
|
||||
if (/^agi_channel\:\s+(.*)$/) {$channel = $1;}
|
||||
if (/^agi_extension\:\s+(.*)$/) {$extension = $1;}
|
||||
if (/^agi_type\:\s+(.*)$/) {$type = $1;}
|
||||
if (/^agi_callerid\:\s+(.*)$/) {$callerid = $1;}
|
||||
if (/^agi_calleridname\:\s+(.*)$/) {$calleridname = $1;}
|
||||
if ( (!$callerid) or ($callerid =~ /unknown/) )
|
||||
{$callerid = $calleridname;}
|
||||
|
||||
### allow for ANI being sent with the DNIS "*3125551212*9999*"
|
||||
if ($extension =~ /^\*\d\d\d\d\d\d\d\d\d\d\*/)
|
||||
{
|
||||
$callerid = $extension;
|
||||
$callerid =~ s/\*\d\d\d\d\*$//gi;
|
||||
$callerid =~ s/\*\d\d\d\d$//gi;
|
||||
$callerid =~ s/^\*//gi;
|
||||
$extension =~ s/^\*\d\d\d\d\d\d\d\d\d\d\*//gi;
|
||||
$extension =~ s/\*$//gi;
|
||||
|
||||
### set the callerid if sent with DNIS
|
||||
print "SET CALLERID $callerid\n";
|
||||
checkresult($result);
|
||||
}
|
||||
}
|
||||
|
||||
if ($V)
|
||||
{
|
||||
|
||||
if ($V) {print STDERR "AGI Environment Dump:\n";}
|
||||
foreach $i (sort keys %AGI) {
|
||||
if ($V) {print STDERR " -- $i = $AGI{$i}\n";}
|
||||
}
|
||||
}
|
||||
|
||||
$AGI->stream_file('beep');
|
||||
|
||||
if ($V) {print STDERR "AGI Environment Dump: |$unique_id|$channel|$extension|$type|$callerid|\n";}
|
||||
|
||||
if ($extension =~ /h/i) {$stage = 'END';}
|
||||
else {$stage = 'START';}
|
||||
|
||||
### call start stage
|
||||
if ($status !~ /HANGUP/)
|
||||
{
|
||||
|
||||
if ($V) {print STDERR "\nCALL PARK STARTED\n";}
|
||||
|
||||
&enter_pin_number;
|
||||
|
||||
if ($M) {print STDERR "+++++ CALL PARK START : |$unique_id|$channel|$extension|$type|$callerid-$pin|$now_date\n";}
|
||||
|
||||
if ($channel =~ /^SIP/) {$channel =~ s/-.*//gi;}
|
||||
# if ($channel =~ /^Zap\//) {$channel =~ s/-\d$//gi;}
|
||||
if (length($callerid)<10) {$callerid = $parked_by;}
|
||||
if (length($pin)>0) {$callerid = $pin;}
|
||||
|
||||
use Net::MySQL;
|
||||
|
||||
if (!$DB_port) {$DB_port='3306';}
|
||||
|
||||
my $mysql = 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";
|
||||
|
||||
$stmtA = "INSERT INTO parked_channels (channel,server_ip,channel_group,extension,parked_by,parked_time) values('$channel','$server_ip','$channel_group','$park_extension','$callerid','$now_date')";
|
||||
if ($V) {print STDERR "\n|$stmtA|\n";}
|
||||
$mysql->query($stmtA) or die "Couldn't execute query:\n";
|
||||
|
||||
|
||||
$stmtA = "INSERT INTO park_log (uniqueid,status,channel,server_ip,parked_time,channel_group) values('$unique_id','PARKED','$channel','$server_ip','$now_date','$channel_group')";
|
||||
if ($V) {print STDERR "\n|$stmtA|\n";}
|
||||
$mysql->query($stmtA) or die "Couldn't execute query:\n";
|
||||
|
||||
|
||||
$mysql->close;
|
||||
}
|
||||
|
||||
|
||||
### call end stage
|
||||
else
|
||||
{
|
||||
|
||||
if ($V) {print STDERR "\nCALL INBOUND HUNG UP\n";}
|
||||
|
||||
use Net::MySQL;
|
||||
|
||||
if (!$DB_port) {$DB_port='3306';}
|
||||
|
||||
my $dbh = 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";
|
||||
|
||||
if ($V) {print STDERR "\nCONNECTED: deleting parked_channels record for $unique_id on $server_ip\n";}
|
||||
|
||||
$stmtA = "DELETE from parked_channels where channel='$channel' and server_ip='$server_ip'";
|
||||
$dbh->query($stmtA) or die "Couldn't execute query:\n";
|
||||
$dbh->close;
|
||||
|
||||
|
||||
if ($M) {print STDERR "+++++ CALL PARK HUNGUP: |$unique_id|\n";}
|
||||
}
|
||||
if ($V) {print STDERR "\nAll Done Call Park Exiting:\n";}
|
||||
|
||||
exit;
|
||||
|
||||
|
||||
|
||||
|
||||
sub enter_pin_number
|
||||
{
|
||||
# please enter the pin number followed by the pound key
|
||||
|
||||
$interrupt_digit='';
|
||||
undef $interrupt_digit;
|
||||
|
||||
$interrupt_digit = $AGI->stream_file('four_digit_id','123456789');
|
||||
|
||||
print STDERR "interrupt_digit |$interrupt_digit|\n";
|
||||
|
||||
$digits_being_entered=1;
|
||||
$totalDTMF='';
|
||||
if ($interrupt_digit > 1)
|
||||
{
|
||||
if ($interrupt_digit == 48) {$interrupt_digit=0;}
|
||||
if ($interrupt_digit == 49) {$interrupt_digit=1;}
|
||||
if ($interrupt_digit == 50) {$interrupt_digit=2;}
|
||||
if ($interrupt_digit == 51) {$interrupt_digit=3;}
|
||||
if ($interrupt_digit == 52) {$interrupt_digit=4;}
|
||||
if ($interrupt_digit == 53) {$interrupt_digit=5;}
|
||||
if ($interrupt_digit == 54) {$interrupt_digit=6;}
|
||||
if ($interrupt_digit == 55) {$interrupt_digit=7;}
|
||||
if ($interrupt_digit == 56) {$interrupt_digit=8;}
|
||||
if ($interrupt_digit == 57) {$interrupt_digit=9;}
|
||||
|
||||
$totalDTMF=$interrupt_digit;
|
||||
}
|
||||
|
||||
$digit_loop_counter=0;
|
||||
#while ( ($digits_being_entered) && ($digit_loop_counter < 20) )
|
||||
# {
|
||||
# $digit = chr($AGI->wait_for_digit('30000')); # wait 30 seconds for input or until the pound key is pressed
|
||||
# if ($digit =~ /\d/)
|
||||
# {
|
||||
# $totalDTMF = "$totalDTMF$digit";
|
||||
# print STDERR "digit |$digit| TotalDTMF |$totalDTMF|\n";
|
||||
# $AGI->say_digits("$digit");
|
||||
# undef $digit;
|
||||
# }
|
||||
# else
|
||||
# {
|
||||
# $digits_being_entered=0;
|
||||
# }
|
||||
#
|
||||
# $digit_loop_counter++;
|
||||
# }
|
||||
|
||||
while ( ($digit_loop_counter < 4) )
|
||||
{
|
||||
$digit = chr($AGI->wait_for_digit('10000')); # wait 10 seconds for input or until the pound key is pressed
|
||||
if ($digit =~ /\d/)
|
||||
{
|
||||
$totalDTMF = "$totalDTMF$digit";
|
||||
print STDERR "digit |$digit| TotalDTMF |$totalDTMF|\n";
|
||||
# $AGI->say_digits("$digit");
|
||||
undef $digit;
|
||||
}
|
||||
else
|
||||
{
|
||||
$digit_loop_counter=4;
|
||||
}
|
||||
|
||||
$digit_loop_counter++;
|
||||
}
|
||||
|
||||
$totalDTMF =~ s/\D//gi;
|
||||
$pin = $totalDTMF;
|
||||
if ($totalDTMF) {print STDERR "digit |$digit| TotalDTMF |$totalDTMF|\n";}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
sub checkresult {
|
||||
my ($res) = @_;
|
||||
my $retval;
|
||||
$tests++;
|
||||
chomp $res;
|
||||
if ($res =~ /^200/) {
|
||||
$res =~ /result=(-?\d+)/;
|
||||
if (!length($1)) {
|
||||
print STDERR "FAIL ($res)\n";
|
||||
$fail++;
|
||||
} else {
|
||||
print STDERR "PASS ($1)\n";
|
||||
$pass++;
|
||||
}
|
||||
} else {
|
||||
print STDERR "FAIL (unexpected result '$res')\n";
|
||||
$fail++;
|
||||
}
|
||||
}
|
||||
@@ -157,7 +157,7 @@ if (!$VDADLOGfile) {$VDADLOGfile = "$PATHlogs/vdautodial.$year-$mon-$mday";}
|
||||
use Time::HiRes ('gettimeofday','usleep','sleep'); # necessary to have perl sleep command of less than one second
|
||||
use DBI;
|
||||
|
||||
### connect to MySQL database defined in the AST_SERVER_conf.pl file
|
||||
### connect to MySQL database defined in the conf file
|
||||
$dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass")
|
||||
or die "Couldn't connect to database: " . DBI->errstr;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user