initial 2.0 tree trunk
git-svn-id: svn://192.168.202.10@18 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
@@ -0,0 +1,688 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
# ADMIN_adjust_GMTnow_on_leads.pl
|
||||
#
|
||||
# program goes throught the vicidial_list table and adjusts the gmt_offset_now
|
||||
# field to change it to today's offset if needed because of Daylight Saving Time
|
||||
#
|
||||
# run every time you load leads into the vicidial_list table
|
||||
#
|
||||
# Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
|
||||
#
|
||||
#
|
||||
# 50810-1540 - Added database server variable definitions lookup
|
||||
# 60615-1717 - Added definition GMT lookup from database not flat text file
|
||||
#
|
||||
|
||||
$MT[0]='';
|
||||
|
||||
### begin parsing run-time options ###
|
||||
if (length($ARGV[0])>1)
|
||||
{
|
||||
$i=0;
|
||||
while ($#ARGV >= $i)
|
||||
{
|
||||
$args = "$args $ARGV[$i]";
|
||||
$i++;
|
||||
}
|
||||
|
||||
if ($args =~ /--help/i)
|
||||
{
|
||||
print "allowed run time options:\n [-q] = quiet\n [-t] = test\n [--debug] = debugging messages\n\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($args =~ /-q/i)
|
||||
{
|
||||
$q=1; $Q=1;
|
||||
}
|
||||
if ($args =~ /--debug/i)
|
||||
{
|
||||
$DB=1;
|
||||
print "\n-----DEBUGGING -----\n\n";
|
||||
}
|
||||
if ($args =~ /--debugX/i)
|
||||
{
|
||||
$DBX=1;
|
||||
print "\n----- SUPER-DUPER DEBUGGING -----\n\n";
|
||||
}
|
||||
if ($args =~ /-t|--test/i)
|
||||
{
|
||||
$T=1; $TEST=1;
|
||||
print "\n-----TESTING -----\n\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print "no command line options set\n";
|
||||
}
|
||||
|
||||
if ($DB) {print "STARTING TIME ZONE DAYLIGHT SAVING TIME CALCULATION SCRIPT\n\n\n\n";}
|
||||
|
||||
### end parsing run-time options ###
|
||||
|
||||
### Make sure this file is in a libs path or put the absolute path to it
|
||||
require("/home/cron/AST_SERVER_conf.pl"); # local configuration file
|
||||
|
||||
if (!$DB_port) {$DB_port='3306';}
|
||||
|
||||
$secX = time();
|
||||
# $secX = '1079989363'; # epoch for March 22, 2993
|
||||
# $secX = '1097989363'; # epoch for October 17, 2004
|
||||
|
||||
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($secX);
|
||||
$mon++;
|
||||
$year = ($year + 1900);
|
||||
if ($mon < 10) {$mon = "0$mon";}
|
||||
if ($mday < 10) {$mday = "0$mday";}
|
||||
if ($hour < 10) {$hour = "0$hour";}
|
||||
if ($min < 10) {$min = "0$min";}
|
||||
if ($sec < 10) {$sec = "0$sec";}
|
||||
$dsec = ( ( ($hour * 3600) + ($min * 60) ) + $sec );
|
||||
|
||||
use Net::MySQL;
|
||||
|
||||
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";
|
||||
|
||||
|
||||
### Grab Server values from the database
|
||||
$stmtA = "SELECT telnet_host,telnet_port,ASTmgrUSERNAME,ASTmgrSECRET,ASTmgrUSERNAMEupdate,ASTmgrUSERNAMElisten,ASTmgrUSERNAMEsend,max_vicidial_trunks,answer_transfer_agent,local_gmt,ext_context FROM servers where server_ip = '$server_ip';";
|
||||
$dbhA->query("$stmtA");
|
||||
if ($dbhA->has_selected_record)
|
||||
{
|
||||
$iter=$dbhA->create_record_iterator;
|
||||
while ( $record = $iter->each)
|
||||
{
|
||||
$DBtelnet_host = "$record->[0]";
|
||||
$DBtelnet_port = "$record->[1]";
|
||||
$DBASTmgrUSERNAME = "$record->[2]";
|
||||
$DBASTmgrSECRET = "$record->[3]";
|
||||
$DBASTmgrUSERNAMEupdate = "$record->[4]";
|
||||
$DBASTmgrUSERNAMElisten = "$record->[5]";
|
||||
$DBASTmgrUSERNAMEsend = "$record->[6]";
|
||||
$DBmax_vicidial_trunks = "$record->[7]";
|
||||
$DBanswer_transfer_agent= "$record->[8]";
|
||||
$DBSERVER_GMT = "$record->[9]";
|
||||
$DBext_context = "$record->[10]";
|
||||
if ($DBtelnet_host) {$telnet_host = $DBtelnet_host;}
|
||||
if ($DBtelnet_port) {$telnet_port = $DBtelnet_port;}
|
||||
if ($DBASTmgrUSERNAME) {$ASTmgrUSERNAME = $DBASTmgrUSERNAME;}
|
||||
if ($DBASTmgrSECRET) {$ASTmgrSECRET = $DBASTmgrSECRET;}
|
||||
if ($DBASTmgrUSERNAMEupdate) {$ASTmgrUSERNAMEupdate = $DBASTmgrUSERNAMEupdate;}
|
||||
if ($DBASTmgrUSERNAMElisten) {$ASTmgrUSERNAMElisten = $DBASTmgrUSERNAMElisten;}
|
||||
if ($DBASTmgrUSERNAMEsend) {$ASTmgrUSERNAMEsend = $DBASTmgrUSERNAMEsend;}
|
||||
if ($DBmax_vicidial_trunks) {$max_vicidial_trunks = $DBmax_vicidial_trunks;}
|
||||
if ($DBanswer_transfer_agent) {$answer_transfer_agent = $DBanswer_transfer_agent;}
|
||||
if ($DBSERVER_GMT) {$SERVER_GMT = $DBSERVER_GMT;}
|
||||
if ($DBext_context) {$ext_context = $DBext_context;}
|
||||
}
|
||||
}
|
||||
|
||||
$LOCAL_GMT_OFF = $SERVER_GMT;
|
||||
$LOCAL_GMT_OFF_STD = $SERVER_GMT;
|
||||
|
||||
if ($isdst) {$LOCAL_GMT_OFF++;}
|
||||
if ($DB) {print "SEED TIME $secX : $year-$mon-$mday $hour:$min:$sec LOCAL GMT OFFSET NOW: $LOCAL_GMT_OFF\n";}
|
||||
|
||||
|
||||
$stmtA = "select distinct phone_code from vicidial_list;";
|
||||
if($DBX){print STDERR "\n|$stmtA|\n";}
|
||||
$dbhA->query($stmtA);
|
||||
if ($dbhA->has_selected_record)
|
||||
{
|
||||
$iterA=$dbhA->create_record_iterator;
|
||||
$rec_countY=0;
|
||||
@phone_codes=@MT;
|
||||
$phone_codes_list='|';
|
||||
while ($recordA = $iterA->each)
|
||||
{
|
||||
$phone_codes[$rec_countY] = $recordA->[0];
|
||||
$phone_codes_ORIG[$rec_countY] = $recordA->[0];
|
||||
$phone_codes[$rec_countY] =~ s/011|0011| |\t|\r|\n//gi;
|
||||
|
||||
# if ( ($phone_codes_list !~ /\|$phone_codes[$rec_countY]\|/) && (length($phone_codes[$rec_countY]) > 0) )
|
||||
# {
|
||||
# $phone_codes_list .= "$phone_codes[$rec_countY]|";
|
||||
# }
|
||||
|
||||
if ($DBX) {print "|",$recordA->[0],"|","\n";}
|
||||
$rec_countY++;
|
||||
}
|
||||
}
|
||||
|
||||
if ($DB) {print " - Unique Country dial codes found: $rec_countY\n";}
|
||||
|
||||
|
||||
$stmtA = "select * from vicidial_phone_codes;";
|
||||
if($DBX){print STDERR "\n|$stmtA|\n";}
|
||||
$dbhA->query($stmtA);
|
||||
if ($dbhA->has_selected_record)
|
||||
{
|
||||
$iterA=$dbhA->create_record_iterator;
|
||||
$rec_countZ=0;
|
||||
@codefile=@MT;
|
||||
while ($recordA = $iterA->each)
|
||||
{
|
||||
$codefile[$rec_countZ] = "$recordA->[0]\t$recordA->[1]\t$recordA->[2]\t$recordA->[3]\t$recordA->[4]\t$recordA->[5]\t$recordA->[6]\t$recordA->[7]\n";
|
||||
$rec_countZ++;
|
||||
}
|
||||
}
|
||||
|
||||
if ($DB) {print " - GMT phone codes records: $rec_countZ\n";}
|
||||
|
||||
# open(codefile, "/home/cron/phone_codes_GMT.txt") || die "can't open /home/cron/phone_codes_GMT.txt: $!\n";
|
||||
# @codefile = <codefile>;
|
||||
# close(codefile);
|
||||
|
||||
$ep=0; $ei=0; $ee=0;
|
||||
$d=0;
|
||||
foreach (@phone_codes)
|
||||
{
|
||||
$match_code = $phone_codes[$d];
|
||||
$match_code_ORIG = $phone_codes_ORIG[$d];
|
||||
|
||||
if ($DB) {print "\nRUNNING LOOP FOR COUNTRY CODE: $match_code\n";}
|
||||
|
||||
$e=0;
|
||||
foreach (@codefile)
|
||||
{
|
||||
chomp($codefile[$e]);
|
||||
if ($codefile[$e] =~ /^$match_code\t/)
|
||||
{
|
||||
@m = split(/\t/, $codefile[$e]);
|
||||
$area_code = $m[2];
|
||||
$area_state = $m[3];
|
||||
$area_GMT = $m[4]; $area_GMT =~ s/\+//gi; $area_GMT = ($area_GMT + 0);
|
||||
$area_GMT_method = $m[6];
|
||||
if ($area_code =~ /S/) # look for state override flag in areacode field
|
||||
{
|
||||
$area_code =~ s/\D//gi;
|
||||
$AC_match = " and phone_number LIKE \"$area_code%\" and state='$area_state'";
|
||||
if ($DB) {print " AREA CODE STATE OVERRIDE: $codefile[$e]\n";}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($area_code =~ /\*/) {$AC_match = '';}
|
||||
else {$AC_match = " and phone_number LIKE \"$area_code%\"";}
|
||||
}
|
||||
if ($DBX) {print "PROCESSING THIS LINE: $codefile[$e]\n";}
|
||||
$stmtA = "select count(*) from vicidial_list where phone_code='$match_code_ORIG' $AC_match;";
|
||||
if($DBX){print STDERR "\n|$stmtA|\n";}
|
||||
$dbhA->query($stmtA);
|
||||
$rec_countZ=0;
|
||||
if ($dbhA->has_selected_record)
|
||||
{
|
||||
$iterA=$dbhA->create_record_iterator;
|
||||
while ($recordA = $iterA->each)
|
||||
{
|
||||
$rec_countZ = $recordA->[0];
|
||||
}
|
||||
}
|
||||
if (!$rec_countZ)
|
||||
{
|
||||
if ($DB) {print " IGNORING: $codefile[$e]\n";}
|
||||
$ei++;
|
||||
}
|
||||
else
|
||||
{
|
||||
$AC_GMT_diff = ($area_GMT - $LOCAL_GMT_OFF_STD);
|
||||
$AC_localtime = ($secX + (3600 * $AC_GMT_diff));
|
||||
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($AC_localtime);
|
||||
$year = ($year + 1900);
|
||||
$mon++;
|
||||
if ($mon < 10) {$mon = "0$mon";}
|
||||
if ($mday < 10) {$mday = "0$mday";}
|
||||
if ($hour < 10) {$hour = "0$hour";}
|
||||
if ($min < 10) {$min = "0$min";}
|
||||
if ($sec < 10) {$sec = "0$sec";}
|
||||
$dsec = ( ( ($hour * 3600) + ($min * 60) ) + $sec );
|
||||
|
||||
$AC_processed=0;
|
||||
if ( (!$AC_processed) && ($area_GMT_method =~ /FSA-LSO/) )
|
||||
{
|
||||
if ($DBX) {print " First Sunday April to Last Sunday October\n";}
|
||||
&USA_dstcalc;
|
||||
if ($DBX) {print " DST: $USA_DST\n";}
|
||||
if ($USA_DST) {$area_GMT++;}
|
||||
$AC_processed++;
|
||||
}
|
||||
if ( (!$AC_processed) && ($area_GMT_method =~ /LSM-LSO/) )
|
||||
{
|
||||
if ($DBX) {print " Last Sunday March to Last Sunday October\n";}
|
||||
&GBR_dstcalc;
|
||||
if ($DBX) {print " DST: $GBR_DST\n";}
|
||||
if ($GBR_DST) {$area_GMT++;}
|
||||
$AC_processed++;
|
||||
}
|
||||
if ( (!$AC_processed) && ($area_GMT_method =~ /LSO-LSM/) )
|
||||
{
|
||||
if ($DBX) {print " Last Sunday October to Last Sunday March\n";}
|
||||
&AUS_dstcalc;
|
||||
if ($DBX) {print " DST: $AUS_DST\n";}
|
||||
if ($AUS_DST) {$area_GMT++;}
|
||||
$AC_processed++;
|
||||
}
|
||||
if ( (!$AC_processed) && ($area_GMT_method =~ /FSO-LSM/) )
|
||||
{
|
||||
if ($DBX) {print " First Sunday October to Last Sunday March\n";}
|
||||
&AUST_dstcalc;
|
||||
if ($DBX) {print " DST: $AUST_DST\n";}
|
||||
if ($AUST_DST) {$area_GMT++;}
|
||||
$AC_processed++;
|
||||
}
|
||||
if ( (!$AC_processed) && ($area_GMT_method =~ /FSO-TSM/) )
|
||||
{
|
||||
if ($DBX) {print " First Sunday October to Third Sunday March\n";}
|
||||
&NZL_dstcalc;
|
||||
if ($DBX) {print " DST: $NZL_DST\n";}
|
||||
if ($NZL_DST) {$area_GMT++;}
|
||||
$AC_processed++;
|
||||
}
|
||||
if (!$AC_processed)
|
||||
{
|
||||
if ($DBX) {print " No DST Method Found\n";}
|
||||
if ($DBX) {print " DST: 0\n";}
|
||||
$AC_processed++;
|
||||
}
|
||||
|
||||
|
||||
if ($AC_processed)
|
||||
{
|
||||
$stmtA = "select count(*) from vicidial_list where phone_code='$match_code_ORIG' $AC_match and gmt_offset_now != '$area_GMT';";
|
||||
if($DBX){print STDERR "\n|$stmtA|\n";}
|
||||
$dbhA->query($stmtA);
|
||||
$rec_countW=0;
|
||||
if ($dbhA->has_selected_record)
|
||||
{
|
||||
$iterA=$dbhA->create_record_iterator;
|
||||
while ($recordA = $iterA->each)
|
||||
{
|
||||
$rec_countW = $recordA->[0];
|
||||
}
|
||||
}
|
||||
if (!$rec_countW)
|
||||
{
|
||||
if ($DB) {print " ALL GMT ALREADY CORRECT FOR : $match_code_ORIG $area_code $area_GMT\n";}
|
||||
$ei++;
|
||||
}
|
||||
else
|
||||
{
|
||||
$stmtA = "update vicidial_list set gmt_offset_now='$area_GMT' where phone_code='$match_code_ORIG' $AC_match and gmt_offset_now != '$area_GMT';";
|
||||
if($DB){print STDERR "\n|$stmtA|\n";}
|
||||
if (!$T) {$dbhA->query($stmtA); }
|
||||
$Prec_countW = sprintf("%8s", $rec_countW);
|
||||
if ($DB) {print " $Prec_countW records in $match_code_ORIG $area_code updated to $area_GMT\n";}
|
||||
$ee++;
|
||||
# sleep(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$ep++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($DBX) {print " IGNORING: $codefile[$e]\n";}
|
||||
$ei++;
|
||||
}
|
||||
$e++;
|
||||
}
|
||||
|
||||
$d++;
|
||||
}
|
||||
|
||||
|
||||
|
||||
$dbhA->close;
|
||||
|
||||
if($DB){print "\nDONE\n";}
|
||||
|
||||
exit;
|
||||
|
||||
|
||||
|
||||
|
||||
sub USA_dstcalc {
|
||||
#**********************************************************************
|
||||
# FSA-LSO
|
||||
# This is returns 1 if Daylight Savings Time is in effect and 0 if
|
||||
# Standard time is in effect.
|
||||
# Based on first Sunday in April and last Sunday in October at 2 am.
|
||||
# INPUTS:
|
||||
# mm INTEGER Month.
|
||||
# dd INTEGER Day of the month.
|
||||
# ns INTEGER Seconds into the day.
|
||||
# dow INTEGER Day of week (0=Sunday, to 6=Saturday)
|
||||
# OPTIONAL INPUT:
|
||||
# timezone INTEGER hour difference UTC - local standard time
|
||||
# (DEFAULT is blank)
|
||||
# make calculations based on UTC time,
|
||||
# which means shift at 10:00 UTC in April
|
||||
# and 9:00 UTC in October
|
||||
# OUTPUT:
|
||||
# INTEGER 1 = DST, 0 = not DST
|
||||
#**********************************************************************
|
||||
|
||||
$USA_DST=0;
|
||||
$mm = $mon;
|
||||
$dd = $mday;
|
||||
$ns = $dsec;
|
||||
$dow= $wday;
|
||||
|
||||
if ($mm < 4 || $mm > 10) {
|
||||
$USA_DST=0; return 0;
|
||||
} elsif ($mm >= 5 && $mm <= 9) {
|
||||
$USA_DST=1; return 1;
|
||||
} elsif ($mm == 4) {
|
||||
if ($dd > 7) {
|
||||
$USA_DST=1; return 1;
|
||||
} elsif ($dd >= ($dow+1)) {
|
||||
if ($timezone) {
|
||||
if ($dow == 0 && $ns < (7200+$timezone*3600)) {
|
||||
$USA_DST=0; return 0;
|
||||
} else {
|
||||
$USA_DST=1; return 1;
|
||||
}
|
||||
} else {
|
||||
if ($dow == 0 && $ns < 7200) {
|
||||
$USA_DST=0; return 0;
|
||||
} else {
|
||||
$USA_DST=1; return 1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$USA_DST=0; return 0;
|
||||
}
|
||||
} elsif ($mm == 10) {
|
||||
if ($dd < 25) {
|
||||
$USA_DST=1; return 1;
|
||||
} elsif ($dd < ($dow+25)) {
|
||||
$USA_DST=1; return 1;
|
||||
} elsif ($dow == 0) {
|
||||
if ($timezone) { # UTC calculations
|
||||
if ($ns < (7200+($timezone-1)*3600)) {
|
||||
$USA_DST=1; return 1;
|
||||
} else {
|
||||
$USA_DST=0; return 0;
|
||||
}
|
||||
} else { # local time calculations
|
||||
if ($ns < 7200) {
|
||||
$USA_DST=1; return 1;
|
||||
} else {
|
||||
$USA_DST=0; return 0;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$USA_DST=0; return 0;
|
||||
}
|
||||
} # end of month checks
|
||||
} # end of subroutine dstcalc
|
||||
|
||||
|
||||
|
||||
|
||||
sub GBR_dstcalc {
|
||||
#**********************************************************************
|
||||
# This is returns 1 if Daylight Savings Time is in effect and 0 if
|
||||
# Standard time is in effect.
|
||||
# Based on last Sunday in March and last Sunday in October at 1 am.
|
||||
#**********************************************************************
|
||||
|
||||
$GBR_DST=0;
|
||||
$mm = $mon;
|
||||
$dd = $mday;
|
||||
$ns = $dsec;
|
||||
$dow= $wday;
|
||||
|
||||
if ($mm < 3 || $mm > 10) {
|
||||
$GBR_DST=0; return 0;
|
||||
} elsif ($mm >= 4 && $mm <= 9) {
|
||||
$GBR_DST=1; return 1;
|
||||
} elsif ($mm == 3) {
|
||||
if ($dd < 25) {
|
||||
$GBR_DST=0; return 0;
|
||||
} elsif ($dd < ($dow+25)) {
|
||||
$GBR_DST=0; return 0;
|
||||
} elsif ($dow == 0) {
|
||||
if ($timezone) { # UTC calculations
|
||||
if ($ns < (3600+($timezone-1)*3600)) {
|
||||
$GBR_DST=0; return 0;
|
||||
} else {
|
||||
$GBR_DST=1; return 1;
|
||||
}
|
||||
} else { # local time calculations
|
||||
if ($ns < 3600) {
|
||||
$GBR_DST=0; return 0;
|
||||
} else {
|
||||
$GBR_DST=1; return 1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$GBR_DST=1; return 1;
|
||||
}
|
||||
} elsif ($mm == 10) {
|
||||
if ($dd < 25) {
|
||||
$GBR_DST=1; return 1;
|
||||
} elsif ($dd < ($dow+25)) {
|
||||
$GBR_DST=1; return 1;
|
||||
} elsif ($dow == 0) {
|
||||
if ($timezone) { # UTC calculations
|
||||
if ($ns < (3600+($timezone-1)*3600)) {
|
||||
$GBR_DST=1; return 1;
|
||||
} else {
|
||||
$GBR_DST=0; return 0;
|
||||
}
|
||||
} else { # local time calculations
|
||||
if ($ns < 3600) {
|
||||
$GBR_DST=1; return 1;
|
||||
} else {
|
||||
$GBR_DST=0; return 0;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$GBR_DST=0; return 0;
|
||||
}
|
||||
} # end of month checks
|
||||
} # end of subroutine dstcalc
|
||||
|
||||
|
||||
|
||||
|
||||
sub AUS_dstcalc {
|
||||
#**********************************************************************
|
||||
# This is returns 1 if Daylight Savings Time is in effect and 0 if
|
||||
# Standard time is in effect.
|
||||
# Based on last Sunday in October and last Sunday in March at 1 am.
|
||||
#**********************************************************************
|
||||
|
||||
$AUS_DST=0;
|
||||
$mm = $mon;
|
||||
$dd = $mday;
|
||||
$ns = $dsec;
|
||||
$dow= $wday;
|
||||
|
||||
if ($mm < 3 || $mm > 10) {
|
||||
$AUS_DST=1; return 1;
|
||||
} elsif ($mm >= 4 && $mm <= 9) {
|
||||
$AUS_DST=0; return 0;
|
||||
} elsif ($mm == 3) {
|
||||
if ($dd < 25) {
|
||||
$AUS_DST=1; return 1;
|
||||
} elsif ($dd < ($dow+25)) {
|
||||
$AUS_DST=1; return 1;
|
||||
} elsif ($dow == 0) {
|
||||
if ($timezone) { # UTC calculations
|
||||
if ($ns < (3600+($timezone-1)*3600)) {
|
||||
$AUS_DST=1; return 1;
|
||||
} else {
|
||||
$AUS_DST=0; return 0;
|
||||
}
|
||||
} else { # local time calculations
|
||||
if ($ns < 3600) {
|
||||
$AUS_DST=1; return 1;
|
||||
} else {
|
||||
$AUS_DST=0; return 0;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$AUS_DST=0; return 0;
|
||||
}
|
||||
} elsif ($mm == 10) {
|
||||
if ($dd < 25) {
|
||||
$AUS_DST=0; return 0;
|
||||
} elsif ($dd < ($dow+25)) {
|
||||
$AUS_DST=0; return 0;
|
||||
} elsif ($dow == 0) {
|
||||
if ($timezone) { # UTC calculations
|
||||
if ($ns < (3600+($timezone-1)*3600)) {
|
||||
$AUS_DST=0; return 0;
|
||||
} else {
|
||||
$AUS_DST=1; return 1;
|
||||
}
|
||||
} else { # local time calculations
|
||||
if ($ns < 3600) {
|
||||
$AUS_DST=0; return 0;
|
||||
} else {
|
||||
$AUS_DST=1; return 1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$AUS_DST=1; return 1;
|
||||
}
|
||||
} # end of month checks
|
||||
} # end of subroutine dstcalc
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
sub AUST_dstcalc {
|
||||
#**********************************************************************
|
||||
# TASMANIA ONLY
|
||||
# This is returns 1 if Daylight Savings Time is in effect and 0 if
|
||||
# Standard time is in effect.
|
||||
# Based on first Sunday in October and last Sunday in March at 1 am.
|
||||
#**********************************************************************
|
||||
|
||||
$AUST_DST=0;
|
||||
$mm = $mon;
|
||||
$dd = $mday;
|
||||
$ns = $dsec;
|
||||
$dow= $wday;
|
||||
|
||||
if ($mm < 3 || $mm > 10) {
|
||||
$AUST_DST=1; return 1;
|
||||
} elsif ($mm >= 4 && $mm <= 9) {
|
||||
$AUST_DST=0; return 0;
|
||||
} elsif ($mm == 3) {
|
||||
if ($dd < 25) {
|
||||
$AUST_DST=1; return 1;
|
||||
} elsif ($dd < ($dow+25)) {
|
||||
$AUST_DST=1; return 1;
|
||||
} elsif ($dow == 0) {
|
||||
if ($timezone) { # UTC calculations
|
||||
if ($ns < (3600+($timezone-1)*3600)) {
|
||||
$AUST_DST=1; return 1;
|
||||
} else {
|
||||
$AUST_DST=0; return 0;
|
||||
}
|
||||
} else { # local time calculations
|
||||
if ($ns < 3600) {
|
||||
$AUST_DST=1; return 1;
|
||||
} else {
|
||||
$AUST_DST=0; return 0;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$AUST_DST=0; return 0;
|
||||
}
|
||||
} elsif ($mm == 10) {
|
||||
if ($dd > 7) {
|
||||
$AUST_DST=1; return 1;
|
||||
} elsif ($dd >= ($dow+1)) {
|
||||
if ($timezone) {
|
||||
if ($dow == 0 && $ns < (7200+$timezone*3600)) {
|
||||
$AUST_DST=0; return 0;
|
||||
} else {
|
||||
$AUST_DST=1; return 1;
|
||||
}
|
||||
} else {
|
||||
if ($dow == 0 && $ns < 3600) {
|
||||
$AUST_DST=0; return 0;
|
||||
} else {
|
||||
$AUST_DST=1; return 1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$AUST_DST=0; return 0;
|
||||
}
|
||||
} # end of month checks
|
||||
} # end of subroutine dstcalc
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
sub NZL_dstcalc {
|
||||
#**********************************************************************
|
||||
# This is returns 1 if Daylight Savings Time is in effect and 0 if
|
||||
# Standard time is in effect.
|
||||
# Based on first Sunday in October and third Sunday in March at 1 am.
|
||||
#**********************************************************************
|
||||
|
||||
$NZL_DST=0;
|
||||
$mm = $mon;
|
||||
$dd = $mday;
|
||||
$ns = $dsec;
|
||||
$dow= $wday;
|
||||
|
||||
if ($mm < 3 || $mm > 10) {
|
||||
$NZL_DST=1; return 1;
|
||||
} elsif ($mm >= 4 && $mm <= 9) {
|
||||
$NZL_DST=0; return 0;
|
||||
} elsif ($mm == 3) {
|
||||
if ($dd < 14) {
|
||||
$NZL_DST=1; return 1;
|
||||
} elsif ($dd < ($dow+14)) {
|
||||
$NZL_DST=1; return 1;
|
||||
} elsif ($dow == 0) {
|
||||
if ($timezone) { # UTC calculations
|
||||
if ($ns < (3600+($timezone-1)*3600)) {
|
||||
$NZL_DST=1; return 1;
|
||||
} else {
|
||||
$NZL_DST=0; return 0;
|
||||
}
|
||||
} else { # local time calculations
|
||||
if ($ns < 3600) {
|
||||
$NZL_DST=1; return 1;
|
||||
} else {
|
||||
$NZL_DST=0; return 0;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$NZL_DST=0; return 0;
|
||||
}
|
||||
} elsif ($mm == 10) {
|
||||
if ($dd > 7) {
|
||||
$NZL_DST=1; return 1;
|
||||
} elsif ($dd >= ($dow+1)) {
|
||||
if ($timezone) {
|
||||
if ($dow == 0 && $ns < (7200+$timezone*3600)) {
|
||||
$NZL_DST=0; return 0;
|
||||
} else {
|
||||
$NZL_DST=1; return 1;
|
||||
}
|
||||
} else {
|
||||
if ($dow == 0 && $ns < 3600) {
|
||||
$NZL_DST=0; return 0;
|
||||
} else {
|
||||
$NZL_DST=1; return 1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$NZL_DST=0; return 0;
|
||||
}
|
||||
} # end of month checks
|
||||
} # end of subroutine dstcalc
|
||||
@@ -0,0 +1,67 @@
|
||||
#!/usr/bin/perl
|
||||
# ADMIN_area_code_populate.pl version 1.1.12 for Perl
|
||||
#
|
||||
# Copyright (C) 2006 Joe Johnson,Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
|
||||
#
|
||||
# Description:
|
||||
# server application that allows load areacodes into to asterisk list database
|
||||
#
|
||||
#
|
||||
# CHANGES
|
||||
# 60615-1514 - Changed to ignore the header row
|
||||
#
|
||||
|
||||
use lib ".\\",".\\libs", './', './libs', '../libs', '/usr/local/perl_TK/libs', 'C:\\AST_VICI\\libs';
|
||||
use Time::HiRes ('gettimeofday','usleep','sleep'); # needed to have perl sleep in increments of less than one second
|
||||
use Net::MySQL;
|
||||
|
||||
### Make sure this file is in a libs path or put the absolute path to it
|
||||
require("/home/cron/AST_SERVER_conf.pl"); # local configuration file
|
||||
|
||||
if (!$DB_port) {$DB_port='3306';}
|
||||
|
||||
$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";
|
||||
|
||||
|
||||
$slash_star = '\*';
|
||||
|
||||
open(codefile, "/home/cron/phone_codes_GMT.txt") || die "can't open /home/cron/phone_codes_GMT.txt: $!\n";
|
||||
@codefile = <codefile>;
|
||||
close(codefile);
|
||||
$pc=0;
|
||||
$ins_stmt="insert into vicidial_phone_codes VALUES ";
|
||||
foreach (@codefile)
|
||||
{
|
||||
@row=split(/\t/, $codefile[$pc]);
|
||||
if ($codefile[$pc] !~ /GEOGRAPHIC DESCRIPTION/)
|
||||
{
|
||||
$pc++;
|
||||
$row[7] =~ s/\r|\n|\t| $//gi;
|
||||
$row[6] =~ s/\r|\n|\t| $//gi;
|
||||
$row[5] =~ s/\r|\n|\t| $//gi;
|
||||
$row[4] =~ s/\r|\n|\t| $//gi;
|
||||
$row[3] =~ s/\r|\n|\t| $//gi;
|
||||
$row[2] =~ s/\r|\n|\t| $//gi;
|
||||
$row[1] =~ s/\r|\n|\t| $//gi;
|
||||
$row[0] =~ s/\r|\n|\t| $//gi;
|
||||
$ins_stmt.="('$row[0]', '$row[1]', '$row[2]', '$row[3]', '$row[4]', '$row[5]', '$row[6]', '$row[7]'), ";
|
||||
if ($pc =~ /00$/)
|
||||
{
|
||||
chop($ins_stmt);
|
||||
chop($ins_stmt);
|
||||
$dbh->query($ins_stmt) || die "can't execute query: |$ins_stmt| $!\n";
|
||||
$ins_stmt="insert into vicidial_phone_codes VALUES ";
|
||||
print STDERR "$pc\n";
|
||||
}
|
||||
}
|
||||
else {$pc++;}
|
||||
}
|
||||
|
||||
chop($ins_stmt);
|
||||
chop($ins_stmt);
|
||||
$dbh->query($ins_stmt);
|
||||
$ins_stmt="insert into vicidial_phone_codes VALUES ";
|
||||
print STDERR "$pc\n";
|
||||
|
||||
exit;
|
||||
@@ -0,0 +1,120 @@
|
||||
#!/usr/bin/perl
|
||||
#
|
||||
# ADMIN_keepalive_AST_VDauto_dial.pl version 0.3
|
||||
#
|
||||
# designed to keep the AST_update processes aline and check every minute
|
||||
#
|
||||
# Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
|
||||
#
|
||||
#
|
||||
# 50810-1452 - removed '-L' flag for screen logging of output (optimization)
|
||||
# 50823-1454 - Added commandline debug options with debug printouts
|
||||
#
|
||||
|
||||
$DB=0; # Debug flag
|
||||
$MT[0]=''; $MT[1]='';
|
||||
@psline=@MT;
|
||||
|
||||
### begin parsing run-time options ###
|
||||
if (length($ARGV[0])>1)
|
||||
{
|
||||
$i=0;
|
||||
while ($#ARGV >= $i)
|
||||
{
|
||||
$args = "$args $ARGV[$i]";
|
||||
$i++;
|
||||
}
|
||||
|
||||
if ($args =~ /--help/i)
|
||||
{
|
||||
print "allowed run time options:\n [-t] = test\n [-debug] = verbose debug messages\n[-debugX] = Extra-verbose debug messages\n\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($args =~ /-debug/i)
|
||||
{
|
||||
$DB=1; # Debug flag
|
||||
}
|
||||
if ($args =~ /--debugX/i)
|
||||
{
|
||||
$DBX=1;
|
||||
print "\n----- SUPER-DUPER DEBUGGING -----\n\n";
|
||||
}
|
||||
if ($args =~ /-t/i)
|
||||
{
|
||||
$TEST=1;
|
||||
$T=1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
# print "no command line options set\n";
|
||||
}
|
||||
### end parsing run-time options ###
|
||||
|
||||
|
||||
#@psoutput = `ps -f -C AST_update --no-headers`;
|
||||
#@psoutput = `ps -f -C AST_updat* --no-headers`;
|
||||
#@psoutput = `/bin/ps -f --no-headers -A`;
|
||||
@psoutput = `/bin/ps -o "%p %a" --no-headers -A`;
|
||||
|
||||
$running_VDAD = 0;
|
||||
|
||||
$i=0;
|
||||
foreach (@psoutput)
|
||||
{
|
||||
chomp($psoutput[$i]);
|
||||
if ($DBX) {print "$i|$psoutput[$i]| \n";}
|
||||
@psline = split(/\/usr\/bin\/perl /,$psoutput[$i]);
|
||||
|
||||
if ($psline[1] =~ /\/home\/cron\/AST_VDauto_dial\.pl/)
|
||||
{
|
||||
$running_VDAD++;
|
||||
if ($DB) {print "VDAD RUNNING: |$psline[1]|\n";}
|
||||
}
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
|
||||
if (!$running_VDAD)
|
||||
{
|
||||
# print "double check that VDAD is not running\n";
|
||||
|
||||
sleep(4);
|
||||
|
||||
#@psoutput = `ps -f -C AST_update --no-headers`;
|
||||
#@psoutput = `ps -f -C AST_updat* --no-headers`;
|
||||
#@psoutput = `/bin/ps -f --no-headers -A`;
|
||||
@psoutput = `/bin/ps -o "%p %a" --no-headers -A`;
|
||||
$i=0;
|
||||
foreach (@psoutput2)
|
||||
{
|
||||
chomp($psoutput2[$i]);
|
||||
if ($DBX) {print "$i|$psoutput[$i]| \n";}
|
||||
@psline = split(/\/usr\/bin\/perl /,$psoutput2[$i]);
|
||||
|
||||
if ($psline[1] =~ /\/home\/cron\/AST_VDauto_dial\.pl/)
|
||||
{
|
||||
$running_VDAD++;
|
||||
if ($DB) {print "VDAD RUNNING: |$psline[1]|\n";}
|
||||
}
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
if (!$running_VDAD)
|
||||
{
|
||||
if ($DB) {print "starting AST_VDauto_dial...\n";}
|
||||
# add a '-L' to the command below to activate logging
|
||||
`/usr/bin/screen -d -m -S ASTVDauto /home/cron/AST_VDauto_dial.pl`;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if ($DB) {print "DONE\n";}
|
||||
|
||||
exit;
|
||||
@@ -0,0 +1,119 @@
|
||||
#!/usr/bin/perl
|
||||
#
|
||||
# ADMIN_keepalive_AST_VDremote_agents.pl version 0.3
|
||||
#
|
||||
# designed to keep the AST_update processes aline and check every minute
|
||||
#
|
||||
# Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
|
||||
#
|
||||
#
|
||||
# 50810-1453 - removed '-L' flag for screen logging of output (optimization)
|
||||
# 50823-1459 - Added commandline debug options with debug printouts
|
||||
#
|
||||
|
||||
$DB=0; # Debug flag
|
||||
$MT[0]=''; $MT[1]='';
|
||||
@psline=@MT;
|
||||
|
||||
### begin parsing run-time options ###
|
||||
if (length($ARGV[0])>1)
|
||||
{
|
||||
$i=0;
|
||||
while ($#ARGV >= $i)
|
||||
{
|
||||
$args = "$args $ARGV[$i]";
|
||||
$i++;
|
||||
}
|
||||
|
||||
if ($args =~ /--help/i)
|
||||
{
|
||||
print "allowed run time options:\n [-t] = test\n [-debug] = verbose debug messages\n[-debugX] = Extra-verbose debug messages\n\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($args =~ /-debug/i)
|
||||
{
|
||||
$DB=1; # Debug flag
|
||||
}
|
||||
if ($args =~ /--debugX/i)
|
||||
{
|
||||
$DBX=1;
|
||||
print "\n----- SUPER-DUPER DEBUGGING -----\n\n";
|
||||
}
|
||||
if ($args =~ /-t/i)
|
||||
{
|
||||
$TEST=1;
|
||||
$T=1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
# print "no command line options set\n";
|
||||
}
|
||||
### end parsing run-time options ###
|
||||
|
||||
#@psoutput = `ps -f -C AST_update --no-headers`;
|
||||
#@psoutput = `ps -f -C AST_updat* --no-headers`;
|
||||
#@psoutput = `/bin/ps -f --no-headers -A`;
|
||||
@psoutput = `/bin/ps -o "%p %a" --no-headers -A`;
|
||||
|
||||
$running_VDra = 0;
|
||||
|
||||
$i=0;
|
||||
foreach (@psoutput)
|
||||
{
|
||||
chomp($psoutput[$i]);
|
||||
if ($DBX) {print "$i|$psoutput[$i]| \n";}
|
||||
@psline = split(/\/usr\/bin\/perl /,$psoutput[$i]);
|
||||
|
||||
if ($psline[1] =~ /\/home\/cron\/AST_VDremote_agents\.pl/)
|
||||
{
|
||||
$running_VDra++;
|
||||
if ($DB) {print "VDra RUNNING: |$psline[1]|\n";}
|
||||
}
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
|
||||
if (!$running_VDra)
|
||||
{
|
||||
# print "double check that update is not running\n";
|
||||
|
||||
sleep(5);
|
||||
|
||||
#@psoutput = `ps -f -C AST_update --no-headers`;
|
||||
#@psoutput = `ps -f -C AST_updat* --no-headers`;
|
||||
#@psoutput = `/bin/ps -f --no-headers -A`;
|
||||
@psoutput = `/bin/ps -o "%p %a" --no-headers -A`;
|
||||
$i=0;
|
||||
foreach (@psoutput2)
|
||||
{
|
||||
chomp($psoutput2[$i]);
|
||||
if ($DBX) {print "$i|$psoutput[$i]| \n";}
|
||||
@psline = split(/\/usr\/bin\/perl /,$psoutput2[$i]);
|
||||
|
||||
if ($psline[1] =~ /\/home\/cron\/AST_VDremote_agents\.pl/)
|
||||
{
|
||||
$running_VDra++;
|
||||
if ($DB) {print "VDra RUNNING: |$psline[1]|\n";}
|
||||
}
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
if (!$running_VDra)
|
||||
{
|
||||
if ($DB) {print "starting AST_VDremote_agents...\n";}
|
||||
# add a '-L' to the command below to activate logging
|
||||
`/usr/bin/screen -d -m -S ASTVDremote /home/cron/AST_VDremote_agents.pl`;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if ($DB) {print "DONE\n";}
|
||||
|
||||
exit;
|
||||
@@ -0,0 +1,169 @@
|
||||
#!/usr/bin/perl
|
||||
#
|
||||
# ADMIN_keepalive_AST_send_listen.pl version 0.3
|
||||
#
|
||||
# designed to keep the AST_manager_listen and manager_send processes alive and check every minute
|
||||
#
|
||||
# if you are on an older system you may need to change the @psoutput lines to fit your ps version
|
||||
#
|
||||
# Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
|
||||
#
|
||||
#
|
||||
# 50810-1450 - removed '-L' flag for screen logging of output (optimization)
|
||||
# 50823-1440 - Added commandline debug options with debug printouts
|
||||
#
|
||||
|
||||
$DB=0; # Debug flag
|
||||
$MT[0]=''; $MT[1]='';
|
||||
@psline=@MT;
|
||||
|
||||
### begin parsing run-time options ###
|
||||
if (length($ARGV[0])>1)
|
||||
{
|
||||
$i=0;
|
||||
while ($#ARGV >= $i)
|
||||
{
|
||||
$args = "$args $ARGV[$i]";
|
||||
$i++;
|
||||
}
|
||||
|
||||
if ($args =~ /--help/i)
|
||||
{
|
||||
print "allowed run time options:\n [-t] = test\n [-debug] = verbose debug messages\n[-debugX] = Extra-verbose debug messages\n\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($args =~ /-debug/i)
|
||||
{
|
||||
$DB=1; # Debug flag
|
||||
}
|
||||
if ($args =~ /--debugX/i)
|
||||
{
|
||||
$DBX=1;
|
||||
print "\n----- SUPER-DUPER DEBUGGING -----\n\n";
|
||||
}
|
||||
if ($args =~ /-t/i)
|
||||
{
|
||||
$TEST=1;
|
||||
$T=1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
# print "no command line options set\n";
|
||||
}
|
||||
### end parsing run-time options ###
|
||||
|
||||
sleep(1);
|
||||
|
||||
|
||||
#@psoutput = `ps -f -C AST_manager --no-headers`;
|
||||
#@psoutput = `ps -f --no-headers -C AST_manager_s*; ps -f --no-headers -C AST_manager_l*`;
|
||||
#@psoutput = `/bin/ps -f --no-headers -A`;
|
||||
@psoutput = `/bin/ps -o "%p %a" --no-headers -A`;
|
||||
|
||||
$running_listen = 0;
|
||||
$running_send = 0;
|
||||
|
||||
$i=0;
|
||||
foreach (@psoutput)
|
||||
{
|
||||
chomp($psoutput[$i]);
|
||||
if ($DBX) {print "$i|$psoutput[$i]| \n";}
|
||||
@psline = split(/\/usr\/bin\/perl /,$psoutput[$i]);
|
||||
|
||||
if ($psline[1] =~ /AST_manager_li/)
|
||||
{
|
||||
$running_listen++;
|
||||
if ($DB) {print "LISTEN RUNNING: |$psline[1]|\n";}
|
||||
}
|
||||
if ($psline[1] =~ /AST_manager_se/)
|
||||
{
|
||||
$running_send++;
|
||||
if ($DB) {print "SEND RUNNING: |$psline[1]|\n";}
|
||||
}
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (!$running_listen)
|
||||
{
|
||||
# print "double check that update_11 is not running\n";
|
||||
|
||||
sleep(1);
|
||||
|
||||
#@psoutput = `ps -f -C AST_manager --no-headers`;
|
||||
#@psoutput = `ps -f --no-headers -C AST_manager_s*; ps -f --no-headers -C AST_manager_l*`;
|
||||
#@psoutput = `/bin/ps -f --no-headers -A`;
|
||||
@psoutput = `/bin/ps -o "%p %a" --no-headers -A`;
|
||||
|
||||
$i=0;
|
||||
foreach (@psoutput2)
|
||||
{
|
||||
chomp($psoutput2[$i]);
|
||||
if ($DBX) {print "$i|$psoutput[$i]| \n";}
|
||||
@psline = split(/\/usr\/bin\/perl /,$psoutput2[$i]);
|
||||
|
||||
if ($psline[1] =~ /AST_manager_li/)
|
||||
{
|
||||
$running_listen++;
|
||||
if ($DB) {print "LISTEN RUNNING: |$psline[1]|\n";}
|
||||
}
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
if (!$running_listen)
|
||||
{
|
||||
if ($DB) {print "starting AST_manager_listen...\n";}
|
||||
# add a '-L' to the command below to activate logging
|
||||
`/usr/bin/screen -d -m -S ASTlisten /home/cron/AST_manager_listen.pl`;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if (!$running_send)
|
||||
{
|
||||
# print "double check that update_12 is not running\n";
|
||||
|
||||
sleep(1);
|
||||
|
||||
#@psoutput = `ps -f -C AST_manager --no-headers`;
|
||||
#@psoutput = `ps -f --no-headers -C AST_manager_s*; ps -f --no-headers -C AST_manager_l*`;
|
||||
#@psoutput = `/bin/ps -f --no-headers -A`;
|
||||
@psoutput = `/bin/ps -o "%p %a" --no-headers -A`;
|
||||
$i=0;
|
||||
foreach (@psoutput)
|
||||
{
|
||||
chomp($psoutput[$i]);
|
||||
if ($DBX) {print "$i|$psoutput[$i]| \n";}
|
||||
@psline = split(/\/usr\/bin\/perl /,$psoutput[$i]);
|
||||
|
||||
if ($psline[1] =~ /AST_manager_se/)
|
||||
{
|
||||
$running_send++;
|
||||
if ($DB) {print "SEND RUNNING: |$psline[1]|";}
|
||||
}
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
if (!$running_send)
|
||||
{
|
||||
if ($DB) {print "starting AST_manager_send...\n";}
|
||||
# add a '-L' to the command below to activate logging
|
||||
`/usr/bin/screen -d -m -S ASTsend /home/cron/AST_manager_send.pl`;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if ($DB) {print "DONE\n";}
|
||||
|
||||
exit;
|
||||
@@ -0,0 +1,121 @@
|
||||
#!/usr/bin/perl
|
||||
#
|
||||
# ADMIN_keepalive_AST_update.pl version 0.4
|
||||
#
|
||||
# designed to keep the AST_update processes aline and check every minute
|
||||
#
|
||||
# Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
|
||||
#
|
||||
#
|
||||
# 50810-1451 - removed '-L' flag for screen logging of output (optimization)
|
||||
# 50823-1446 - Added commandline debug options with debug printouts
|
||||
# 51229-1027 - fixed typo of array name
|
||||
#
|
||||
|
||||
$DB=0; # Debug flag
|
||||
$MT[0]=''; $MT[1]='';
|
||||
@psline=@MT;
|
||||
|
||||
### begin parsing run-time options ###
|
||||
if (length($ARGV[0])>1)
|
||||
{
|
||||
$i=0;
|
||||
while ($#ARGV >= $i)
|
||||
{
|
||||
$args = "$args $ARGV[$i]";
|
||||
$i++;
|
||||
}
|
||||
|
||||
if ($args =~ /--help/i)
|
||||
{
|
||||
print "allowed run time options:\n [-t] = test\n [-debug] = verbose debug messages\n[-debugX] = Extra-verbose debug messages\n\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($args =~ /-debug/i)
|
||||
{
|
||||
$DB=1; # Debug flag
|
||||
}
|
||||
if ($args =~ /--debugX/i)
|
||||
{
|
||||
$DBX=1;
|
||||
print "\n----- SUPER-DUPER DEBUGGING -----\n\n";
|
||||
}
|
||||
if ($args =~ /-t/i)
|
||||
{
|
||||
$TEST=1;
|
||||
$T=1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
# print "no command line options set\n";
|
||||
}
|
||||
### end parsing run-time options ###
|
||||
|
||||
|
||||
#@psoutput = `ps -f -C AST_update --no-headers`;
|
||||
#@psoutput = `ps -f -C AST_updat* --no-headers`;
|
||||
#@psoutput = `/bin/ps -f --no-headers -A`;
|
||||
@psoutput = `/bin/ps -o "%p %a" --no-headers -A`;
|
||||
|
||||
$running_update = 0;
|
||||
|
||||
$i=0;
|
||||
foreach (@psoutput)
|
||||
{
|
||||
chomp($psoutput[$i]);
|
||||
if ($DBX) {print "$i|$psoutput[$i]| \n";}
|
||||
@psline = split(/\/usr\/bin\/perl /,$psoutput[$i]);
|
||||
|
||||
if ($psline[1] =~ /\/home\/cron\/AST_update\.pl/)
|
||||
{
|
||||
$running_update++;
|
||||
if ($DB) {print "UPDATE RUNNING: |$psline[1]|\n";}
|
||||
}
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
|
||||
if (!$running_update)
|
||||
{
|
||||
# print "double check that update is not running\n";
|
||||
|
||||
sleep(5);
|
||||
|
||||
#@psoutput = `ps -f -C AST_update --no-headers`;
|
||||
#@psoutput = `ps -f -C AST_updat* --no-headers`;
|
||||
#@psoutput = `/bin/ps -f --no-headers -A`;
|
||||
@psoutput2 = `/bin/ps -o "%p %a" --no-headers -A`;
|
||||
$i=0;
|
||||
foreach (@psoutput2)
|
||||
{
|
||||
chomp($psoutput2[$i]);
|
||||
if ($DBX) {print "$i|$psoutput[$i]| \n";}
|
||||
@psline = split(/\/usr\/bin\/perl /,$psoutput2[$i]);
|
||||
|
||||
if ($psline[1] =~ /\/home\/cron\/AST_update\.pl/)
|
||||
{
|
||||
$running_update++;
|
||||
if ($DB) {print "UPDATE RUNNING: |$psline[1]|\n";}
|
||||
}
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
if (!$running_update)
|
||||
{
|
||||
if ($DB) {print "starting AST_update...\n";}
|
||||
# add a '-L' to the command below to activate logging
|
||||
`/usr/bin/screen -d -m -S ASTupdate /home/cron/AST_update.pl`;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if ($DB) {print "DONE\n";}
|
||||
|
||||
exit;
|
||||
@@ -0,0 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
/home/cron/ADMIN_keepalive_AST_send_listen.pl
|
||||
|
||||
exit
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
#!/usr/bin/perl
|
||||
# ADMIN_restart_roll_logs.pl - script to roll the Asterisk logs on machine restart
|
||||
# have this run on the astersik server
|
||||
#
|
||||
# Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
|
||||
#
|
||||
|
||||
($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";
|
||||
|
||||
|
||||
print "rolling AST_update log...\n";
|
||||
`mv -f /home/cron/LOG_AST_update.log /home/cron/LOGS/LOG_AST_update.log.$now_date`;
|
||||
|
||||
print "rolling MSAST_update log...\n";
|
||||
`mv -f /home/cron/MSLOG_AST_update.log /home/cron/LOGS/MSLOG_AST_update.log.$now_date`;
|
||||
|
||||
print "rolling LIAST_update log...\n";
|
||||
`mv -f /home/cron/LILOG_AST_update.log /home/cron/LOGS/LILOG_AST_update.log.$now_date`;
|
||||
|
||||
print "rolling VDAST_update log...\n";
|
||||
`mv -f /home/cron/VDLOG_AST_update.log /home/cron/LOGS/VDLOG_AST_update.log.$now_date`;
|
||||
|
||||
print "rolling Asterisk messages log...\n";
|
||||
`mv -f /var/log/asterisk/messages /var/log/asterisk/messages.$now_date`;
|
||||
|
||||
print "rolling Asterisk event log...\n";
|
||||
`mv -f /var/log/asterisk/event_log /var/log/asterisk/event_log.$now_date`;
|
||||
|
||||
print "rolling Asterisk cdr logs...\n";
|
||||
`mv -f /var/log/asterisk/cdr-csv/Master.csv /var/log/asterisk/cdr-csv/Master.csv.$now_date`;
|
||||
`mv -f /var/log/asterisk/cdr-custom/Master.csv /var/log/asterisk/cdr-custom/Master.csv.$now_date`;
|
||||
|
||||
print "rolling Asterisk screen log...\n";
|
||||
`mv -f /screenlog.0 /screenlog.0.$now_date`;
|
||||
|
||||
print "rolling Asterisk root screen log...\n";
|
||||
`mv -f /root/screenlog.0 /root/screenlog.0.$now_date`;
|
||||
|
||||
|
||||
print "FINISHED... EXITING\n";
|
||||
|
||||
exit;
|
||||
@@ -0,0 +1,124 @@
|
||||
#!/usr/bin/perl
|
||||
#
|
||||
# AST_CRON_mix_recordings.pl
|
||||
# runs every 5 minutes and mixes the call recordings in the monitor together
|
||||
# and puts the resulting ALL file into the DONE directory in the "monitor" dir
|
||||
#
|
||||
# soxmix is REQUIRED to use this script, soxmix is available only as part of
|
||||
# the sox audio package, and only in newer versions. Make sure you have soxmix
|
||||
# installed properly and in your path
|
||||
#
|
||||
# put an entry into the cron of of your asterisk machine to run this script
|
||||
# every 5 minutes or however often you desire
|
||||
#
|
||||
# make sure that the following directories exist:
|
||||
# /var/spool/asterisk/monitor # default Asterisk recording directory
|
||||
# /var/spool/asterisk/monitor/DONE # where the combined files are put
|
||||
# /var/spool/asterisk/monitor/ORIG # where the original in/out files are put
|
||||
#
|
||||
# This program assumes that recordings are saved as .wav
|
||||
# should be easy to change this code if you use .gsm instead
|
||||
#
|
||||
# This program also sends the ALL combined file to an FTP server for archival
|
||||
# purposes, you can comment out the Net::Ping and Net::FTP lines as well as the
|
||||
# file transfer section of the code to deactivate remote copying of the
|
||||
# recording files
|
||||
#
|
||||
# Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
|
||||
#
|
||||
#
|
||||
# 51021-1058 Added quotes around CLI executed commands
|
||||
# 51122-1458 Added soxmix binary path check
|
||||
# 60318-0921 Added ability to mix gsm audio files
|
||||
#
|
||||
|
||||
|
||||
#$v=1;
|
||||
|
||||
# Customize variables for FTP
|
||||
$FTP_host = '10.0.0.4';
|
||||
$FTP_user = 'cron';
|
||||
$FTP_pass = 'test';
|
||||
$FTP_dir = 'RECORDINGS';
|
||||
|
||||
### directory where in/out recordings are saved to by Asterisk
|
||||
$dir1 = '/var/spool/asterisk/monitor';
|
||||
|
||||
$soxmixbin = '';
|
||||
if ( -e ('/usr/bin/soxmix')) {$soxmixbin = '/usr/bin/soxmix';}
|
||||
else
|
||||
{
|
||||
if ( -e ('/usr/local/bin/soxmix')) {$soxmixbin = '/usr/local/bin/soxmix';}
|
||||
else
|
||||
{
|
||||
print "Can't find soxmix binary! Exiting...\n";
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
use Net::Ping;
|
||||
use Net::FTP;
|
||||
|
||||
|
||||
opendir(FILE, "$dir1/");
|
||||
@FILES = readdir(FILE);
|
||||
|
||||
$i=0;
|
||||
foreach(@FILES)
|
||||
{
|
||||
$size1 = 0;
|
||||
$size2 = 0;
|
||||
|
||||
if ( (length($FILES[$i]) > 4) && (!-d $FILES[$i]) )
|
||||
{
|
||||
|
||||
$size1 = (-s "$dir1/$FILES[$i]");
|
||||
if ($v) {print "$FILES[$i] $size1\n";}
|
||||
sleep(1);
|
||||
$size2 = (-s "$dir1/$FILES[$i]");
|
||||
if ($v) {print "$FILES[$i] $size2\n\n";}
|
||||
|
||||
if ( ($FILES[$i] !~ /out\.wav|out\.gsm/i) && ($size1 eq $size2) && (length($FILES[$i]) > 4))
|
||||
{
|
||||
$INfile = $FILES[$i];
|
||||
$OUTfile = $FILES[$i];
|
||||
$OUTfile =~ s/-in\.wav/-out.wav/gi;
|
||||
$OUTfile =~ s/-in\.gsm/-out.gsm/gi;
|
||||
$ALLfile = $FILES[$i];
|
||||
$ALLfile =~ s/-in\.wav/-all.wav/gi;
|
||||
$ALLfile =~ s/-in\.gsm/-all.gsm/gi;
|
||||
|
||||
if ($v) {print "|$INfile| |$OUTfile| |$ALLfile|\n\n";}
|
||||
|
||||
`$soxmixbin "$dir1/$INfile" "$dir1/$OUTfile" "$dir1/$ALLfile"`;
|
||||
if ($v) {print "|$INfile| |$OUTfile| |$ALLfile|\n\n";}
|
||||
if (!$T)
|
||||
{
|
||||
`mv -f "$dir1/$INfile" "$dir1/ORIG/$INfile"`;
|
||||
`mv -f "$dir1/$OUTfile" "$dir1/ORIG/$OUTfile"`;
|
||||
`mv -f "$dir1/$ALLfile" "$dir1/DONE/$ALLfile"`;
|
||||
}
|
||||
|
||||
### BEGIN Remote file transfer
|
||||
$p = Net::Ping->new();
|
||||
$ping_good = $p->ping("$FTP_host");
|
||||
|
||||
if ($ping_good)
|
||||
{
|
||||
$ftp = Net::FTP->new("$FTP_host", Port => 21);
|
||||
$ftp->login("$FTP_user","$FTP_pass");
|
||||
$ftp->cwd("$FTP_dir");
|
||||
$ftp->binary();
|
||||
$ftp->put("$dir1/DONE/$ALLfile", "$ALLfile");
|
||||
$ftp->quit;
|
||||
}
|
||||
### END Remote file transfer
|
||||
|
||||
}
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
|
||||
if ($v) {print "DONE... EXITING\n\n";}
|
||||
|
||||
exit;
|
||||
@@ -0,0 +1,100 @@
|
||||
#!/usr/bin/perl
|
||||
#
|
||||
# AST_CRON_mix_recordings_BASIC.pl
|
||||
# runs every 5 minutes and mixes the call recordings in the monitor together
|
||||
# and puts the resulting ALL file into the DONE directory in the "monitor" dir
|
||||
#
|
||||
# soxmix is REQUIRED to use this script, soxmix is available only as part of
|
||||
# the sox audio package, and only in newer versions. Make sure you have soxmix
|
||||
# installed properly and in your path
|
||||
#
|
||||
# put an entry into the cron of of your asterisk machine to run this script
|
||||
# every 5 minutes or however often you desire
|
||||
#
|
||||
# make sure that the following directories exist:
|
||||
# /var/spool/asterisk/monitor # default Asterisk recording directory
|
||||
# /var/spool/asterisk/monitor/DONE # where the combined files are put
|
||||
# /var/spool/asterisk/monitor/ORIG # where the original in/out files are put
|
||||
#
|
||||
# This program assumes that recordings are saved as .wav
|
||||
# should be easy to change this code if you use .gsm instead
|
||||
#
|
||||
# This program also sends the ALL combined file to an FTP server for archival
|
||||
# purposes, you can comment out the Net::Ping and Net::FTP lines as well as the
|
||||
# file transfer section of the code to deactivate remote copying of the
|
||||
# recording files
|
||||
#
|
||||
# Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
|
||||
#
|
||||
#
|
||||
# 51021-1058 Added quotes around CLI executed commands
|
||||
# 51122-1456 Added soxmix binary path check
|
||||
# 60318-0921 Added ability to mix gsm audio files
|
||||
#
|
||||
|
||||
|
||||
#$v=1;
|
||||
|
||||
|
||||
### directory where in/out recordings are saved to by Asterisk
|
||||
$dir1 = '/var/spool/asterisk/monitor';
|
||||
|
||||
$soxmixbin = '';
|
||||
if ( -e ('/usr/bin/soxmix')) {$soxmixbin = '/usr/bin/soxmix';}
|
||||
else
|
||||
{
|
||||
if ( -e ('/usr/local/bin/soxmix')) {$soxmixbin = '/usr/local/bin/soxmix';}
|
||||
else
|
||||
{
|
||||
print "Can't find soxmix binary! Exiting...\n";
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
opendir(FILE, "$dir1/");
|
||||
@FILES = readdir(FILE);
|
||||
|
||||
$i=0;
|
||||
foreach(@FILES)
|
||||
{
|
||||
$size1 = 0;
|
||||
$size2 = 0;
|
||||
|
||||
if ( (length($FILES[$i]) > 4) && (!-d $FILES[$i]) )
|
||||
{
|
||||
|
||||
$size1 = (-s "$dir1/$FILES[$i]");
|
||||
if ($v) {print "$FILES[$i] $size1\n";}
|
||||
sleep(1);
|
||||
$size2 = (-s "$dir1/$FILES[$i]");
|
||||
if ($v) {print "$FILES[$i] $size2\n\n";}
|
||||
|
||||
|
||||
if ( ($FILES[$i] !~ /out\.wav|out\.gsm/i) && ($size1 eq $size2) && (length($FILES[$i]) > 4))
|
||||
{
|
||||
$INfile = $FILES[$i];
|
||||
$OUTfile = $FILES[$i];
|
||||
$OUTfile =~ s/-in\.wav/-out.wav/gi;
|
||||
$OUTfile =~ s/-in\.gsm/-out.gsm/gi;
|
||||
$ALLfile = $FILES[$i];
|
||||
$ALLfile =~ s/-in\.wav/-all.wav/gi;
|
||||
$ALLfile =~ s/-in\.gsm/-all.gsm/gi;
|
||||
|
||||
if ($v) {print "|$INfile| |$OUTfile| |$ALLfile|\n\n";}
|
||||
|
||||
`$soxmixbin "$dir1/$INfile" "$dir1/$OUTfile" "$dir1/$ALLfile"`;
|
||||
if ($v) {print "|$INfile| |$OUTfile| |$ALLfile|\n\n";}
|
||||
if (!$T)
|
||||
{
|
||||
`mv -f "$dir1/$INfile" "$dir1/ORIG/$INfile"`;
|
||||
`mv -f "$dir1/$OUTfile" "$dir1/ORIG/$OUTfile"`;
|
||||
`mv -f "$dir1/$ALLfile" "$dir1/DONE/$ALLfile"`;
|
||||
}
|
||||
}
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
|
||||
if ($v) {print "DONE... EXITING\n\n";}
|
||||
|
||||
exit;
|
||||
@@ -0,0 +1,151 @@
|
||||
#!/usr/bin/perl
|
||||
#
|
||||
# AST_CRON_mix_recordings_GSM.pl
|
||||
# runs every 5 minutes and mixes the call recordings in the monitor together
|
||||
# and puts the resulting ALL file into the DONE directory in the "monitor" dir
|
||||
# and converts the ALL file to GSM format to save space.
|
||||
#
|
||||
# soxmix is REQUIRED to use this script, soxmix is available only as part of
|
||||
# the sox audio package, and only in newer versions. Make sure you have soxmix
|
||||
# installed properly and in your path
|
||||
#
|
||||
# put an entry into the cron of of your asterisk machine to run this script
|
||||
# every 5 minutes or however often you desire
|
||||
#
|
||||
# make sure that the following directories exist:
|
||||
# /var/spool/asterisk/monitor # default Asterisk recording directory
|
||||
# /var/spool/asterisk/monitor/DONE # where the combined files are put
|
||||
# /var/spool/asterisk/monitor/ORIG # where the original in/out files are put
|
||||
#
|
||||
# This program assumes that recordings are saved as .wav
|
||||
# should be easy to change this code if you use .gsm instead
|
||||
#
|
||||
# This program also sends the ALL combined file to an FTP server for archival
|
||||
# purposes, you can comment out the Net::Ping and Net::FTP lines as well as the
|
||||
# file transfer section of the code to deactivate remote copying of the
|
||||
# recording files
|
||||
#
|
||||
# Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
|
||||
#
|
||||
#
|
||||
# 51021-1058 Added quotes around CLI executed commands
|
||||
# 51122-1455 Added soxmix and sox binary path check
|
||||
#
|
||||
|
||||
|
||||
#$v=1;
|
||||
|
||||
# Customize variables for FTP
|
||||
$FTP_host = '10.0.0.4';
|
||||
$FTP_user = 'cron';
|
||||
$FTP_pass = 'test';
|
||||
$FTP_dir = 'RECORDINGS';
|
||||
$FTP_port = '21';
|
||||
|
||||
### directory where in/out recordings are saved to by Asterisk
|
||||
$dir1 = '/var/spool/asterisk/monitor';
|
||||
|
||||
$soxmixbin = '';
|
||||
if ( -e ('/usr/bin/soxmix')) {$soxmixbin = '/usr/bin/soxmix';}
|
||||
else
|
||||
{
|
||||
if ( -e ('/usr/local/bin/soxmix')) {$soxmixbin = '/usr/local/bin/soxmix';}
|
||||
else
|
||||
{
|
||||
print "Can't find soxmix binary! Exiting...\n";
|
||||
exit;
|
||||
}
|
||||
}
|
||||
$soxbin = '';
|
||||
if ( -e ('/usr/bin/sox')) {$soxbin = '/usr/bin/sox';}
|
||||
else
|
||||
{
|
||||
if ( -e ('/usr/local/bin/sox')) {$soxbin = '/usr/local/bin/sox';}
|
||||
else
|
||||
{
|
||||
print "Can't find sox binary! Exiting...\n";
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
use Net::Ping;
|
||||
use Net::FTP;
|
||||
|
||||
|
||||
opendir(FILE, "$dir1/");
|
||||
@FILES = readdir(FILE);
|
||||
|
||||
$i=0;
|
||||
foreach(@FILES)
|
||||
{
|
||||
$size1 = 0;
|
||||
$size2 = 0;
|
||||
|
||||
if ( (length($FILES[$i]) > 4) && (!-d $FILES[$i]) )
|
||||
{
|
||||
|
||||
$size1 = (-s "$dir1/$FILES[$i]");
|
||||
if ($v) {print "$FILES[$i] $size1\n";}
|
||||
sleep(1);
|
||||
$size2 = (-s "$dir1/$FILES[$i]");
|
||||
if ($v) {print "$FILES[$i] $size2\n\n";}
|
||||
|
||||
|
||||
if ( ($FILES[$i] !~ /out\.wav/i) && ($size1 eq $size2) && (length($FILES[$i]) > 4))
|
||||
{
|
||||
$INfile = $FILES[$i];
|
||||
$OUTfile = $FILES[$i];
|
||||
$OUTfile =~ s/-in\.wav/-out.wav/gi;
|
||||
$ALLfile = $FILES[$i];
|
||||
$ALLfile =~ s/-in\.wav/-all.wav/gi;
|
||||
$GSMfile = $ALLfile;
|
||||
$GSMfile =~ s/-all\.wav/-all.gsm/gi;
|
||||
|
||||
if ($v) {print "|$INfile| |$OUTfile| |$ALLfile|\n\n";}
|
||||
|
||||
`$soxmixbin "$dir1/$INfile" "$dir1/$OUTfile" "$dir1/$ALLfile"`;
|
||||
if ($v) {print "|$INfile| |$OUTfile| |$ALLfile|\n\n";}
|
||||
if (!$T)
|
||||
{
|
||||
`mv -f "$dir1/$INfile" "$dir1/ORIG/$INfile"`;
|
||||
`mv -f "$dir1/$OUTfile" "$dir1/ORIG/$OUTfile"`;
|
||||
`mv -f "$dir1/$ALLfile" "$dir1/DONE/$ALLfile"`;
|
||||
}
|
||||
else
|
||||
{
|
||||
`cp -f "$dir1/$ALLfile" "$dir1/DONE/$ALLfile"`;
|
||||
}
|
||||
|
||||
`$soxbin "$dir1/DONE/$ALLfile" "$dir1/DONE/$GSMfile"`;
|
||||
|
||||
if (!$T)
|
||||
{
|
||||
`rm -f "$dir1/DONE/$ALLfile"`;
|
||||
}
|
||||
|
||||
if($DB){print STDERR "\n|/usr/bin/sox $live_folder/$filename[$k]$WAV $arch_folder/$filename[$k]$GSM|\n";}
|
||||
chmod 0755, "$dir1/DONE/$GSMfile";
|
||||
|
||||
### BEGIN Remote file transfer
|
||||
# $p = Net::Ping->new();
|
||||
# $ping_good = $p->ping("$FTP_host");
|
||||
|
||||
# if ($ping_good)
|
||||
# {
|
||||
$ftp = Net::FTP->new("$FTP_host", Port => $FTP_port, Debug => 0, Passive => 1);
|
||||
$ftp->login("$FTP_user","$FTP_pass");
|
||||
$ftp->cwd("$FTP_dir");
|
||||
$ftp->binary();
|
||||
$ftp->put("$dir1/DONE/$GSMfile", "$GSMfile");
|
||||
$ftp->quit;
|
||||
# }
|
||||
### END Remote file transfer
|
||||
|
||||
}
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
|
||||
if ($v) {print "DONE... EXITING\n\n";}
|
||||
|
||||
exit;
|
||||
@@ -0,0 +1,152 @@
|
||||
#!/usr/bin/perl
|
||||
#
|
||||
# AST_CRON_mix_recordings_MP3.pl
|
||||
# runs every 5 minutes and mixes the call recordings in the monitor together
|
||||
# and puts the resulting ALL file into the DONE directory in the "monitor" dir
|
||||
# and converts the ALL file to GSM format to save space.
|
||||
#
|
||||
# soxmix is REQUIRED to use this script, soxmix is available only as part of
|
||||
# the sox audio package, and only in newer versions. Make sure you have soxmix
|
||||
# installed properly and in your path
|
||||
#
|
||||
# put an entry into the cron of of your asterisk machine to run this script
|
||||
# every 5 minutes or however often you desire
|
||||
#
|
||||
# make sure that the following directories exist:
|
||||
# /var/spool/asterisk/monitor # default Asterisk recording directory
|
||||
# /var/spool/asterisk/monitor/DONE # where the combined files are put
|
||||
# /var/spool/asterisk/monitor/ORIG # where the original in/out files are put
|
||||
#
|
||||
# This program assumes that recordings are saved as .wav
|
||||
# should be easy to change this code if you use .gsm instead
|
||||
#
|
||||
# This program also sends the ALL combined file to an FTP server for archival
|
||||
# purposes, you can comment out the Net::Ping and Net::FTP lines as well as the
|
||||
# file transfer section of the code to deactivate remote copying of the
|
||||
# recording files
|
||||
#
|
||||
# Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
|
||||
# Contributions by Mike Lord <mike@channelblend.com>
|
||||
#
|
||||
# 51021-1058 - Added quotes around CLI executed commands
|
||||
# 51122-1455 - Added soxmix and sox binary path check
|
||||
# 60616-1027 - Modified to convert to MP3 format
|
||||
#
|
||||
|
||||
|
||||
#$v=1;
|
||||
|
||||
# Customize variables for FTP
|
||||
$FTP_host = '10.0.0.4';
|
||||
$FTP_user = 'cron';
|
||||
$FTP_pass = 'test';
|
||||
$FTP_dir = 'recordings';
|
||||
$FTP_port = '21';
|
||||
|
||||
### directory where in/out recordings are saved to by Asterisk
|
||||
$dir1 = '/var/spool/asterisk/monitor';
|
||||
|
||||
$soxmixbin = '';
|
||||
if ( -e ('/usr/bin/soxmix')) {$soxmixbin = '/usr/bin/soxmix';}
|
||||
else
|
||||
{
|
||||
if ( -e ('/usr/local/bin/soxmix')) {$soxmixbin = '/usr/local/bin/soxmix';}
|
||||
else
|
||||
{
|
||||
print "Can't find soxmix binary! Exiting...\n";
|
||||
exit;
|
||||
}
|
||||
}
|
||||
$lamebin = '';
|
||||
if ( -e ('/usr/bin/lame')) {$lamebin = '/usr/bin/lame';}
|
||||
else
|
||||
{
|
||||
if ( -e ('/usr/local/bin/lame')) {$lamebin = '/usr/local/bin/lame';}
|
||||
else
|
||||
{
|
||||
print "Can't find lame binary! Exiting...\n";
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
use Net::Ping;
|
||||
use Net::FTP;
|
||||
|
||||
|
||||
opendir(FILE, "$dir1/");
|
||||
@FILES = readdir(FILE);
|
||||
|
||||
$i=0;
|
||||
foreach(@FILES)
|
||||
{
|
||||
$size1 = 0;
|
||||
$size2 = 0;
|
||||
|
||||
if ( (length($FILES[$i]) > 4) && (!-d $FILES[$i]) )
|
||||
{
|
||||
|
||||
$size1 = (-s "$dir1/$FILES[$i]");
|
||||
if ($v) {print "$FILES[$i] $size1\n";}
|
||||
sleep(1);
|
||||
$size2 = (-s "$dir1/$FILES[$i]");
|
||||
if ($v) {print "$FILES[$i] $size2\n\n";}
|
||||
|
||||
|
||||
if ( ($FILES[$i] !~ /out\.wav/i) && ($size1 eq $size2) && (length($FILES[$i]) > 4))
|
||||
{
|
||||
$INfile = $FILES[$i];
|
||||
$OUTfile = $FILES[$i];
|
||||
$OUTfile =~ s/-in\.wav/-out.wav/gi;
|
||||
$ALLfile = $FILES[$i];
|
||||
$ALLfile =~ s/-in\.wav/-all.wav/gi;
|
||||
$MP3file = $ALLfile;
|
||||
$MP3file =~ s/-all\.wav/-all.mp3/gi;
|
||||
|
||||
if ($v) {print "|$INfile| |$OUTfile| |$ALLfile|\n\n";}
|
||||
|
||||
`$soxmixbin "$dir1/$INfile" "$dir1/$OUTfile" "$dir1/$ALLfile"`;
|
||||
if ($v) {print "|$INfile| |$OUTfile| |$ALLfile|\n\n";}
|
||||
if (!$T)
|
||||
{
|
||||
`mv -f "$dir1/$INfile" "$dir1/ORIG/$INfile"`;
|
||||
`mv -f "$dir1/$OUTfile" "$dir1/ORIG/$OUTfile"`;
|
||||
`mv -f "$dir1/$ALLfile" "$dir1/DONE/$ALLfile"`;
|
||||
}
|
||||
else
|
||||
{
|
||||
`cp -f "$dir1/$ALLfile" "$dir1/DONE/$ALLfile"`;
|
||||
}
|
||||
|
||||
`$lamebin -b 16 -m m --silent "$dir1/DONE/$ALLfile" "$dir1/DONE/$MP3file"`;
|
||||
|
||||
if (!$T)
|
||||
{
|
||||
`rm -f "$dir1/DONE/$ALLfile"`;
|
||||
}
|
||||
|
||||
if($DB){print STDERR "\n|/usr/bin/sox $live_folder/$filename[$k]$WAV $arch_folder/$filename[$k]$GSM|\n";}
|
||||
chmod 0755, "$dir1/DONE/$MP3file";
|
||||
|
||||
### BEGIN Remote file transfer
|
||||
# $p = Net::Ping->new();
|
||||
# $ping_good = $p->ping("$FTP_host");
|
||||
|
||||
# if ($ping_good)
|
||||
# {
|
||||
$ftp = Net::FTP->new("$FTP_host", Port => $FTP_port, Debug => 0, Passive => 1);
|
||||
$ftp->login("$FTP_user","$FTP_pass");
|
||||
$ftp->cwd("$FTP_dir");
|
||||
$ftp->binary();
|
||||
$ftp->put("$dir1/DONE/$MP3file", "$MP3file");
|
||||
$ftp->quit;
|
||||
# }
|
||||
### END Remote file transfer
|
||||
|
||||
}
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
|
||||
if ($v) {print "DONE... EXITING\n\n";}
|
||||
|
||||
exit;
|
||||
@@ -0,0 +1,153 @@
|
||||
#!/usr/bin/perl
|
||||
#
|
||||
# AST_DB_optimize.pl version 0.1
|
||||
#
|
||||
# DESCRIPTION:
|
||||
# optimizes the tables used in the asterisk MySQL database
|
||||
#
|
||||
# It is recommended that you run this program on the local Asterisk machine
|
||||
#
|
||||
# Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
|
||||
#
|
||||
|
||||
### Make sure this file is in a libs path or put the absolute path to it
|
||||
require("/home/cron/AST_SERVER_conf.pl"); # local configuration file
|
||||
|
||||
if (!$DB_port) {$DB_port='3306';}
|
||||
|
||||
use Net::MySQL;
|
||||
|
||||
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";
|
||||
|
||||
|
||||
|
||||
|
||||
$stmtA = "optimize table call_log;";
|
||||
if($DB){print STDERR "\n|$stmtA|\n";}
|
||||
if (!$T) {$dbhA->query($stmtA); }
|
||||
if ($dbhA->has_selected_record)
|
||||
{
|
||||
$iterA=$dbhA->create_record_iterator;
|
||||
while ($recordA = $iterA->each)
|
||||
{
|
||||
if ($DB) {print "|",$recordA->[0],"|",$recordA->[1],"|",$recordA->[2],"|",$recordA->[3],"|","\n";}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$stmtA = "optimize table park_log;";
|
||||
if($DB){print STDERR "\n|$stmtA|\n";}
|
||||
if (!$T) {$dbhA->query($stmtA); }
|
||||
if ($dbhA->has_selected_record)
|
||||
{
|
||||
$iterA=$dbhA->create_record_iterator;
|
||||
while ($recordA = $iterA->each)
|
||||
{
|
||||
if ($DB) {print "|",$recordA->[0],"|",$recordA->[1],"|",$recordA->[2],"|",$recordA->[3],"|","\n";}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$stmtA = "optimize table vicidial_log;";
|
||||
if($DB){print STDERR "\n|$stmtA|\n";}
|
||||
if (!$T) {$dbhA->query($stmtA); }
|
||||
if ($dbhA->has_selected_record)
|
||||
{
|
||||
$iterA=$dbhA->create_record_iterator;
|
||||
while ($recordA = $iterA->each)
|
||||
{
|
||||
if ($DB) {print "|",$recordA->[0],"|",$recordA->[1],"|",$recordA->[2],"|",$recordA->[3],"|","\n";}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$stmtA = "optimize table vicidial_closer_log;";
|
||||
if($DB){print STDERR "\n|$stmtA|\n";}
|
||||
if (!$T) {$dbhA->query($stmtA); }
|
||||
if ($dbhA->has_selected_record)
|
||||
{
|
||||
$iterA=$dbhA->create_record_iterator;
|
||||
while ($recordA = $iterA->each)
|
||||
{
|
||||
if ($DB) {print "|",$recordA->[0],"|",$recordA->[1],"|",$recordA->[2],"|",$recordA->[3],"|","\n";}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$stmtA = "optimize table vicidial_xfer_log;";
|
||||
if($DB){print STDERR "\n|$stmtA|\n";}
|
||||
if (!$T) {$dbhA->query($stmtA); }
|
||||
if ($dbhA->has_selected_record)
|
||||
{
|
||||
$iterA=$dbhA->create_record_iterator;
|
||||
while ($recordA = $iterA->each)
|
||||
{
|
||||
if ($DB) {print "|",$recordA->[0],"|",$recordA->[1],"|",$recordA->[2],"|",$recordA->[3],"|","\n";}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$stmtA = "optimize table vicidial_list;";
|
||||
if($DB){print STDERR "\n|$stmtA|\n";}
|
||||
if (!$T) {$dbhA->query($stmtA); }
|
||||
if ($dbhA->has_selected_record)
|
||||
{
|
||||
$iterA=$dbhA->create_record_iterator;
|
||||
while ($recordA = $iterA->each)
|
||||
{
|
||||
if ($DB) {print "|",$recordA->[0],"|",$recordA->[1],"|",$recordA->[2],"|",$recordA->[3],"|","\n";}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$stmtA = "optimize table vicidial_manager;";
|
||||
if($DB){print STDERR "\n|$stmtA|\n";}
|
||||
if (!$T) {$dbhA->query($stmtA); }
|
||||
if ($dbhA->has_selected_record)
|
||||
{
|
||||
$iterA=$dbhA->create_record_iterator;
|
||||
while ($recordA = $iterA->each)
|
||||
{
|
||||
if ($DB) {print "|",$recordA->[0],"|",$recordA->[1],"|",$recordA->[2],"|",$recordA->[3],"|","\n";}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$stmtA = "optimize table vicidial_auto_calls;";
|
||||
if($DB){print STDERR "\n|$stmtA|\n";}
|
||||
if (!$T) {$dbhA->query($stmtA); }
|
||||
if ($dbhA->has_selected_record)
|
||||
{
|
||||
$iterA=$dbhA->create_record_iterator;
|
||||
while ($recordA = $iterA->each)
|
||||
{
|
||||
if ($DB) {print "|",$recordA->[0],"|",$recordA->[1],"|",$recordA->[2],"|",$recordA->[3],"|","\n";}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$stmtA = "optimize table vicidial_live_agents;";
|
||||
if($DB){print STDERR "\n|$stmtA|\n";}
|
||||
if (!$T) {$dbhA->query($stmtA); }
|
||||
if ($dbhA->has_selected_record)
|
||||
{
|
||||
$iterA=$dbhA->create_record_iterator;
|
||||
while ($recordA = $iterA->each)
|
||||
{
|
||||
if ($DB) {print "|",$recordA->[0],"|",$recordA->[1],"|",$recordA->[2],"|",$recordA->[3],"|","\n";}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
$dbhA->close;
|
||||
|
||||
|
||||
exit;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
# AST_SERVER_conf.pl
|
||||
#
|
||||
# Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
|
||||
#
|
||||
|
||||
# Customized Variables
|
||||
$server_ip = '10.10.10.15'; # Asterisk server IP
|
||||
$DB_server = 'localhost'; # MySQL server IP
|
||||
$DB_database = 'asterisk'; # MySQL database name
|
||||
$DB_user = 'cron'; # MySQL user
|
||||
$DB_pass = '1234'; # MySQL pass
|
||||
$DB_port = '3306'; # MySQL connection port
|
||||
|
||||
$LOGfile = '/home/cron/LOG_AST_update.log';
|
||||
$telnetlog = '/home/cron/telnetlog.log';
|
||||
$MSLOGfile = '/home/cron/MSLOG_AST_update.log';
|
||||
$MStelnetlog = '/home/cron/MStelnetlog.log';
|
||||
$LILOGfile = '/home/cron/LILOG_AST_update.log';
|
||||
$LItelnetlog = '/home/cron/LItelnetlog.log';
|
||||
$KHLOGfile = '/home/cron/KHLOG_AST_update.log';
|
||||
$VDADLOGfile = '/home/cron/VDLOG_AST_update.log';
|
||||
|
||||
return 1;
|
||||
@@ -0,0 +1,887 @@
|
||||
#!/usr/bin/perl
|
||||
#
|
||||
# AST_VDauto_dial.pl version 0.11
|
||||
#
|
||||
# DESCRIPTION:
|
||||
# uses Net::MySQL to place auto_dial calls on the VICIDIAL dialer system
|
||||
#
|
||||
# SUMMARY:
|
||||
# This program was designed for people using the Asterisk PBX with VICIDIAL
|
||||
#
|
||||
# For the client to use VICIDIAL, this program must be in the cron constantly
|
||||
#
|
||||
# For this program to work you need to have the "asterisk" MySQL database
|
||||
# created and create the tables listed in the CONF_MySQL.txt file, also make sure
|
||||
# that the machine running this program has read/write/update/delete access
|
||||
# to that database
|
||||
#
|
||||
# It is recommended that you run this program on the local Asterisk machine
|
||||
#
|
||||
# This script is to run perpetually querying every second to place new phone
|
||||
# calls from the vicidial_hopper based upon how many available agents there are
|
||||
# and the value of the auto_dial_level setting in the campaign screen of the
|
||||
# admin web page
|
||||
#
|
||||
# It is good practice to keep this program running by placing the associated
|
||||
# KEEPALIVE script running every minute to ensure this program is always running
|
||||
#
|
||||
# Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
|
||||
#
|
||||
# changes:
|
||||
# 50125-1201 - Changed dial timeout to 120 seconds from 180 seconds
|
||||
# 50317-0954 - Added duplicate check per cycle to account for DB lockups
|
||||
# 50322-1302 - Added campaign custom callerid feature
|
||||
# 50324-1353 - Added optional variable to record ring time thru separate diap prefix
|
||||
# 50606-2308 - Added code to ensure no calls placed out on inactive campaign
|
||||
# 50617-1248 - Added code to place LOGOUT entry in auto-paused user logs
|
||||
# 50620-1349 - Added custom vdad transfer AGI extension per campaign
|
||||
# 50810-1610 - Added database server variable definitions lookup
|
||||
# 50810-1630 - Added max_vicidial_trunks server limiter on active lines
|
||||
# 50812-0957 - corrected max_trunks logic, added update of server every 25 sec
|
||||
# 60120-1522 - corrected time error for hour variable, caused agi problems
|
||||
# 60427-1223 - Fixed Blended in/out CLOSER campaign issue
|
||||
# 60608-1134 - Altered vac table field of call_type for IN OUT distinction
|
||||
# 60612-1324 - Altered dead call section to accept BUSY detection from VD_hangup
|
||||
# - Altered dead call section to accept DISCONNECT detection from VD_hangup
|
||||
# 60614-1142 - Added code to work with recycled leads, multi called_since_last_reset values
|
||||
# - Removed gmt lead validation because it is already done by VDhopper
|
||||
#
|
||||
|
||||
|
||||
### begin parsing run-time options ###
|
||||
if (length($ARGV[0])>1)
|
||||
{
|
||||
$i=0;
|
||||
while ($#ARGV >= $i)
|
||||
{
|
||||
$args = "$args $ARGV[$i]";
|
||||
$i++;
|
||||
}
|
||||
|
||||
if ($args =~ /--help/i)
|
||||
{
|
||||
print "allowed run time options:\n [-t] = test\n [-debug] = verbose debug messages\n [--delay=XXX] = delay of XXX seconds per loop, default 2.5 seconds\n\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($args =~ /--delay=/i)
|
||||
{
|
||||
@data_in = split(/--delay=/,$args);
|
||||
$loop_delay = $data_in[1];
|
||||
print " LOOP DELAY OVERRIDE!!!!! = $loop_delay seconds\n\n";
|
||||
$loop_delay = ($loop_delay * 1000);
|
||||
}
|
||||
else
|
||||
{
|
||||
$loop_delay = '2500';
|
||||
}
|
||||
if ($args =~ /-debug/i)
|
||||
{
|
||||
$DB=1; # Debug flag, set to 0 for no debug messages, On an active system this will generate hundreds of lines of output per minute
|
||||
}
|
||||
if ($args =~ /-t/i)
|
||||
{
|
||||
$TEST=1;
|
||||
$T=1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print "no command line options set\n";
|
||||
$loop_delay = '2500';
|
||||
$DB=1;
|
||||
}
|
||||
### end parsing run-time options ###
|
||||
|
||||
|
||||
# constants
|
||||
$US='__';
|
||||
$MT[0]='';
|
||||
$RECcount=''; ### leave blank for no REC count
|
||||
$RECprefix='7'; ### leave blank for no REC prefix
|
||||
|
||||
### Make sure this file is in a libs path or put the absolute path to it
|
||||
require("/home/cron/AST_SERVER_conf.pl"); # local configuration file
|
||||
|
||||
if (!$DB_port) {$DB_port='3306';}
|
||||
|
||||
&get_time_now; # update time/date variables
|
||||
|
||||
$event_string='PROGRAM STARTED||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||';
|
||||
&event_logger; # writes to the log and if debug flag is set prints to STDOUT
|
||||
|
||||
use lib './lib', '../lib';
|
||||
use Time::HiRes ('gettimeofday','usleep','sleep'); # necessary to have perl sleep command of less than one second
|
||||
use Net::MySQL;
|
||||
|
||||
### connect to MySQL database defined in the AST_SERVER_conf.pl file
|
||||
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";
|
||||
|
||||
### Grab Server values from the database
|
||||
$stmtA = "SELECT telnet_host,telnet_port,ASTmgrUSERNAME,ASTmgrSECRET,ASTmgrUSERNAMEupdate,ASTmgrUSERNAMElisten,ASTmgrUSERNAMEsend,max_vicidial_trunks,answer_transfer_agent,local_gmt,ext_context FROM servers where server_ip = '$server_ip';";
|
||||
$dbhA->query("$stmtA");
|
||||
if ($dbhA->has_selected_record)
|
||||
{
|
||||
$iter=$dbhA->create_record_iterator;
|
||||
while ( $record = $iter->each)
|
||||
{
|
||||
$DBtelnet_host = "$record->[0]";
|
||||
$DBtelnet_port = "$record->[1]";
|
||||
$DBASTmgrUSERNAME = "$record->[2]";
|
||||
$DBASTmgrSECRET = "$record->[3]";
|
||||
$DBASTmgrUSERNAMEupdate = "$record->[4]";
|
||||
$DBASTmgrUSERNAMElisten = "$record->[5]";
|
||||
$DBASTmgrUSERNAMEsend = "$record->[6]";
|
||||
$DBmax_vicidial_trunks = "$record->[7]";
|
||||
$DBanswer_transfer_agent= "$record->[8]";
|
||||
$DBSERVER_GMT = "$record->[9]";
|
||||
$DBext_context = "$record->[10]";
|
||||
if ($DBtelnet_host) {$telnet_host = $DBtelnet_host;}
|
||||
if ($DBtelnet_port) {$telnet_port = $DBtelnet_port;}
|
||||
if ($DBASTmgrUSERNAME) {$ASTmgrUSERNAME = $DBASTmgrUSERNAME;}
|
||||
if ($DBASTmgrSECRET) {$ASTmgrSECRET = $DBASTmgrSECRET;}
|
||||
if ($DBASTmgrUSERNAMEupdate) {$ASTmgrUSERNAMEupdate = $DBASTmgrUSERNAMEupdate;}
|
||||
if ($DBASTmgrUSERNAMElisten) {$ASTmgrUSERNAMElisten = $DBASTmgrUSERNAMElisten;}
|
||||
if ($DBASTmgrUSERNAMEsend) {$ASTmgrUSERNAMEsend = $DBASTmgrUSERNAMEsend;}
|
||||
if ($DBmax_vicidial_trunks) {$max_vicidial_trunks = $DBmax_vicidial_trunks;}
|
||||
if ($DBanswer_transfer_agent) {$answer_transfer_agent = $DBanswer_transfer_agent;}
|
||||
if ($DBSERVER_GMT) {$SERVER_GMT = $DBSERVER_GMT;}
|
||||
if ($DBext_context) {$ext_context = $DBext_context;}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$event_string='LOGGED INTO MYSQL SERVER ON 1 CONNECTION|';
|
||||
&event_logger;
|
||||
|
||||
$one_day_interval = 12; # 1 month loops for one year
|
||||
while($one_day_interval > 0)
|
||||
{
|
||||
|
||||
$endless_loop=5760000; # 30 days minutes at XXX seconds per loop
|
||||
|
||||
while($endless_loop > 0)
|
||||
{
|
||||
&get_time_now;
|
||||
|
||||
###############################################################################
|
||||
###### first figure out how many calls should be placed for each campaign per server
|
||||
###############################################################################
|
||||
@DBlive_user=@MT;
|
||||
@DBlive_server_ip=@MT;
|
||||
@DBlive_campaign=@MT;
|
||||
@DBlive_conf_exten=@MT;
|
||||
@DBcampaigns=@MT;
|
||||
@DBIPaddress=@MT;
|
||||
@DBIPcampaign=@MT;
|
||||
@DBIPactive=@MT;
|
||||
@DBIPvdadexten=@MT;
|
||||
@DBIPcount=@MT;
|
||||
@DBIPadlevel=@MT;
|
||||
@DBIPdialtimeout=@MT;
|
||||
@DBIPdialprefix=@MT;
|
||||
@DBIPcampaigncid=@MT;
|
||||
@DBIPexistcalls=@MT;
|
||||
@DBIPgoalcalls=@MT;
|
||||
@DBIPmakecalls=@MT;
|
||||
@DBIPclosercamp=@MT;
|
||||
|
||||
$active_line_counter=0;
|
||||
$user_counter=0;
|
||||
$user_campaigns = '|';
|
||||
$user_campaigns_counter = 0;
|
||||
$user_campaignIP = '|';
|
||||
$user_CIPct = 0;
|
||||
|
||||
##### Get a listing of the users that are active and ready to take calls
|
||||
##### Also get a listing of the campaigns and campaigns/serverIP that will be used
|
||||
$dbhA->query("SELECT user,server_ip,campaign_id,conf_exten FROM vicidial_live_agents where status IN('READY','QUEUE','INCALL','DONE') and server_ip='$server_ip' and last_update_time > '$BDtsSQLdate' order by last_call_time");
|
||||
if ($dbhA->has_selected_record)
|
||||
{
|
||||
$iter=$dbhA->create_record_iterator;
|
||||
while ( $record = $iter->each)
|
||||
{
|
||||
$DBlive_user[$user_counter] = "$record->[0]";
|
||||
$DBlive_server_ip[$user_counter] = "$record->[1]";
|
||||
$DBlive_campaign[$user_counter] = "$record->[2]";
|
||||
$DBlive_conf_exten[$user_counter] = "$record->[3]";
|
||||
|
||||
if ($user_campaigns !~ /\|$DBlive_campaign[$user_counter]\|/i)
|
||||
{
|
||||
$user_campaigns .= "$DBlive_campaign[$user_counter]|";
|
||||
$DBcampaigns[$user_campaigns_counter] = $DBlive_campaign[$user_counter];
|
||||
$user_campaigns_counter++;
|
||||
}
|
||||
if ($user_campaignIP !~ /\|$DBlive_campaign[$user_counter]__$DBlive_server_ip[$user_counter]\|/i)
|
||||
{
|
||||
$user_campaignIP .= "$DBlive_campaign[$user_counter]__$DBlive_server_ip[$user_counter]|";
|
||||
$DBIPcampaign[$user_CIPct] = "$DBlive_campaign[$user_counter]";
|
||||
$DBIPaddress[$user_CIPct] = "$DBlive_server_ip[$user_counter]";
|
||||
$user_CIPct++;
|
||||
}
|
||||
$user_counter++;
|
||||
}
|
||||
}
|
||||
|
||||
$event_string="LIVE AGENTS LOGGED IN: $user_counter";
|
||||
&event_logger;
|
||||
|
||||
$user_CIPct = 0;
|
||||
foreach(@DBIPcampaign)
|
||||
{
|
||||
$user_counter=0;
|
||||
foreach(@DBlive_campaign)
|
||||
{
|
||||
if ( ($DBlive_campaign[$user_counter] =~ /$DBIPcampaign[$user_CIPct]/i) && ($DBlive_server_ip[$user_counter] =~ /$DBIPaddress[$user_CIPct]/i) )
|
||||
{
|
||||
$DBIPcount[$user_CIPct]++
|
||||
}
|
||||
$user_counter++;
|
||||
}
|
||||
|
||||
### grab the dial_level and multiply by active agents to get your goalcalls
|
||||
$DBIPadlevel[$user_CIPct]=0;
|
||||
$dbhA->query("SELECT auto_dial_level,local_call_time,dial_timeout,dial_prefix,campaign_cid,active,campaign_vdad_exten,closer_campaigns FROM vicidial_campaigns where campaign_id='$DBIPcampaign[$user_CIPct]'");
|
||||
if ($dbhA->has_selected_record)
|
||||
{
|
||||
$iter=$dbhA->create_record_iterator;
|
||||
while ( $record = $iter->each)
|
||||
{
|
||||
$DBIPadlevel[$user_CIPct] = "$record->[0]";
|
||||
$DBIPcalltime[$user_CIPct] = "$record->[1]";
|
||||
$DBIPdialtimeout[$user_CIPct] = "$record->[2]";
|
||||
$DBIPdialprefix[$user_CIPct] = "$record->[3]";
|
||||
$DBIPcampaigncid[$user_CIPct] = "$record->[4]";
|
||||
$DBIPactive[$user_CIPct] = "$record->[5]";
|
||||
$DBIPvdadexten[$user_CIPct] = "$record->[6]";
|
||||
$DBIPclosercamp[$user_CIPct] = "$record->[7]";
|
||||
}
|
||||
}
|
||||
|
||||
$DBIPgoalcalls[$user_CIPct] = ($DBIPadlevel[$user_CIPct] * $DBIPcount[$user_CIPct]);
|
||||
if ($DBIPactive[$user_CIPct] =~ /N/) {$DBIPgoalcalls[$user_CIPct] = 0;}
|
||||
$DBIPgoalcalls[$user_CIPct] = sprintf("%.0f", $DBIPgoalcalls[$user_CIPct]);
|
||||
|
||||
$event_string="$DBIPcampaign[$user_CIPct] $DBIPaddress[$user_CIPct]: agents: $DBIPcount[$user_CIPct] dial_level: $DBIPadlevel[$user_CIPct]";
|
||||
&event_logger;
|
||||
|
||||
$active_line_counter=0;
|
||||
$active_line_goal=0;
|
||||
### see how many total VDAD calls are going on right now for max limiter
|
||||
$dbhA->query("SELECT count(*) FROM vicidial_auto_calls where server_ip='$DBIPaddress[$user_CIPct]' and status IN('SENT','RINGING','LIVE','XFER');");
|
||||
if ($dbhA->has_selected_record)
|
||||
{
|
||||
$iter=$dbhA->create_record_iterator;
|
||||
while ( $record = $iter->each)
|
||||
{
|
||||
$active_line_counter = "$record->[0]";
|
||||
}
|
||||
}
|
||||
|
||||
### see how many calls are alrady active per campaign per server and
|
||||
### subtract that number from goalcalls to determine how many new
|
||||
### calls need to be placed in this loop
|
||||
if ($DBIPcampaign[$user_CIPct] =~ /CLOSER/)
|
||||
{
|
||||
if (length($DBIPclosercamp[$user_CIPct]) > 2)
|
||||
{
|
||||
$DBIPclosercamp[$user_CIPct] =~ s/^ | -$//gi;
|
||||
$DBIPclosercamp[$user_CIPct] =~ s/ /','/gi;
|
||||
$DBIPclosercamp[$user_CIPct] = "'$DBIPclosercamp[$user_CIPct]'";
|
||||
}
|
||||
else {$DBIPclosercamp[$user_CIPct]=''}
|
||||
|
||||
$campaign_query = "( (call_type='IN' and campaign_id IN($DBIPclosercamp[$user_CIPct])) or (campaign_id='$DBIPcampaign[$user_CIPct]' and call_type='OUT') )";
|
||||
}
|
||||
else {$campaign_query = "(campaign_id='$DBIPcampaign[$user_CIPct]' and call_type='OUT')";}
|
||||
$dbhA->query("SELECT count(*) FROM vicidial_auto_calls where $campaign_query and server_ip='$DBIPaddress[$user_CIPct]' and status IN('SENT','RINGING','LIVE','XFER','CLOSER');");
|
||||
if ($dbhA->has_selected_record)
|
||||
{
|
||||
$iter=$dbhA->create_record_iterator;
|
||||
while ( $record = $iter->each)
|
||||
{
|
||||
$DBIPexistcalls[$user_CIPct] = "$record->[0]";
|
||||
}
|
||||
}
|
||||
|
||||
$DBIPmakecalls[$user_CIPct] = ($DBIPgoalcalls[$user_CIPct] - $DBIPexistcalls[$user_CIPct]);
|
||||
$MVT_msg = '';
|
||||
$active_line_goal = ($active_line_counter + $DBIPmakecalls[$user_CIPct]);
|
||||
if ($active_line_goal > $max_vicidial_trunks)
|
||||
{
|
||||
$MVT_msg = "MVT override: $max_vicidial_trunks";
|
||||
$DBIPmakecalls[$user_CIPct] = ($max_vicidial_trunks - $active_line_counter);
|
||||
}
|
||||
$event_string="$DBIPcampaign[$user_CIPct] $DBIPaddress[$user_CIPct]: Calls to place: $DBIPmakecalls[$user_CIPct] ($DBIPgoalcalls[$user_CIPct] - $DBIPexistcalls[$user_CIPct]) $MVT_msg";
|
||||
&event_logger;
|
||||
|
||||
$user_CIPct++;
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
###### second lookup leads and place calls for each campaign/server_ip
|
||||
###### go one lead at a time and place the call by inserting a record into vicidial_manager
|
||||
###############################################################################
|
||||
|
||||
$user_CIPct = 0;
|
||||
foreach(@DBIPcampaign)
|
||||
{
|
||||
$event_string="$DBIPcampaign[$user_CIPct] $DBIPaddress[$user_CIPct]: CALLING";
|
||||
&event_logger;
|
||||
$call_CMPIPct=0;
|
||||
$lead_id_call_list='|';
|
||||
my $UDaffected_rows=0;
|
||||
if ($call_CMPIPct < $DBIPmakecalls[$user_CIPct])
|
||||
{
|
||||
$stmtA = "UPDATE vicidial_hopper set status='QUEUE', user='VDAD_$server_ip' where campaign_id='$DBIPcampaign[$user_CIPct]' and status='READY' order by hopper_id LIMIT $DBIPmakecalls[$user_CIPct]";
|
||||
print "|$stmtA|\n";
|
||||
$dbhA->query("$stmtA");
|
||||
my $UDaffected_rows = $dbhA->get_affected_rows_length;
|
||||
print "hopper rows updated to QUEUE: |$UDaffected_rows|\n";
|
||||
|
||||
if ($UDaffected_rows)
|
||||
{
|
||||
$lead_id=''; $phone_code=''; $phone_number=''; $called_count='';
|
||||
while ($call_CMPIPct < $UDaffected_rows)
|
||||
{
|
||||
$stmtA = "SELECT lead_id FROM vicidial_hopper where campaign_id='$DBIPcampaign[$user_CIPct]' and status='QUEUE' and user='VDAD_$server_ip' LIMIT 1";
|
||||
print "|$stmtA|\n";
|
||||
$dbhA->query("$stmtA");
|
||||
if ($dbhA->has_selected_record)
|
||||
{
|
||||
$iter=$dbhA->create_record_iterator;
|
||||
$rec_countCUSTDATA=0;
|
||||
while ( $record = $iter->each)
|
||||
{
|
||||
$lead_id = "$record->[0]";
|
||||
}
|
||||
}
|
||||
|
||||
if ($lead_id_call_list =~ /\|$lead_id\|/)
|
||||
{
|
||||
print "!!!!!!!!!!!!!!!!duplicate lead_id for this run: |$lead_id| $lead_id_call_list\n";
|
||||
open(DUPout, ">>/home/cron/VDAD_DUPLICATE.$file_date")
|
||||
|| die "Can't open /home/cron/VDAD_DUPLICATE.$file_date: $!\n";
|
||||
print DUPout "$now_date-----$lead_id_call_list-----$lead_id\n";
|
||||
close(DUPout);
|
||||
}
|
||||
else
|
||||
{
|
||||
$stmtA = "UPDATE vicidial_hopper set status='INCALL' where lead_id='$lead_id'";
|
||||
print "|$stmtA|\n";
|
||||
$dbhA->query("$stmtA");
|
||||
my $UQaffected_rows = $dbhA->get_affected_rows_length;
|
||||
print "hopper row updated to INCALL: |$UQaffected_rows|$lead_id|\n";
|
||||
|
||||
$stmtA = "SELECT * FROM vicidial_list where lead_id='$lead_id';";
|
||||
$dbhA->query("$stmtA");
|
||||
if ($dbhA->has_selected_record)
|
||||
{
|
||||
$iter=$dbhA->create_record_iterator;
|
||||
$rec_countCUSTDATA=0;
|
||||
while ( $record = $iter->each)
|
||||
{
|
||||
$gmt_offset_now = "$record->[8]";
|
||||
$called_since_last_reset = "$record->[9]";
|
||||
$phone_code = "$record->[10]";
|
||||
$phone_number = "$record->[11]";
|
||||
$called_count = "$record->[30]";
|
||||
|
||||
$rec_countCUSTDATA++;
|
||||
}
|
||||
}
|
||||
|
||||
if ($rec_countCUSTDATA)
|
||||
{
|
||||
### update called_count
|
||||
$called_count++;
|
||||
if ($called_since_last_reset =~ /^Y/)
|
||||
{
|
||||
if ($called_since_last_reset =~ /^Y$/) {$CSLR = 'Y1';}
|
||||
else
|
||||
{
|
||||
$called_since_last_reset =~ s/^Y//gi;
|
||||
$called_since_last_reset++;
|
||||
$CSLR = "Y$called_since_last_reset";
|
||||
}
|
||||
}
|
||||
else {$CSLR = 'Y';}
|
||||
|
||||
$stmtA = "UPDATE vicidial_list set called_since_last_reset='$CSLR', called_count='$called_count',user='VDAD' where lead_id='$lead_id'";
|
||||
$dbhA->query("$stmtA");
|
||||
my $affected_rows = $dbhA->get_affected_rows_length;
|
||||
|
||||
$stmtA = "DELETE FROM vicidial_hopper where lead_id='$lead_id'";
|
||||
$dbhA->query("$stmtA");
|
||||
my $affected_rows = $dbhA->get_affected_rows_length;
|
||||
|
||||
$CCID_on=0; $CCID='';
|
||||
$local_DEF = 'Local/';
|
||||
$local_AMP = '@';
|
||||
$Local_out_prefix = '9';
|
||||
$Local_dial_timeout = '60';
|
||||
if ($DBIPdialtimeout[$user_CIPct] > 4) {$Local_dial_timeout = $DBIPdialtimeout[$user_CIPct];}
|
||||
$Local_dial_timeout = ($Local_dial_timeout * 1000);
|
||||
if (length($DBIPdialprefix[$user_CIPct]) > 0) {$Local_out_prefix = "$DBIPdialprefix[$user_CIPct]";}
|
||||
if (length($DBIPvdadexten[$user_CIPct]) > 0) {$VDAD_dial_exten = "$DBIPvdadexten[$user_CIPct]";}
|
||||
else {$VDAD_dial_exten = "$answer_transfer_agent";}
|
||||
|
||||
if (length($DBIPcampaigncid[$user_CIPct]) > 6) {$CCID = "$DBIPcampaigncid[$user_CIPct]"; $CCID_on++;}
|
||||
if ($DBIPdialprefix[$user_CIPct] =~ /x/i) {$Local_out_prefix = '';}
|
||||
|
||||
if ($RECcount)
|
||||
{
|
||||
if ( (length($RECprefix)>0) && ($called_count < $RECcount) )
|
||||
{$Local_out_prefix .= "$RECprefix";}
|
||||
}
|
||||
$PADlead_id = sprintf("%09s", $lead_id); while (length($PADlead_id) > 9) {chop($PADlead_id);}
|
||||
|
||||
$lead_id_call_list .= "$lead_id|";
|
||||
|
||||
### use manager middleware-app to connect the next call to the meetme room
|
||||
# VmmddhhmmssLLLLLLLLL
|
||||
$VqueryCID = "V$CIDdate$PADlead_id";
|
||||
if ($CCID_on) {$CIDstring = "\"$VqueryCID\" <$CCID>";}
|
||||
else {$CIDstring = "$VqueryCID";}
|
||||
|
||||
### insert a NEW record to the vicidial_manager table to be processed
|
||||
$stmtA = "INSERT INTO vicidial_manager values('','','$SQLdate','NEW','N','$DBIPaddress[$user_CIPct]','','Originate','$VqueryCID','Exten: $VDAD_dial_exten','Context: $ext_context','Channel: $local_DEF$Local_out_prefix$phone_code$phone_number$local_AMP$ext_context','Priority: 1','Callerid: $CIDstring','Timeout: $Local_dial_timeout','','','','')";
|
||||
$dbhA->query($stmtA);
|
||||
|
||||
$event_string = "| number call dialed|$DBIPcampaign[$user_CIPct]|$VqueryCID|$stmtA|$gmt_offset_now|";
|
||||
&event_logger;
|
||||
|
||||
### insert a SENT record to the vicidial_auto_calls table
|
||||
$stmtA = "INSERT INTO vicidial_auto_calls (server_ip,campaign_id,status,lead_id,callerid,phone_code,phone_number,call_time,call_type) values('$DBIPaddress[$user_CIPct]','$DBIPcampaign[$user_CIPct]','SENT','$lead_id','$VqueryCID','$phone_code','$phone_number','$SQLdate','OUT')";
|
||||
$dbhA->query($stmtA);
|
||||
|
||||
### sleep for a tenth of a second to not flood the server with new calls
|
||||
usleep(1*100*1000);
|
||||
|
||||
}
|
||||
}
|
||||
$call_CMPIPct++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$user_CIPct++;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
&get_time_now;
|
||||
|
||||
###############################################################################
|
||||
###### third we will grab the callerids of the vicidial_auto_calls records and check for dead calls
|
||||
###### we also check to make sure that it isn't a call that has been transferred,
|
||||
###### if it has been we need to leave the vicidial_list status alone
|
||||
###############################################################################
|
||||
|
||||
@KLcallerid = @MT;
|
||||
@KLserver_ip = @MT;
|
||||
@KLchannel = @MT;
|
||||
$kill_vac=0;
|
||||
|
||||
$stmtA = "SELECT callerid,server_ip,channel,uniqueid FROM vicidial_auto_calls where server_ip='$server_ip' order by call_time;";
|
||||
$dbhA->query("$stmtA");
|
||||
if ($dbhA->has_selected_record)
|
||||
{
|
||||
$iter=$dbhA->create_record_iterator;
|
||||
$rec_countCUSTDATA=0;
|
||||
while ( $record = $iter->each)
|
||||
{
|
||||
$KLcallerid[$kill_vac] = "$record->[0]";
|
||||
$KLserver_ip[$kill_vac] = "$record->[1]";
|
||||
$KLchannel[$kill_vac] = "$record->[2]";
|
||||
$KLuniqueid[$kill_vac] = "$record->[3]";
|
||||
|
||||
$kill_vac++;
|
||||
}
|
||||
}
|
||||
|
||||
$kill_vac=0;
|
||||
foreach(@KLcallerid)
|
||||
{
|
||||
if (length($KLserver_ip[$kill_vac]) > 7)
|
||||
{
|
||||
$end_epoch=0; $CLuniqueid='';
|
||||
|
||||
$stmtA = "SELECT end_epoch,uniqueid FROM call_log where caller_code='$KLcallerid[$kill_vac]' and server_ip='$KLserver_ip[$kill_vac]' order by end_epoch, start_time desc limit 1;";
|
||||
$dbhA->query("$stmtA");
|
||||
if ($dbhA->has_selected_record)
|
||||
{
|
||||
$iter=$dbhA->create_record_iterator;
|
||||
$rec_countCUSTDATA=0;
|
||||
while ( $record = $iter->each)
|
||||
{
|
||||
$end_epoch = "$record->[0]";
|
||||
$CLuniqueid = "$record->[1]";
|
||||
}
|
||||
}
|
||||
|
||||
if ( (length($KLuniqueid[$kill_vac]) > 15) && (length($CLuniqueid) < 15) )
|
||||
{
|
||||
$stmtA = "SELECT end_epoch,uniqueid FROM call_log where uniqueid='$KLuniqueid[$kill_vac]' and server_ip='$KLserver_ip[$kill_vac]' order by end_epoch, start_time desc limit 1;";
|
||||
$dbhA->query("$stmtA");
|
||||
if ($dbhA->has_selected_record)
|
||||
{
|
||||
$iter=$dbhA->create_record_iterator;
|
||||
$rec_countCUSTDATA=0;
|
||||
while ( $record = $iter->each)
|
||||
{
|
||||
$end_epoch = "$record->[0]";
|
||||
$CLuniqueid = "$record->[1]";
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($end_epoch > 1000)
|
||||
{
|
||||
$CLlead_id=''; $auto_call_id=''; $CLstatus=''; $CLcampaign_id=''; $CLphone_number=''; $CLphone_code='';
|
||||
|
||||
$stmtA = "SELECT auto_call_id,lead_id,phone_number,status,campaign_id,phone_code FROM vicidial_auto_calls where callerid='$KLcallerid[$kill_vac]'";
|
||||
$dbhA->query("$stmtA");
|
||||
if ($dbhA->has_selected_record)
|
||||
{
|
||||
$iter=$dbhA->create_record_iterator;
|
||||
$rec_countCUSTDATA=0;
|
||||
while ( $record = $iter->each)
|
||||
{
|
||||
$auto_call_id = "$record->[0]";
|
||||
$CLlead_id = "$record->[1]";
|
||||
$CLphone_number = "$record->[2]";
|
||||
$CLstatus = "$record->[3]";
|
||||
$CLcampaign_id = "$record->[4]";
|
||||
$CLphone_code = "$record->[5]";
|
||||
}
|
||||
}
|
||||
$stmtA = "DELETE from vicidial_auto_calls where auto_call_id='$auto_call_id'";
|
||||
# $stmtA = "UPDATE vicidial_auto_calls set status='PAUSED' where callerid='$KLcallerid[$kill_vac]'";
|
||||
$dbhA->query("$stmtA");
|
||||
my $affected_rows = $dbhA->get_affected_rows_length;
|
||||
|
||||
$event_string = "| dead call vac deleted|$auto_call_id|$CLlead_id|$KLcallerid[$kill_vac]|$end_epoch|$affected_rows|$KLchannel[$kill_vac]|";
|
||||
&event_logger;
|
||||
|
||||
if ($CLstatus !~ /XFER|CLOSER/)
|
||||
{
|
||||
if ($CLstatus =~ /BUSY/) {$CLnew_status = 'B';}
|
||||
else
|
||||
{
|
||||
if ($CLstatus =~ /DISCONNECT/) {$CLnew_status = 'DC';}
|
||||
else {$CLnew_status = 'NA';}
|
||||
}
|
||||
if ($CLstatus =~ /LIVE/) {$CLnew_status = 'DROP';}
|
||||
else
|
||||
{
|
||||
$end_epoch = ($now_date_epoch + 1);
|
||||
$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('$CLuniqueid','$CLlead_id','$CLcampaign_id','$SQLdate','$now_date_epoch','$CLnew_status','$CLphone_code','$CLphone_number','VDAD','N','1','$end_epoch')";
|
||||
if($M){print STDERR "\n|$stmtA|\n";}
|
||||
$dbhA->query($stmtA);
|
||||
|
||||
$event_string = "| dead NA call added to log $CLuniqueid|$CLlead_id|$CLphone_number|$CLstatus|$CLnew_status|";
|
||||
&event_logger;
|
||||
|
||||
}
|
||||
|
||||
$stmtA = "UPDATE vicidial_list set status='$CLnew_status' where lead_id='$CLlead_id'";
|
||||
$dbhA->query("$stmtA");
|
||||
my $affected_rows = $dbhA->get_affected_rows_length;
|
||||
|
||||
$event_string = "| dead call vac lead marked $CLnew_status|$CLlead_id|$CLphone_number|$CLstatus|";
|
||||
&event_logger;
|
||||
|
||||
$stmtA = "UPDATE vicidial_live_agents set status='PAUSED',random_id='10' where callerid='$KLcallerid[$kill_vac]';";
|
||||
$dbhA->query("$stmtA");
|
||||
my $affected_rows = $dbhA->get_affected_rows_length;
|
||||
|
||||
$event_string = "| dead call vla agent PAUSED $affected_rows|$CLlead_id|$CLphone_number|$CLstatus|";
|
||||
&event_logger;
|
||||
}
|
||||
else
|
||||
{
|
||||
$event_string = "| dead call vac XFERd do nothing|$CLlead_id|$CLphone_number|$CLstatus|";
|
||||
&event_logger;
|
||||
}
|
||||
}
|
||||
}
|
||||
$kill_vac++;
|
||||
}
|
||||
|
||||
|
||||
|
||||
### pause agents that have disconnected or closed their apps over 30 seconds ago
|
||||
$stmtA = "UPDATE vicidial_live_agents set status='PAUSED',random_id='10' where server_ip='$server_ip' and last_update_time < '$PDtsSQLdate' and status NOT IN('PAUSED')";
|
||||
$dbhA->query("$stmtA");
|
||||
my $affected_rows = $dbhA->get_affected_rows_length;
|
||||
|
||||
$event_string = "| lagged call vla agent PAUSED $affected_rows|$PDtsSQLdate|$BDtsSQLdate|$tsSQLdate|";
|
||||
&event_logger;
|
||||
|
||||
if ($affected_rows > 0)
|
||||
{
|
||||
@VALOuser=@MT; @VALOcampaign=@MT; @VALOtimelog=@MT; @VALOextension=@MT;
|
||||
$logcount=0;
|
||||
$stmtA = "SELECT user,campaign_id,last_update_time,extension FROM vicidial_live_agents where server_ip='$server_ip' and status = 'PAUSED' and random_id='10' order by last_update_time desc limit $affected_rows";
|
||||
$dbhA->query("$stmtA");
|
||||
if ($dbhA->has_selected_record)
|
||||
{
|
||||
$iter=$dbhA->create_record_iterator;
|
||||
$rec_countCUSTDATA=0;
|
||||
while ( $record = $iter->each)
|
||||
{
|
||||
$VALOuser[$logcount] = "$record->[0]";
|
||||
$VALOcampaign[$logcount] = "$record->[1]";
|
||||
$VALOtimelog[$logcount] = "$record->[2]";
|
||||
$VALOextension[$logcount] = "$record->[3]";
|
||||
$logcount++;
|
||||
}
|
||||
}
|
||||
$logrun=0;
|
||||
foreach(@VALOuser)
|
||||
{
|
||||
$stmtA = "INSERT INTO vicidial_user_log (user,event,campaign_id,event_date,event_epoch) values('$VALOuser[$logrun]','LOGOUT','$VALOcampaign[$logrun]','$SQLdate','$now_date_epoch');";
|
||||
$dbhA->query("$stmtA");
|
||||
my $affected_rows = $dbhA->get_affected_rows_length;
|
||||
|
||||
$event_string = "| lagged agent LOGOUT entry inserted $VALOuser[$logrun]|$VALOcampaign[$logrun]|$VALOextension[$logcount]|";
|
||||
&event_logger;
|
||||
|
||||
$logrun++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
### delete call records that are SENT for over 3 minutes
|
||||
$stmtA = "DELETE FROM vicidial_auto_calls where server_ip='$server_ip' and call_time < '$XDSQLdate' and status NOT IN('XFER','CLOSER','LIVE')";
|
||||
$dbhA->query("$stmtA");
|
||||
my $affected_rows = $dbhA->get_affected_rows_length;
|
||||
|
||||
$event_string = "| lagged call vac agent DELETED $affected_rows|$XDSQLdate|";
|
||||
&event_logger;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
###############################################################################
|
||||
###### last, wait for a little bit and repeat the loop
|
||||
###############################################################################
|
||||
|
||||
### sleep for 2 and a half seconds before beginning the loop again
|
||||
usleep(1*$loop_delay*1000);
|
||||
|
||||
$endless_loop--;
|
||||
if($DB){print STDERR "\nloop counter: |$endless_loop|\n";}
|
||||
|
||||
### putting a blank file called "VDAD.kill" in the directory will automatically safely kill this program
|
||||
if (-e '/home/cron/VDAD.kill')
|
||||
{
|
||||
unlink('/home/cron/VDAD.kill');
|
||||
$endless_loop=0;
|
||||
$one_day_interval=0;
|
||||
print "\nPROCESS KILLED MANUALLY... EXITING\n\n"
|
||||
}
|
||||
if ($endless_loop =~ /0$/) # run every ten cycles (about 25 seconds)
|
||||
{
|
||||
### delete call records that are LIVE for over 10 minutes
|
||||
$stmtA = "DELETE FROM vicidial_auto_calls where server_ip='$server_ip' and call_time < '$TDSQLdate' and status NOT IN('XFER','CLOSER')";
|
||||
$dbhA->query("$stmtA");
|
||||
my $affected_rows = $dbhA->get_affected_rows_length;
|
||||
|
||||
$event_string = "| lagged call vac agent DELETED $affected_rows|$TDSQLdate|LIVE|";
|
||||
&event_logger;
|
||||
|
||||
### Grab Server values from the database in case they've changed
|
||||
$stmtA = "SELECT max_vicidial_trunks,answer_transfer_agent,local_gmt,ext_context FROM servers where server_ip = '$server_ip';";
|
||||
$dbhA->query("$stmtA");
|
||||
if ($dbhA->has_selected_record)
|
||||
{
|
||||
$iter=$dbhA->create_record_iterator;
|
||||
while ( $record = $iter->each)
|
||||
{
|
||||
$DBmax_vicidial_trunks = "$record->[0]";
|
||||
$DBanswer_transfer_agent= "$record->[1]";
|
||||
$DBSERVER_GMT = "$record->[2]";
|
||||
$DBext_context = "$record->[3]";
|
||||
if ($DBmax_vicidial_trunks) {$max_vicidial_trunks = $DBmax_vicidial_trunks;}
|
||||
if ($DBanswer_transfer_agent) {$answer_transfer_agent = $DBanswer_transfer_agent;}
|
||||
if ($DBSERVER_GMT) {$SERVER_GMT = $DBSERVER_GMT;}
|
||||
if ($DBext_context) {$ext_context = $DBext_context;}
|
||||
}
|
||||
}
|
||||
|
||||
$event_string = "| updating server parameters $max_vicidial_trunks|$answer_transfer_agent|$SERVER_GMT|$ext_context|";
|
||||
&event_logger;
|
||||
|
||||
&get_time_now;
|
||||
|
||||
#@psoutput = `/bin/ps -f --no-headers -A`;
|
||||
@psoutput = `/bin/ps -o "%p %a" --no-headers -A`;
|
||||
|
||||
$running_listen = 0;
|
||||
|
||||
$i=0;
|
||||
foreach (@psoutput)
|
||||
{
|
||||
chomp($psoutput[$i]);
|
||||
|
||||
@psline = split(/\/usr\/bin\/perl /,$psoutput[$i]);
|
||||
|
||||
if ($psline[1] =~ /AST_manager_li/) {$running_listen++;}
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
if (!$running_listen)
|
||||
{
|
||||
$endless_loop=0;
|
||||
$one_day_interval=0;
|
||||
print "\nPROCESS KILLED NO LISTENER RUNNING... EXITING\n\n";
|
||||
}
|
||||
|
||||
if($DB){print "checking to see if listener is dead |$running_listen|\n";}
|
||||
}
|
||||
|
||||
$bad_grabber_counter=0;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
if($DB){print "DONE... Exiting... Goodbye... See you later... Not really, initiating next loop...\n";}
|
||||
|
||||
$event_string='HANGING UP|';
|
||||
&event_logger;
|
||||
|
||||
$one_day_interval--;
|
||||
|
||||
}
|
||||
|
||||
$event_string='CLOSING DB CONNECTION|';
|
||||
&event_logger;
|
||||
|
||||
|
||||
$dbhA->close;
|
||||
|
||||
|
||||
if($DB){print "DONE... Exiting... Goodbye... See you later... Really I mean it this time\n";}
|
||||
|
||||
|
||||
exit;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
sub get_time_now #get the current date and time and epoch for logging call lengths and datetimes
|
||||
{
|
||||
$secX = time();
|
||||
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($secX);
|
||||
$LOCAL_GMT_OFF = $SERVER_GMT;
|
||||
$LOCAL_GMT_OFF_STD = $SERVER_GMT;
|
||||
if ($isdst) {$LOCAL_GMT_OFF++;}
|
||||
|
||||
$GMT_now = ($secX - ($LOCAL_GMT_OFF * 3600));
|
||||
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($GMT_now);
|
||||
if ($hour < 10) {$hour = "0$hour";}
|
||||
if ($min < 10) {$min = "0$min";}
|
||||
|
||||
if ($DB) {print "TIME DEBUG: $LOCAL_GMT_OFF_STD|$LOCAL_GMT_OFF|$isdst| GMT: $hour:$min\n";}
|
||||
|
||||
($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) {$hour = "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";
|
||||
$file_date = "$year-$mon-$mday";
|
||||
$CIDdate = "$mon$mday$hour$min$sec";
|
||||
$tsSQLdate = "$year$mon$mday$hour$min$sec";
|
||||
$SQLdate = "$year-$mon-$mday $hour:$min:$sec";
|
||||
|
||||
$BDtarget = ($secX - 10);
|
||||
($Bsec,$Bmin,$Bhour,$Bmday,$Bmon,$Byear,$Bwday,$Byday,$Bisdst) = localtime($BDtarget);
|
||||
$Byear = ($Byear + 1900);
|
||||
$Bmon++;
|
||||
if ($Bmon < 10) {$Bmon = "0$Bmon";}
|
||||
if ($Bmday < 10) {$Bmday = "0$Bmday";}
|
||||
if ($Bhour < 10) {$Bhour = "0$Bhour";}
|
||||
if ($Bmin < 10) {$Bmin = "0$Bmin";}
|
||||
if ($Bsec < 10) {$Bsec = "0$Bsec";}
|
||||
$BDtsSQLdate = "$Byear$Bmon$Bmday$Bhour$Bmin$Bsec";
|
||||
|
||||
$PDtarget = ($secX - 30);
|
||||
($Psec,$Pmin,$Phour,$Pmday,$Pmon,$Pyear,$Pwday,$Pyday,$Pisdst) = localtime($PDtarget);
|
||||
$Pyear = ($Pyear + 1900);
|
||||
$Pmon++;
|
||||
if ($Pmon < 10) {$Pmon = "0$Pmon";}
|
||||
if ($Pmday < 10) {$Pmday = "0$Pmday";}
|
||||
if ($Phour < 10) {$Phour = "0$Phour";}
|
||||
if ($Pmin < 10) {$Pmin = "0$Pmin";}
|
||||
if ($Psec < 10) {$Psec = "0$Psec";}
|
||||
$PDtsSQLdate = "$Pyear$Pmon$Pmday$Phour$Pmin$Psec";
|
||||
|
||||
$XDtarget = ($secX - 120);
|
||||
($Xsec,$Xmin,$Xhour,$Xmday,$Xmon,$Xyear,$Xwday,$Xyday,$Xisdst) = localtime($XDtarget);
|
||||
$Xyear = ($Xyear + 1900);
|
||||
$Xmon++;
|
||||
if ($Xmon < 10) {$Xmon = "0$Xmon";}
|
||||
if ($Xmday < 10) {$Xmday = "0$Xmday";}
|
||||
if ($Xhour < 10) {$Xhour = "0$Xhour";}
|
||||
if ($Xmin < 10) {$Xmin = "0$Xmin";}
|
||||
if ($Xsec < 10) {$Xsec = "0$Xsec";}
|
||||
$XDSQLdate = "$Xyear-$Xmon-$Xmday $Xhour:$Xmin:$Xsec";
|
||||
|
||||
$TDtarget = ($secX - 600);
|
||||
($Tsec,$Tmin,$Thour,$Tmday,$Tmon,$Tyear,$Twday,$Tyday,$Tisdst) = localtime($TDtarget);
|
||||
$Tyear = ($Tyear + 1900);
|
||||
$Tmon++;
|
||||
if ($Tmon < 10) {$Tmon = "0$Tmon";}
|
||||
if ($Tmday < 10) {$Tmday = "0$Tmday";}
|
||||
if ($Thour < 10) {$Thour = "0$Thour";}
|
||||
if ($Tmin < 10) {$Tmin = "0$Tmin";}
|
||||
if ($Tsec < 10) {$Tsec = "0$Tsec";}
|
||||
$TDSQLdate = "$Tyear-$Tmon-$Tmday $Thour:$Tmin:$Tsec";
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
sub event_logger
|
||||
{
|
||||
|
||||
if ($DB) {print "$now_date|$event_string|\n";}
|
||||
### open the log file for writing ###
|
||||
open(Lout, ">>$VDADLOGfile")
|
||||
|| die "Can't open $VDADLOGfile: $!\n";
|
||||
|
||||
print Lout "$now_date|$event_string|\n";
|
||||
|
||||
close(Lout);
|
||||
|
||||
$event_string='';
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,493 @@
|
||||
#!/usr/bin/perl
|
||||
#
|
||||
# AST_VDremote_agents.pl version 0.1
|
||||
#
|
||||
# DESCRIPTION:
|
||||
# uses Net::MySQL to keep remote agents logged in to the VICIDIAL system
|
||||
#
|
||||
# SUMMARY:
|
||||
# This program was designed for people using the Asterisk PBX with VICIDIAL
|
||||
#
|
||||
# For the client to use VICIDIAL with remote agents, this must always be running
|
||||
#
|
||||
# It is recommended that you run this program on the local Asterisk machine
|
||||
#
|
||||
# This script is to run perpetually querying every second to update the remote
|
||||
# agents that should appear to be logged in so that the calls can be transferred
|
||||
# out to them properly.
|
||||
#
|
||||
# It is good practice to keep this program running by placing the associated
|
||||
# KEEPALIVE script running every minute to ensure this program is always running
|
||||
#
|
||||
# Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
|
||||
#
|
||||
# changes:
|
||||
# 50215-0954 - First version of script
|
||||
# 50810-1615 - Added database server variable definitions lookup
|
||||
#
|
||||
|
||||
### begin parsing run-time options ###
|
||||
if (length($ARGV[0])>1)
|
||||
{
|
||||
$i=0;
|
||||
while ($#ARGV >= $i)
|
||||
{
|
||||
$args = "$args $ARGV[$i]";
|
||||
$i++;
|
||||
}
|
||||
|
||||
if ($args =~ /--help/i)
|
||||
{
|
||||
print "allowed run time options:\n [-t] = test\n [-v] = verbose debug messages\n [--delay=XXX] = delay of XXX seconds per loop, default 2 seconds\n\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($args =~ /--delay=/i)
|
||||
{
|
||||
@data_in = split(/--delay=/,$args);
|
||||
$loop_delay = $data_in[1];
|
||||
print " LOOP DELAY OVERRIDE!!!!! = $loop_delay seconds\n\n";
|
||||
$loop_delay = ($loop_delay * 1000);
|
||||
}
|
||||
else
|
||||
{
|
||||
$loop_delay = '2000';
|
||||
}
|
||||
if ($args =~ /-v/i)
|
||||
{
|
||||
$V=1; # Debug flag, set to 0 for no debug messages, On an active system this will generate hundreds of lines of output per minute
|
||||
}
|
||||
if ($args =~ /-t/i)
|
||||
{
|
||||
$TEST=1;
|
||||
$T=1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print "no command line options set\n";
|
||||
$loop_delay = '2000';
|
||||
$V=1;
|
||||
}
|
||||
### end parsing run-time options ###
|
||||
|
||||
|
||||
# constants
|
||||
$US='__';
|
||||
$MT[0]='';
|
||||
|
||||
### Make sure this file is in a libs path or put the absolute path to it
|
||||
require("/home/cron/AST_SERVER_conf.pl"); # local configuration file
|
||||
|
||||
if (!$DB_port) {$DB_port='3306';}
|
||||
|
||||
use lib './lib', '../lib';
|
||||
use Time::HiRes ('gettimeofday','usleep','sleep'); # necessary to have perl sleep command of less than one second
|
||||
use Net::MySQL;
|
||||
|
||||
### connect to MySQL database defined in the AST_SERVER_conf.pl file
|
||||
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";
|
||||
|
||||
### Grab Server values from the database
|
||||
$stmtA = "SELECT local_gmt FROM servers where server_ip = '$server_ip';";
|
||||
$dbhA->query("$stmtA");
|
||||
if ($dbhA->has_selected_record)
|
||||
{
|
||||
$iter=$dbhA->create_record_iterator;
|
||||
while ( $record = $iter->each)
|
||||
{
|
||||
$DBSERVER_GMT = "$record->[0]";
|
||||
if ($DBSERVER_GMT) {$SERVER_GMT = $DBSERVER_GMT;}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
&get_time_now; # update time/date variables
|
||||
|
||||
$event_string='PROGRAM STARTED||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||';
|
||||
&event_logger; # writes to the log and if debug flag is set prints to STDOUT
|
||||
|
||||
|
||||
$event_string='LOGGED INTO MYSQL SERVER ON 1 CONNECTION|';
|
||||
&event_logger;
|
||||
|
||||
$one_day_interval = 12; # 1 month loops for one year
|
||||
while($one_day_interval > 0)
|
||||
{
|
||||
|
||||
$endless_loop=5760000; # 30 days minutes at XXX seconds per loop
|
||||
|
||||
while($endless_loop > 0)
|
||||
{
|
||||
&get_time_now;
|
||||
|
||||
if ($endless_loop =~ /0$|5$/)
|
||||
{
|
||||
### delete call records that are LIVE for over 10 minutes and last_update_time < '$PDtsSQLdate'
|
||||
$stmtA = "DELETE FROM vicidial_live_agents where server_ip='$server_ip' and status IN('PAUSED') and extension LIKE \"R/%\"";
|
||||
$dbhA->query("$stmtA");
|
||||
my $affected_rows = $dbhA->get_affected_rows_length;
|
||||
|
||||
$event_string = "| lagged call vla agent DELETED $affected_rows";
|
||||
&event_logger;
|
||||
|
||||
|
||||
$stmtA = "UPDATE vicidial_live_agents set status='INCALL', last_call_time='$SQLdate' where server_ip='$server_ip' and status IN('QUEUE') and extension LIKE \"R/%\"";
|
||||
$dbhA->query("$stmtA");
|
||||
my $affected_rows = $dbhA->get_affected_rows_length;
|
||||
|
||||
$event_string = "| QUEUEd call listing vla UPDATEd $affected_rows";
|
||||
&event_logger;
|
||||
|
||||
#@psoutput = `/bin/ps -f --no-headers -A`;
|
||||
@psoutput = `/bin/ps -o "%p %a" --no-headers -A`;
|
||||
|
||||
$running_listen = 0;
|
||||
|
||||
$i=0;
|
||||
foreach (@psoutput)
|
||||
{
|
||||
chomp($psoutput[$i]);
|
||||
|
||||
@psline = split(/\/usr\/bin\/perl /,$psoutput[$i]);
|
||||
|
||||
if ($psline[1] =~ /AST_manager_li/) {$running_listen++;}
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
if (!$running_listen)
|
||||
{
|
||||
$endless_loop=0;
|
||||
$one_day_interval=0;
|
||||
print "\nPROCESS KILLED NO LISTENER RUNNING... EXITING\n\n";
|
||||
}
|
||||
|
||||
if($DB){print "checking to see if listener is dead |$running_listen|\n";}
|
||||
}
|
||||
|
||||
|
||||
|
||||
$user_counter=0;
|
||||
@DBremote_user=@MT;
|
||||
@DBremote_server_ip=@MT;
|
||||
@DBremote_campaign=@MT;
|
||||
@DBremote_conf_exten=@MT;
|
||||
@DBremote_closer=@MT;
|
||||
@DBremote_random=@MT;
|
||||
@loginexistsRANDOM=@MT;
|
||||
@loginexistsALL=@MT;
|
||||
@VD_user=@MT;
|
||||
@VD_extension=@MT;
|
||||
@VD_status=@MT;
|
||||
@VD_uniqueid=@MT;
|
||||
@VD_callerid=@MT;
|
||||
@VD_random=@MT;
|
||||
###############################################################################
|
||||
###### first grab all of the ACTIVE remote agents information from the database
|
||||
###############################################################################
|
||||
$dbhA->query("SELECT * FROM vicidial_remote_agents where status IN('ACTIVE') and server_ip='$server_ip' order by user_start");
|
||||
if ($dbhA->has_selected_record)
|
||||
{
|
||||
$iter=$dbhA->create_record_iterator;
|
||||
while ( $record = $iter->each)
|
||||
{
|
||||
$user_start = "$record->[1]";
|
||||
$number_of_lines = "$record->[2]";
|
||||
$conf_exten = "$record->[4]";
|
||||
$campaign_id = "$record->[6]";
|
||||
$closer_campaigns = "$record->[7]";
|
||||
|
||||
$y=0;
|
||||
while ($y < $number_of_lines)
|
||||
{
|
||||
$random = int( rand(9999999)) + 10000000;
|
||||
$user_id = ($user_start + $y);
|
||||
$DBremote_user[$user_counter] = "$user_id";
|
||||
$DBremote_server_ip[$user_counter] = "$server_ip";
|
||||
$DBremote_campaign[$user_counter] = "$campaign_id";
|
||||
$DBremote_conf_exten[$user_counter] = "$conf_exten";
|
||||
$DBremote_closer[$user_counter] = "$closer_campaigns";
|
||||
$DBremote_random[$user_counter] = "$random";
|
||||
|
||||
$y++;
|
||||
$user_counter++;
|
||||
}
|
||||
|
||||
}
|
||||
if ($V) {print STDERR "$user_counter live remote agents ACTIVE\n";}
|
||||
}
|
||||
|
||||
|
||||
###############################################################################
|
||||
###### second traverse array of remote agents to be active and insert or update
|
||||
###### in vicidial_live_agents table
|
||||
###############################################################################
|
||||
$h=0;
|
||||
foreach(@DBremote_user)
|
||||
{
|
||||
if (length($DBremote_user[$h])>1)
|
||||
{
|
||||
|
||||
### check to see if the record exists and only needs random number update
|
||||
$dbhA->query("SELECT count(*) FROM vicidial_live_agents where user='$DBremote_user[$h]' and server_ip='$server_ip' and campaign_id='$DBremote_campaign[$h]' and conf_exten='$DBremote_conf_exten[$h]' and closer_campaigns='$DBremote_closer[$h]'");
|
||||
if ($dbhA->has_selected_record)
|
||||
{
|
||||
$iter=$dbhA->create_record_iterator;
|
||||
while ( $record = $iter->each)
|
||||
{
|
||||
$loginexistsRANDOM[$h] = "$record->[0]";
|
||||
}
|
||||
}
|
||||
if ($loginexistsRANDOM[$h] > 0)
|
||||
{
|
||||
$stmtA = "UPDATE vicidial_live_agents set random_id='$DBremote_random[$h]' where user='$DBremote_user[$h]' and server_ip='$server_ip' and campaign_id='$DBremote_campaign[$h]' and conf_exten='$DBremote_conf_exten[$h]' and closer_campaigns='$DBremote_closer[$h]'";
|
||||
$dbhA->query("$stmtA");
|
||||
my $affected_rows = $dbhA->get_affected_rows_length;
|
||||
if ($V) {print STDERR "$DBremote_user[$h] $DBremote_campaign[$h] ONLY RANDOM ID UPDATE: $affected_rows\n";}
|
||||
}
|
||||
### check if record for user on server exists at all in vicidial_live_agents
|
||||
else
|
||||
{
|
||||
$dbhA->query("SELECT count(*) FROM vicidial_live_agents where user='$DBremote_user[$h]' and server_ip='$server_ip'");
|
||||
if ($dbhA->has_selected_record)
|
||||
{
|
||||
$iter=$dbhA->create_record_iterator;
|
||||
while ( $record = $iter->each)
|
||||
{
|
||||
$loginexistsALL[$h] = "$record->[0]";
|
||||
}
|
||||
}
|
||||
if ($loginexistsALL[$h] > 0)
|
||||
{
|
||||
$stmtA = "UPDATE vicidial_live_agents set random_id='$DBremote_random[$h]',campaign_id='$DBremote_campaign[$h]',conf_exten='$DBremote_conf_exten[$h]',closer_campaigns='$DBremote_closer[$h]', status='READY' where user='$DBremote_user[$h]' and server_ip='$server_ip'";
|
||||
$dbhA->query("$stmtA");
|
||||
my $affected_rows = $dbhA->get_affected_rows_length;
|
||||
if ($V) {print STDERR "$DBremote_user[$h] ALL UPDATE: $affected_rows\n";}
|
||||
}
|
||||
### no records exist so insert a new one
|
||||
else
|
||||
{
|
||||
$stmtA = "INSERT INTO vicidial_live_agents (user,server_ip,conf_exten,extension,status,campaign_id,random_id,last_call_time,last_update_time,last_call_finish,closer_campaigns,channel,uniqueid,callerid) values('$DBremote_user[$h]','$server_ip','$DBremote_conf_exten[$h]','R/$DBremote_user[$h]','READY','$DBremote_campaign[$h]','$DBremote_random[$h]','$SQLdate','$tsSQLdate','$SQLdate','$DBremote_closer[$h]','','','')";
|
||||
$dbhA->query("$stmtA");
|
||||
if ($V) {print STDERR "$DBremote_user[$h] NEW INSERT\n";}
|
||||
}
|
||||
}
|
||||
}
|
||||
$h++;
|
||||
}
|
||||
|
||||
|
||||
###############################################################################
|
||||
###### third validate that the calls that the vicidial_live_agents are on are not dead
|
||||
###### and if they are wipe out the values and set the agent record back to READY
|
||||
###############################################################################
|
||||
$dbhA->query("SELECT user,extension,status,uniqueid,callerid FROM vicidial_live_agents where extension LIKE \"R/%\" and server_ip='$server_ip' and uniqueid > 10");
|
||||
if ($dbhA->has_selected_record)
|
||||
{
|
||||
$iter=$dbhA->create_record_iterator;
|
||||
$z=0;
|
||||
while ( $record = $iter->each)
|
||||
{
|
||||
$VDuser = "$record->[0]";
|
||||
$VDextension = "$record->[1]";
|
||||
$VDstatus = "$record->[2]";
|
||||
$VDuniqueid = "$record->[3]";
|
||||
$VDcallerid = "$record->[4]";
|
||||
$VDrandom = int( rand(9999999)) + 10000000;
|
||||
|
||||
$VD_user[$z] = "$VDuser";
|
||||
$VD_extension[$z] = "$VDextension";
|
||||
$VD_status[$z] = "$VDstatus";
|
||||
$VD_uniqueid[$z] = "$VDuniqueid";
|
||||
$VD_callerid[$z] = "$VDcallerid";
|
||||
$VD_random[$z] = "$VDrandom";
|
||||
|
||||
$z++;
|
||||
}
|
||||
if ($V) {print STDERR "$z remote agents on calls\n";}
|
||||
}
|
||||
$z=0;
|
||||
foreach(@VD_user)
|
||||
{
|
||||
$dbhA->query("SELECT count(*) FROM vicidial_auto_calls where uniqueid='$VD_uniqueid[$z]' and server_ip='$server_ip'");
|
||||
if ($dbhA->has_selected_record)
|
||||
{
|
||||
$iter=$dbhA->create_record_iterator;
|
||||
while ( $record = $iter->each)
|
||||
{
|
||||
$autocallexists[$z] = "$record->[0]";
|
||||
}
|
||||
}
|
||||
if ($autocallexists[$z] < 1)
|
||||
{
|
||||
$stmtA = "UPDATE vicidial_live_agents set random_id='$VD_random[$z]',status='READY', last_call_finish='$SQLdate',lead_id='',uniqueid='',callerid='',channel='' where user='$VD_user[$z]' and server_ip='$server_ip'";
|
||||
$dbhA->query("$stmtA");
|
||||
my $affected_rows = $dbhA->get_affected_rows_length;
|
||||
if ($V) {print STDERR "$VD_user[$z] CALL WIPE UPDATE: $affected_rows|$VD_uniqueid[$z]\n";}
|
||||
}
|
||||
|
||||
$z++;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
###############################################################################
|
||||
###### last, wait for a little bit and repeat the loop
|
||||
###############################################################################
|
||||
|
||||
### sleep for X seconds before beginning the loop again
|
||||
usleep(1*$loop_delay*1000);
|
||||
|
||||
$endless_loop--;
|
||||
if($DB){print STDERR "\nloop counter: |$endless_loop|\n";}
|
||||
|
||||
### putting a blank file called "VDAD.kill" in the directory will automatically safely kill this program
|
||||
if (-e '/home/cron/VDAD.kill')
|
||||
{
|
||||
unlink('/home/cron/VDAD.kill');
|
||||
$endless_loop=0;
|
||||
$one_day_interval=0;
|
||||
print "\nPROCESS KILLED MANUALLY... EXITING\n\n"
|
||||
}
|
||||
|
||||
$bad_grabber_counter=0;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
if($DB){print "DONE... Exiting... Goodbye... See you later... Not really, initiating next loop...\n";}
|
||||
|
||||
$event_string='HANGING UP|';
|
||||
&event_logger;
|
||||
|
||||
$one_day_interval--;
|
||||
|
||||
}
|
||||
|
||||
$event_string='CLOSING DB CONNECTION|';
|
||||
&event_logger;
|
||||
|
||||
|
||||
$dbhA->close;
|
||||
|
||||
|
||||
if($DB){print "DONE... Exiting... Goodbye... See you later... Really I mean it this time\n";}
|
||||
|
||||
|
||||
exit;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
sub get_time_now #get the current date and time and epoch for logging call lengths and datetimes
|
||||
{
|
||||
$secX = time();
|
||||
$secX = time();
|
||||
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($secX);
|
||||
$LOCAL_GMT_OFF = $SERVER_GMT;
|
||||
$LOCAL_GMT_OFF_STD = $SERVER_GMT;
|
||||
if ($isdst) {$LOCAL_GMT_OFF++;}
|
||||
|
||||
$GMT_now = ($secX - ($LOCAL_GMT_OFF * 3600));
|
||||
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($GMT_now);
|
||||
if ($hour < 10) {$hour = "0$hour";}
|
||||
if ($min < 10) {$min = "0$min";}
|
||||
|
||||
if ($DB) {print "TIME DEBUG: $LOCAL_GMT_OFF_STD|$LOCAL_GMT_OFF|$isdst| GMT: $hour:$min\n";}
|
||||
|
||||
($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";
|
||||
$CIDdate = "$mon$mday$hour$min$sec";
|
||||
$tsSQLdate = "$year$mon$mday$hour$min$sec";
|
||||
$SQLdate = "$year-$mon-$mday $hour:$min:$sec";
|
||||
$filedate = "$year-$mon-$mday";
|
||||
|
||||
$BDtarget = ($secX - 10);
|
||||
($Bsec,$Bmin,$Bhour,$Bmday,$Bmon,$Byear,$Bwday,$Byday,$Bisdst) = localtime($BDtarget);
|
||||
$Byear = ($Byear + 1900);
|
||||
$Bmon++;
|
||||
if ($Bmon < 10) {$Bmon = "0$Bmon";}
|
||||
if ($Bmday < 10) {$Bmday = "0$Bmday";}
|
||||
if ($Bhour < 10) {$Bhour = "0$Bhour";}
|
||||
if ($Bmin < 10) {$Bmin = "0$Bmin";}
|
||||
if ($Bsec < 10) {$Bsec = "0$Bsec";}
|
||||
$BDtsSQLdate = "$Byear$Bmon$Bmday$Bhour$Bmin$Bsec";
|
||||
|
||||
$PDtarget = ($secX - 30);
|
||||
($Psec,$Pmin,$Phour,$Pmday,$Pmon,$Pyear,$Pwday,$Pyday,$Pisdst) = localtime($PDtarget);
|
||||
$Pyear = ($Pyear + 1900);
|
||||
$Pmon++;
|
||||
if ($Pmon < 10) {$Pmon = "0$Pmon";}
|
||||
if ($Pmday < 10) {$Pmday = "0$Pmday";}
|
||||
if ($Phour < 10) {$Phour = "0$Phour";}
|
||||
if ($Pmin < 10) {$Pmin = "0$Pmin";}
|
||||
if ($Psec < 10) {$Psec = "0$Psec";}
|
||||
$PDtsSQLdate = "$Pyear$Pmon$Pmday$Phour$Pmin$Psec";
|
||||
|
||||
$XDtarget = ($secX - 120);
|
||||
($Xsec,$Xmin,$Xhour,$Xmday,$Xmon,$Xyear,$Xwday,$Xyday,$Xisdst) = localtime($XDtarget);
|
||||
$Xyear = ($Xyear + 1900);
|
||||
$Xmon++;
|
||||
if ($Xmon < 10) {$Xmon = "0$Xmon";}
|
||||
if ($Xmday < 10) {$Xmday = "0$Xmday";}
|
||||
if ($Xhour < 10) {$Xhour = "0$Xhour";}
|
||||
if ($Xmin < 10) {$Xmin = "0$Xmin";}
|
||||
if ($Xsec < 10) {$Xsec = "0$Xsec";}
|
||||
$XDSQLdate = "$Xyear-$Xmon-$Xmday $Xhour:$Xmin:$Xsec";
|
||||
|
||||
$TDtarget = ($secX - 600);
|
||||
($Tsec,$Tmin,$Thour,$Tmday,$Tmon,$Tyear,$Twday,$Tyday,$Tisdst) = localtime($TDtarget);
|
||||
$Tyear = ($Tyear + 1900);
|
||||
$Tmon++;
|
||||
if ($Tmon < 10) {$Tmon = "0$Tmon";}
|
||||
if ($Tmday < 10) {$Tmday = "0$Tmday";}
|
||||
if ($Thour < 10) {$Thour = "0$Thour";}
|
||||
if ($Tmin < 10) {$Tmin = "0$Tmin";}
|
||||
if ($Tsec < 10) {$Tsec = "0$Tsec";}
|
||||
$TDSQLdate = "$Tyear-$Tmon-$Tmday $Thour:$Tmin:$Tsec";
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
sub event_logger
|
||||
{
|
||||
|
||||
if ($DB) {print "$now_date|$event_string|\n";}
|
||||
### open the log file for writing ###
|
||||
open(Lout, ">>/home/cron/remote.$filedate")
|
||||
|| die "Can't open /home/cron/remote.$filedate: $!\n";
|
||||
|
||||
print Lout "$now_date|$event_string|\n";
|
||||
|
||||
close(Lout);
|
||||
|
||||
$event_string='';
|
||||
}
|
||||
@@ -0,0 +1,336 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
# AST_agent_week.pl
|
||||
#
|
||||
# This script is designed to gather stats for all agent activity over the course
|
||||
# of a week(Sunday to Saturday) and print it in an ASCI text file to be placed
|
||||
# on a web server for viewing.
|
||||
#
|
||||
# CHANGES
|
||||
# 60517-1100 - First version
|
||||
#
|
||||
|
||||
$txt = '.txt';
|
||||
$US = '_';
|
||||
$MT[0] = '';
|
||||
|
||||
### begin parsing run-time options ###
|
||||
if (length($ARGV[0])>1)
|
||||
{
|
||||
$i=0;
|
||||
while ($#ARGV >= $i)
|
||||
{
|
||||
$args = "$args $ARGV[$i]";
|
||||
$i++;
|
||||
}
|
||||
|
||||
if ($args =~ /--help/i)
|
||||
{
|
||||
print "allowed run time options:\n [-q] = quiet\n [-t] = test\n\n";
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($args =~ /--debug/i)
|
||||
{
|
||||
$DB=1;
|
||||
print "\n-----DEBUG MODE-----\n\n";
|
||||
}
|
||||
if ($args =~ /-q/i)
|
||||
{
|
||||
$q=1; $Q=1;
|
||||
}
|
||||
if ($args =~ /-t/i)
|
||||
{
|
||||
$T=1; $TEST=1;
|
||||
print "\n-----TESTING-----\n\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print "no command line options set\n";
|
||||
}
|
||||
### end parsing run-time options ###
|
||||
|
||||
|
||||
$secX = time();
|
||||
($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) {$hour = "0$hour";}
|
||||
if ($min < 10) {$min = "0$min";}
|
||||
if ($sec < 10) {$sec = "0$sec";}
|
||||
$filedate = "$year$mon$mday-$hour$min$sec";
|
||||
$ABIfiledate = "$mon-$mday-$year$us$hour$min$sec";
|
||||
$shipdate = "$year-$mon-$mday";
|
||||
$datestamp = "$year/$mon/$mday $hour:$min";
|
||||
|
||||
$STARTtarget = ($secX - (86400 * $wday));
|
||||
($Ssec,$Smin,$Shour,$Smday,$Smon,$Syear,$Swday,$Syday,$Sisdst) = localtime($STARTtarget);
|
||||
$Syear = ($Syear + 1900); $Smon++;
|
||||
if ($Smon < 10) {$Smon = "0$Smon";}
|
||||
if ($Smday < 10) {$Smday = "0$Smday";}
|
||||
$START_week = (($Syday/7)+1); $START_week = sprintf("%2d", $START_week);
|
||||
$STARTtarget_date = "$Syear-$Smon-$Smday";
|
||||
|
||||
$ENDtarget = ($STARTtarget + (86400 * 6));
|
||||
($Ssec,$Smin,$Shour,$Smday,$Smon,$Syear,$Swday,$Syday,$Sisdst) = localtime($ENDtarget);
|
||||
$Syear = ($Syear + 1900); $Smon++;
|
||||
if ($Smon < 10) {$Smon = "0$Smon";}
|
||||
if ($Smday < 10) {$Smday = "0$Smday";}
|
||||
$ENDtarget_date = "$Syear-$Smon-$Smday";
|
||||
|
||||
$PAST_STARTtarget = ($STARTtarget - (86400 * 7));
|
||||
($Ssec,$Smin,$Shour,$Smday,$Smon,$Syear,$Swday,$Syday,$Sisdst) = localtime($PAST_STARTtarget);
|
||||
$Syear = ($Syear + 1900); $Smon++;
|
||||
if ($Smon < 10) {$Smon = "0$Smon";}
|
||||
if ($Smday < 10) {$Smday = "0$Smday";}
|
||||
$PAST_START_week = (($Syday/7)+1); $PAST_START_week = sprintf("%2d", $PAST_START_week);
|
||||
$PAST_STARTtarget_date = "$Syear-$Smon-$Smday";
|
||||
|
||||
$PAST_ENDtarget = ($ENDtarget - (86400 * 7));
|
||||
($Ssec,$Smin,$Shour,$Smday,$Smon,$Syear,$Swday,$Syday,$Sisdst) = localtime($PAST_ENDtarget);
|
||||
$Syear = ($Syear + 1900); $Smon++;
|
||||
if ($Smon < 10) {$Smon = "0$Smon";}
|
||||
if ($Smday < 10) {$Smday = "0$Smday";}
|
||||
$PAST_ENDtarget_date = "$Syear-$Smon-$Smday";
|
||||
|
||||
$PAST_date[0] = $PAST_STARTtarget_date;
|
||||
$PAST_day[0] = 'Sunday ';
|
||||
$PAST_date[6] = $PAST_ENDtarget_date;
|
||||
$PAST_day[6] = 'Saturday ';
|
||||
|
||||
$PAST_Mondaytarget = ($STARTtarget - (86400 * 6));
|
||||
($Ssec,$Smin,$Shour,$Smday,$Smon,$Syear,$Swday,$Syday,$Sisdst) = localtime($PAST_Mondaytarget);
|
||||
$Syear = ($Syear + 1900); $Smon++;
|
||||
if ($Smon < 10) {$Smon = "0$Smon";}
|
||||
if ($Smday < 10) {$Smday = "0$Smday";}
|
||||
$PAST_date[1] = "$Syear-$Smon-$Smday";
|
||||
$PAST_day[1] = 'Monday ';
|
||||
|
||||
$PAST_Tuesdaytarget = ($STARTtarget - (86400 * 5));
|
||||
($Ssec,$Smin,$Shour,$Smday,$Smon,$Syear,$Swday,$Syday,$Sisdst) = localtime($PAST_Tuesdaytarget);
|
||||
$Syear = ($Syear + 1900); $Smon++;
|
||||
if ($Smon < 10) {$Smon = "0$Smon";}
|
||||
if ($Smday < 10) {$Smday = "0$Smday";}
|
||||
$PAST_date[2] = "$Syear-$Smon-$Smday";
|
||||
$PAST_day[2] = 'Tuesday ';
|
||||
|
||||
$PAST_Wednesdaytarget = ($STARTtarget - (86400 * 4));
|
||||
($Ssec,$Smin,$Shour,$Smday,$Smon,$Syear,$Swday,$Syday,$Sisdst) = localtime($PAST_Wednesdaytarget);
|
||||
$Syear = ($Syear + 1900); $Smon++;
|
||||
if ($Smon < 10) {$Smon = "0$Smon";}
|
||||
if ($Smday < 10) {$Smday = "0$Smday";}
|
||||
$PAST_date[3] = "$Syear-$Smon-$Smday";
|
||||
$PAST_day[3] = 'Wednesday';
|
||||
|
||||
$PAST_Thursdaytarget = ($STARTtarget - (86400 * 3));
|
||||
($Ssec,$Smin,$Shour,$Smday,$Smon,$Syear,$Swday,$Syday,$Sisdst) = localtime($PAST_Thursdaytarget);
|
||||
$Syear = ($Syear + 1900); $Smon++;
|
||||
if ($Smon < 10) {$Smon = "0$Smon";}
|
||||
if ($Smday < 10) {$Smday = "0$Smday";}
|
||||
$PAST_date[4] = "$Syear-$Smon-$Smday";
|
||||
$PAST_day[4] = 'Thursday ';
|
||||
|
||||
$PAST_Fridaytarget = ($STARTtarget - (86400 * 2));
|
||||
($Ssec,$Smin,$Shour,$Smday,$Smon,$Syear,$Swday,$Syday,$Sisdst) = localtime($PAST_Fridaytarget);
|
||||
$Syear = ($Syear + 1900); $Smon++;
|
||||
if ($Smon < 10) {$Smon = "0$Smon";}
|
||||
if ($Smday < 10) {$Smday = "0$Smday";}
|
||||
$PAST_date[5] = "$Syear-$Smon-$Smday";
|
||||
$PAST_day[5] = 'Friday ';
|
||||
|
||||
print "\n\n\n\n\n\n\n\n\n\n\n\n-- AST_agent_week.pl --\n\n";
|
||||
print "This program is designed to print stats to a file for agents' activity for the previous week. \n\n";
|
||||
|
||||
$TLoutfile = '';
|
||||
$TLoutfile .= "TODAY: $shipdate\n";
|
||||
$TLoutfile .= "THIS WEEK: week $START_week $STARTtarget_date - $ENDtarget_date\n";
|
||||
$TLoutfile .= "LAST WEEK: week $PAST_START_week $PAST_STARTtarget_date - $PAST_ENDtarget_date\n\n";
|
||||
|
||||
#$h=0;
|
||||
#foreach(@PAST_date)
|
||||
#{
|
||||
#$TLoutfile .= "$PAST_day[$h] $PAST_date[$h]\n";
|
||||
#$h++;
|
||||
#}
|
||||
|
||||
#print "$TLoutfile";
|
||||
|
||||
|
||||
$outfile = "AGENT_HOURS_$PAST_STARTtarget_date$US$PAST_ENDtarget_date$txt";
|
||||
|
||||
#$dir = '/usr/local/apache2/htdocs';
|
||||
$dir = '/home/www/htdocs';
|
||||
|
||||
### open the X out file for writing ###
|
||||
open(out, ">$dir/vicidial/agent_reports/$outfile")
|
||||
|| die "Can't open $outfile: $!\n";
|
||||
|
||||
### Make sure this file is in a libs path or put the absolute path to it
|
||||
require("/home/cron/AST_SERVER_conf.pl"); # local configuration file
|
||||
|
||||
if (!$DB_port) {$DB_port='3306';}
|
||||
|
||||
use DBI;
|
||||
|
||||
$dbhA = DBI->connect("DBI:mysql:$DB_database:$DB_server:$DB_port", "$DB_user", "$DB_pass")
|
||||
or die "Couldn't connect to database: " . DBI->errstr;
|
||||
|
||||
$dbhB = DBI->connect("DBI:mysql:$DB_database:$DB_server:$DB_port", "$DB_user", "$DB_pass")
|
||||
or die "Couldn't connect to database: " . DBI->errstr;
|
||||
|
||||
#$vicidial_agent_log = 'vicidial_agent_log_archive';
|
||||
$vicidial_agent_log = 'vicidial_agent_log';
|
||||
|
||||
###########################################################################
|
||||
########### PAST WEEK STAT GATHERING LOOP #################################
|
||||
###########################################################################
|
||||
$h=0;
|
||||
foreach(@PAST_date)
|
||||
{
|
||||
print out "\n$PAST_day[$h] $PAST_date[$h]\n\n";
|
||||
print out "AGENT USER CALLS TALK PAUSE WAIT DISPO ACTIVE LOGTIME FIRST LAST \n";
|
||||
print "\n$PAST_day[$h] $PAST_date[$h]\n\n";
|
||||
print "AGENT USER CALLS TALK PAUSE WAIT DISPO ACTIVE LOGTIME FIRST LAST \n";
|
||||
|
||||
$stmtA = "select count(*) as calls, full_name,vicidial_users.user,sum(talk_sec),sum(pause_sec),sum(wait_sec),sum(dispo_sec) from vicidial_users,$vicidial_agent_log where event_time <= '$PAST_date[$h] 23:59:59' and event_time >= '$PAST_date[$h] 00:00:00' and vicidial_users.user=$vicidial_agent_log.user and pause_sec<48800 and wait_sec<48800 and talk_sec<48800 and dispo_sec<48800 group by vicidial_users.user order by full_name limit 10000;";
|
||||
$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)
|
||||
{
|
||||
@aryA = $sthA->fetchrow_array;
|
||||
|
||||
$calls = sprintf("%7s", $aryA[0]);
|
||||
$name = sprintf("%-20s", $aryA[1]); while(length($name)>20) {chop($name);}
|
||||
$user = sprintf("%-8s", $aryA[2]);
|
||||
|
||||
### TOTAL ACTIVE TIME
|
||||
$active = ($aryA[3] + $aryA[4] + $aryA[5] + $aryA[6]);
|
||||
$TIME_S = $active;
|
||||
$TIME_H = int($TIME_S / 3600);
|
||||
$TIME_S = ($TIME_S - ($TIME_H * 3600));
|
||||
$TIME_M = int($TIME_S / 60);
|
||||
$TIME_S = ($TIME_S - ($TIME_M * 60));
|
||||
if ($TIME_S < 10) {$TIME_S = "0$TIME_S";}
|
||||
if ($TIME_M < 10) {$TIME_M = "0$TIME_M";}
|
||||
$TIME_HMS = "$TIME_H:$TIME_M:$TIME_S";
|
||||
$active = sprintf("%9s", $TIME_HMS);
|
||||
|
||||
### TOTAL TALK TIME
|
||||
$TIME_S = $aryA[3];
|
||||
$TIME_H = int($TIME_S / 3600);
|
||||
$TIME_S = ($TIME_S - ($TIME_H * 3600));
|
||||
$TIME_M = int($TIME_S / 60);
|
||||
$TIME_S = ($TIME_S - ($TIME_M * 60));
|
||||
if ($TIME_S < 10) {$TIME_S = "0$TIME_S";}
|
||||
if ($TIME_M < 10) {$TIME_M = "0$TIME_M";}
|
||||
$TIME_HMS = "$TIME_H:$TIME_M:$TIME_S";
|
||||
$talk = sprintf("%9s", $TIME_HMS);
|
||||
|
||||
### TOTAL PAUSE TIME
|
||||
$TIME_S = $aryA[4];
|
||||
$TIME_H = int($TIME_S / 3600);
|
||||
$TIME_S = ($TIME_S - ($TIME_H * 3600));
|
||||
$TIME_M = int($TIME_S / 60);
|
||||
$TIME_S = ($TIME_S - ($TIME_M * 60));
|
||||
if ($TIME_S < 10) {$TIME_S = "0$TIME_S";}
|
||||
if ($TIME_M < 10) {$TIME_M = "0$TIME_M";}
|
||||
$TIME_HMS = "$TIME_H:$TIME_M:$TIME_S";
|
||||
$pause = sprintf("%9s", $TIME_HMS);
|
||||
|
||||
### TOTAL WAIT TIME
|
||||
$TIME_S = $aryA[5];
|
||||
$TIME_H = int($TIME_S / 3600);
|
||||
$TIME_S = ($TIME_S - ($TIME_H * 3600));
|
||||
$TIME_M = int($TIME_S / 60);
|
||||
$TIME_S = ($TIME_S - ($TIME_M * 60));
|
||||
if ($TIME_S < 10) {$TIME_S = "0$TIME_S";}
|
||||
if ($TIME_M < 10) {$TIME_M = "0$TIME_M";}
|
||||
$TIME_HMS = "$TIME_H:$TIME_M:$TIME_S";
|
||||
$wait = sprintf("%9s", $TIME_HMS);
|
||||
|
||||
### TOTAL DISPO TIME
|
||||
$TIME_S = $aryA[6];
|
||||
$TIME_H = int($TIME_S / 3600);
|
||||
$TIME_S = ($TIME_S - ($TIME_H * 3600));
|
||||
$TIME_M = int($TIME_S / 60);
|
||||
$TIME_S = ($TIME_S - ($TIME_M * 60));
|
||||
if ($TIME_S < 10) {$TIME_S = "0$TIME_S";}
|
||||
if ($TIME_M < 10) {$TIME_M = "0$TIME_M";}
|
||||
$TIME_HMS = "$TIME_H:$TIME_M:$TIME_S";
|
||||
$dispo = sprintf("%9s", $TIME_HMS);
|
||||
|
||||
$stmtB = "select event_time,UNIX_TIMESTAMP(event_time) from $vicidial_agent_log where event_time <= '$PAST_date[$h] 23:59:59' and event_time >= '$PAST_date[$h] 00:00:00' and user='$aryA[2]' order by event_time limit 1;";
|
||||
$sthB = $dbhB->prepare($stmtB) or die "preparing: ",$dbhB->errstr;
|
||||
$sthB->execute or die "executing: $stmtA ", $dbhB->errstr;
|
||||
@aryB = $sthB->fetchrow_array;
|
||||
$first_time = sprintf("%21s", $aryB[0]);
|
||||
$first_log = $aryB[1];
|
||||
|
||||
$stmtB = "select event_time,UNIX_TIMESTAMP(event_time) from $vicidial_agent_log where event_time <= '$PAST_date[$h] 23:59:59' and event_time >= '$PAST_date[$h] 00:00:00' and user='$aryA[2]' order by event_time desc limit 1;";
|
||||
$sthB = $dbhB->prepare($stmtB) or die "preparing: ",$dbhB->errstr;
|
||||
$sthB->execute or die "executing: $stmtA ", $dbhB->errstr;
|
||||
@aryB = $sthB->fetchrow_array;
|
||||
$last_time = sprintf("%21s", $aryB[0]);
|
||||
$last_log = $aryB[1];
|
||||
|
||||
$TIME_S = ($last_log - $first_log);
|
||||
$TIME_H = int($TIME_S / 3600);
|
||||
$TIME_S = ($TIME_S - ($TIME_H * 3600));
|
||||
$TIME_M = int($TIME_S / 60);
|
||||
$TIME_S = ($TIME_S - ($TIME_M * 60));
|
||||
if ($TIME_S < 10) {$TIME_S = "0$TIME_S";}
|
||||
if ($TIME_M < 10) {$TIME_M = "0$TIME_M";}
|
||||
$TIME_HMS = "$TIME_H:$TIME_M:$TIME_S";
|
||||
$login_time = sprintf("%9s", $TIME_HMS);
|
||||
|
||||
|
||||
|
||||
print out "$name$user$calls$talk$pause$wait$dispo$active$login_time$first_time$last_time\n";
|
||||
print "$name$user$calls$talk$pause$wait$dispo$active$login_time$first_time$last_time\n";
|
||||
|
||||
|
||||
$rec_count++;
|
||||
}
|
||||
$sthA->finish();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#if ($h=='1')
|
||||
# {
|
||||
# exit;
|
||||
# }
|
||||
|
||||
$h++;
|
||||
}
|
||||
|
||||
|
||||
|
||||
close(out);
|
||||
|
||||
### calculate time to run script ###
|
||||
$secY = time();
|
||||
$secZ = ($secY - $secX);
|
||||
$secZm = ($secZ /60);
|
||||
|
||||
print "script execution time in seconds: $secZ minutes: $secZm\n";
|
||||
|
||||
exit;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,236 @@
|
||||
#!/usr/bin/perl
|
||||
#
|
||||
# AST_cleanup_agent_log.pl version 0.1
|
||||
#
|
||||
# DESCRIPTION:
|
||||
# to be run frequently to clean up the vicidial_agent_log to fix erroneous time
|
||||
# calculations due to out-of-order vicidial_agent_log updates. This happens 0.5%
|
||||
# of the time in our test setups, but that leads to inaccurate time logs so we
|
||||
# wrote this script to fix the miscalculations
|
||||
#
|
||||
# This program only needs to be run by one server
|
||||
#
|
||||
# Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
|
||||
#
|
||||
|
||||
|
||||
# constants
|
||||
$COUNTER_OUTPUT=1; # set to 1 to display the counter as the script runs
|
||||
$US='__';
|
||||
$MT[0]='';
|
||||
|
||||
### begin parsing run-time options ###
|
||||
if (length($ARGV[0])>1)
|
||||
{
|
||||
$i=0;
|
||||
while ($#ARGV >= $i)
|
||||
{
|
||||
$args = "$args $ARGV[$i]";
|
||||
$i++;
|
||||
}
|
||||
|
||||
if ($args =~ /--help/i)
|
||||
{
|
||||
print "allowed run time options:\n [-t] = test\n [-debug] = verbose debug messages\n[-debugX] = Extra-verbose debug messages\n\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($args =~ /-debug/i)
|
||||
{
|
||||
$DB=1; # Debug flag
|
||||
print "\n----- DEBUGGING -----\n\n";
|
||||
}
|
||||
if ($args =~ /--debugX/i)
|
||||
{
|
||||
$DBX=1;
|
||||
print "\n----- SUPER-DUPER DEBUGGING -----\n\n";
|
||||
}
|
||||
if ($args =~ /-t/i)
|
||||
{
|
||||
$TEST=1;
|
||||
$T=1;
|
||||
print "\n----- TEST RUN, NO UPDATES -----\n\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
# print "no command line options set\n";
|
||||
}
|
||||
### end parsing run-time options ###
|
||||
|
||||
### Make sure this file is in a libs path or put the absolute path to it
|
||||
require("/home/cron/AST_SERVER_conf.pl"); # local configuration file
|
||||
|
||||
if (!$DB_port) {$DB_port='3306';}
|
||||
|
||||
use Net::MySQL;
|
||||
|
||||
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";
|
||||
|
||||
|
||||
|
||||
if ($DB) {print " - cleaning up pause time\n";}
|
||||
### Grab any pause time record greater than 50000
|
||||
$stmtA = "SELECT agent_log_id,pause_epoch,wait_epoch from vicidial_agent_log where pause_sec>50000;";
|
||||
if ($DBX) {print "$stmtA\n";}
|
||||
$dbhA->query("$stmtA");
|
||||
if ($dbhA->has_selected_record)
|
||||
{
|
||||
$i=0;
|
||||
$iter=$dbhA->create_record_iterator;
|
||||
while ( $record = $iter->each)
|
||||
{
|
||||
$DBout = '';
|
||||
$agent_log_id[$i] = "$record->[0]";
|
||||
$pause_epoch[$i] = "$record->[1]";
|
||||
$wait_epoch[$i] = "$record->[2]";
|
||||
$pause_sec[$i] = int($wait_epoch[$i] - $pause_epoch[$i]);
|
||||
if ( ($pause_sec[$i] < 0) || ($pause_sec[$i] > 50000) )
|
||||
{
|
||||
$DBout = "Override output: $pause_sec[$i]";
|
||||
$pause_sec[$i] = 0;
|
||||
}
|
||||
if ($DBX) {print "$i - $agent_log_id[$i] |$wait_epoch[$i]|$pause_epoch[$i]|$pause_sec[$i]|$DBout|\n";}
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
$h=0;
|
||||
while ($h < $i)
|
||||
{
|
||||
$stmtA = "UPDATE vicidial_agent_log set pause_sec='$pause_sec[$h]' where agent_log_id='$agent_log_id[$h]';";
|
||||
if($DBX){print STDERR "\n|$stmtA|\n";}
|
||||
if (!$TEST) {$dbhA->query($stmtA); }# or die "Couldn't execute query: |$stmtA|\n";
|
||||
$h++;
|
||||
}
|
||||
if ($DB) {print STDERR " Pause times fixed: $h\n";}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@agent_log_id=@MT;
|
||||
@wait_epoch=@MT;
|
||||
|
||||
if ($DBX) {print "\n\n";}
|
||||
if ($DB) {print " - cleaning up wait time\n";}
|
||||
### Grab any pause time record greater than 50000
|
||||
$stmtA = "SELECT agent_log_id,wait_epoch,talk_epoch from vicidial_agent_log where wait_sec>50000;";
|
||||
if ($DBX) {print "$stmtA\n";}
|
||||
$dbhA->query("$stmtA");
|
||||
if ($dbhA->has_selected_record)
|
||||
{
|
||||
$i=0;
|
||||
$iter=$dbhA->create_record_iterator;
|
||||
while ( $record = $iter->each)
|
||||
{
|
||||
$DBout = '';
|
||||
$agent_log_id[$i] = "$record->[0]";
|
||||
$wait_epoch[$i] = "$record->[1]";
|
||||
$talk_epoch[$i] = "$record->[2]";
|
||||
$wait_sec[$i] = int($talk_epoch[$i] - $wait_epoch[$i]);
|
||||
if ( ($wait_sec[$i] < 0) || ($wait_sec[$i] > 50000) )
|
||||
{
|
||||
$DBout = "Override output: $wait_sec[$i]";
|
||||
$wait_sec[$i] = 0;
|
||||
}
|
||||
if ($DBX) {print "$i - $agent_log_id[$i] |$talk_epoch[$i]|$wait_epoch[$i]|$wait_sec[$i]|$DBout|\n";}
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
$h=0;
|
||||
while ($h < $i)
|
||||
{
|
||||
$stmtA = "UPDATE vicidial_agent_log set wait_sec='$wait_sec[$h]' where agent_log_id='$agent_log_id[$h]';";
|
||||
if($DBX){print STDERR "\n|$stmtA|\n";}
|
||||
if (!$TEST) {$dbhA->query($stmtA); }# or die "Couldn't execute query: |$stmtA|\n";
|
||||
$h++;
|
||||
}
|
||||
if ($DB) {print STDERR " Wait times fixed: $h\n";}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@agent_log_id=@MT;
|
||||
@talk_epoch=@MT;
|
||||
|
||||
if ($DBX) {print "\n\n";}
|
||||
if ($DB) {print " - cleaning up talk time\n";}
|
||||
### Grab any pause time record greater than 50000
|
||||
$stmtA = "SELECT agent_log_id,talk_epoch,dispo_epoch from vicidial_agent_log where talk_sec>50000;";
|
||||
if ($DBX) {print "$stmtA\n";}
|
||||
$dbhA->query("$stmtA");
|
||||
if ($dbhA->has_selected_record)
|
||||
{
|
||||
$i=0;
|
||||
$iter=$dbhA->create_record_iterator;
|
||||
while ( $record = $iter->each)
|
||||
{
|
||||
$DBout = '';
|
||||
$agent_log_id[$i] = "$record->[0]";
|
||||
$talk_epoch[$i] = "$record->[1]";
|
||||
$dispo_epoch[$i] = "$record->[2]";
|
||||
$talk_sec[$i] = int($dispo_epoch[$i] - $talk_epoch[$i]);
|
||||
if ( ($talk_sec[$i] < 0) || ($talk_sec[$i] > 50000) )
|
||||
{
|
||||
$DBout = "Override output: $talk_sec[$i]";
|
||||
$talk_sec[$i] = 0;
|
||||
}
|
||||
if ($DBX) {print "$i - $agent_log_id[$i] |$dispo_epoch[$i]|$talk_epoch[$i]|$talk_sec[$i]|$DBout|\n";}
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
$h=0;
|
||||
while ($h < $i)
|
||||
{
|
||||
$stmtA = "UPDATE vicidial_agent_log set talk_sec='$talk_sec[$h]' where agent_log_id='$agent_log_id[$h]';";
|
||||
if($DBX){print STDERR "|$stmtA|\n";}
|
||||
if (!$TEST) {$dbhA->query($stmtA); }# or die "Couldn't execute query: |$stmtA|\n";
|
||||
$h++;
|
||||
}
|
||||
if ($DB) {print STDERR " Talk times fixed: $h\n";}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@agent_log_id=@MT;
|
||||
@dispo_epoch=@MT;
|
||||
|
||||
if ($DBX) {print "\n\n";}
|
||||
if ($DB) {print " - cleaning up dispo time\n";}
|
||||
$stmtA = "UPDATE vicidial_agent_log set dispo_sec='0' where dispo_sec>50000;";
|
||||
if($DBX){print STDERR "|$stmtA|\n";}
|
||||
if (!$TEST)
|
||||
{
|
||||
$dbhA->query($stmtA); # or die "Couldn't execute query: |$stmtA|\n";
|
||||
$affected_rows = $dbhA->get_affected_rows_length;
|
||||
}
|
||||
if ($DB) {print STDERR " Bad Dispo times zeroed out: $affected_rows\n";}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if ($DB) {print STDERR "\nDONE\n";}
|
||||
|
||||
|
||||
|
||||
$dbhA->close;
|
||||
|
||||
|
||||
exit;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,220 @@
|
||||
#!/usr/bin/perl
|
||||
#
|
||||
# AST_conf_update.pl version 0.3
|
||||
#
|
||||
# DESCRIPTION:
|
||||
# uses the Asterisk Manager interface and Net::MySQL to update whether a conference
|
||||
# is still in use or not. If not in use 3 times in a row the extension in the
|
||||
# conferences DB record is erased freeing that conference to be used again
|
||||
#
|
||||
# SUMMARY:
|
||||
# This program was designed for people using the Asterisk PBX with conferences
|
||||
#
|
||||
# This program should be in the cron running every minute (like AST_vm_update.pl)
|
||||
#
|
||||
# For this program to work you need to have the "asterisk" MySQL database
|
||||
# created with the conferences table in it, also make sure
|
||||
# that the account running this program has read/write/update/delete access
|
||||
# to that database
|
||||
#
|
||||
# It is recommended that you run this program on the local Asterisk machine
|
||||
#
|
||||
# If this script is run ever minute there is a theoretical limit of
|
||||
# 600 conferences that it can check due to the wait interval. If you have
|
||||
# more than this either change the cron when this script is run or change the
|
||||
# wait interval below
|
||||
#
|
||||
# Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
|
||||
#
|
||||
# 50810-1532 - Added database server variable definitions lookup
|
||||
# 50823-1456 - Added commandline arguments for debug at runtime
|
||||
#
|
||||
|
||||
# constants
|
||||
$DB=0; # Debug flag, set to 0 for no debug messages per minute
|
||||
$US='__';
|
||||
$MT[0]='';
|
||||
|
||||
### begin parsing run-time options ###
|
||||
if (length($ARGV[0])>1)
|
||||
{
|
||||
$i=0;
|
||||
while ($#ARGV >= $i)
|
||||
{
|
||||
$args = "$args $ARGV[$i]";
|
||||
$i++;
|
||||
}
|
||||
|
||||
if ($args =~ /--help/i)
|
||||
{
|
||||
print "allowed run time options:\n [-t] = test\n [-debug] = verbose debug messages\n\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($args =~ /-debug/i)
|
||||
{
|
||||
$DB=1; # Debug flag
|
||||
}
|
||||
if ($args =~ /-t/i)
|
||||
{
|
||||
$TEST=1;
|
||||
$T=1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
# print "no command line options set\n";
|
||||
}
|
||||
### end parsing run-time options ###
|
||||
|
||||
### Make sure this file is in a libs path or put the absolute path to it
|
||||
require("/home/cron/AST_SERVER_conf.pl"); # local configuration file
|
||||
|
||||
if (!$DB_port) {$DB_port='3306';}
|
||||
|
||||
use lib './lib', '../lib';
|
||||
use Time::HiRes ('gettimeofday','usleep','sleep'); # necessary to have perl sleep command of less than one second
|
||||
use Net::MySQL;
|
||||
use Net::Telnet ();
|
||||
|
||||
|
||||
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";
|
||||
|
||||
### Grab Server values from the database
|
||||
$stmtA = "SELECT telnet_host,telnet_port,ASTmgrUSERNAME,ASTmgrSECRET,ASTmgrUSERNAMEupdate,ASTmgrUSERNAMElisten,ASTmgrUSERNAMEsend,max_vicidial_trunks,answer_transfer_agent,local_gmt,ext_context FROM servers where server_ip = '$server_ip';";
|
||||
$dbhA->query("$stmtA");
|
||||
if ($dbhA->has_selected_record)
|
||||
{
|
||||
$iter=$dbhA->create_record_iterator;
|
||||
while ( $record = $iter->each)
|
||||
{
|
||||
$DBtelnet_host = "$record->[0]";
|
||||
$DBtelnet_port = "$record->[1]";
|
||||
$DBASTmgrUSERNAME = "$record->[2]";
|
||||
$DBASTmgrSECRET = "$record->[3]";
|
||||
$DBASTmgrUSERNAMEupdate = "$record->[4]";
|
||||
$DBASTmgrUSERNAMElisten = "$record->[5]";
|
||||
$DBASTmgrUSERNAMEsend = "$record->[6]";
|
||||
$DBmax_vicidial_trunks = "$record->[7]";
|
||||
$DBanswer_transfer_agent= "$record->[8]";
|
||||
$DBSERVER_GMT = "$record->[9]";
|
||||
$DBext_context = "$record->[10]";
|
||||
if ($DBtelnet_host) {$telnet_host = $DBtelnet_host;}
|
||||
if ($DBtelnet_port) {$telnet_port = $DBtelnet_port;}
|
||||
if ($DBASTmgrUSERNAME) {$ASTmgrUSERNAME = $DBASTmgrUSERNAME;}
|
||||
if ($DBASTmgrSECRET) {$ASTmgrSECRET = $DBASTmgrSECRET;}
|
||||
if ($DBASTmgrUSERNAMEupdate) {$ASTmgrUSERNAMEupdate = $DBASTmgrUSERNAMEupdate;}
|
||||
if ($DBASTmgrUSERNAMElisten) {$ASTmgrUSERNAMElisten = $DBASTmgrUSERNAMElisten;}
|
||||
if ($DBASTmgrUSERNAMEsend) {$ASTmgrUSERNAMEsend = $DBASTmgrUSERNAMEsend;}
|
||||
if ($DBmax_vicidial_trunks) {$max_vicidial_trunks = $DBmax_vicidial_trunks;}
|
||||
if ($DBanswer_transfer_agent) {$answer_transfer_agent = $DBanswer_transfer_agent;}
|
||||
if ($DBSERVER_GMT) {$SERVER_GMT = $DBSERVER_GMT;}
|
||||
if ($DBext_context) {$ext_context = $DBext_context;}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@PTextensions=@MT; @PT_conf_extens=@MT; @PTmessages=@MT; @PTold_messages=@MT; @NEW_messages=@MT; @OLD_messages=@MT;
|
||||
$dbhA->query("SELECT extension,conf_exten from conferences where server_ip='$server_ip' and extension is NOT NULL and extension != '';");
|
||||
if ($dbhA->has_selected_record)
|
||||
{
|
||||
$iter=$dbhA->create_record_iterator;
|
||||
$rec_count=0;
|
||||
while ( $record = $iter->each)
|
||||
{
|
||||
$PTextensions[$rec_count] = "$record->[0]";
|
||||
$PT_conf_extens[$rec_count] = "$record->[1]";
|
||||
$rec_count++;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$telnet_port) {$telnet_port = '5038';}
|
||||
|
||||
### connect to asterisk manager through telnet
|
||||
$t = new Net::Telnet (Port => $telnet_port,
|
||||
Prompt => '/.*[\$%#>] $/',
|
||||
Output_record_separator => '',);
|
||||
#$fh = $t->dump_log("$telnetlog"); # uncomment for telnet log
|
||||
if (length($ASTmgrUSERNAMEsend) > 3) {$telnet_login = $ASTmgrUSERNAMEsend;}
|
||||
else {$telnet_login = $ASTmgrUSERNAME;}
|
||||
|
||||
$t->open("$telnet_host");
|
||||
$t->waitfor('/0\n$/'); # print login
|
||||
$t->print("Action: Login\nUsername: $telnet_login\nSecret: $ASTmgrSECRET\n\n");
|
||||
$t->waitfor('/Authentication accepted/'); # waitfor auth accepted
|
||||
|
||||
|
||||
$i=0;
|
||||
foreach(@PTextensions)
|
||||
{
|
||||
@list_channels=@MT;
|
||||
$t->buffer_empty;
|
||||
@list_channels = $t->cmd(String => "Action: Command\nCommand: Meetme list $PT_conf_extens[$i]\n\nAction: Ping\n\n", Prompt => '/Response: Pong.*/');
|
||||
|
||||
$j=0;
|
||||
$conf_empty[$i]=0;
|
||||
$conf_users[$i]='';
|
||||
foreach(@list_channels)
|
||||
{
|
||||
if($DB){print "|$list_channels[$j]|\n";}
|
||||
if ($list_channels[$j] =~ /No active conferences|No such conference/i)
|
||||
{$conf_empty[$i]++;}
|
||||
# if ($list_channels[$j] =~ /^User /i)
|
||||
# {
|
||||
# $userx = '';
|
||||
# $userx = $list_channels[$j];
|
||||
# $userx =~ s/User \#: //gi;
|
||||
# $conf_users[$i] .= "$userx|";
|
||||
# }
|
||||
$j++;
|
||||
}
|
||||
|
||||
if($DB){print "Meetme list $PT_conf_extens[$i]- Exten:|$PTextensions[$i]| Empty:|$conf_empty[$i]| ";}
|
||||
if (!$conf_empty[$i])
|
||||
{
|
||||
if($DB){print "CONFERENCE STILL HAS PARTICIPANTS, DOING NOTHING FOR THIS CONFERENCE\n";}
|
||||
if ($PTextensions[$i] =~ /Xtimeout\d$/i)
|
||||
{
|
||||
$PTextensions[$i] =~ s/Xtimeout\d$//gi;
|
||||
$stmtA = "UPDATE conferences set extension='$PTextensions[$i]' where server_ip='$server_ip' and conf_exten='$PT_conf_extens[$i]';";
|
||||
if($DB){print STDERR "\n|$stmtA|\n";}
|
||||
$dbhA->query($stmtA) or die "Couldn't execute query:|$stmtA|\n";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$NEWexten[$i] = $PTextensions[$i];
|
||||
if ($PTextensions[$i] =~ /Xtimeout3$/i) {$NEWexten[$i] =~ s/Xtimeout3$/Xtimeout2/gi;}
|
||||
if ($PTextensions[$i] =~ /Xtimeout2$/i) {$NEWexten[$i] =~ s/Xtimeout2$/Xtimeout1/gi;}
|
||||
if ($PTextensions[$i] =~ /Xtimeout1$/i) {$NEWexten[$i] = '';}
|
||||
if ( ($PTextensions[$i] !~ /Xtimeout\d$/i) and (length($PTextensions[$i])> 0) ) {$NEWexten[$i] .= 'Xtimeout3';}
|
||||
|
||||
|
||||
$stmtA = "UPDATE conferences set extension='$NEWexten[$i]' where server_ip='$server_ip' and conf_exten='$PT_conf_extens[$i]';";
|
||||
if($DB){print STDERR "\n|$stmtA|\n";}
|
||||
$dbhA->query($stmtA) or die "Couldn't execute query:|$stmtA|\n";
|
||||
}
|
||||
|
||||
$i++;
|
||||
### sleep for 10 hundredths of a second
|
||||
usleep(1*100*1000);
|
||||
}
|
||||
|
||||
|
||||
$t->buffer_empty;
|
||||
@hangup = $t->cmd(String => "Action: Logoff\n\n", Prompt => "/.*/");
|
||||
$t->buffer_empty;
|
||||
$ok = $t->close;
|
||||
|
||||
$dbhA->close;
|
||||
|
||||
if($DB){print "DONE... Exiting... Goodbye... See you later... \n";}
|
||||
|
||||
exit;
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,189 @@
|
||||
#!/usr/bin/perl
|
||||
#
|
||||
# AST_flush_DBqueue.pl version 0.2
|
||||
#
|
||||
# DESCRIPTION:
|
||||
# - clears out mysql records for this server for the ACQS vicidial_manager table
|
||||
# - optimizes tables used frequently by VICIDIAL
|
||||
#
|
||||
# It is recommended that you run this program on the local Asterisk machine
|
||||
#
|
||||
# Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
|
||||
#
|
||||
|
||||
$secX = time();
|
||||
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
|
||||
$year = ($year + 1900);
|
||||
$yy = $year; $yy =~ s/^..//gi;
|
||||
$mon++;
|
||||
if ($mon < 10) {$mon = "0$mon";}
|
||||
if ($mday < 10) {$mday = "0$mday";}
|
||||
if ($hour < 10) {$hour = "0$hour";}
|
||||
if ($min < 10) {$min = "0$min";}
|
||||
if ($sec < 10) {$sec = "0$sec";}
|
||||
$SQLdate_NOW="$year-$mon-$mday $hour:$min:$sec";
|
||||
|
||||
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time()-3600);
|
||||
$year = ($year + 1900);
|
||||
$yy = $year; $yy =~ s/^..//gi;
|
||||
$mon++;
|
||||
if ($mon < 10) {$mon = "0$mon";}
|
||||
if ($mday < 10) {$mday = "0$mday";}
|
||||
if ($hour < 10) {$hour = "0$hour";}
|
||||
if ($min < 10) {$min = "0$min";}
|
||||
if ($sec < 10) {$sec = "0$sec";}
|
||||
$SQLdate_NEG_1hour="$year-$mon-$mday $hour:$min:$sec";
|
||||
|
||||
### begin parsing run-time options ###
|
||||
if (length($ARGV[0])>1)
|
||||
{
|
||||
$i=0;
|
||||
while ($#ARGV >= $i)
|
||||
{
|
||||
$args = "$args $ARGV[$i]";
|
||||
$i++;
|
||||
}
|
||||
|
||||
if ($args =~ /--help/i)
|
||||
{
|
||||
print "allowed run time options:\n [-q] = quiet\n [-t] = test\n [--debug] = debugging messages\n\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($args =~ /-q/i)
|
||||
{
|
||||
$q=1; $Q=1;
|
||||
}
|
||||
if ($args =~ /--debug/i)
|
||||
{
|
||||
$DB=1;
|
||||
print "\n-----DEBUGGING -----\n\n";
|
||||
}
|
||||
if ($args =~ /-t|--test/i)
|
||||
{
|
||||
$T=1; $TEST=1;
|
||||
print "\n-----TESTING -----\n\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print "no command line options set\n";
|
||||
}
|
||||
### end parsing run-time options ###
|
||||
|
||||
|
||||
if (!$Q) {print "TEST\n\n";}
|
||||
if (!$Q) {print "NOW DATETIME: $SQLdate_NOW\n";}
|
||||
if (!$Q) {print "1 HOUR AGO DATETIME: $SQLdate_NEG_1hour\n\n";}
|
||||
|
||||
### Make sure this file is in a libs path or put the absolute path to it
|
||||
require("/home/cron/AST_SERVER_conf.pl"); # local configuration file
|
||||
|
||||
if (!$DB_port) {$DB_port='3306';}
|
||||
|
||||
use Net::MySQL;
|
||||
|
||||
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";
|
||||
|
||||
|
||||
|
||||
$stmtA = "delete from vicidial_manager where server_ip='$server_ip' and entry_date < '$SQLdate_NEG_1hour';";
|
||||
if($DB){print STDERR "\n|$stmtA|\n";}
|
||||
if (!$T) {$dbhA->query($stmtA); }
|
||||
if (!$Q) {print " - vicidial_manager 2 hour flush\n";}
|
||||
|
||||
|
||||
$stmtA = "update park_log set status='HUNGUP' where hangup_time is not null;";
|
||||
if($DB){print STDERR "\n|$stmtA|\n";}
|
||||
if (!$T) {$dbhA->query($stmtA); }
|
||||
if ($dbhA->has_selected_record)
|
||||
{
|
||||
$iterA=$dbhA->create_record_iterator;
|
||||
$rec_countY=0;
|
||||
while ($recordA = $iterA->each)
|
||||
{
|
||||
if (!$Q) {print "|",$recordA->[0],"|",$recordA->[1],"|",$recordA->[2],"|",$recordA->[3],"|","\n";}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$Q) {print " - park_log HUNGUP flush \n";}
|
||||
|
||||
|
||||
$stmtA = "optimize table vicidial_manager;";
|
||||
if($DB){print STDERR "\n|$stmtA|\n";}
|
||||
if (!$T) {$dbhA->query($stmtA); }
|
||||
if ($dbhA->has_selected_record)
|
||||
{
|
||||
$iterA=$dbhA->create_record_iterator;
|
||||
$rec_countY=0;
|
||||
while ($recordA = $iterA->each)
|
||||
{
|
||||
if (!$Q) {print "|",$recordA->[0],"|",$recordA->[1],"|",$recordA->[2],"|",$recordA->[3],"|","\n";}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$Q) {print " - optimize vicidial_manager \n";}
|
||||
|
||||
|
||||
$stmtA = "optimize table vicidial_live_agents;";
|
||||
if($DB){print STDERR "\n|$stmtA|\n";}
|
||||
if (!$T) {$dbhA->query($stmtA); }
|
||||
if ($dbhA->has_selected_record)
|
||||
{
|
||||
$iterA=$dbhA->create_record_iterator;
|
||||
$rec_countY=0;
|
||||
while ($recordA = $iterA->each)
|
||||
{
|
||||
if (!$Q) {print "|",$recordA->[0],"|",$recordA->[1],"|",$recordA->[2],"|",$recordA->[3],"|","\n";}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$Q) {print " - optimize vicidial_live_agents \n";}
|
||||
|
||||
|
||||
$stmtA = "optimize table vicidial_auto_calls;";
|
||||
if($DB){print STDERR "\n|$stmtA|\n";}
|
||||
if (!$T) {$dbhA->query($stmtA); }
|
||||
if ($dbhA->has_selected_record)
|
||||
{
|
||||
$iterA=$dbhA->create_record_iterator;
|
||||
$rec_countY=0;
|
||||
while ($recordA = $iterA->each)
|
||||
{
|
||||
if (!$Q) {print "|",$recordA->[0],"|",$recordA->[1],"|",$recordA->[2],"|",$recordA->[3],"|","\n";}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$Q) {print " - optimize vicidial_auto_calls \n";}
|
||||
|
||||
|
||||
$stmtA = "optimize table vicidial_hopper;";
|
||||
if($DB){print STDERR "\n|$stmtA|\n";}
|
||||
if (!$T) {$dbhA->query($stmtA); }
|
||||
if ($dbhA->has_selected_record)
|
||||
{
|
||||
$iterA=$dbhA->create_record_iterator;
|
||||
$rec_countY=0;
|
||||
while ($recordA = $iterA->each)
|
||||
{
|
||||
if (!$Q) {print "|",$recordA->[0],"|",$recordA->[1],"|",$recordA->[2],"|",$recordA->[3],"|","\n";}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$Q) {print " - optimize vicidial_hopper \n";}
|
||||
|
||||
|
||||
|
||||
|
||||
$dbhA->close;
|
||||
|
||||
|
||||
exit;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,335 @@
|
||||
#!/usr/bin/perl
|
||||
#
|
||||
# AST_manager_kill_hung_congested.pl version 0.2
|
||||
#
|
||||
# Part of the Asterisk Central Queue System (ACQS)
|
||||
#
|
||||
# DESCRIPTION:
|
||||
# kills CONGEST local channels every 15 seconds
|
||||
#
|
||||
# For the client program to work in ACQS mode, this program must be running
|
||||
#
|
||||
# For this program to work you need to have the "asterisk" MySQL database
|
||||
# created and create the tables listed in the CONF_MySQL.txt file, also make sure
|
||||
# that the machine running this program has read/write/update/delete access
|
||||
# to that database
|
||||
#
|
||||
# In your Asterisk server setup you also need to have several things activated
|
||||
# and defined. See the CONF_Asterisk.txt file for details
|
||||
#
|
||||
# put this in the cron to run every minute
|
||||
#
|
||||
# Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
|
||||
#
|
||||
# 50823-1525 - Added commandline debug options with debug printouts
|
||||
#
|
||||
|
||||
# constants
|
||||
$DB=0; # Debug flag, set to 0 for no debug messages, On an active system this will generate thousands of lines of output per minute
|
||||
$US='__';
|
||||
$MT[0]='';
|
||||
|
||||
|
||||
### begin parsing run-time options ###
|
||||
if (length($ARGV[0])>1)
|
||||
{
|
||||
$i=0;
|
||||
while ($#ARGV >= $i)
|
||||
{
|
||||
$args = "$args $ARGV[$i]";
|
||||
$i++;
|
||||
}
|
||||
|
||||
if ($args =~ /--help/i)
|
||||
{
|
||||
print "allowed run time options:\n [-t] = test\n [-debug] = verbose debug messages\n[-debugX] = Extra-verbose debug messages\n\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($args =~ /-debug/i)
|
||||
{
|
||||
$DB=1; # Debug flag
|
||||
}
|
||||
if ($args =~ /--debugX/i)
|
||||
{
|
||||
$DBX=1;
|
||||
print "\n----- SUPER-DUPER DEBUGGING -----\n\n";
|
||||
}
|
||||
if ($args =~ /-t/i)
|
||||
{
|
||||
$TEST=1;
|
||||
$T=1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
# print "no command line options set\n";
|
||||
}
|
||||
### end parsing run-time options ###
|
||||
|
||||
|
||||
### Make sure this file is in a libs path or put the absolute path to it
|
||||
require("/home/cron/AST_SERVER_conf.pl"); # local configuration file
|
||||
|
||||
|
||||
&get_time_now;
|
||||
|
||||
# $event_string='PROGRAM STARTED||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||';
|
||||
# &event_logger;
|
||||
|
||||
#use lib './lib', '../lib';
|
||||
use Net::MySQL;
|
||||
#use Net::Telnet ();
|
||||
|
||||
my $dbhA = Net::MySQL->new(hostname => "$DB_server", database => "$DB_database", user => "$DB_user", password => "$DB_pass")
|
||||
or die "Couldn't connect to database: \n";
|
||||
|
||||
#$event_string='LOGGED INTO MYSQL SERVER ON 1 CONNECTION|';
|
||||
#&event_logger;
|
||||
|
||||
$stmtA = "SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and extension = 'CONGEST' and channel LIKE \"Local%\" limit 99";
|
||||
# $event_string="SQL_QUERY|$stmtA|";
|
||||
# &event_logger;
|
||||
|
||||
$dbhA->query("$stmtA");
|
||||
if ($dbhA->has_selected_record)
|
||||
{
|
||||
$iter=$dbhA->create_record_iterator;
|
||||
$rec_count=0;
|
||||
while ( $record = $iter->each)
|
||||
{
|
||||
if($DB){print STDERR $record->[0],"\n";}
|
||||
$congest_kill[$rec_count] = "$record->[0]";
|
||||
$rec_count++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$i=0;
|
||||
foreach(@congest_kill)
|
||||
{
|
||||
$i_count = $i;
|
||||
if ($i_count < 10) {$i_count = "0$i_count";}
|
||||
|
||||
if (length($congest_kill[$i])>0)
|
||||
{
|
||||
### use manager middleware-app to zapbarge call being placed from meetme
|
||||
$KCqueryCID = "KC$i_count$CIDdate";
|
||||
|
||||
### insert a NEW record to the vicidial_manager table to be processed
|
||||
$stmtA = "INSERT INTO vicidial_manager values('','','$now_date','NEW','N','$server_ip','','Hangup','$KCqueryCID','Channel: $congest_kill[$i]','','','','','','','','','')";
|
||||
|
||||
$event_string = "SUBRT|killing_congest|KC|$KCqueryCID|$congest_kill[$i]|$stmtA|";
|
||||
event_logger;
|
||||
|
||||
if ($DB) {print "KILLING $congest_kill[$i]\n";}
|
||||
$dbhA->query($stmtA) or die "Couldn't execute query:\n";
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
|
||||
|
||||
sleep(14);
|
||||
|
||||
######## 22222 starting another loop
|
||||
&get_time_now;
|
||||
@congest_kill = @MT;
|
||||
|
||||
|
||||
|
||||
$stmtA = "SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and extension = 'CONGEST' and channel LIKE \"Local%\" limit 99";
|
||||
# $event_string="SQL_QUERY|$stmtA|";
|
||||
# &event_logger;
|
||||
|
||||
$dbhA->query("$stmtA");
|
||||
if ($dbhA->has_selected_record)
|
||||
{
|
||||
$iter=$dbhA->create_record_iterator;
|
||||
$rec_count=0;
|
||||
while ( $record = $iter->each)
|
||||
{
|
||||
if($DB){print STDERR $record->[0],"\n";}
|
||||
$congest_kill[$rec_count] = "$record->[0]";
|
||||
$rec_count++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$i=0;
|
||||
foreach(@congest_kill)
|
||||
{
|
||||
$i_count = $i;
|
||||
if ($i_count < 10) {$i_count = "0$i_count";}
|
||||
|
||||
if (length($congest_kill[$i])>0)
|
||||
{
|
||||
### use manager middleware-app to zapbarge call being placed from meetme
|
||||
$KCqueryCID = "KC$i_count$CIDdate";
|
||||
|
||||
### insert a NEW record to the vicidial_manager table to be processed
|
||||
$stmtA = "INSERT INTO vicidial_manager values('','','$now_date','NEW','N','$server_ip','','Hangup','$KCqueryCID','Channel: $congest_kill[$i]','','','','','','','','','')";
|
||||
|
||||
$event_string = "SUBRT|killing_congest|KC|$KCqueryCID|$congest_kill[$i]|$stmtA|";
|
||||
event_logger;
|
||||
|
||||
if ($DB) {print "KILLING $congest_kill[$i]\n";}
|
||||
$dbhA->query($stmtA) or die "Couldn't execute query:\n";
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
|
||||
|
||||
sleep(15);
|
||||
|
||||
######## 33333 starting another loop
|
||||
&get_time_now;
|
||||
@congest_kill = @MT;
|
||||
|
||||
|
||||
|
||||
|
||||
$stmtA = "SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and extension = 'CONGEST' and channel LIKE \"Local%\" limit 99";
|
||||
# $event_string="SQL_QUERY|$stmtA|";
|
||||
# &event_logger;
|
||||
|
||||
$dbhA->query("$stmtA");
|
||||
if ($dbhA->has_selected_record)
|
||||
{
|
||||
$iter=$dbhA->create_record_iterator;
|
||||
$rec_count=0;
|
||||
while ( $record = $iter->each)
|
||||
{
|
||||
if($DB){print STDERR $record->[0],"\n";}
|
||||
$congest_kill[$rec_count] = "$record->[0]";
|
||||
$rec_count++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$i=0;
|
||||
foreach(@congest_kill)
|
||||
{
|
||||
$i_count = $i;
|
||||
if ($i_count < 10) {$i_count = "0$i_count";}
|
||||
|
||||
if (length($congest_kill[$i])>0)
|
||||
{
|
||||
### use manager middleware-app to zapbarge call being placed from meetme
|
||||
$KCqueryCID = "KC$i_count$CIDdate";
|
||||
|
||||
### insert a NEW record to the vicidial_manager table to be processed
|
||||
$stmtA = "INSERT INTO vicidial_manager values('','','$now_date','NEW','N','$server_ip','','Hangup','$KCqueryCID','Channel: $congest_kill[$i]','','','','','','','','','')";
|
||||
|
||||
$event_string = "SUBRT|killing_congest|KC|$KCqueryCID|$congest_kill[$i]|$stmtA|";
|
||||
event_logger;
|
||||
|
||||
if ($DB) {print "KILLING $congest_kill[$i]\n";}
|
||||
$dbhA->query($stmtA) or die "Couldn't execute query:\n";
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
|
||||
|
||||
sleep(15);
|
||||
|
||||
######## 44444 starting another loop
|
||||
&get_time_now;
|
||||
@congest_kill = @MT;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$stmtA = "SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and extension = 'CONGEST' and channel LIKE \"Local%\" limit 99";
|
||||
# $event_string="SQL_QUERY|$stmtA|";
|
||||
# &event_logger;
|
||||
|
||||
$dbhA->query("$stmtA");
|
||||
if ($dbhA->has_selected_record)
|
||||
{
|
||||
$iter=$dbhA->create_record_iterator;
|
||||
$rec_count=0;
|
||||
while ( $record = $iter->each)
|
||||
{
|
||||
if($DB){print STDERR $record->[0],"\n";}
|
||||
$congest_kill[$rec_count] = "$record->[0]";
|
||||
$rec_count++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$i=0;
|
||||
foreach(@congest_kill)
|
||||
{
|
||||
$i_count = $i;
|
||||
if ($i_count < 10) {$i_count = "0$i_count";}
|
||||
|
||||
if (length($congest_kill[$i])>0)
|
||||
{
|
||||
### use manager middleware-app to zapbarge call being placed from meetme
|
||||
$KCqueryCID = "KC$i_count$CIDdate";
|
||||
|
||||
### insert a NEW record to the vicidial_manager table to be processed
|
||||
$stmtA = "INSERT INTO vicidial_manager values('','','$now_date','NEW','N','$server_ip','','Hangup','$KCqueryCID','Channel: $congest_kill[$i]','','','','','','','','','')";
|
||||
|
||||
$event_string = "SUBRT|killing_congest|KC|$KCqueryCID|$congest_kill[$i]|$stmtA|";
|
||||
event_logger;
|
||||
|
||||
if ($DB) {print "KILLING $congest_kill[$i]\n";}
|
||||
$dbhA->query($stmtA) or die "Couldn't execute query:\n";
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
|
||||
|
||||
|
||||
# $event_string='CLOSING DB CONNECTION|';
|
||||
# &event_logger;
|
||||
|
||||
$dbhA->close;
|
||||
|
||||
|
||||
if($DB){print "DONE... Exiting... Goodbye... See you later... \n";}
|
||||
|
||||
|
||||
exit;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
sub get_time_now #get the current date and time and epoch for logging call lengths and datetimes
|
||||
{
|
||||
($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";
|
||||
$action_log_date = "$year-$mon-$mday";
|
||||
$CIDdate = "$year$mon$mday$hour$min$sec";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
sub event_logger {
|
||||
### open the log file for writing ###
|
||||
open(Lout, ">>$KHLOGfile")
|
||||
|| die "Can't open $KHLOGfile: $!\n";
|
||||
|
||||
print Lout "$now_date|$event_string|\n";
|
||||
|
||||
close(Lout);
|
||||
|
||||
$event_string='';
|
||||
}
|
||||
@@ -0,0 +1,594 @@
|
||||
#!/usr/bin/perl
|
||||
#
|
||||
# AST_manager_listen.pl version 1.1.11 build 60403-1230
|
||||
#
|
||||
# Part of the Asterisk Central Queue System (ACQS)
|
||||
#
|
||||
# DESCRIPTION:
|
||||
# connects to the Asterisk Manager interface and updates records in the
|
||||
# vicidial_manager table of the asterisk database in MySQL based upon the
|
||||
# events that it receives
|
||||
#
|
||||
# SUMMARY:
|
||||
# This program was designed as the listen-only part of the ACQS. It's job is to
|
||||
# look for certain events and based upon either the uniqueid or the callerid of
|
||||
# the call update the status and information of an action record in the
|
||||
# vicidial_manager table of the asterisk MySQL database.
|
||||
#
|
||||
# Win32 - ActiveState Perl 5.8.0
|
||||
# UNIX - Gnome or KDE with Tk/Tcl and perl Tk/Tcl modules loaded
|
||||
# Both - Net::MySQL, Net::Telnet and Time::HiRes perl modules loaded
|
||||
#
|
||||
# For the client program to work in ACQS mode, this program must be running
|
||||
#
|
||||
# For this program to work you need to have the "asterisk" MySQL database
|
||||
# created and create the tables listed in the CONF_MySQL.txt file, also make sure
|
||||
# that the machine running this program has read/write/update/delete access
|
||||
# to that database
|
||||
#
|
||||
# In your Asterisk server setup you also need to have several things activated
|
||||
# and defined. See the CONF_Asterisk.txt file for details
|
||||
#
|
||||
# Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
|
||||
#
|
||||
# changes:
|
||||
# 50322-1300 changed callerid parsing to remove quotes and number
|
||||
# 50616-1559 Added NewCallerID parsing and updating
|
||||
# 50621-1406 Added Asterisk server shutdown and connection dead detection
|
||||
# 50810-1534 Added database server variable definitions lookup
|
||||
# 50824-1606 Altered CVS/1.2 support for different output
|
||||
# 50901-2359 Another CVS/1.2 output parsing fix
|
||||
# 51222-1553 fixed parentheses bug in manager output
|
||||
# 60403-1230 Added SVN/1.2.6 support for different output
|
||||
#
|
||||
|
||||
# constants
|
||||
$DB=1; # Debug flag, set to 0 for no debug messages, lots of output
|
||||
$US='__';
|
||||
$MT[0]='';
|
||||
|
||||
### begin parsing run-time options ###
|
||||
if (length($ARGV[0])>1)
|
||||
{
|
||||
$i=0;
|
||||
while ($#ARGV >= $i)
|
||||
{
|
||||
$args = "$args $ARGV[$i]";
|
||||
$i++;
|
||||
}
|
||||
|
||||
if ($args =~ /--help/i)
|
||||
{
|
||||
print "allowed run time options:\n [-t] = test\n [-debug] = verbose debug messages\n[-debugX] = Extra-verbose debug messages\n\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($args =~ /-debug/i)
|
||||
{
|
||||
$DB=1; # Debug flag
|
||||
}
|
||||
if ($args =~ /--debugX/i)
|
||||
{
|
||||
$DBX=1;
|
||||
print "\n----- SUPER-DUPER DEBUGGING -----\n\n";
|
||||
}
|
||||
if ($args =~ /-t/i)
|
||||
{
|
||||
$TEST=1;
|
||||
$T=1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
# print "no command line options set\n";
|
||||
}
|
||||
### end parsing run-time options ###
|
||||
|
||||
|
||||
|
||||
### Make sure this file is in a libs path or put the absolute path to it
|
||||
require("/home/cron/AST_SERVER_conf.pl"); # local configuration file
|
||||
|
||||
if (!$DB_port) {$DB_port='3306';}
|
||||
|
||||
&get_time_now;
|
||||
|
||||
$event_string='PROGRAM STARTED||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||';
|
||||
&event_logger;
|
||||
|
||||
#use lib './lib', '../lib';
|
||||
use Time::HiRes ('gettimeofday','usleep','sleep'); # necessary to have perl sleep command of less than one second
|
||||
use Net::MySQL;
|
||||
use Net::Telnet ();
|
||||
|
||||
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";
|
||||
|
||||
$event_string='LOGGED INTO MYSQL SERVER ON 1 CONNECTION|';
|
||||
&event_logger;
|
||||
|
||||
|
||||
### Grab Server values from the database
|
||||
$stmtA = "SELECT telnet_host,telnet_port,ASTmgrUSERNAME,ASTmgrSECRET,ASTmgrUSERNAMEupdate,ASTmgrUSERNAMElisten,ASTmgrUSERNAMEsend,max_vicidial_trunks,answer_transfer_agent,local_gmt,ext_context FROM servers where server_ip = '$server_ip';";
|
||||
$dbhA->query("$stmtA");
|
||||
if ($dbhA->has_selected_record)
|
||||
{
|
||||
$iter=$dbhA->create_record_iterator;
|
||||
while ( $record = $iter->each)
|
||||
{
|
||||
$DBtelnet_host = "$record->[0]";
|
||||
$DBtelnet_port = "$record->[1]";
|
||||
$DBASTmgrUSERNAME = "$record->[2]";
|
||||
$DBASTmgrSECRET = "$record->[3]";
|
||||
$DBASTmgrUSERNAMEupdate = "$record->[4]";
|
||||
$DBASTmgrUSERNAMElisten = "$record->[5]";
|
||||
$DBASTmgrUSERNAMEsend = "$record->[6]";
|
||||
$DBmax_vicidial_trunks = "$record->[7]";
|
||||
$DBanswer_transfer_agent= "$record->[8]";
|
||||
$DBSERVER_GMT = "$record->[9]";
|
||||
$DBext_context = "$record->[10]";
|
||||
if ($DBtelnet_host) {$telnet_host = $DBtelnet_host;}
|
||||
if ($DBtelnet_port) {$telnet_port = $DBtelnet_port;}
|
||||
if ($DBASTmgrUSERNAME) {$ASTmgrUSERNAME = $DBASTmgrUSERNAME;}
|
||||
if ($DBASTmgrSECRET) {$ASTmgrSECRET = $DBASTmgrSECRET;}
|
||||
if ($DBASTmgrUSERNAMEupdate) {$ASTmgrUSERNAMEupdate = $DBASTmgrUSERNAMEupdate;}
|
||||
if ($DBASTmgrUSERNAMElisten) {$ASTmgrUSERNAMElisten = $DBASTmgrUSERNAMElisten;}
|
||||
if ($DBASTmgrUSERNAMEsend) {$ASTmgrUSERNAMEsend = $DBASTmgrUSERNAMEsend;}
|
||||
if ($DBmax_vicidial_trunks) {$max_vicidial_trunks = $DBmax_vicidial_trunks;}
|
||||
if ($DBanswer_transfer_agent) {$answer_transfer_agent = $DBanswer_transfer_agent;}
|
||||
if ($DBSERVER_GMT) {$SERVER_GMT = $DBSERVER_GMT;}
|
||||
if ($DBext_context) {$ext_context = $DBext_context;}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!$telnet_port) {$telnet_port = '5038';}
|
||||
|
||||
$one_day_interval = 90; # 1 day loops for 3 months
|
||||
while($one_day_interval > 0)
|
||||
{
|
||||
|
||||
$event_string="STARTING NEW MANAGER TELNET CONNECTION||ATTEMPT|ONE DAY INTERVAL:$one_day_interval|";
|
||||
&event_logger;
|
||||
# Errmode => Return,
|
||||
|
||||
### connect to asterisk manager through telnet
|
||||
$tn = new Net::Telnet (Port => $telnet_port,
|
||||
Prompt => '/.*[\$%#>] $/',
|
||||
Output_record_separator => '',);
|
||||
#$fh = $tn->dump_log("$LItelnetlog"); # uncomment for telnet log
|
||||
if (length($ASTmgrUSERNAMElisten) > 3) {$telnet_login = $ASTmgrUSERNAMElisten;}
|
||||
else {$telnet_login = $ASTmgrUSERNAME;}
|
||||
$tn->open("$telnet_host");
|
||||
$tn->waitfor('/0\n$/'); # print login
|
||||
$tn->print("Action: Login\nUsername: $telnet_login\nSecret: $ASTmgrSECRET\n\n");
|
||||
$tn->waitfor('/Authentication accepted/'); # waitfor auth accepted
|
||||
|
||||
$tn->buffer_empty;
|
||||
|
||||
$event_string="STARTING NEW MANAGER TELNET CONNECTION|$telnet_login|CONFIRMED CONNECTION|ONE DAY INTERVAL:$one_day_interval|";
|
||||
&event_logger;
|
||||
|
||||
$endless_loop=864000; # 1 day at .10 seconds per loop
|
||||
|
||||
while($endless_loop > 0)
|
||||
{
|
||||
### sleep for 10 hundredths of a second
|
||||
usleep(1*100*1000);
|
||||
|
||||
$msg='';
|
||||
$read_input_buf = $tn->get(Errmode => Return, Timeout => 1,);
|
||||
$input_buf_length = length($read_input_buf);
|
||||
$msg = $tn->errmsg;
|
||||
if ($msg =~ /filehandle isn\'t open/i)
|
||||
{
|
||||
$endless_loop=0;
|
||||
$one_day_interval=0;
|
||||
print "ERRMSG: |$msg|\n";
|
||||
print "\nAsterisk server shutting down, PROCESS KILLED... EXITING\n\n";
|
||||
$event_string="Asterisk server shutting down, PROCESS KILLED... EXITING|ONE DAY INTERVAL:$one_day_interval|$msg|";
|
||||
&event_logger;
|
||||
}
|
||||
|
||||
if ( ($read_input_buf !~ /\n\n/) or ($input_buf_length < 10) )
|
||||
{
|
||||
# if ($read_input_buf =~ /\n/) {print "\n|||$input_buf_length|||$read_input_buf|||\n";}
|
||||
$input_buf = "$input_buf$read_input_buf";
|
||||
}
|
||||
else
|
||||
{
|
||||
$partial=0;
|
||||
$partial_input_buf='';
|
||||
|
||||
if ($read_input_buf !~ /\n\n$/)
|
||||
{
|
||||
$read_input_buf =~ s/\(|\)/ /gi; # replace parens with space
|
||||
$partial_input_buf = $read_input_buf;
|
||||
$partial_input_buf =~ s/\n/-----/gi;
|
||||
$partial_input_buf =~ s/\*/\\\*/gi;
|
||||
$partial_input_buf =~ s/.*----------//gi;
|
||||
$partial_input_buf =~ s/-----/\n/gi;
|
||||
$read_input_buf =~ s/$partial_input_buf$//gi;
|
||||
$partial++;
|
||||
}
|
||||
|
||||
|
||||
# |1 DIALINGs updated|
|
||||
# Nested quantifiers in regex; marked by <-- HERE in m/Event: Newexten
|
||||
# Channel: Zap/16-1
|
||||
# Context: demo
|
||||
# Extension: 990009*CL_UMGCOF_L** <-- HERE 1479503*conf***
|
||||
# Priority: 2
|
||||
# Application: Dial
|
||||
# AppData: Zap/g3/90009*CL_UMGCOF_L**1479503*conf***|20
|
||||
# Uniqueid: 1101224775.6783
|
||||
# $/ at /home/cron/AST_manager_listen.pl line 114.
|
||||
|
||||
|
||||
$input_buf = "$input_buf$read_input_buf";
|
||||
@input_lines = split(/\n\n/, $input_buf);
|
||||
|
||||
if($DB){print "input buffer: $input_buf_length lines: $#input_lines partial: $partial\n";}
|
||||
if ( ($DB) && ($partial) ) {print "-----[$partial_input_buf]-----\n\n";}
|
||||
if($DB){print "|$input_buf|\n";}
|
||||
|
||||
$manager_string = "$input_buf";
|
||||
&manager_output_logger;
|
||||
|
||||
$input_buf = "$partial_input_buf";
|
||||
|
||||
|
||||
@command_line=@MT;
|
||||
$ILcount=0;
|
||||
foreach(@input_lines)
|
||||
{
|
||||
if ( ($input_lines[$ILcount] =~ /State: Ringing|State: Up|State: Dialing|Event: Newstate|Event: Hangup|Event: Newcallerid|Event: Shutdown/) && ($input_lines[$ILcount] !~ /ZOMBIE/) )
|
||||
{
|
||||
$input_lines[$ILcount] =~ s/^\n|^\n\n//gi;
|
||||
@command_line=split(/\n/, $input_lines[$ILcount]);
|
||||
if ($input_lines[$ILcount] =~ /Event: Shutdown/)
|
||||
{
|
||||
$endless_loop=0;
|
||||
$one_day_interval=0;
|
||||
print "\nAsterisk server shutting down, PROCESS KILLED... EXITING\n\n";
|
||||
$event_string="Asterisk server shutting down, PROCESS KILLED... EXITING|ONE DAY INTERVAL:$one_day_interval|";
|
||||
&event_logger;
|
||||
}
|
||||
|
||||
if ($input_lines[$ILcount] =~ /Event: Hangup/)
|
||||
{
|
||||
if ( ($command_line[2] =~ /^Channel: /i) && ($command_line[3] =~ /^Uniqueid: /i) ) ### post 2005-08-07 CVS -- added Privilege line
|
||||
{
|
||||
$channel = $command_line[2];
|
||||
$channel =~ s/Channel: |\s*$//gi;
|
||||
$uniqueid = $command_line[3];
|
||||
$uniqueid =~ s/Uniqueid: |\s*$//gi;
|
||||
$stmtA = "UPDATE vicidial_manager set status='DEAD', channel='$channel' where server_ip = '$server_ip' and uniqueid = '$uniqueid'";
|
||||
|
||||
print STDERR "|$stmtA|\n";
|
||||
$dbhA->query("$stmtA");
|
||||
my $affected_rows = $dbhA->get_affected_rows_length;
|
||||
if($DB){print "|$affected_rows HANGUPS updated|\n";}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( ($command_line[3] =~ /^Channel: /i) && ($command_line[4] =~ /^Uniqueid: /i) ) ### post 2006-03-20 SVN -- Added Timestamp line
|
||||
{
|
||||
$channel = $command_line[3];
|
||||
$channel =~ s/Channel: |\s*$//gi;
|
||||
$uniqueid = $command_line[4];
|
||||
$uniqueid =~ s/Uniqueid: |\s*$//gi;
|
||||
$stmtA = "UPDATE vicidial_manager set status='DEAD', channel='$channel' where server_ip = '$server_ip' and uniqueid = '$uniqueid'";
|
||||
|
||||
print STDERR "|$stmtA|\n";
|
||||
$dbhA->query("$stmtA");
|
||||
my $affected_rows = $dbhA->get_affected_rows_length;
|
||||
if($DB){print "|$affected_rows HANGUPS updated|\n";}
|
||||
}
|
||||
else
|
||||
{
|
||||
$channel = $command_line[1];
|
||||
$channel =~ s/Channel: |\s*$//gi;
|
||||
$uniqueid = $command_line[2];
|
||||
$uniqueid =~ s/Uniqueid: |\s*$//gi;
|
||||
$stmtA = "UPDATE vicidial_manager set status='DEAD', channel='$channel' where server_ip = '$server_ip' and uniqueid = '$uniqueid'";
|
||||
|
||||
print STDERR "|$stmtA|\n";
|
||||
$dbhA->query("$stmtA");
|
||||
my $affected_rows = $dbhA->get_affected_rows_length;
|
||||
if($DB){print "|$affected_rows HANGUPS updated|\n";}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($input_lines[$ILcount] =~ /State: Dialing/)
|
||||
{
|
||||
if ( ($command_line[1] =~ /^Channel: /i) && ($command_line[4] =~ /^Uniqueid: /i) ) ### pre 2004-10-07 CVS
|
||||
{
|
||||
$channel = $command_line[1];
|
||||
$channel =~ s/Channel: |\s*$//gi;
|
||||
$callid = $command_line[3];
|
||||
$callid =~ s/Callerid: |\s*$//gi;
|
||||
$callid =~ s/^\"//gi; $callid =~ s/\".*$//gi;
|
||||
$uniqueid = $command_line[4];
|
||||
$uniqueid =~ s/Uniqueid: |\s*$//gi;
|
||||
$stmtA = "UPDATE vicidial_manager set status='SENT', channel='$channel', uniqueid = '$uniqueid' where server_ip = '$server_ip' and callerid = '$callid'";
|
||||
print STDERR "|$stmtA|\n";
|
||||
$dbhA->query("$stmtA");
|
||||
my $affected_rows = $dbhA->get_affected_rows_length;
|
||||
if($DB){print "|$affected_rows DIALINGs updated|\n";}
|
||||
}
|
||||
if ( ($command_line[1] =~ /^Channel: /i) && ($command_line[4] =~ /^CalleridName: /i) ) ### post 2004-10-07 CVS
|
||||
{
|
||||
$channel = $command_line[1];
|
||||
$channel =~ s/Channel: |\s*$//gi;
|
||||
$callid = $command_line[4];
|
||||
$callid =~ s/CalleridName: |\s*$//gi;
|
||||
$callid =~ s/^\"//gi; $callid =~ s/\".*$//gi;
|
||||
$uniqueid = $command_line[5];
|
||||
$uniqueid =~ s/Uniqueid: |\s*$//gi;
|
||||
$stmtA = "UPDATE vicidial_manager set status='SENT', channel='$channel', uniqueid = '$uniqueid' where server_ip = '$server_ip' and callerid = '$callid'";
|
||||
print STDERR "|$stmtA|\n";
|
||||
$dbhA->query("$stmtA");
|
||||
my $affected_rows = $dbhA->get_affected_rows_length;
|
||||
if($DB){print "|$affected_rows DIALINGs updated|\n";}
|
||||
}
|
||||
if ( ($command_line[2] =~ /^Channel: /i) && ($command_line[5] =~ /^CalleridName: /i) ) ### post 2005-08-07 CVS
|
||||
{
|
||||
$channel = $command_line[2];
|
||||
$channel =~ s/Channel: |\s*$//gi;
|
||||
$callid = $command_line[5];
|
||||
$callid =~ s/CalleridName: |\s*$//gi;
|
||||
$callid =~ s/^\"//gi; $callid =~ s/\".*$//gi;
|
||||
$uniqueid = $command_line[6];
|
||||
$uniqueid =~ s/Uniqueid: |\s*$//gi;
|
||||
$stmtA = "UPDATE vicidial_manager set status='SENT', channel='$channel', uniqueid = '$uniqueid' where server_ip = '$server_ip' and callerid = '$callid'";
|
||||
print STDERR "|$stmtA|\n";
|
||||
$dbhA->query("$stmtA");
|
||||
my $affected_rows = $dbhA->get_affected_rows_length;
|
||||
if($DB){print "|$affected_rows DIALINGs updated|\n";}
|
||||
}
|
||||
if ( ($command_line[3] =~ /^Channel: /i) && ($command_line[6] =~ /^CalleridName: /i) ) ### post 2006-03-20 -- Added Timestamp line
|
||||
{
|
||||
$channel = $command_line[3];
|
||||
$channel =~ s/Channel: |\s*$//gi;
|
||||
$callid = $command_line[6];
|
||||
$callid =~ s/CalleridName: |\s*$//gi;
|
||||
$callid =~ s/^\"//gi; $callid =~ s/\".*$//gi;
|
||||
$uniqueid = $command_line[7];
|
||||
$uniqueid =~ s/Uniqueid: |\s*$//gi;
|
||||
$stmtA = "UPDATE vicidial_manager set status='SENT', channel='$channel', uniqueid = '$uniqueid' where server_ip = '$server_ip' and callerid = '$callid'";
|
||||
print STDERR "|$stmtA|\n";
|
||||
$dbhA->query("$stmtA");
|
||||
my $affected_rows = $dbhA->get_affected_rows_length;
|
||||
if($DB){print "|$affected_rows DIALINGs updated|\n";}
|
||||
}
|
||||
}
|
||||
if ($input_lines[$ILcount] =~ /State: Ringing|State: Up/)
|
||||
{
|
||||
if ( ($command_line[1] =~ /^Channel: /i) && ($command_line[4] =~ /^Uniqueid: /i) ) ### pre 2004-10-07 CVS
|
||||
{
|
||||
$channel = $command_line[1];
|
||||
$channel =~ s/Channel: |\s*$//gi;
|
||||
$callid = $command_line[3];
|
||||
$callid =~ s/Callerid: |\s*$//gi;
|
||||
$callid =~ s/^\"//gi; $callid =~ s/\".*$//gi;
|
||||
$uniqueid = $command_line[4];
|
||||
$uniqueid =~ s/Uniqueid: |\s*$//gi;
|
||||
$stmtA = "UPDATE vicidial_manager set status='UPDATED', channel='$channel', uniqueid = '$uniqueid' where server_ip = '$server_ip' and callerid = '$callid'";
|
||||
if ($channel !~ /local/i)
|
||||
{
|
||||
print STDERR "|$stmtA|\n";
|
||||
$dbhA->query("$stmtA");
|
||||
my $affected_rows = $dbhA->get_affected_rows_length;
|
||||
if($DB){print "|$affected_rows RINGINGs updated|\n";}
|
||||
}
|
||||
}
|
||||
if ( ($command_line[1] =~ /^Channel: /i) && ($command_line[4] =~ /^CalleridName: /i) ) ### post 2004-10-07 CVS
|
||||
{
|
||||
$channel = $command_line[1];
|
||||
$channel =~ s/Channel: |\s*$//gi;
|
||||
$callid = $command_line[4];
|
||||
$callid =~ s/CalleridName: |\s*$//gi;
|
||||
$callid =~ s/^\"//gi; $callid =~ s/\".*$//gi;
|
||||
$uniqueid = $command_line[5];
|
||||
$uniqueid =~ s/Uniqueid: |\s*$//gi;
|
||||
$stmtA = "UPDATE vicidial_manager set status='UPDATED', channel='$channel', uniqueid = '$uniqueid' where server_ip = '$server_ip' and callerid = '$callid'";
|
||||
if ($channel !~ /local/i)
|
||||
{
|
||||
print STDERR "|$stmtA|\n";
|
||||
$dbhA->query("$stmtA");
|
||||
my $affected_rows = $dbhA->get_affected_rows_length;
|
||||
if($DB){print "|$affected_rows RINGINGs updated|\n";}
|
||||
}
|
||||
}
|
||||
if ( ($command_line[2] =~ /^Channel: /i) && ($command_line[5] =~ /^CalleridName: /i) ) ### post 2005-08-07 CVS
|
||||
{
|
||||
$channel = $command_line[2];
|
||||
$channel =~ s/Channel: |\s*$//gi;
|
||||
$callid = $command_line[5];
|
||||
$callid =~ s/CalleridName: |\s*$//gi;
|
||||
$callid =~ s/^\"//gi; $callid =~ s/\".*$//gi;
|
||||
$uniqueid = $command_line[6];
|
||||
$uniqueid =~ s/Uniqueid: |\s*$//gi;
|
||||
$stmtA = "UPDATE vicidial_manager set status='UPDATED', channel='$channel', uniqueid = '$uniqueid' where server_ip = '$server_ip' and callerid = '$callid'";
|
||||
if ($channel !~ /local/i)
|
||||
{
|
||||
print STDERR "|$stmtA|\n";
|
||||
$dbhA->query("$stmtA");
|
||||
my $affected_rows = $dbhA->get_affected_rows_length;
|
||||
if($DB){print "|$affected_rows RINGINGs updated|\n";}
|
||||
}
|
||||
}
|
||||
if ( ($command_line[3] =~ /^Channel: /i) && ($command_line[6] =~ /^CalleridName: /i) ) ### post 2006-03-20 SVN -- Added Timestamp line
|
||||
{
|
||||
$channel = $command_line[3];
|
||||
$channel =~ s/Channel: |\s*$//gi;
|
||||
$callid = $command_line[6];
|
||||
$callid =~ s/CalleridName: |\s*$//gi;
|
||||
$callid =~ s/^\"//gi; $callid =~ s/\".*$//gi;
|
||||
$uniqueid = $command_line[7];
|
||||
$uniqueid =~ s/Uniqueid: |\s*$//gi;
|
||||
$stmtA = "UPDATE vicidial_manager set status='UPDATED', channel='$channel', uniqueid = '$uniqueid' where server_ip = '$server_ip' and callerid = '$callid'";
|
||||
if ($channel !~ /local/i)
|
||||
{
|
||||
print STDERR "|$stmtA|\n";
|
||||
$dbhA->query("$stmtA");
|
||||
my $affected_rows = $dbhA->get_affected_rows_length;
|
||||
if($DB){print "|$affected_rows RINGINGs updated|\n";}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($input_lines[$ILcount] =~ /Event: Newcallerid/)
|
||||
{
|
||||
if ( ($command_line[1] =~ /^Channel: /i) && ($command_line[3] =~ /^Uniqueid: /i) )
|
||||
{
|
||||
$channel = $command_line[1];
|
||||
$channel =~ s/Channel: |\s*$//gi;
|
||||
$callid = $command_line[2];
|
||||
$callid =~ s/Callerid: |\s*$//gi;
|
||||
$callid =~ s/^\"//gi; $callid =~ s/\".*$//gi;
|
||||
$uniqueid = $command_line[3];
|
||||
$uniqueid =~ s/Uniqueid: |\s*$//gi;
|
||||
$stmtA = "UPDATE vicidial_manager set status='UPDATED', channel='$channel', uniqueid = '$uniqueid' where server_ip = '$server_ip' and callerid = '$callid'";
|
||||
if ($channel =~ /local/i)
|
||||
{
|
||||
print STDERR "|$stmtA|\n";
|
||||
$dbhA->query("$stmtA");
|
||||
my $affected_rows = $dbhA->get_affected_rows_length;
|
||||
if($DB){print "|$affected_rows RINGINGs updated|\n";}
|
||||
}
|
||||
}
|
||||
if ( ($command_line[3] =~ /^Channel: /i) && ($command_line[6] =~ /^Uniqueid: /i) ) ### post 2006-03-20 SVN -- Added Timestamp line
|
||||
{
|
||||
$channel = $command_line[3];
|
||||
$channel =~ s/Channel: |\s*$//gi;
|
||||
$callid = $command_line[5];
|
||||
$callid =~ s/Callerid: |\s*$//gi;
|
||||
$callid =~ s/^\"//gi; $callid =~ s/\".*$//gi;
|
||||
$uniqueid = $command_line[6];
|
||||
$uniqueid =~ s/Uniqueid: |\s*$//gi;
|
||||
$stmtA = "UPDATE vicidial_manager set status='UPDATED', channel='$channel', uniqueid = '$uniqueid' where server_ip = '$server_ip' and callerid = '$callid'";
|
||||
if ($channel =~ /local/i)
|
||||
{
|
||||
print STDERR "|$stmtA|\n";
|
||||
$dbhA->query("$stmtA");
|
||||
my $affected_rows = $dbhA->get_affected_rows_length;
|
||||
if($DB){print "|$affected_rows RINGINGs updated|\n";}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
$ILcount++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
$endless_loop--;
|
||||
$keepalive_count_loop++;
|
||||
if($DB){print STDERR "loop counter: |$endless_loop|$keepalive_count_loop|\r";}
|
||||
|
||||
### putting a blank file called "sendmgr.kill" in a directory will automatically safely kill this program
|
||||
if ( (-e '/home/cron/listenmgr.kill') or ($sendonlyone) )
|
||||
{
|
||||
unlink('/home/cron/listenmgr.kill');
|
||||
$endless_loop=0;
|
||||
$one_day_interval=0;
|
||||
print "\nPROCESS KILLED MANUALLY... EXITING\n\n";
|
||||
}
|
||||
|
||||
### run a keepalive command to flush whatever is in the buffer through and to keep the connection alive
|
||||
if ($endless_loop =~ /00$|50$/)
|
||||
{
|
||||
&get_time_now;
|
||||
|
||||
@list_lines = $tn->cmd(String => "Action: Command\nCommand: show uptime\n\n", Prompt => '/--END COMMAND--.*/', Errmode => Return, Timeout => 1);
|
||||
if($DB){print "input lines: $#list_lines\n";}
|
||||
|
||||
if($DB){print "+++++++++++++++++++++++++++++++sending keepalive transmit line $endless_loop|$now_date|\n";}
|
||||
$keepalive_count_loop=0;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
if($DB){print "DONE... Exiting... Goodbye... See you later... Not really, initiating next loop...$one_day_interval left\n";}
|
||||
|
||||
$event_string='HANGING UP|';
|
||||
&event_logger;
|
||||
|
||||
@hangup = $tn->cmd(String => "Action: Logoff\n\n", Prompt => "/.*/", Errmode => Return, Timeout => 1);
|
||||
|
||||
$ok = $tn->close;
|
||||
|
||||
$one_day_interval--;
|
||||
|
||||
}
|
||||
|
||||
$event_string='CLOSING DB CONNECTION|';
|
||||
&event_logger;
|
||||
|
||||
|
||||
$dbhA->close;
|
||||
|
||||
|
||||
if($DB){print "DONE... Exiting... Goodbye... See you later... Really I mean it this time\n";}
|
||||
|
||||
|
||||
exit;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
sub get_time_now #get the current date and time and epoch for logging call lengths and datetimes
|
||||
{
|
||||
($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";
|
||||
$action_log_date = "$year-$mon-$mday";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
sub event_logger {
|
||||
### open the log file for writing ###
|
||||
open(Lout, ">>$LILOGfile")
|
||||
|| die "Can't open $LILOGfile: $!\n";
|
||||
|
||||
print Lout "$now_date|$event_string|\n";
|
||||
|
||||
close(Lout);
|
||||
|
||||
$event_string='';
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
sub manager_output_logger
|
||||
{
|
||||
open(MOout, ">>/home/cron/listen.$action_log_date")
|
||||
|| die "Can't open /home/cron/listen.$action_log_date: $!\n";
|
||||
|
||||
print MOout "$now_date|$manager_string|\n";
|
||||
|
||||
close(MOout);
|
||||
}
|
||||
@@ -0,0 +1,384 @@
|
||||
#!/usr/bin/perl
|
||||
#
|
||||
# AST_manager_send.pl version 0.2
|
||||
#
|
||||
# Part of the Asterisk Central Queue System (ACQS)
|
||||
#
|
||||
# DESCRIPTION:
|
||||
# spawns child processes (AST_send_action_child.pl) to execute action commands
|
||||
# on the Asterisk manager interface from records in the vicidial_manager table
|
||||
# of the asterisk database in MySQL that are marked as a status of NEW
|
||||
#
|
||||
# SUMMARY:
|
||||
# This program was designed as the send-only part of the ACQS. It's job is to
|
||||
# pick NEW actions from the vicidial_manager table and send them to be executed
|
||||
# by separate child process. This allows for a higher degree of flexibility and
|
||||
# scalability over just using a single process. Also, this means that a single
|
||||
# action execution lock cannot bring the entire system down.
|
||||
#
|
||||
# Win32 - ActiveState Perl 5.8.0
|
||||
# UNIX - Gnome or KDE with Tk/Tcl and perl Tk/Tcl modules loaded
|
||||
# Both - Net::MySQL, Net::Telnet and Time::HiRes perl modules loaded
|
||||
#
|
||||
# For the client program to work in ACQS mode, this program must be running
|
||||
#
|
||||
# For this program to work you need to have the "asterisk" MySQL database
|
||||
# created and create the tables listed in the CONF_MySQL.txt file, also make sure
|
||||
# that the machine running this program has read/write/update/delete access
|
||||
# to that database
|
||||
#
|
||||
# In your Asterisk server setup you also need to have several things activated
|
||||
# and defined. See the CONF_Asterisk.txt file for details
|
||||
#
|
||||
# Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
|
||||
#
|
||||
# 50823-1514 - Added commandline debug options with debug printouts
|
||||
# 50902-1051 - Added extra debug output launch sub(commented out)
|
||||
#
|
||||
|
||||
# constants
|
||||
$COUNTER_OUTPUT=1; # set to 1 to display the counter as the script runs
|
||||
$US='__';
|
||||
$MT[0]='';
|
||||
|
||||
### begin parsing run-time options ###
|
||||
if (length($ARGV[0])>1)
|
||||
{
|
||||
$i=0;
|
||||
while ($#ARGV >= $i)
|
||||
{
|
||||
$args = "$args $ARGV[$i]";
|
||||
$i++;
|
||||
}
|
||||
|
||||
if ($args =~ /--help/i)
|
||||
{
|
||||
print "allowed run time options:\n [-t] = test\n [-debug] = verbose debug messages\n[-debugX] = Extra-verbose debug messages\n\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($args =~ /-debug/i)
|
||||
{
|
||||
$DB=1; # Debug flag
|
||||
}
|
||||
if ($args =~ /--debugX/i)
|
||||
{
|
||||
$DBX=1;
|
||||
print "\n----- SUPER-DUPER DEBUGGING -----\n\n";
|
||||
}
|
||||
if ($args =~ /-sendonlyone/i)
|
||||
{
|
||||
$sendonlyone=1;
|
||||
print "\n-----SEND ONLY ONE COMMAND -----\n\n";
|
||||
}
|
||||
if ($args =~ /-t/i)
|
||||
{
|
||||
$TEST=1;
|
||||
$T=1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
# print "no command line options set\n";
|
||||
}
|
||||
### end parsing run-time options ###
|
||||
|
||||
### Make sure this file is in a libs path or put the absolute path to it
|
||||
require("/home/cron/AST_SERVER_conf.pl"); # local configuration file
|
||||
|
||||
if (!$DB_port) {$DB_port='3306';}
|
||||
|
||||
&get_time_now;
|
||||
|
||||
$event_string='PROGRAM STARTED||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||';
|
||||
&event_logger;
|
||||
|
||||
#use lib './lib', '../lib';
|
||||
use Time::HiRes ('gettimeofday','usleep','sleep'); # necessary to have perl sleep command of less than one second
|
||||
use Net::MySQL;
|
||||
#use Net::Telnet ();
|
||||
|
||||
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";
|
||||
|
||||
|
||||
$event_string='LOGGED INTO MYSQL SERVER ON 1 CONNECTION|';
|
||||
&event_logger;
|
||||
|
||||
$one_day_interval = 90; # 1 day loops for 3 months
|
||||
while($one_day_interval > 0)
|
||||
{
|
||||
|
||||
|
||||
$endless_loop=864000; # 10 days at .20 seconds per loop
|
||||
|
||||
while($endless_loop > 0)
|
||||
{
|
||||
|
||||
$affected_rows=0;
|
||||
$NEW_actions=0;
|
||||
|
||||
$stmtA = "SELECT count(*) from vicidial_manager where server_ip = '$server_ip' and status = 'NEW'";
|
||||
$dbhA->query("$stmtA");
|
||||
if ($dbhA->has_selected_record)
|
||||
{
|
||||
$iter=$dbhA->create_record_iterator;
|
||||
$rec_count=0;
|
||||
while ( $record = $iter->each)
|
||||
{
|
||||
if($DB){print STDERR $record->[0]," NEW Actions to send on server $server_ip $endless_loop\n";}
|
||||
$NEW_actions = "$record->[0]";
|
||||
}
|
||||
}
|
||||
|
||||
if (!$NEW_actions)
|
||||
{
|
||||
$affected_rows=0;
|
||||
}
|
||||
else
|
||||
{
|
||||
$stmtA = "UPDATE vicidial_manager set status='QUEUE' where server_ip = '$server_ip' and status = 'NEW' order by entry_date limit 1";
|
||||
$dbhA->query("$stmtA");
|
||||
$affected_rows = $dbhA->get_affected_rows_length;
|
||||
if ($DB) {print STDERR "rows updated to QUEUE: |$affected_rows|\n";}
|
||||
}
|
||||
|
||||
|
||||
if ($affected_rows)
|
||||
{
|
||||
$stmtA = "SELECT * FROM vicidial_manager where server_ip = '$server_ip' and status = 'QUEUE' order by entry_date desc limit 1";
|
||||
$event_string="SQL_QUERY|$stmtA|";
|
||||
&event_logger;
|
||||
|
||||
$dbhA->query("$stmtA");
|
||||
if ($dbhA->has_selected_record)
|
||||
{
|
||||
$iter=$dbhA->create_record_iterator;
|
||||
$rec_count=0;
|
||||
while ( $record = $iter->each)
|
||||
{
|
||||
if($DB){print STDERR $record->[0],"|", $record->[1],"|", $record->[6],"|", $record->[7],"|", $record->[8],"\n";}
|
||||
$man_id = "$record->[0]";
|
||||
$uniqueid = "$record->[1]";
|
||||
$channel = "$record->[6]";
|
||||
$action = "$record->[7]";
|
||||
$callid = "$record->[8]";
|
||||
$cmd_line_b = "$record->[9]";
|
||||
$cmd_line_c = "$record->[10]";
|
||||
$cmd_line_d = "$record->[11]";
|
||||
$cmd_line_e = "$record->[12]";
|
||||
$cmd_line_f = "$record->[13]";
|
||||
$cmd_line_g = "$record->[14]";
|
||||
$cmd_line_h = "$record->[15]";
|
||||
$cmd_line_i = "$record->[16]";
|
||||
$cmd_line_j = "$record->[17]";
|
||||
$cmd_line_k = "$record->[18]";
|
||||
|
||||
$originate_command = '';
|
||||
$originate_command .= "Action: $action\n";
|
||||
if (length($cmd_line_b)>3) {$originate_command .= "$cmd_line_b\n";}
|
||||
if (length($cmd_line_c)>3) {$originate_command .= "$cmd_line_c\n";}
|
||||
if (length($cmd_line_d)>3) {$originate_command .= "$cmd_line_d\n";}
|
||||
if (length($cmd_line_e)>3) {$originate_command .= "$cmd_line_e\n";}
|
||||
if (length($cmd_line_f)>3) {$originate_command .= "$cmd_line_f\n";}
|
||||
if (length($cmd_line_g)>3) {$originate_command .= "$cmd_line_g\n";}
|
||||
if (length($cmd_line_h)>3) {$originate_command .= "$cmd_line_h\n";}
|
||||
if (length($cmd_line_i)>3) {$originate_command .= "$cmd_line_i\n";}
|
||||
if (length($cmd_line_j)>3) {$originate_command .= "$cmd_line_j\n";}
|
||||
if (length($cmd_line_k)>3) {$originate_command .= "$cmd_line_k\n";}
|
||||
$originate_command .= "\n";
|
||||
|
||||
$SENDNOW=1;
|
||||
if ($originate_command =~ /Action: Hangup|Action: Redirect/)
|
||||
{
|
||||
$SENDNOW=0;
|
||||
if($DB){print STDERR "\n|checking for dead call before executing|$callid|$uniqueid|\n";}
|
||||
$dbhA->query("SELECT count(*) FROM vicidial_manager where server_ip = '$server_ip' and callerid='$callid' and status = 'DEAD'");
|
||||
if ($dbhA->has_selected_record)
|
||||
{
|
||||
$iter=$dbhA->create_record_iterator;
|
||||
$rec_countH=0;
|
||||
while ( $record = $iter->each)
|
||||
{
|
||||
$rec_countH = "$record->[0]";
|
||||
}
|
||||
if (!$rec_countH){$SENDNOW=1;}
|
||||
else
|
||||
{
|
||||
$launch_string = "|not sending command line is dead|$callid|$uniqueid|";
|
||||
# &launch_logger;
|
||||
if($DB){print STDERR "\n$launch_string\n";}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$event_string="----BEGIN NEW COMMAND----\n$originate_command----END NEW COMMAND----\n";
|
||||
&event_logger;
|
||||
|
||||
if ($SENDNOW)
|
||||
{
|
||||
# $tn->buffer_empty;
|
||||
|
||||
$launch_string = "/home/cron/AST_send_action_child.pl --data1=$man_id $callid $uniqueid $channel";
|
||||
# &launch_logger;
|
||||
|
||||
system("/home/cron/AST_send_action_child.pl --data1=$man_id >> /home/cron/action.$action_log_date \&");
|
||||
|
||||
$launch_string = "SENT $man_id $callid $uniqueid $channel";
|
||||
# &launch_logger;
|
||||
|
||||
$stmtA = "UPDATE vicidial_manager set status='SENT' where man_id='$man_id'";
|
||||
if($DB){print STDERR "\n|$stmtA|\n";}
|
||||
$dbhA->query($stmtA);
|
||||
|
||||
$event_string="SQL_QUERY|$stmtA|";
|
||||
&event_logger;
|
||||
}
|
||||
else
|
||||
{
|
||||
$stmtA = "UPDATE vicidial_manager set status='DEAD' where man_id='$man_id'";
|
||||
if($DB){print STDERR "\n|$stmtA|\n";}
|
||||
$dbhA->query($stmtA);
|
||||
$event_string="COMMAND NOT SENT, SQL_QUERY|$stmtA|";
|
||||
&event_logger;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ($affected_rows)
|
||||
{
|
||||
### sleep for 10 hundredths of a second
|
||||
usleep(1*100*1000);
|
||||
}
|
||||
else
|
||||
{
|
||||
### sleep for 20 hundredths of a second
|
||||
usleep(1*200*1000);
|
||||
}
|
||||
|
||||
$endless_loop--;
|
||||
if( ($COUNTER_OUTPUT) or ($DB) ){print STDERR "loop counter: |$endless_loop|\r";}
|
||||
|
||||
### putting a blank file called "sendmgr.kill" in a directory will automatically safely kill this program
|
||||
if ( (-e '/home/cron/sendmgr.kill') or ($sendonlyone) )
|
||||
{
|
||||
unlink('/home/cron/sendmgr.kill');
|
||||
$endless_loop=0;
|
||||
$one_day_interval=0;
|
||||
print "\nPROCESS KILLED MANUALLY... EXITING\n\n";
|
||||
}
|
||||
|
||||
if ($endless_loop =~ /0$/)
|
||||
{
|
||||
&get_time_now;
|
||||
|
||||
if( ($COUNTER_OUTPUT) or ($DB) ){print "checking to see if listener is dead |$sendonlyone|$running_listen|\n";}
|
||||
#@psoutput = `/bin/ps -f --no-headers -A`;
|
||||
@psoutput = `/bin/ps -o "%p %a" --no-headers -A`;
|
||||
|
||||
$running_listen = 0;
|
||||
|
||||
$i=0;
|
||||
foreach (@psoutput)
|
||||
{
|
||||
chomp($psoutput[$i]);
|
||||
|
||||
if ($DBX) {print "$i|$psoutput[$i]| \n";}
|
||||
@psline = split(/\/usr\/bin\/perl /,$psoutput[$i]);
|
||||
|
||||
if ($psline[1] =~ /AST_manager_li/)
|
||||
{
|
||||
$running_listen++;
|
||||
if ($DB) {print "SEND RUNNING: |$psline[1]|\n";}
|
||||
}
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
if (!$running_listen)
|
||||
{
|
||||
$sendonlyone++;
|
||||
if( ($COUNTER_OUTPUT) or ($DB) ){print "LISTENER DEAD STOPPING PROGRAM... ATTEMPTING TO START keepalive SCRIPT\n";}
|
||||
$event_string='LISTENER DEAD STOPPING PROGRAM... ATTEMPTING TO START keepalive SCRIPT|';
|
||||
&event_logger;
|
||||
`/usr/bin/at now < /home/cron/ADMIN_keepalive_send_listen.at 2>/dev/null 1>&2`;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
if( ($COUNTER_OUTPUT) or ($DB) ){print "DONE... Exiting... Goodbye... See you later... Not really, initiating next loop...$one_day_interval left\n";}
|
||||
|
||||
$one_day_interval--;
|
||||
|
||||
}
|
||||
|
||||
$event_string='CLOSING DB CONNECTION|';
|
||||
&event_logger;
|
||||
|
||||
|
||||
$dbhA->close;
|
||||
|
||||
|
||||
if( ($COUNTER_OUTPUT) or ($DB) ){print "DONE... Exiting... Goodbye... See you later... Really I mean it this time\n";}
|
||||
|
||||
|
||||
exit;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
sub get_time_now #get the current date and time and epoch for logging call lengths and datetimes
|
||||
{
|
||||
($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";
|
||||
$action_log_date = "$year-$mon-$mday";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
sub event_logger {
|
||||
### open the log file for writing ###
|
||||
open(Lout, ">>$MSLOGfile")
|
||||
|| die "Can't open $MSLOGfile: $!\n";
|
||||
|
||||
print Lout "$now_date|$event_string|\n";
|
||||
|
||||
close(Lout);
|
||||
|
||||
$event_string='';
|
||||
}
|
||||
|
||||
sub launch_logger {
|
||||
### open the log file for writing ###
|
||||
open(LLout, ">>/home/cron/action_launch.$action_log_date")
|
||||
|| die "Can't open /home/cron/action_launch.$action_log_date: $!\n";
|
||||
|
||||
print LLout "$now_date|$launch_string|\n";
|
||||
|
||||
close(LLout);
|
||||
|
||||
$event_string='';
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
#!/usr/bin/perl
|
||||
#
|
||||
# AST_reset_mysql_vars.pl version 0.2
|
||||
#
|
||||
# !!! DO NOT RUN THIS WHILE THERE ARE ACTIVE CALLS ON THE ASTERISK SERVER !!!
|
||||
#
|
||||
# DESCRIPTION:
|
||||
# clears out mysql records for this server
|
||||
#
|
||||
# It is recommended that you run this program on the local Asterisk machine
|
||||
#
|
||||
# Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
|
||||
#
|
||||
|
||||
|
||||
### Make sure this file is in a libs path or put the absolute path to it
|
||||
require("/home/cron/AST_SERVER_conf.pl"); # local configuration file
|
||||
|
||||
if (!$DB_port) {$DB_port='3306';}
|
||||
|
||||
use Net::MySQL;
|
||||
|
||||
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";
|
||||
|
||||
|
||||
|
||||
$stmtA = "UPDATE conferences set extension='' where server_ip='$server_ip';";
|
||||
if($DB){print STDERR "\n|$stmtA|\n";}
|
||||
$dbhA->query($stmtA); # or die "Couldn't execute query: |$stmtA|\n";
|
||||
print " - conferences reset\n";
|
||||
|
||||
$stmtA = "UPDATE vicidial_conferences set extension='' where server_ip='$server_ip';";
|
||||
if($DB){print STDERR "\n|$stmtA|\n";}
|
||||
$dbhA->query($stmtA); # or die "Couldn't execute query: |$stmtA|\n";
|
||||
print " - vicidial_conferences reset\n";
|
||||
|
||||
# $stmtA = "UPDATE vicidial_manager set status='DEAD' where server_ip='$server_ip' and status='NEW';";
|
||||
# if($DB){print STDERR "\n|$stmtA|\n";}
|
||||
# $dbhA->query($stmtA); # or die "Couldn't execute query: |$stmtA|\n";
|
||||
# print " - vicidial_manager queue reset\n";
|
||||
|
||||
$stmtA = "DELETE from vicidial_manager where server_ip='$server_ip';";
|
||||
if($DB){print STDERR "\n|$stmtA|\n";}
|
||||
$dbhA->query($stmtA); # or die "Couldn't execute query: |$stmtA|\n";
|
||||
print " - vicidial_manager delete\n";
|
||||
|
||||
$stmtA = "DELETE from vicidial_auto_calls where server_ip='$server_ip';";
|
||||
if($DB){print STDERR "\n|$stmtA|\n";}
|
||||
$dbhA->query($stmtA); # or die "Couldn't execute query: |$stmtA|\n";
|
||||
print " - vicidial_manager delete\n";
|
||||
|
||||
$stmtA = "DELETE from vicidial_live_agents where server_ip='$server_ip';";
|
||||
if($DB){print STDERR "\n|$stmtA|\n";}
|
||||
$dbhA->query($stmtA); # or die "Couldn't execute query: |$stmtA|\n";
|
||||
print " - vicidial_manager delete\n";
|
||||
|
||||
$stmtA = "DELETE from vicidial_users where full_name='5555';";
|
||||
if($DB){print STDERR "\n|$stmtA|\n";}
|
||||
$dbhA->query($stmtA); # or die "Couldn't execute query: |$stmtA|\n";
|
||||
print " - vicidial_manager delete\n";
|
||||
|
||||
$dbhA->close;
|
||||
|
||||
|
||||
exit;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,258 @@
|
||||
#!/usr/bin/perl
|
||||
#
|
||||
# AST_send_action_child.pl version 0.2
|
||||
#
|
||||
# Part of the Asterisk Central Queue System (ACQS)
|
||||
#
|
||||
# DESCRIPTION:
|
||||
# This script is spawned every time an action is to be executed by the main
|
||||
# AST_manager_send.pl script and sends actions blindly to the Asterisk manager
|
||||
#
|
||||
# SUMMARY:
|
||||
# This program was designed as the blind-send part of the ACQS. It's job is to
|
||||
# be spawned by the AST_manager_send.pl script lookup the record in the MySQL DB
|
||||
# to be executed. connect to the manager interface, send the action and logoff
|
||||
# then exit.
|
||||
#
|
||||
# Win32 - ActiveState Perl 5.8.0
|
||||
# UNIX - Gnome or KDE with Tk/Tcl and perl Tk/Tcl modules loaded
|
||||
# Both - Net::MySQL, Net::Telnet and Time::HiRes perl modules loaded
|
||||
#
|
||||
# For the client program to work in ACQS mode, this program must be running
|
||||
#
|
||||
# For this program to work you need to have the "asterisk" MySQL database
|
||||
# created and create the tables listed in the CONF_MySQL.txt file, also make sure
|
||||
# that the machine running this program has read/write/update/delete access
|
||||
# to that database
|
||||
#
|
||||
# In your Asterisk server setup you also need to have several things activated
|
||||
# and defined. See the CONF_Asterisk.txt file for details
|
||||
#
|
||||
# Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
|
||||
#
|
||||
# 50810-1547 - Added database server variable definitions lookup
|
||||
# 50823-1527 - Altered commandline debug options with debug printouts
|
||||
# 50902-1032 - Changed default logging to fulllog
|
||||
#
|
||||
|
||||
$FULL_LOG = 1; # set to 1 for a full response log to be created in /home/cron/action_full.date
|
||||
|
||||
$secX = time();
|
||||
|
||||
($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";
|
||||
$action_log_date = "$year-$mon-$mday";
|
||||
|
||||
### Make sure this file is in a libs path or put the absolute path to it
|
||||
require("/home/cron/AST_SERVER_conf.pl"); # local configuration file
|
||||
|
||||
if (!$DB_port) {$DB_port='3306';}
|
||||
|
||||
### begin parsing run-time options ###
|
||||
if (length($ARGV[0])>1)
|
||||
{
|
||||
$i=0;
|
||||
while ($#ARGV >= $i)
|
||||
{
|
||||
$ARGS = "$ARGS $ARGV[$i]\n";
|
||||
$i++;
|
||||
}
|
||||
|
||||
# print "DB0: |$ARGS|$#ARGV|$i|\n";
|
||||
|
||||
if ($ARGS =~ /--help/i)
|
||||
{
|
||||
print "allowed run time options:\n [-debug] = debug output\n [-debugX] = Extra-debug output\n [-fulllog] = full response logging\n [--data1=XXXXXXX] = vicidial_manager record\n\n\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($args =~ /-debug/i)
|
||||
{
|
||||
$DB=1; # Debug flag
|
||||
}
|
||||
if ($args =~ /--debugX/i)
|
||||
{
|
||||
$DBX=1;
|
||||
print "\n----- SUPER-DUPER DEBUGGING -----\n\n";
|
||||
}
|
||||
if ($args =~ /-fulllog/i)
|
||||
{
|
||||
$FULL_LOG=1; # Full response logging enabled
|
||||
}
|
||||
if ($ARGS =~ /--data1=/i)
|
||||
{
|
||||
$data1 = $ARGS;
|
||||
# print "DB1: |$ARGS|\n";
|
||||
$data1 =~ s/^.*--data1=//gi;
|
||||
# print "DB2: |$data1|\n";
|
||||
$data1 =~ s/ .*$//gi;
|
||||
# print "DB3: |$data1|\n";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
#print "no command line options set\n\n";
|
||||
}
|
||||
|
||||
if (length($data1)>1)
|
||||
{
|
||||
# print "Data1 value = |$data1|\n";
|
||||
|
||||
use Net::MySQL;
|
||||
use Net::Telnet ();
|
||||
|
||||
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";
|
||||
|
||||
### Grab Server values from the database
|
||||
$stmtA = "SELECT telnet_host,telnet_port,ASTmgrUSERNAME,ASTmgrSECRET,ASTmgrUSERNAMEsend FROM servers where server_ip = '$server_ip';";
|
||||
$dbhA->query("$stmtA");
|
||||
if ($dbhA->has_selected_record)
|
||||
{
|
||||
$iter=$dbhA->create_record_iterator;
|
||||
while ( $record = $iter->each)
|
||||
{
|
||||
$DBtelnet_host = "$record->[0]";
|
||||
$DBtelnet_port = "$record->[1]";
|
||||
$DBASTmgrUSERNAME = "$record->[2]";
|
||||
$DBASTmgrSECRET = "$record->[3]";
|
||||
$DBASTmgrUSERNAMEsend = "$record->[4]";
|
||||
if ($DBtelnet_host) {$telnet_host = $DBtelnet_host;}
|
||||
if ($DBtelnet_port) {$telnet_port = $DBtelnet_port;}
|
||||
if ($DBASTmgrUSERNAME) {$ASTmgrUSERNAME = $DBASTmgrUSERNAME;}
|
||||
if ($DBASTmgrSECRET) {$ASTmgrSECRET = $DBASTmgrSECRET;}
|
||||
if ($DBASTmgrUSERNAMEsend) {$ASTmgrUSERNAMEsend = $DBASTmgrUSERNAMEsend;}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$stmtA = "SELECT * FROM vicidial_manager where man_id = '$data1'";
|
||||
$dbhA->query("$stmtA");
|
||||
if ($dbhA->has_selected_record)
|
||||
{
|
||||
$iter=$dbhA->create_record_iterator;
|
||||
$rec_count=0;
|
||||
while ( $record = $iter->each)
|
||||
{
|
||||
$man_id = "$record->[0]";
|
||||
$uniqueid = "$record->[1]";
|
||||
$channel = "$record->[6]";
|
||||
$action = "$record->[7]";
|
||||
$callid = "$record->[8]";
|
||||
$cmd_line_b = "$record->[9]";
|
||||
$cmd_line_c = "$record->[10]";
|
||||
$cmd_line_d = "$record->[11]";
|
||||
$cmd_line_e = "$record->[12]";
|
||||
$cmd_line_f = "$record->[13]";
|
||||
$cmd_line_g = "$record->[14]";
|
||||
$cmd_line_h = "$record->[15]";
|
||||
$cmd_line_i = "$record->[16]";
|
||||
$cmd_line_j = "$record->[17]";
|
||||
$cmd_line_k = "$record->[18]";
|
||||
|
||||
$originate_command = '';
|
||||
$originate_command .= "Action: $action\n";
|
||||
if (length($cmd_line_b)>3) {$originate_command .= "$cmd_line_b\n";}
|
||||
if (length($cmd_line_c)>3) {$originate_command .= "$cmd_line_c\n";}
|
||||
if (length($cmd_line_d)>3) {$originate_command .= "$cmd_line_d\n";}
|
||||
if (length($cmd_line_e)>3) {$originate_command .= "$cmd_line_e\n";}
|
||||
if (length($cmd_line_f)>3) {$originate_command .= "$cmd_line_f\n";}
|
||||
if (length($cmd_line_g)>3) {$originate_command .= "$cmd_line_g\n";}
|
||||
if (length($cmd_line_h)>3) {$originate_command .= "$cmd_line_h\n";}
|
||||
if (length($cmd_line_i)>3) {$originate_command .= "$cmd_line_i\n";}
|
||||
if (length($cmd_line_j)>3) {$originate_command .= "$cmd_line_j\n";}
|
||||
if (length($cmd_line_k)>3) {$originate_command .= "$cmd_line_k\n";}
|
||||
$originate_command .= "\n";
|
||||
}
|
||||
}
|
||||
|
||||
$dbhA->close;
|
||||
|
||||
|
||||
print "$now_date|$data1|\n$originate_command";
|
||||
$event_string = "0|$data1|";
|
||||
$event_string .= "\n$originate_command";
|
||||
if ($FULL_LOG) {&full_event_logger;}
|
||||
|
||||
if (!$telnet_port) {$telnet_port = '5038';}
|
||||
|
||||
### connect to asterisk manager through telnet
|
||||
$tn = new Net::Telnet (Port => $telnet_port,
|
||||
Prompt => '/.*[\$%#>] $/',
|
||||
Output_record_separator => '',
|
||||
Errmode => Return,);
|
||||
#$fh = $tn->dump_log("$MStelnetlog"); # uncomment for telnet log
|
||||
if (length($ASTmgrUSERNAMEsend) > 3) {$telnet_login = $ASTmgrUSERNAMEsend;}
|
||||
else {$telnet_login = $ASTmgrUSERNAME;}
|
||||
$tn->open("$telnet_host");
|
||||
$tn->waitfor('/0\n$/'); # print login
|
||||
$tn->print("Action: Login\nUsername: $telnet_login\nSecret: $ASTmgrSECRET\n\n");
|
||||
$tn->waitfor('/Authentication accepted/'); # waitfor auth accepted
|
||||
|
||||
$tn->buffer_empty;
|
||||
|
||||
@list_channels = $tn->cmd(String => "$originate_command", Prompt => '/.*/');
|
||||
|
||||
sleep(3);
|
||||
|
||||
if ($FULL_LOG)
|
||||
{
|
||||
$event_string = "1|$data1|"; $k=0;
|
||||
foreach(@list_channels) {$event_string .= "$list_channels[$k]"; $k++;}
|
||||
$read_input_buf = $tn->get(Errmode => Return, Timeout => 1,);
|
||||
$event_string .= "$read_input_buf";
|
||||
&full_event_logger;
|
||||
}
|
||||
|
||||
$tn->buffer_empty;
|
||||
|
||||
@hangup = $tn->cmd(String => "Action: Logoff\n\n", Prompt => "/.*/");
|
||||
|
||||
sleep(2);
|
||||
|
||||
if ($FULL_LOG)
|
||||
{
|
||||
$event_string = "2|$data1|"; $k=0;
|
||||
foreach(@list_channels) {$event_string .= "$list_channels[$k]"; $k++;}
|
||||
$read_input_buf = $tn->get(Errmode => Return, Timeout => 1,);
|
||||
$event_string .= "$read_input_buf";
|
||||
&full_event_logger;
|
||||
}
|
||||
|
||||
$tn->buffer_empty;
|
||||
|
||||
$ok = $tn->close;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
$secZ = time();
|
||||
$script_time = ($secZ - $secX);
|
||||
print "DONE execute time: $script_time seconds\n";
|
||||
|
||||
exit;
|
||||
|
||||
sub full_event_logger {
|
||||
### open the log file for writing ###
|
||||
open(Lout, ">>/home/cron/action_full.$action_log_date")
|
||||
|| die "Can't open /home/cron/action_full.$action_log_date: $!\n";
|
||||
|
||||
print Lout "$now_date|$event_string|\n";
|
||||
|
||||
close(Lout);
|
||||
|
||||
$event_string='';
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,202 @@
|
||||
#!/usr/bin/perl
|
||||
#
|
||||
# AST_vm_update.pl version 0.3
|
||||
#
|
||||
# DESCRIPTION:
|
||||
# uses the Asterisk Manager interface and Net::MySQL to update the count of
|
||||
# voicemail messages for each mailbox (in the phone table) in the voicemail
|
||||
# table list is used by client apps for voicemail notification
|
||||
#
|
||||
# SUMMARY:
|
||||
# This program was designed for people using the Asterisk PBX with voicemail
|
||||
#
|
||||
# For the client program to notify of new messaged, this program must be in the
|
||||
# cron running every minute
|
||||
#
|
||||
# For this program to work you need to have the "asterisk" MySQL database
|
||||
# created and create the tables listed in the CONF_MySQL.txt file, also make sure
|
||||
# that the machine running this program has read/write/update/delete access
|
||||
# to that database
|
||||
#
|
||||
# It is recommended that you run this program on the local Asterisk machine
|
||||
#
|
||||
# If this script is run ever minute there is a theoretical limit of
|
||||
# 600 mailboxes that it can check due to the wait interval. If you have
|
||||
# more than this either change the cron when this script is run or change the
|
||||
# wait interval below
|
||||
#
|
||||
# Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
|
||||
#
|
||||
# 50823-1422 - Added database server variable definitions lookup
|
||||
# 50823-1452 - Added commandline arguments for debug at runtime
|
||||
#
|
||||
|
||||
# constants
|
||||
$DB=0; # Debug flag, set to 0 for no debug messages per minute
|
||||
$US='__';
|
||||
$MT[0]='';
|
||||
|
||||
### begin parsing run-time options ###
|
||||
if (length($ARGV[0])>1)
|
||||
{
|
||||
$i=0;
|
||||
while ($#ARGV >= $i)
|
||||
{
|
||||
$args = "$args $ARGV[$i]";
|
||||
$i++;
|
||||
}
|
||||
|
||||
if ($args =~ /--help/i)
|
||||
{
|
||||
print "allowed run time options:\n [-t] = test\n [-debug] = verbose debug messages\n\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($args =~ /-debug/i)
|
||||
{
|
||||
$DB=1; # Debug flag
|
||||
}
|
||||
if ($args =~ /-t/i)
|
||||
{
|
||||
$TEST=1;
|
||||
$T=1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
# print "no command line options set\n";
|
||||
}
|
||||
### end parsing run-time options ###
|
||||
|
||||
### Make sure this file is in a libs path or put the absolute path to it
|
||||
require("/home/cron/AST_SERVER_conf.pl"); # local configuration file
|
||||
|
||||
if (!$DB_port) {$DB_port='3306';}
|
||||
|
||||
use lib './lib', '../lib';
|
||||
use Time::HiRes ('gettimeofday','usleep','sleep'); # necessary to have perl sleep command of less than one second
|
||||
use Net::MySQL;
|
||||
use Net::Telnet ();
|
||||
|
||||
|
||||
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";
|
||||
|
||||
### Grab Server values from the database
|
||||
$stmtA = "SELECT telnet_host,telnet_port,ASTmgrUSERNAME,ASTmgrSECRET,ASTmgrUSERNAMEupdate,ASTmgrUSERNAMElisten,ASTmgrUSERNAMEsend,max_vicidial_trunks,answer_transfer_agent,local_gmt,ext_context FROM servers where server_ip = '$server_ip';";
|
||||
$dbhA->query("$stmtA");
|
||||
if ($dbhA->has_selected_record)
|
||||
{
|
||||
$iter=$dbhA->create_record_iterator;
|
||||
while ( $record = $iter->each)
|
||||
{
|
||||
$DBtelnet_host = "$record->[0]";
|
||||
$DBtelnet_port = "$record->[1]";
|
||||
$DBASTmgrUSERNAME = "$record->[2]";
|
||||
$DBASTmgrSECRET = "$record->[3]";
|
||||
$DBASTmgrUSERNAMEupdate = "$record->[4]";
|
||||
$DBASTmgrUSERNAMElisten = "$record->[5]";
|
||||
$DBASTmgrUSERNAMEsend = "$record->[6]";
|
||||
$DBmax_vicidial_trunks = "$record->[7]";
|
||||
$DBanswer_transfer_agent= "$record->[8]";
|
||||
$DBSERVER_GMT = "$record->[9]";
|
||||
$DBext_context = "$record->[10]";
|
||||
if ($DBtelnet_host) {$telnet_host = $DBtelnet_host;}
|
||||
if ($DBtelnet_port) {$telnet_port = $DBtelnet_port;}
|
||||
if ($DBASTmgrUSERNAME) {$ASTmgrUSERNAME = $DBASTmgrUSERNAME;}
|
||||
if ($DBASTmgrSECRET) {$ASTmgrSECRET = $DBASTmgrSECRET;}
|
||||
if ($DBASTmgrUSERNAMEupdate) {$ASTmgrUSERNAMEupdate = $DBASTmgrUSERNAMEupdate;}
|
||||
if ($DBASTmgrUSERNAMElisten) {$ASTmgrUSERNAMElisten = $DBASTmgrUSERNAMElisten;}
|
||||
if ($DBASTmgrUSERNAMEsend) {$ASTmgrUSERNAMEsend = $DBASTmgrUSERNAMEsend;}
|
||||
if ($DBmax_vicidial_trunks) {$max_vicidial_trunks = $DBmax_vicidial_trunks;}
|
||||
if ($DBanswer_transfer_agent) {$answer_transfer_agent = $DBanswer_transfer_agent;}
|
||||
if ($DBSERVER_GMT) {$SERVER_GMT = $DBSERVER_GMT;}
|
||||
if ($DBext_context) {$ext_context = $DBext_context;}
|
||||
}
|
||||
}
|
||||
|
||||
@PTextensions=@MT; @PTvoicemail_ids=@MT; @PTmessages=@MT; @PTold_messages=@MT; @NEW_messages=@MT; @OLD_messages=@MT;
|
||||
$dbhA->query("SELECT extension,voicemail_id,messages,old_messages from phones where server_ip='$server_ip'");
|
||||
if ($dbhA->has_selected_record)
|
||||
{
|
||||
$iter=$dbhA->create_record_iterator;
|
||||
$rec_count=0;
|
||||
while ( $record = $iter->each)
|
||||
{
|
||||
$PTextensions[$rec_count] = "$record->[0]";
|
||||
$PTvoicemail_ids[$rec_count] = "$record->[1]";
|
||||
$PTmessages[$rec_count] = "$record->[2]";
|
||||
$PTold_messages[$rec_count] = "$record->[3]";
|
||||
$rec_count++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
### connect to asterisk manager through telnet
|
||||
$t = new Net::Telnet (Port => 5038,
|
||||
Prompt => '/.*[\$%#>] $/',
|
||||
Output_record_separator => '',);
|
||||
#$fh = $t->dump_log("$telnetlog"); # uncomment for telnet log
|
||||
if (length($ASTmgrUSERNAMEsend) > 3) {$telnet_login = $ASTmgrUSERNAMEsend;}
|
||||
else {$telnet_login = $ASTmgrUSERNAME;}
|
||||
|
||||
$t->open("$telnet_host");
|
||||
$t->waitfor('/0\n$/'); # print login
|
||||
$t->print("Action: Login\nUsername: $telnet_login\nSecret: $ASTmgrSECRET\n\n");
|
||||
$t->waitfor('/Authentication accepted/'); # waitfor auth accepted
|
||||
|
||||
|
||||
$i=0;
|
||||
foreach(@PTextensions)
|
||||
{
|
||||
@list_channels=@MT;
|
||||
$t->buffer_empty;
|
||||
@list_channels = $t->cmd(String => "Action: MailboxCount\nMailbox: $PTvoicemail_ids[$i]\n\nAction: Ping\n\n", Prompt => '/Response: Pong.*/');
|
||||
|
||||
$j=0;
|
||||
foreach(@list_channels)
|
||||
{
|
||||
if ($list_channels[$j] =~ /Mailbox: $PTvoicemail_ids[$i]/)
|
||||
{
|
||||
$NEW_messages[$i] = "$list_channels[$j+1]";
|
||||
$NEW_messages[$i] =~ s/NewMessages: |\n//gi;
|
||||
$OLD_messages[$i] = "$list_channels[$j+2]";
|
||||
$OLD_messages[$i] =~ s/OldMessages: |\n//gi;
|
||||
}
|
||||
|
||||
$j++;
|
||||
}
|
||||
|
||||
if($DB){print "MailboxCount- $PTvoicemail_ids[$i] NEW:|$NEW_messages[$i]| OLD:|$OLD_messages[$i]| ";}
|
||||
if ( ($NEW_messages[$i] eq $PTmessages[$i]) && ($OLD_messages[$i] eq $PTold_messages[$i]) )
|
||||
{
|
||||
if($DB){print "MESSAGE COUNT UNCHANGED, DOING NOTHING FOR THIS MAILBOX\n";}
|
||||
}
|
||||
else
|
||||
{
|
||||
$stmtA = "UPDATE phones set messages='$NEW_messages[$i]', old_messages='$OLD_messages[$i]' where server_ip='$server_ip' and extension='$PTextensions[$i]'";
|
||||
if($DB){print STDERR "\n|$stmtA|\n";}
|
||||
$dbhA->query($stmtA) or die "Couldn't execute query:|$stmtA|\n";
|
||||
}
|
||||
|
||||
$i++;
|
||||
### sleep for 10 hundredths of a second
|
||||
usleep(1*100*1000);
|
||||
}
|
||||
|
||||
|
||||
$t->buffer_empty;
|
||||
@hangup = $t->cmd(String => "Action: Logoff\n\n", Prompt => "/.*/");
|
||||
$t->buffer_empty;
|
||||
$ok = $t->close;
|
||||
|
||||
$dbhA->close;
|
||||
|
||||
if($DB){print "DONE... Exiting... Goodbye... See you later... \n";}
|
||||
|
||||
exit;
|
||||
|
||||
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,336 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
# AST_agent_week.pl
|
||||
#
|
||||
# This script is designed to gather stats for all agent activity over the course
|
||||
# of a week(Sunday to Saturday) and print it in an ASCI text file to be placed
|
||||
# on a web server for viewing.
|
||||
#
|
||||
# CHANGES
|
||||
# 60517-1100 - First version
|
||||
#
|
||||
|
||||
$txt = '.txt';
|
||||
$US = '_';
|
||||
$MT[0] = '';
|
||||
|
||||
### begin parsing run-time options ###
|
||||
if (length($ARGV[0])>1)
|
||||
{
|
||||
$i=0;
|
||||
while ($#ARGV >= $i)
|
||||
{
|
||||
$args = "$args $ARGV[$i]";
|
||||
$i++;
|
||||
}
|
||||
|
||||
if ($args =~ /--help/i)
|
||||
{
|
||||
print "allowed run time options:\n [-q] = quiet\n [-t] = test\n\n";
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($args =~ /--debug/i)
|
||||
{
|
||||
$DB=1;
|
||||
print "\n-----DEBUG MODE-----\n\n";
|
||||
}
|
||||
if ($args =~ /-q/i)
|
||||
{
|
||||
$q=1; $Q=1;
|
||||
}
|
||||
if ($args =~ /-t/i)
|
||||
{
|
||||
$T=1; $TEST=1;
|
||||
print "\n-----TESTING-----\n\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print "no command line options set\n";
|
||||
}
|
||||
### end parsing run-time options ###
|
||||
|
||||
|
||||
$secX = time();
|
||||
($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) {$hour = "0$hour";}
|
||||
if ($min < 10) {$min = "0$min";}
|
||||
if ($sec < 10) {$sec = "0$sec";}
|
||||
$filedate = "$year$mon$mday-$hour$min$sec";
|
||||
$ABIfiledate = "$mon-$mday-$year$us$hour$min$sec";
|
||||
$shipdate = "$year-$mon-$mday";
|
||||
$datestamp = "$year/$mon/$mday $hour:$min";
|
||||
|
||||
$STARTtarget = ($secX - (86400 * $wday));
|
||||
($Ssec,$Smin,$Shour,$Smday,$Smon,$Syear,$Swday,$Syday,$Sisdst) = localtime($STARTtarget);
|
||||
$Syear = ($Syear + 1900); $Smon++;
|
||||
if ($Smon < 10) {$Smon = "0$Smon";}
|
||||
if ($Smday < 10) {$Smday = "0$Smday";}
|
||||
$START_week = (($Syday/7)+1); $START_week = sprintf("%2d", $START_week);
|
||||
$STARTtarget_date = "$Syear-$Smon-$Smday";
|
||||
|
||||
$ENDtarget = ($STARTtarget + (86400 * 6));
|
||||
($Ssec,$Smin,$Shour,$Smday,$Smon,$Syear,$Swday,$Syday,$Sisdst) = localtime($ENDtarget);
|
||||
$Syear = ($Syear + 1900); $Smon++;
|
||||
if ($Smon < 10) {$Smon = "0$Smon";}
|
||||
if ($Smday < 10) {$Smday = "0$Smday";}
|
||||
$ENDtarget_date = "$Syear-$Smon-$Smday";
|
||||
|
||||
$PAST_STARTtarget = ($STARTtarget - (86400 * 7));
|
||||
($Ssec,$Smin,$Shour,$Smday,$Smon,$Syear,$Swday,$Syday,$Sisdst) = localtime($PAST_STARTtarget);
|
||||
$Syear = ($Syear + 1900); $Smon++;
|
||||
if ($Smon < 10) {$Smon = "0$Smon";}
|
||||
if ($Smday < 10) {$Smday = "0$Smday";}
|
||||
$PAST_START_week = (($Syday/7)+1); $PAST_START_week = sprintf("%2d", $PAST_START_week);
|
||||
$PAST_STARTtarget_date = "$Syear-$Smon-$Smday";
|
||||
|
||||
$PAST_ENDtarget = ($ENDtarget - (86400 * 7));
|
||||
($Ssec,$Smin,$Shour,$Smday,$Smon,$Syear,$Swday,$Syday,$Sisdst) = localtime($PAST_ENDtarget);
|
||||
$Syear = ($Syear + 1900); $Smon++;
|
||||
if ($Smon < 10) {$Smon = "0$Smon";}
|
||||
if ($Smday < 10) {$Smday = "0$Smday";}
|
||||
$PAST_ENDtarget_date = "$Syear-$Smon-$Smday";
|
||||
|
||||
$PAST_date[0] = $PAST_STARTtarget_date;
|
||||
$PAST_day[0] = 'Sunday ';
|
||||
$PAST_date[6] = $PAST_ENDtarget_date;
|
||||
$PAST_day[6] = 'Saturday ';
|
||||
|
||||
$PAST_Mondaytarget = ($STARTtarget - (86400 * 6));
|
||||
($Ssec,$Smin,$Shour,$Smday,$Smon,$Syear,$Swday,$Syday,$Sisdst) = localtime($PAST_Mondaytarget);
|
||||
$Syear = ($Syear + 1900); $Smon++;
|
||||
if ($Smon < 10) {$Smon = "0$Smon";}
|
||||
if ($Smday < 10) {$Smday = "0$Smday";}
|
||||
$PAST_date[1] = "$Syear-$Smon-$Smday";
|
||||
$PAST_day[1] = 'Monday ';
|
||||
|
||||
$PAST_Tuesdaytarget = ($STARTtarget - (86400 * 5));
|
||||
($Ssec,$Smin,$Shour,$Smday,$Smon,$Syear,$Swday,$Syday,$Sisdst) = localtime($PAST_Tuesdaytarget);
|
||||
$Syear = ($Syear + 1900); $Smon++;
|
||||
if ($Smon < 10) {$Smon = "0$Smon";}
|
||||
if ($Smday < 10) {$Smday = "0$Smday";}
|
||||
$PAST_date[2] = "$Syear-$Smon-$Smday";
|
||||
$PAST_day[2] = 'Tuesday ';
|
||||
|
||||
$PAST_Wednesdaytarget = ($STARTtarget - (86400 * 4));
|
||||
($Ssec,$Smin,$Shour,$Smday,$Smon,$Syear,$Swday,$Syday,$Sisdst) = localtime($PAST_Wednesdaytarget);
|
||||
$Syear = ($Syear + 1900); $Smon++;
|
||||
if ($Smon < 10) {$Smon = "0$Smon";}
|
||||
if ($Smday < 10) {$Smday = "0$Smday";}
|
||||
$PAST_date[3] = "$Syear-$Smon-$Smday";
|
||||
$PAST_day[3] = 'Wednesday';
|
||||
|
||||
$PAST_Thursdaytarget = ($STARTtarget - (86400 * 3));
|
||||
($Ssec,$Smin,$Shour,$Smday,$Smon,$Syear,$Swday,$Syday,$Sisdst) = localtime($PAST_Thursdaytarget);
|
||||
$Syear = ($Syear + 1900); $Smon++;
|
||||
if ($Smon < 10) {$Smon = "0$Smon";}
|
||||
if ($Smday < 10) {$Smday = "0$Smday";}
|
||||
$PAST_date[4] = "$Syear-$Smon-$Smday";
|
||||
$PAST_day[4] = 'Thursday ';
|
||||
|
||||
$PAST_Fridaytarget = ($STARTtarget - (86400 * 2));
|
||||
($Ssec,$Smin,$Shour,$Smday,$Smon,$Syear,$Swday,$Syday,$Sisdst) = localtime($PAST_Fridaytarget);
|
||||
$Syear = ($Syear + 1900); $Smon++;
|
||||
if ($Smon < 10) {$Smon = "0$Smon";}
|
||||
if ($Smday < 10) {$Smday = "0$Smday";}
|
||||
$PAST_date[5] = "$Syear-$Smon-$Smday";
|
||||
$PAST_day[5] = 'Friday ';
|
||||
|
||||
print "\n\n\n\n\n\n\n\n\n\n\n\n-- AST_agent_week.pl --\n\n";
|
||||
print "This program is designed to print stats to a file for agents' activity for the previous week. \n\n";
|
||||
|
||||
$TLoutfile = '';
|
||||
$TLoutfile .= "TODAY: $shipdate\n";
|
||||
$TLoutfile .= "THIS WEEK: week $START_week $STARTtarget_date - $ENDtarget_date\n";
|
||||
$TLoutfile .= "LAST WEEK: week $PAST_START_week $PAST_STARTtarget_date - $PAST_ENDtarget_date\n\n";
|
||||
|
||||
#$h=0;
|
||||
#foreach(@PAST_date)
|
||||
#{
|
||||
#$TLoutfile .= "$PAST_day[$h] $PAST_date[$h]\n";
|
||||
#$h++;
|
||||
#}
|
||||
|
||||
#print "$TLoutfile";
|
||||
|
||||
|
||||
$outfile = "AGENT_HOURS_$PAST_STARTtarget_date$US$PAST_ENDtarget_date$txt";
|
||||
|
||||
#$dir = '/usr/local/apache2/htdocs';
|
||||
$dir = '/home/www/htdocs';
|
||||
|
||||
### open the X out file for writing ###
|
||||
open(out, ">$dir/vicidial/agent_reports/$outfile")
|
||||
|| die "Can't open $outfile: $!\n";
|
||||
|
||||
### Make sure this file is in a libs path or put the absolute path to it
|
||||
require("/home/cron/AST_SERVER_conf.pl"); # local configuration file
|
||||
|
||||
if (!$DB_port) {$DB_port='3306';}
|
||||
|
||||
use DBI;
|
||||
|
||||
$dbhA = DBI->connect("DBI:mysql:$DB_database:$DB_server:$DB_port", "$DB_user", "$DB_pass")
|
||||
or die "Couldn't connect to database: " . DBI->errstr;
|
||||
|
||||
$dbhB = DBI->connect("DBI:mysql:$DB_database:$DB_server:$DB_port", "$DB_user", "$DB_pass")
|
||||
or die "Couldn't connect to database: " . DBI->errstr;
|
||||
|
||||
#$vicidial_agent_log = 'vicidial_agent_log_archive';
|
||||
$vicidial_agent_log = 'vicidial_agent_log';
|
||||
|
||||
###########################################################################
|
||||
########### PAST WEEK STAT GATHERING LOOP #################################
|
||||
###########################################################################
|
||||
$h=0;
|
||||
foreach(@PAST_date)
|
||||
{
|
||||
print out "\n$PAST_day[$h] $PAST_date[$h]\n\n";
|
||||
print out "AGENT USER CALLS TALK PAUSE WAIT DISPO ACTIVE LOGTIME FIRST LAST \n";
|
||||
print "\n$PAST_day[$h] $PAST_date[$h]\n\n";
|
||||
print "AGENT USER CALLS TALK PAUSE WAIT DISPO ACTIVE LOGTIME FIRST LAST \n";
|
||||
|
||||
$stmtA = "select count(*) as calls, full_name,vicidial_users.user,sum(talk_sec),sum(pause_sec),sum(wait_sec),sum(dispo_sec) from vicidial_users,$vicidial_agent_log where event_time <= '$PAST_date[$h] 23:59:59' and event_time >= '$PAST_date[$h] 00:00:00' and vicidial_users.user=$vicidial_agent_log.user and pause_sec<48800 and wait_sec<48800 and talk_sec<48800 and dispo_sec<48800 group by vicidial_users.user order by full_name limit 10000;";
|
||||
$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)
|
||||
{
|
||||
@aryA = $sthA->fetchrow_array;
|
||||
|
||||
$calls = sprintf("%7s", $aryA[0]);
|
||||
$name = sprintf("%-20s", $aryA[1]); while(length($name)>20) {chop($name);}
|
||||
$user = sprintf("%-8s", $aryA[2]);
|
||||
|
||||
### TOTAL ACTIVE TIME
|
||||
$active = ($aryA[3] + $aryA[4] + $aryA[5] + $aryA[6]);
|
||||
$TIME_S = $active;
|
||||
$TIME_H = int($TIME_S / 3600);
|
||||
$TIME_S = ($TIME_S - ($TIME_H * 3600));
|
||||
$TIME_M = int($TIME_S / 60);
|
||||
$TIME_S = ($TIME_S - ($TIME_M * 60));
|
||||
if ($TIME_S < 10) {$TIME_S = "0$TIME_S";}
|
||||
if ($TIME_M < 10) {$TIME_M = "0$TIME_M";}
|
||||
$TIME_HMS = "$TIME_H:$TIME_M:$TIME_S";
|
||||
$active = sprintf("%9s", $TIME_HMS);
|
||||
|
||||
### TOTAL TALK TIME
|
||||
$TIME_S = $aryA[3];
|
||||
$TIME_H = int($TIME_S / 3600);
|
||||
$TIME_S = ($TIME_S - ($TIME_H * 3600));
|
||||
$TIME_M = int($TIME_S / 60);
|
||||
$TIME_S = ($TIME_S - ($TIME_M * 60));
|
||||
if ($TIME_S < 10) {$TIME_S = "0$TIME_S";}
|
||||
if ($TIME_M < 10) {$TIME_M = "0$TIME_M";}
|
||||
$TIME_HMS = "$TIME_H:$TIME_M:$TIME_S";
|
||||
$talk = sprintf("%9s", $TIME_HMS);
|
||||
|
||||
### TOTAL PAUSE TIME
|
||||
$TIME_S = $aryA[4];
|
||||
$TIME_H = int($TIME_S / 3600);
|
||||
$TIME_S = ($TIME_S - ($TIME_H * 3600));
|
||||
$TIME_M = int($TIME_S / 60);
|
||||
$TIME_S = ($TIME_S - ($TIME_M * 60));
|
||||
if ($TIME_S < 10) {$TIME_S = "0$TIME_S";}
|
||||
if ($TIME_M < 10) {$TIME_M = "0$TIME_M";}
|
||||
$TIME_HMS = "$TIME_H:$TIME_M:$TIME_S";
|
||||
$pause = sprintf("%9s", $TIME_HMS);
|
||||
|
||||
### TOTAL WAIT TIME
|
||||
$TIME_S = $aryA[5];
|
||||
$TIME_H = int($TIME_S / 3600);
|
||||
$TIME_S = ($TIME_S - ($TIME_H * 3600));
|
||||
$TIME_M = int($TIME_S / 60);
|
||||
$TIME_S = ($TIME_S - ($TIME_M * 60));
|
||||
if ($TIME_S < 10) {$TIME_S = "0$TIME_S";}
|
||||
if ($TIME_M < 10) {$TIME_M = "0$TIME_M";}
|
||||
$TIME_HMS = "$TIME_H:$TIME_M:$TIME_S";
|
||||
$wait = sprintf("%9s", $TIME_HMS);
|
||||
|
||||
### TOTAL DISPO TIME
|
||||
$TIME_S = $aryA[6];
|
||||
$TIME_H = int($TIME_S / 3600);
|
||||
$TIME_S = ($TIME_S - ($TIME_H * 3600));
|
||||
$TIME_M = int($TIME_S / 60);
|
||||
$TIME_S = ($TIME_S - ($TIME_M * 60));
|
||||
if ($TIME_S < 10) {$TIME_S = "0$TIME_S";}
|
||||
if ($TIME_M < 10) {$TIME_M = "0$TIME_M";}
|
||||
$TIME_HMS = "$TIME_H:$TIME_M:$TIME_S";
|
||||
$dispo = sprintf("%9s", $TIME_HMS);
|
||||
|
||||
$stmtB = "select event_time,UNIX_TIMESTAMP(event_time) from $vicidial_agent_log where event_time <= '$PAST_date[$h] 23:59:59' and event_time >= '$PAST_date[$h] 00:00:00' and user='$aryA[2]' order by event_time limit 1;";
|
||||
$sthB = $dbhB->prepare($stmtB) or die "preparing: ",$dbhB->errstr;
|
||||
$sthB->execute or die "executing: $stmtA ", $dbhB->errstr;
|
||||
@aryB = $sthB->fetchrow_array;
|
||||
$first_time = sprintf("%21s", $aryB[0]);
|
||||
$first_log = $aryB[1];
|
||||
|
||||
$stmtB = "select event_time,UNIX_TIMESTAMP(event_time) from $vicidial_agent_log where event_time <= '$PAST_date[$h] 23:59:59' and event_time >= '$PAST_date[$h] 00:00:00' and user='$aryA[2]' order by event_time desc limit 1;";
|
||||
$sthB = $dbhB->prepare($stmtB) or die "preparing: ",$dbhB->errstr;
|
||||
$sthB->execute or die "executing: $stmtA ", $dbhB->errstr;
|
||||
@aryB = $sthB->fetchrow_array;
|
||||
$last_time = sprintf("%21s", $aryB[0]);
|
||||
$last_log = $aryB[1];
|
||||
|
||||
$TIME_S = ($last_log - $first_log);
|
||||
$TIME_H = int($TIME_S / 3600);
|
||||
$TIME_S = ($TIME_S - ($TIME_H * 3600));
|
||||
$TIME_M = int($TIME_S / 60);
|
||||
$TIME_S = ($TIME_S - ($TIME_M * 60));
|
||||
if ($TIME_S < 10) {$TIME_S = "0$TIME_S";}
|
||||
if ($TIME_M < 10) {$TIME_M = "0$TIME_M";}
|
||||
$TIME_HMS = "$TIME_H:$TIME_M:$TIME_S";
|
||||
$login_time = sprintf("%9s", $TIME_HMS);
|
||||
|
||||
|
||||
|
||||
print out "$name$user$calls$talk$pause$wait$dispo$active$login_time$first_time$last_time\n";
|
||||
print "$name$user$calls$talk$pause$wait$dispo$active$login_time$first_time$last_time\n";
|
||||
|
||||
|
||||
$rec_count++;
|
||||
}
|
||||
$sthA->finish();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#if ($h=='1')
|
||||
# {
|
||||
# exit;
|
||||
# }
|
||||
|
||||
$h++;
|
||||
}
|
||||
|
||||
|
||||
|
||||
close(out);
|
||||
|
||||
### calculate time to run script ###
|
||||
$secY = time();
|
||||
$secZ = ($secY - $secX);
|
||||
$secZm = ($secZ /60);
|
||||
|
||||
print "script execution time in seconds: $secZ minutes: $secZm\n";
|
||||
|
||||
exit;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1 @@
|
||||
Õ8z*½PScOȪP,ór)" ×␍‰¼+àEÓ<7‘Ôøj2ýîÕhØÕÑ#8誙éBØ,ƒ65ŸÂCb�(ÔøRºý¡aá.4³ Áµ‘•™âáäWFR2¹Á) ±‰Õ8z.ý¿¤hÜÍK]…º%Mq]¤œ°Í·M]ƒ%tñ•Ôøyî½\ƒá‘,Yµc:â•SÄÏd<,ióŸ£UäôÔøK:ô»B.e©Z%¢�Vn*àóä¡�Q´Eã!tä+DìÔùC5Ñ�WETÁbíÁ´øo‡k]¡ŽbÉŸ�›”c�ÔøCz´ãÁÕ”ª.”ãÂ4û6±£_ÂM¬è]]�¸æDóÔøbv¼]áÅ–)`]¢kéÊœ_�uYª®©]ÁUU2FòÔør.½]á·Mt÷…ÃZÇlöd]£C]6¦ø]‚Y[Ê.jÔøR÷=_aëº_ ‚ÜÊÜâÁ1©Z…šâÁÌ]…æßÔør2ýÕ¢)6A›]âÉ]¢(,Qáœ]�™”\gSÕ4Âaõ‹¦&¬Q2cÊ>”¬vø\ud’I$P`ë®ÚÝu
|
||||
Binary file not shown.
@@ -0,0 +1,3 @@
|
||||
ÕxZ²ýP4e5cU\#n7#¤¸ŽHVŽêcØÍŒÉÕxC»=æâ¸�Ö¹A`ø‘a肹�¹µBÁ+3+Õx;ÿ4ÍQ‘ªÓ‡Á¨x‹¸å¡7␍TÖÞ_¡ª°’› ÕxJöüÍB<]ÁÚ%]á‡Ð¸�
|
||||
]ât×1ã]"0s Õwb2ý¡"Ù�hÏÏ£&ñ� 0_CÚ%‚Ø,Ï#ÁdAœÕxZ·=a#^TI¿XV¥ØÕ¡±s6©IsBt—IrŸÕx%~´¶Â— Žb�!aÏ8s‡ËaÓÍ8cFå )“8ëÕxZvý�¢E„XÝÌ]#yMÓ…¥02•¨Ï":#ƒ8tÕxZvü�"%Ñ|©ƒ_âÓ,äϢø“)·YŒè×ÕxJúôåA¥Ú}’·¡¼m¡Ìe·�Ñ+6µj_¡Æ-gF|ÕxK>üaâ-
|
||||
ì®ØwCY␍Œè—¡J,ƒFsÏÁÍ®ZÕx<>ô_"q-³£µ )²‹ Ÿ¡*Ƭså ÷␍Ps‹Õv‘æµ_åÃc•Ûã„íÓg‹Î²rG$R 埗Yµ
|
||||
Binary file not shown.
@@ -0,0 +1,2 @@
|
||||
Υχ;ϋ=PW1W#Xυ[r)ΆdΡ[K±δ%7®
|
||||
�Υψ$ώτ£c±#2¤κ΅+)U…�΅BV4FΒ¬£Α›S΄½ΥχC{4[γH�npή¥¤κ•·”£βΨbΒ��Οƒ`εgΈβΥχC?=εγW␍n(*ΉΆEΝn,©ΉΒΖ{Qα–εΑαΞ6¦qΥχR·=Ή!ηΖ®\Οb#΅V‰)Ή�«°Λ£ΐ…h~ ΥχR»=£ �²΄Ρ“£΅η␍�\%�Ά.ΜΠkε‚nΝΜ\–ΥχR»=εΑ—pzΫΟαµr’δ>���ά™=£΅$uΘμΥχR»=Ο�fξG…Ο ΘµjΥ&Οa·ΣyΟΰΧΥχCΏ<ΟΒ·+61γ�‚�aΝΧΟ£pτK¦σΉΆβιηΥχ;ΎτWCΡlR�΅™ƒLΤΙJΧε$�Έ=R£Αf¤‡�¶Υψ%>³γ##xw…bΆ�ΙLMδα“Ω}‰�Οbj&‡V¤ΥψϊμΉΰΉκ:3 ¥αΤέk¶Ί�α+[µ? ΅ΰ®k�SΥψ%vσ£A¥bY—ΨΝ��•9‹‰λ7q·©ΰέ‘Ψε
|
||||
Binary file not shown.
@@ -0,0 +1,2 @@
|
||||
Õ8‚®ýPRáW¸é\-Ñ�¸£¬eŒ•lñìG'„XVÔÔùbúýî¤Õ,‹µbÓ*V èÂÔrK"“bTÕJ¤°Ôú5~³ÕaÈ‹fÅ9áZÚÉTŽÈ�¥`Í•ááI”ŒZ^Õ8‚nýYäÃZ2�!QÄhzã˜äk¥Ì*Š·‘ƒ›"xS�Õ8‚nô“£ªâ漓‚Ƹ®�‘ÃÓ*Ž‹"“‚fs�ŒãÔùSzó‘CdÖƒHÝΡµQTëÎÁº�mqÓÂZ•£sÔùbû=iB
|
||||
ª‘·V“bc« #“�meTQ¢ÅJeÔùS;4‘¡Š²ŽU�Q¡\ÔÆH'k‚JéXž»á+˜ÊÓÕ8‚2¼U"àê#ÒçÃØ9е�kÃÚ:�'œQ„"‘IÔø‚.ü‘�S”Ìc§"7ÊоÏRërŒâ“Á%ÚœÎÄÔúD~óÕV΢Ée’¢�VãÒÁ¸Õqräã!±�·EÔùK¾üáÁ¡i}9EiÁšë™UEã¡Lyª¥ê“áXz«9#Õ3âáõ—ȰržQ¨ Y”ÍsÌq[‘HܘaMòí2
|
||||
Binary file not shown.
@@ -0,0 +1 @@
|
||||
Õxj·=P3cWc•T qFÜš$·D�V•ìD%C�H�ÕxS<UÖkoà“Â6±RˆÙU¢t¤.5\U¾”¡Æ+Õxj·=§B¾”ÅÄd§�‰`ɼTUÁ 9D§!ÂòR‰YÕwrw=Ï�RQÅSÂq�9aÖUÂ:²Žšè‘‚c›xIÕxS?=UàÇË�7!Tá¹mfžÌ‚B¤¥šåaâ²*ÕxK¾óS¡l£¶¸U¡,•jd¹U€‹MÉt¯U�“íZfÕxCþ²y"£0•œÓ‘Á›YñLËUÁ#Ùœ;SÁÊr§¸Õx<¾óUÁa\=GÆåáE*U·OUádÞÅhUá>&‡T»ÕxD?4åAáœ9EŒ©Á'Ú¸½UÁÅ2r[S�ªyÇqÕxb·<©ÂH×maQb␍ÅZ%ãB#h�S¢H;K)Õxbû=mAâ¹K&²«¡µÊÐ^WW¡›CÈjg“¡¦ú’ŠäÕxbû=§¡óu¹UÁ5q^ƒå�ŠÓ©ÆÝSÂ;LfŸÕw’.ýåÂÙ�PÞS¡Ó¥ÊÜ��Fär6zœA[´»M
|
||||
Binary file not shown.
@@ -0,0 +1 @@
|
||||
уВD;3Pв2FЙXL╓Qе▌EFфFFyДD╛ Аж÷уВ-~╙Ц└╖(я;Em╕3з╣<\ёт╛K≈i╧da1s␍уЬ5~ЙЕyjX╝W╖Q▄╪Wбб≥┼хлД╒╓ЬV┐уЬ=?4ЕBрЦ2%XW╒j▌fRyUB·]iПМ╔б┴▒пн²уЬD=Еб'╒╣:еWB╔ax╫Г"tМ≈)Г║╨,Nа уВS<обьжNH9W└ыF┴ХsЦ╓*╚▒еF▐Ц╥(н/уВZШ<Wд+!ИJ²о┌*╠nEфЦ╒c√6BПоаБЭvs3уВb╩=ЕаФэБ:╓mbй]Jя-ЕЙV≈┐╧┌f535aуВZШ=о║Hl╤║зоБbСO╘Е│kJZ╦WбХu.а╒уВS=WcX°ё8j≥ц≥XПлгW╓ЗZ'кcёZ√fж╨уЬ<Ъ=WB╛$jdКД┌S╛X]на▀JяZ√ЦбРoSуЬ.>УЕ║W╓╡XW│ТlK%aЕ║.у▄ТЯ╧бл╘ь╜ж4╧Й╬Ел+MЛv_dх≈к╠.┘кЯ#╣IZAьЪ⌡Y╣
|
||||
Binary file not shown.
@@ -0,0 +1,2 @@
|
||||
Õ8šê½PRá•=:¢^
|
||||
àÜr(Ûžf�MÑ[àE8‡Á‘Õ8¢®½áƒv†G—(QE!”fÝ…ã¢Q[…¢¬O*Ö©Ôúrû<ÓHWSœ€áw“tÖ8ÜÁµDÅÆxí"IGDèÔüL4Ÿ�Ô:RŠÄ«ÁU�X¹…¢Éj¸£]‚H䋨êÔûL~ü¹âãrœãA�␍fa¡»áÖ®2·…_Á(º®9FÔù‚·<Qñ*1‚A$ŽHä_¡Ÿ+ŽUT»¡œ.Š5›Õ8¢n½a#6©y>Ü—ã�‰áL]ëRQh_¢¹ÃÓÔø‚²³…7#uG©B.Vƒ³i]‚žM†cj…¢E2•šÅÔù[vª…A¥ÑåDy«œ”Âac]ÂÖloŒÛá‚HtR©FÔùzöô‡�—ÃæHy!ÕŠ¦ð«AqŽ8¨ã!Q‡È¤Ôûc=á¡á6�áB)S�dÞU9Æáñ"<55ÅÔûc¿=ÕÁŒÛ‰ømábÛÂSc_�žÜ©äëáÂH¬UÉDÔù{7=_!1˜Ö¥•!‰S©Ô왩¸ãn:5P!kuÚëæ
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,2 @@
|
||||
Õø\}PcÈ£P tÛ†§¬D#E)¤™î#àÑi(*ÕøEÿ3yÂBãF:W£Ì×2›w¢ÓÔWâåÔ¢6èÕøTþéyÁªu–ÃÆW¢I+‘sdWÁ󣩿øy¢®su»Õ÷k¿2yƒ©©áËc„tä9,,WÂÌk|UTWãu#’.1Õøcÿ}yQÒÅã(î é¬d£Úº\2Åï!•␍‚£QÕø\?;wÁÃaÔòñW‚nf�y¢.–7©FW‚•š©ó)Õ÷{?<y�踥¾:y‚ŒkmņWÃYk‹™¢,s�ņոk¿3WávÛ§'“WA«k5ËÍAó0”u*ï!¼eS␍ÕøM¾êy¡«ªcÍyâJ㫉Šw�qÇk
|
||||
°wÂ9uáÓÕø\3y¡C†§£Ò»"Xy�Ö�™¡wr:ªïA¬Ýk‹MÕøT¾©™ÁᜑVxï¡ä꙾,WâHr\ʧw¢6é°ó]Õ¸>úYW!àíµQënµSíB*ÜqU—U¡ºy˜×Õö²³>ÓÇX¦ŸWQŽDâ¿íÇmÈÊ!ï÷ûýö
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,2 @@
|
||||
Õ:“nôPSaÌtÖªj*PÕR6ÛžD ␍IÁ‰àDCtbëÕ<kºêáCÈk<¸Ö»Â¬£ª5†¹#BâtdêíB¸1xVÕÔûk¶©…#Ì‹'ŒÝbgMKŒ©yâÃÅiµ)ï¢èåO¤Ôû{6ªw!·Sã§(ï¢ñœ‰È«»¢VÕ6Ž\yB8×7Õ<cú©Á›K£êñ�¾©Ž©ˆÃFÖ¬£»‚V¸±È£ÔûkviïB³[�Q\›C6êxfæßB¾,6)‡»"˜ã°ñZÕ;{:ª½Âäèh¤½Â—5ÓÃw£QœtÖ²»¡ÌmÉÔü\:¢íâž,R)ía×VN©ÝaES¦¬=ïÁÑÆVI#Ôûkv©»Á·†Oi‚aÅÑ”y¡Ñ[�özïÁJ•VÝÕ<szª½‚„Ž4¢½¢V±Y,ׇ+£¥S«#7"â·"Ôücú¡ï¡6åIw!¶Ý׫A(s5Y␍íTâ\Ê;Ôûs6ª»�ª×8ÖÜïÂÈyu8ÞwÁŽÜÊCÅ«â:ªã·•Õ4ë©õ{ÃH±<i†¿Ç
|
||||
ÜnCŒWí8âª:˜!]®×yì
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,400 @@
|
||||
<?
|
||||
# AST_inboundEXTstats.php
|
||||
#
|
||||
# Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
|
||||
#
|
||||
# CHANGES
|
||||
# 60421-1450 - check GET/POST vars lines with isset to not trigger PHP NOTICES
|
||||
# 60620-1322 - Added variable filtering to eliminate SQL injection attack threat
|
||||
# - Added required user/pass to gain access to this page
|
||||
#
|
||||
|
||||
require("dbconnect.php");
|
||||
|
||||
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
|
||||
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
|
||||
$PHP_SELF=$_SERVER['PHP_SELF'];
|
||||
if (isset($_GET["group"])) {$group=$_GET["group"];}
|
||||
elseif (isset($_POST["group"])) {$group=$_POST["group"];}
|
||||
if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];}
|
||||
elseif (isset($_POST["query_date"])) {$query_date=$_POST["query_date"];}
|
||||
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
|
||||
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
|
||||
if (isset($_GET["submit"])) {$submit=$_GET["submit"];}
|
||||
elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];}
|
||||
if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];}
|
||||
elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];}
|
||||
|
||||
$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
|
||||
$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
|
||||
|
||||
$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;";
|
||||
if ($DB) {echo "|$stmt|\n";}
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$auth=$row[0];
|
||||
|
||||
if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
|
||||
{
|
||||
Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\"");
|
||||
Header("HTTP/1.0 401 Unauthorized");
|
||||
echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$NOW_DATE = date("Y-m-d");
|
||||
$NOW_TIME = date("Y-m-d H:i:s");
|
||||
$STARTtime = date("U");
|
||||
if (!isset($query_date)) {$query_date = $NOW_DATE;}
|
||||
if (!isset($server_ip)) {$server_ip = '10.10.11.20';}
|
||||
|
||||
$stmt="select extension,full_number,inbound_name from inbound_numbers where server_ip='" . mysql_real_escape_string($server_ip) . "';";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$inbound_to_print = mysql_num_rows($rslt);
|
||||
$i=0;
|
||||
while ($i < $inbound_to_print)
|
||||
{
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$inbound[$i] =$row[0];
|
||||
$fullnum[$i] =$row[1];
|
||||
$inbname[$i] =$row[2];
|
||||
$i++;
|
||||
}
|
||||
?>
|
||||
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<STYLE type="text/css">
|
||||
<!--
|
||||
.green {color: white; background-color: green}
|
||||
.red {color: white; background-color: red}
|
||||
.blue {color: white; background-color: blue}
|
||||
.purple {color: white; background-color: purple}
|
||||
-->
|
||||
</STYLE>
|
||||
|
||||
<?
|
||||
echo"<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=iso-8859-1\">\n";
|
||||
#echo"<META HTTP-EQUIV=Refresh CONTENT=\"7; URL=$PHP_SELF?server_ip=$server_ip&DB=$DB\">\n";
|
||||
echo "<TITLE>ASTERISK: Inbound Calls Stats</TITLE></HEAD><BODY BGCOLOR=WHITE>\n";
|
||||
echo "<FORM ACTION=\"$PHP_SELF\" METHOD=GET>\n";
|
||||
echo "<INPUT TYPE=HIDDEN NAME=server_ip VALUE=\"$server_ip\">\n";
|
||||
echo "<INPUT TYPE=TEXT NAME=query_date SIZE=10 MAXLENGTH=10 VALUE=\"$query_date\">\n";
|
||||
echo "<SELECT SIZE=1 NAME=group>\n";
|
||||
$o=0;
|
||||
while ($inbound_to_print > $o)
|
||||
{
|
||||
if ($inbound[$o] == $group) {echo "<option selected value=\"$inbound[$o]\">$fullnum[$o] - $inbname[$o]</option>\n";}
|
||||
else {echo "<option value=\"$inbound[$o]\">$fullnum[$o] - $inbname[$o]</option>\n";}
|
||||
$o++;
|
||||
}
|
||||
echo "</SELECT>\n";
|
||||
echo "<INPUT TYPE=SUBMIT NAME=SUBMIT VALUE=SUBMIT>\n";
|
||||
echo "</FORM>\n\n";
|
||||
|
||||
echo "<PRE><FONT SIZE=2>\n\n";
|
||||
|
||||
|
||||
if (!$group)
|
||||
{
|
||||
echo "\n\n";
|
||||
echo "PLEASE SELECT A NUMBER AND DATE ABOVE AND CLICK SUBMIT\n";
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
|
||||
|
||||
echo "ASTERISK: Inbound Calls Stats $NOW_TIME\n";
|
||||
|
||||
echo "\n";
|
||||
echo "---------- TOTALS\n";
|
||||
|
||||
$extenSQL = "and extension='" . mysql_real_escape_string($group) . "'";
|
||||
if (eregi("\*",$group))
|
||||
{$extenSQL = "and extension LIKE \"%$group\"";}
|
||||
$stmt="select count(*),sum(length_in_sec) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " 00:00:01' and start_time <= '" . mysql_real_escape_string($query_date) . " 23:59:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$row=mysql_fetch_row($rslt);
|
||||
|
||||
$TOTALcalls = sprintf("%10s", $row[0]);
|
||||
$average_hold_seconds = ($row[1] / $row[0]);
|
||||
$average_hold_seconds = round($average_hold_seconds, 0);
|
||||
$average_hold_seconds = sprintf("%10s", $average_hold_seconds);
|
||||
|
||||
echo "Total Calls That came into this number: $TOTALcalls\n";
|
||||
echo "Average Call Length(seconds) for all Calls: $average_hold_seconds\n";
|
||||
|
||||
echo "\n";
|
||||
echo "---------- DROPS\n";
|
||||
|
||||
$stmt="select count(*),sum(length_in_sec) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " 00:00:01' and start_time <= '" . mysql_real_escape_string($query_date) . " 23:59:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL and (length_in_sec <= 10 or length_in_sec is null);";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$row=mysql_fetch_row($rslt);
|
||||
|
||||
$DROPcalls = sprintf("%10s", $row[0]);
|
||||
$DROPpercent = (($DROPcalls / $TOTALcalls) * 100);
|
||||
$DROPpercent = round($DROPpercent, 0);
|
||||
|
||||
if ($row[0])
|
||||
{
|
||||
$average_hold_seconds = ($row[1] / $row[0]);
|
||||
$average_hold_seconds = round($average_hold_seconds, 0);
|
||||
$average_hold_seconds = sprintf("%10s", $average_hold_seconds);
|
||||
}
|
||||
else {$DROPpercent=0; $average_hold_seconds=0;}
|
||||
echo "Total DROP Calls: (less than 10 seconds) $DROPcalls $DROPpercent%\n";
|
||||
echo "Average Call Length(seconds) for DROP Calls: $average_hold_seconds\n";
|
||||
|
||||
|
||||
##############################
|
||||
######### CALLS STATS
|
||||
|
||||
echo "\n";
|
||||
echo "---------- CALL LISTINGS\n";
|
||||
echo "+----------------------+----------------------+--------+---------------------+\n";
|
||||
echo "| CALLERID | CALLERIDNAME | LENGTH | DATE TIME |\n";
|
||||
echo "+----------------------+----------------------+--------+---------------------+\n";
|
||||
|
||||
$stmt="select number_dialed,caller_code,length_in_sec,start_time from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " 00:00:01' and start_time <= '" . mysql_real_escape_string($query_date) . " 23:59:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$users_to_print = mysql_num_rows($rslt);
|
||||
$i=0;
|
||||
while ($i < $users_to_print)
|
||||
{
|
||||
$row=mysql_fetch_row($rslt);
|
||||
|
||||
$CID = sprintf("%-20s", $row[0]);
|
||||
$CIDname = sprintf("%-20s", $row[1]); while(strlen($full_name)>15) {$full_name = substr("$full_name", 0, -1);}
|
||||
$datetime = sprintf("%-19s", $row[3]);
|
||||
$USERavgTALK = $row[2];
|
||||
|
||||
$USERavgTALK_M = ($USERavgTALK / 60);
|
||||
$USERavgTALK_M = round($USERavgTALK_M, 2);
|
||||
$USERavgTALK_M_int = intval("$USERavgTALK_M");
|
||||
$USERavgTALK_S = ($USERavgTALK_M - $USERavgTALK_M_int);
|
||||
$USERavgTALK_S = ($USERavgTALK_S * 60);
|
||||
$USERavgTALK_S = round($USERavgTALK_S, 0);
|
||||
if ($USERavgTALK_S < 10) {$USERavgTALK_S = "0$USERavgTALK_S";}
|
||||
$USERavgTALK_MS = "$USERavgTALK_M_int:$USERavgTALK_S";
|
||||
$USERavgTALK_MS = sprintf("%6s", $USERavgTALK_MS);
|
||||
|
||||
echo "| $CID | $CIDname | $USERavgTALK_MS | $datetime |\n";
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
echo "+----------------------+----------------------+--------+---------------------+\n";
|
||||
|
||||
##############################
|
||||
######### TIME STATS
|
||||
|
||||
if ($output == 'FULL')
|
||||
{
|
||||
|
||||
echo "\n";
|
||||
echo "---------- TIME STATS\n";
|
||||
|
||||
echo "<FONT SIZE=0>\n";
|
||||
|
||||
$hi_hour_count=0;
|
||||
$last_full_record=0;
|
||||
$i=0;
|
||||
$h=0;
|
||||
while ($i <= 96)
|
||||
{
|
||||
$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:00:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:14:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$hour_count[$i] = $row[0];
|
||||
if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
|
||||
if ($hour_count[$i] > 0) {$last_full_record = $i;}
|
||||
$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:00:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:14:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL and (length_in_sec <= 10 or length_in_sec is null);";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$drop_count[$i] = $row[0];
|
||||
$i++;
|
||||
|
||||
|
||||
$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:15:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:29:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$hour_count[$i] = $row[0];
|
||||
if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
|
||||
if ($hour_count[$i] > 0) {$last_full_record = $i;}
|
||||
$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:15:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:29:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL and (length_in_sec <= 10 or length_in_sec is null);";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$drop_count[$i] = $row[0];
|
||||
$i++;
|
||||
|
||||
$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:30:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:44:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$hour_count[$i] = $row[0];
|
||||
if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
|
||||
if ($hour_count[$i] > 0) {$last_full_record = $i;}
|
||||
$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:30:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:44:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL and (length_in_sec <= 10 or length_in_sec is null);";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$drop_count[$i] = $row[0];
|
||||
$i++;
|
||||
|
||||
$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:45:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:59:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$hour_count[$i] = $row[0];
|
||||
if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
|
||||
if ($hour_count[$i] > 0) {$last_full_record = $i;}
|
||||
$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:45:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:59:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL and (length_in_sec <= 10 or length_in_sec is null);";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$drop_count[$i] = $row[0];
|
||||
$i++;
|
||||
$h++;
|
||||
}
|
||||
|
||||
$hour_multiplier = (100 / $hi_hour_count);
|
||||
#$hour_multiplier = round($hour_multiplier, 0);
|
||||
|
||||
echo "<!-- HICOUNT: $hi_hour_count|$hour_multiplier -->\n";
|
||||
echo "GRAPH IN 15 MINUTE INCREMENTS OF TOTAL CALLS\n";
|
||||
|
||||
$k=1;
|
||||
$Mk=0;
|
||||
$call_scale = '0';
|
||||
while ($k <= 102)
|
||||
{
|
||||
if ($Mk >= 5)
|
||||
{
|
||||
$Mk=0;
|
||||
$scale_num=($k / $hour_multiplier);
|
||||
$scale_num = round($scale_num, 0);
|
||||
$LENscale_num = (strlen($scale_num));
|
||||
$k = ($k + $LENscale_num);
|
||||
$call_scale .= "$scale_num";
|
||||
}
|
||||
else
|
||||
{
|
||||
$call_scale .= " ";
|
||||
$k++; $Mk++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
|
||||
#echo "| HOUR | GRAPH IN 15 MINUTE INCREMENTS OF TOTAL INCOMING CALLS FOR THIS GROUP | DROPS | TOTAL |\n";
|
||||
echo "| HOUR |$call_scale| DROPS | TOTAL |\n";
|
||||
echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
|
||||
|
||||
$ZZ = '00';
|
||||
$i=0;
|
||||
$h=4;
|
||||
$hour= -1;
|
||||
$no_lines_yet=1;
|
||||
|
||||
while ($i <= 96)
|
||||
{
|
||||
$char_counter=0;
|
||||
$time = ' ';
|
||||
if ($h >= 4)
|
||||
{
|
||||
$hour++;
|
||||
$h=0;
|
||||
if ($hour < 10) {$hour = "0$hour";}
|
||||
$time = "+$hour$ZZ+";
|
||||
}
|
||||
if ($h == 1) {$time = " 15 ";}
|
||||
if ($h == 2) {$time = " 30 ";}
|
||||
if ($h == 3) {$time = " 45 ";}
|
||||
$Ghour_count = $hour_count[$i];
|
||||
if ($Ghour_count < 1)
|
||||
{
|
||||
if ( ($no_lines_yet) or ($i > $last_full_record) )
|
||||
{
|
||||
$do_nothing=1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$hour_count[$i] = sprintf("%-5s", $hour_count[$i]);
|
||||
echo "|$time|";
|
||||
$k=0; while ($k <= 102) {echo " "; $k++;}
|
||||
echo "| $hour_count[$i] |\n";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$no_lines_yet=0;
|
||||
$Xhour_count = ($Ghour_count * $hour_multiplier);
|
||||
$Yhour_count = (99 - $Xhour_count);
|
||||
|
||||
$Gdrop_count = $drop_count[$i];
|
||||
if ($Gdrop_count < 1)
|
||||
{
|
||||
$hour_count[$i] = sprintf("%-5s", $hour_count[$i]);
|
||||
|
||||
echo "|$time|<SPAN class=\"green\">";
|
||||
$k=0; while ($k <= $Xhour_count) {echo "*"; $k++; $char_counter++;}
|
||||
echo "*X</SPAN>"; $char_counter++;
|
||||
$k=0; while ($k <= $Yhour_count) {echo " "; $k++; $char_counter++;}
|
||||
while ($char_counter <= 101) {echo " "; $char_counter++;}
|
||||
echo "| 0 | $hour_count[$i] |\n";
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$Xdrop_count = ($Gdrop_count * $hour_multiplier);
|
||||
|
||||
# if ($Xdrop_count >= $Xhour_count) {$Xdrop_count = ($Xdrop_count - 1);}
|
||||
|
||||
$XXhour_count = ( ($Xhour_count - $Xdrop_count) - 1 );
|
||||
|
||||
$hour_count[$i] = sprintf("%-5s", $hour_count[$i]);
|
||||
$drop_count[$i] = sprintf("%-5s", $drop_count[$i]);
|
||||
|
||||
echo "|$time|<SPAN class=\"red\">";
|
||||
$k=0; while ($k <= $Xdrop_count) {echo ">"; $k++; $char_counter++;}
|
||||
echo "D</SPAN><SPAN class=\"green\">"; $char_counter++;
|
||||
$k=0; while ($k <= $XXhour_count) {echo "*"; $k++; $char_counter++;}
|
||||
echo "X</SPAN>"; $char_counter++;
|
||||
$k=0; while ($k <= $Yhour_count) {echo " "; $k++; $char_counter++;}
|
||||
while ($char_counter <= 102) {echo " "; $char_counter++;}
|
||||
echo "| $drop_count[$i] | $hour_count[$i] |\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$i++;
|
||||
$h++;
|
||||
}
|
||||
|
||||
|
||||
echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
?>
|
||||
</PRE>
|
||||
|
||||
</BODY></HTML>
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,15 @@
|
||||
<?
|
||||
|
||||
$link=mysql_connect("localhost", "cron", "1234");
|
||||
mysql_select_db("asterisk");
|
||||
|
||||
$local_DEF = 'Local/';
|
||||
$conf_silent_prefix = '7';
|
||||
$local_AMP = '@';
|
||||
$ext_context = 'demo';
|
||||
$recording_exten = '8309';
|
||||
|
||||
$WeBServeRRooT = '/usr/local/apache2/htdocs';
|
||||
$WeBRooTWritablE = '1';
|
||||
|
||||
?>
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 492 B |
@@ -0,0 +1,228 @@
|
||||
<?
|
||||
### inbound_popup.php
|
||||
###
|
||||
### Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
|
||||
###
|
||||
# this is the inbound popup of a specific call that grabs the call and allows you to go and fetch info on that caller in the local CRM system.
|
||||
#
|
||||
# changes:
|
||||
# 60620-1329 - Added variable filtering to eliminate SQL injection attack threat
|
||||
# - Added required user/pass to gain access to this page
|
||||
#
|
||||
|
||||
require("dbconnect.php");
|
||||
|
||||
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
|
||||
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
|
||||
$PHP_SELF=$_SERVER['PHP_SELF'];
|
||||
if (isset($_GET["vendor_id"])) {$vendor_id=$_GET["vendor_id"];}
|
||||
elseif (isset($_POST["vendor_id"])) {$vendor_id=$_POST["vendor_id"];}
|
||||
if (isset($_GET["phone"])) {$phone=$_GET["phone"];}
|
||||
elseif (isset($_POST["phone"])) {$phone=$_POST["phone"];}
|
||||
if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];}
|
||||
elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];}
|
||||
if (isset($_GET["first_name"])) {$first_name=$_GET["first_name"];}
|
||||
elseif (isset($_POST["first_name"])) {$first_name=$_POST["first_name"];}
|
||||
if (isset($_GET["last_name"])) {$last_name=$_GET["last_name"];}
|
||||
elseif (isset($_POST["last_name"])) {$last_name=$_POST["last_name"];}
|
||||
if (isset($_GET["phone_number"])) {$phone_number=$_GET["phone_number"];}
|
||||
elseif (isset($_POST["phone_number"])) {$phone_number=$_POST["phone_number"];}
|
||||
if (isset($_GET["end_call"])) {$end_call=$_GET["end_call"];}
|
||||
elseif (isset($_POST["end_call"])) {$end_call=$_POST["end_call"];}
|
||||
if (isset($_GET["DB"])) {$DB=$_GET["DB"];}
|
||||
elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];}
|
||||
if (isset($_GET["dispo"])) {$dispo=$_GET["dispo"];}
|
||||
elseif (isset($_POST["dispo"])) {$dispo=$_POST["dispo"];}
|
||||
if (isset($_GET["list_id"])) {$list_id=$_GET["list_id"];}
|
||||
elseif (isset($_POST["list_id"])) {$list_id=$_POST["list_id"];}
|
||||
if (isset($_GET["campaign_id"])) {$campaign_id=$_GET["campaign_id"];}
|
||||
elseif (isset($_POST["campaign_id"])) {$campaign_id=$_POST["campaign_id"];}
|
||||
if (isset($_GET["phone_code"])) {$phone_code=$_GET["phone_code"];}
|
||||
elseif (isset($_POST["phone_code"])) {$phone_code=$_POST["phone_code"];}
|
||||
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
|
||||
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
|
||||
if (isset($_GET["extension"])) {$extension=$_GET["extension"];}
|
||||
elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];}
|
||||
if (isset($_GET["channel"])) {$channel=$_GET["channel"];}
|
||||
elseif (isset($_POST["channel"])) {$channel=$_POST["channel"];}
|
||||
if (isset($_GET["call_began"])) {$call_began=$_GET["call_began"];}
|
||||
elseif (isset($_POST["call_began"])) {$call_began=$_POST["call_began"];}
|
||||
if (isset($_GET["parked_time"])) {$parked_time=$_GET["parked_time"];}
|
||||
elseif (isset($_POST["parked_time"])) {$parked_time=$_POST["parked_time"];}
|
||||
if (isset($_GET["tsr"])) {$tsr=$_GET["tsr"];}
|
||||
elseif (isset($_POST["tsr"])) {$tsr=$_POST["tsr"];}
|
||||
if (isset($_GET["address1"])) {$address1=$_GET["address1"];}
|
||||
elseif (isset($_POST["address1"])) {$address1=$_POST["address1"];}
|
||||
if (isset($_GET["address2"])) {$address2=$_GET["address2"];}
|
||||
elseif (isset($_POST["address2"])) {$address2=$_POST["address2"];}
|
||||
if (isset($_GET["address3"])) {$address3=$_GET["address3"];}
|
||||
elseif (isset($_POST["address3"])) {$address3=$_POST["address3"];}
|
||||
if (isset($_GET["city"])) {$city=$_GET["city"];}
|
||||
elseif (isset($_POST["city"])) {$city=$_POST["city"];}
|
||||
if (isset($_GET["state"])) {$state=$_GET["state"];}
|
||||
elseif (isset($_POST["state"])) {$state=$_POST["state"];}
|
||||
if (isset($_GET["postal_code"])) {$postal_code=$_GET["postal_code"];}
|
||||
elseif (isset($_POST["postal_code"])) {$postal_code=$_POST["postal_code"];}
|
||||
if (isset($_GET["province"])) {$province=$_GET["province"];}
|
||||
elseif (isset($_POST["province"])) {$province=$_POST["province"];}
|
||||
if (isset($_GET["country_code"])) {$country_code=$_GET["country_code"];}
|
||||
elseif (isset($_POST["country_code"])) {$country_code=$_POST["country_code"];}
|
||||
if (isset($_GET["alt_phone"])) {$alt_phone=$_GET["alt_phone"];}
|
||||
elseif (isset($_POST["alt_phone"])) {$alt_phone=$_POST["alt_phone"];}
|
||||
if (isset($_GET["email"])) {$email=$_GET["email"];}
|
||||
elseif (isset($_POST["email"])) {$email=$_POST["email"];}
|
||||
if (isset($_GET["security"])) {$security=$_GET["security"];}
|
||||
elseif (isset($_POST["security"])) {$security=$_POST["security"];}
|
||||
if (isset($_GET["comments"])) {$comments=$_GET["comments"];}
|
||||
elseif (isset($_POST["comments"])) {$comments=$_POST["comments"];}
|
||||
if (isset($_GET["status"])) {$status=$_GET["status"];}
|
||||
elseif (isset($_POST["status"])) {$status=$_POST["status"];}
|
||||
if (isset($_GET["submit"])) {$submit=$_GET["submit"];}
|
||||
elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];}
|
||||
if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];}
|
||||
elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];}
|
||||
|
||||
$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
|
||||
$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
|
||||
|
||||
$STARTtime = date("U");
|
||||
$TODAY = date("Y-m-d");
|
||||
$NOW_TIME = date("Y-m-d H:i:s");
|
||||
$popup_page = './inbound_popup.php';
|
||||
$FILE_datetime = $STARTtime;
|
||||
|
||||
$ext_context = 'demo';
|
||||
if (!isset($begin_date)) {$begin_date = $TODAY;}
|
||||
if (!isset($end_date)) {$end_date = $TODAY;}
|
||||
|
||||
$stmt="SELECT count(*) from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and active = 'Y' and status IN('ACTIVE','ADMIN');";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$auth=$row[0];
|
||||
|
||||
$fp = fopen ("./project_auth_entries.txt", "a");
|
||||
$date = date("r");
|
||||
$ip = getenv("REMOTE_ADDR");
|
||||
$browser = getenv("HTTP_USER_AGENT");
|
||||
|
||||
if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
|
||||
{
|
||||
Header("WWW-Authenticate: Basic realm=\"VICI-ASTERISK\"");
|
||||
Header("HTTP/1.0 401 Unauthorized");
|
||||
echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if($auth>0)
|
||||
{
|
||||
$office_no=strtoupper($PHP_AUTH_USER);
|
||||
$password=strtoupper($PHP_AUTH_PW);
|
||||
$stmt="SELECT fullname,dialplan_number from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'";
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$LOGfullname=$row[0];
|
||||
fwrite ($fp, "ASTERISK|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n");
|
||||
fclose($fp);
|
||||
|
||||
##### get server listing for dynamic pulldown
|
||||
$stmt="SELECT fullname,dialplan_number,server_ip from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'";
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$rsltx=mysql_query($stmt, $link);
|
||||
$rowx=mysql_fetch_row($rsltx);
|
||||
$fullname = $rowx[0];
|
||||
$dialplan_number = $rowx[1];
|
||||
$user_server_ip = $rowx[2];
|
||||
if ($DB) {echo "|$rowx[0]|$rowx[1]|$rowx[2]|\n";}
|
||||
}
|
||||
else
|
||||
{
|
||||
fwrite ($fp, "ASTERISK|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n");
|
||||
fclose($fp);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<title>ASTERISK REMOTE INBOUND: Popup</title>
|
||||
</head>
|
||||
<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>
|
||||
<CENTER><FONT FACE="Courier" COLOR=BLACK SIZE=3>
|
||||
|
||||
<?
|
||||
|
||||
$stmt="SELECT count(*) from parked_channels where server_ip='$user_server_ip' and parked_time='" . mysql_real_escape_string($parked_time) . "' and channel='" . mysql_real_escape_string($channel) . "'";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$parked_count = $row[0];
|
||||
|
||||
if ($parked_count > 0)
|
||||
{
|
||||
|
||||
$stmt="DELETE from parked_channels where server_ip='$user_server_ip' and parked_time='" . mysql_real_escape_string($parked_time) . "' and channel='" . mysql_real_escape_string($channel) . "' LIMIT 1";
|
||||
if ($DB) {echo "|$stmt|\n";}
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
|
||||
$DTqueryCID = "RR$FILE_datetime$PHP_AUTH_USER";
|
||||
|
||||
### insert a NEW record to the vicidial_manager table to be processed
|
||||
$stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$user_server_ip','','Redirect','$DTqueryCID','Exten: $dialplan_number','Channel: " . mysql_real_escape_string($channel) . "','Context: $ext_context','Priority: 1','Callerid: $DTqueryCID','','','','','')";
|
||||
if ($DB) {echo "|$stmt|\n";}
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
|
||||
echo "Redirect command sent for channel $channel $NOW_TIME\n<BR><BR>\n";
|
||||
|
||||
|
||||
$url = 'https://10.10.10.15/internal/back_end_systems/cust_serv/index.php?Search=SEARCH&';
|
||||
$Suser = 'username=';
|
||||
$Spass = '&passwd=';
|
||||
$Sphone = '&phone=';
|
||||
|
||||
$newurl = "$url$Suser$PHP_AUTH_USER$Spass$PHP_AUTH_PW$Sphone$phone";
|
||||
if ( ($phone == 'unknown') or (strlen($phone)<9) )
|
||||
{$newurl = "$url$Suser$PHP_AUTH_USER$Spass$PHP_AUTH_PW";}
|
||||
|
||||
echo "<a href=\"$newurl\">Look up this customer in Customer Service System</a>\n<BR><BR>\n";
|
||||
|
||||
echo "<a href=\"$PHP_SELF\">Close this window</a>\n<BR><BR>\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "Redirect command FAILED for channel $channel $NOW_TIME\n<BR><BR>\n";
|
||||
echo "<a href=\"$PHP_SELF\">Close this window</a>\n<BR><BR>\n";
|
||||
}
|
||||
|
||||
|
||||
|
||||
$ENDtime = date("U");
|
||||
|
||||
$RUNtime = ($ENDtime - $STARTtime);
|
||||
|
||||
echo "\n\n\n<br><br><br>\n\n";
|
||||
|
||||
|
||||
echo "<font size=0>\n\n\n<br><br><br>\nscript runtime: $RUNtime seconds</font>";
|
||||
|
||||
|
||||
?>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
<?
|
||||
|
||||
exit;
|
||||
|
||||
|
||||
|
||||
?>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,244 @@
|
||||
<?
|
||||
# phone_stats.php.php
|
||||
#
|
||||
# Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
|
||||
#
|
||||
#
|
||||
# changes:
|
||||
# 60620-1333 - Added variable filtering to eliminate SQL injection attack threat
|
||||
# - Added required user/pass to gain access to this page
|
||||
#
|
||||
|
||||
require("dbconnect.php");
|
||||
|
||||
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
|
||||
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
|
||||
$PHP_SELF=$_SERVER['PHP_SELF'];
|
||||
if (isset($_GET["group"])) {$group=$_GET["group"];}
|
||||
elseif (isset($_POST["group"])) {$group=$_POST["group"];}
|
||||
if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];}
|
||||
elseif (isset($_POST["query_date"])) {$query_date=$_POST["query_date"];}
|
||||
if (isset($_GET["begin_date"])) {$begin_date=$_GET["begin_date"];}
|
||||
elseif (isset($_POST["begin_date"])) {$begin_date=$_POST["begin_date"];}
|
||||
if (isset($_GET["end_date"])) {$end_date=$_GET["end_date"];}
|
||||
elseif (isset($_POST["end_date"])) {$end_date=$_POST["end_date"];}
|
||||
if (isset($_GET["extension"])) {$extension=$_GET["extension"];}
|
||||
elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];}
|
||||
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
|
||||
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
|
||||
if (isset($_GET["user"])) {$user=$_GET["user"];}
|
||||
elseif (isset($_POST["user"])) {$user=$_POST["user"];}
|
||||
if (isset($_GET["full_name"])) {$full_name=$_GET["full_name"];}
|
||||
elseif (isset($_POST["full_name"])) {$full_name=$_POST["full_name"];}
|
||||
if (isset($_GET["submit"])) {$submit=$_GET["submit"];}
|
||||
elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];}
|
||||
if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];}
|
||||
elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];}
|
||||
|
||||
$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
|
||||
$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
|
||||
|
||||
$STARTtime = date("U");
|
||||
$TODAY = date("Y-m-d");
|
||||
$admin_page = './admin.php';
|
||||
|
||||
if (!isset($begin_date)) {$begin_date = $TODAY;}
|
||||
if (!isset($end_date)) {$end_date = $TODAY;}
|
||||
|
||||
$stmt="SELECT count(*) from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and active = 'Y' and status='ADMIN';";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$auth=$row[0];
|
||||
|
||||
$fp = fopen ("./project_auth_entries.txt", "a");
|
||||
$date = date("r");
|
||||
$ip = getenv("REMOTE_ADDR");
|
||||
$browser = getenv("HTTP_USER_AGENT");
|
||||
|
||||
if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
|
||||
{
|
||||
Header("WWW-Authenticate: Basic realm=\"VICI-ASTERISK\"");
|
||||
Header("HTTP/1.0 401 Unauthorized");
|
||||
echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if($auth>0)
|
||||
{
|
||||
$office_no=strtoupper($PHP_AUTH_USER);
|
||||
$password=strtoupper($PHP_AUTH_PW);
|
||||
$stmt="SELECT fullname from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$LOGfullname=$row[0];
|
||||
fwrite ($fp, "ASTERISK|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n");
|
||||
fclose($fp);
|
||||
|
||||
##### get server listing for dynamic pulldown
|
||||
$stmt="SELECT fullname from phones where server_ip='$server_ip' and extension='$extension'";
|
||||
$rsltx=mysql_query($stmt, $link);
|
||||
$rowx=mysql_fetch_row($rsltx);
|
||||
$fullname = $row[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
fwrite ($fp, "ASTERISK|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n");
|
||||
fclose($fp);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<title>ASTERISK ADMIN: Phone Stats</title>
|
||||
</head>
|
||||
<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>
|
||||
<CENTER>
|
||||
<TABLE WIDTH=620 BGCOLOR=#D9E6FE cellpadding=2 cellspacing=0><TR BGCOLOR=#015B91><TD ALIGN=LEFT><FONT FACE="ARIAL,HELVETICA" COLOR=WHITE SIZE=2><B> ASTERISK ADMIN: Administration</TD><TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA" COLOR=WHITE SIZE=2><B><? echo date("l F j, Y G:i:s A") ?> </TD></TR>
|
||||
<TR BGCOLOR=#F0F5FE><TD ALIGN=LEFT COLSPAN=2><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=1><B> <a href="<? echo $admin_page ?>"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=1>LIST ALL PHONES</a> | <a href="<? echo $admin_page ?>?ADD=1"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=1>ADD A NEW PHONE</a> | <a href="<? echo $admin_page ?>?ADD=5"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=1>SEARCH FOR A PHONE</a> | <a href="<? echo $admin_page ?>?ADD=11"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=1>ADD A SERVER</a> | <a href="<? echo $admin_page ?>?ADD=10"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=1>LIST ALL SERVERS</a></TD></TR>
|
||||
<TR BGCOLOR=#F0F5FE><TD ALIGN=LEFT COLSPAN=2><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=1><B> <a href="<? echo $admin_page ?>?ADD=100"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=1>SHOW ALL CONFERENCES</a> | <a href="<? echo $admin_page ?>?ADD=111"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=1>ADD A NEW CONFERENCE</a></TD></TR>
|
||||
|
||||
|
||||
|
||||
|
||||
<?
|
||||
|
||||
echo "<TR BGCOLOR=\"#F0F5FE\"><TD ALIGN=LEFT COLSPAN=2><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2><B> \n";
|
||||
|
||||
echo "<form action=$PHP_SELF method=POST>\n";
|
||||
echo "<input type=hidden name=extension value=\"$extension\">\n";
|
||||
echo "<input type=hidden name=server_ip value=\"$server_ip\">\n";
|
||||
echo "<input type=text name=begin_date value=\"$begin_date\" size=10 maxsize=10> to \n";
|
||||
echo "<input type=text name=end_date value=\"$end_date\" size=10 maxsize=10> \n";
|
||||
echo "<input type=submit name=submit value=submit>\n";
|
||||
|
||||
|
||||
echo " $user - $full_name\n";
|
||||
|
||||
echo "</B></TD></TR>\n";
|
||||
echo "<TR><TD ALIGN=LEFT COLSPAN=2>\n";
|
||||
|
||||
|
||||
$stmt="SELECT count(*),channel_group, sum(length_in_sec) from call_log where extension='$extension' and server_ip='$server_ip' and start_time >= '$begin_date 0:00:01' and start_time <= '$end_date 23:59:59' group by channel_group order by channel_group";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
$statuses_to_print = mysql_num_rows($rslt);
|
||||
# echo "|$stmt|\n";
|
||||
|
||||
echo "<br><center>\n";
|
||||
|
||||
echo "<B>CALL TIME AND CHANNELS:</B>\n";
|
||||
|
||||
echo "<center><TABLE width=300 cellspacing=0 cellpadding=1>\n";
|
||||
echo "<tr><td><font size=2>CHANNEL GROUP </td><td align=right><font size=2>COUNT</td><td align=right><font size=2> HOURS:MINUTES</td></tr>\n";
|
||||
|
||||
$total_calls=0;
|
||||
$o=0;
|
||||
while ($statuses_to_print > $o) {
|
||||
$row=mysql_fetch_row($rslt);
|
||||
if (eregi("1$|3$|5$|7$|9$", $o))
|
||||
{$bgcolor='bgcolor="#B9CBFD"';}
|
||||
else
|
||||
{$bgcolor='bgcolor="#9BB9FB"';}
|
||||
|
||||
$call_seconds = $row[2];
|
||||
$call_hours = ($call_seconds / 3600);
|
||||
$call_hours = round($call_hours, 2);
|
||||
$call_hours_int = intval("$call_hours");
|
||||
$call_minutes = ($call_hours - $call_hours_int);
|
||||
$call_minutes = ($call_minutes * 60);
|
||||
$call_minutes_int = round($call_minutes, 0);
|
||||
if ($call_minutes_int < 10) {$call_minutes_int = "0$call_minutes_int";}
|
||||
|
||||
echo "<tr $bgcolor><td><font size=2>$row[1]</td>";
|
||||
echo "<td align=right><font size=2> $row[0]</td>\n";
|
||||
echo "<td align=right><font size=2> $call_hours_int:$call_minutes_int</td></tr>\n";
|
||||
$total_calls = ($total_calls + $row[0]);
|
||||
|
||||
$call_seconds=0;
|
||||
$o++;
|
||||
}
|
||||
|
||||
$stmt="SELECT sum(length_in_sec) from call_log where extension='$extension' and server_ip='$server_ip' and start_time >= '$begin_date 0:00:01' and start_time <= '$end_date 23:59:59'";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
$counts_to_print = mysql_num_rows($rslt);
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$call_seconds = $row[0];
|
||||
$call_hours = ($call_seconds / 3600);
|
||||
$call_hours = round($call_hours, 2);
|
||||
$call_hours_int = intval("$call_hours");
|
||||
$call_minutes = ($call_hours - $call_hours_int);
|
||||
$call_minutes = ($call_minutes * 60);
|
||||
$call_minutes_int = round($call_minutes, 0);
|
||||
if ($call_minutes_int < 10) {$call_minutes_int = "0$call_minutes_int";}
|
||||
# echo "|$stmt|\n";
|
||||
|
||||
echo "<tr><td><font size=2>TOTAL CALLS </td><td align=right><font size=2> $total_calls</td><td align=right><font size=2> $call_hours_int:$call_minutes_int</td></tr>\n";
|
||||
echo "</TABLE></center>\n";
|
||||
echo "<br><br>\n";
|
||||
|
||||
echo "<center>\n";
|
||||
|
||||
echo "<B>LAST 1000 CALLS FOR DATE RANGE:</B>\n";
|
||||
echo "<TABLE width=400 cellspacing=0 cellpadding=1>\n";
|
||||
echo "<tr><td><font size=2>NUMBER </td><td><font size=2>CHANNEL GROUP </td><td align=right><font size=2> DATE</td><td align=right><font size=2> LENGTH(MIN.)</td></tr>\n";
|
||||
|
||||
$stmt="SELECT number_dialed,channel_group,start_time,length_in_min from call_log where extension='$extension' and server_ip='$server_ip' and start_time >= '$begin_date 0:00:01' and start_time <= '$end_date 23:59:59' LIMIT 1000";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
$events_to_print = mysql_num_rows($rslt);
|
||||
# echo "|$stmt|\n";
|
||||
|
||||
$total_calls=0;
|
||||
$o=0;
|
||||
$event_start_seconds='';
|
||||
$event_stop_seconds='';
|
||||
while ($events_to_print > $o) {
|
||||
$row=mysql_fetch_row($rslt);
|
||||
if (eregi("1$|3$|5$|7$|9$", $o))
|
||||
{$bgcolor='bgcolor="#B9CBFD"';}
|
||||
else
|
||||
{$bgcolor='bgcolor="#9BB9FB"';}
|
||||
echo "<tr $bgcolor><td><font size=2>$row[0]</td>";
|
||||
echo "<td align=right><font size=2> $row[1]</td>\n";
|
||||
echo "<td align=right><font size=2> $row[2]</td>\n";
|
||||
echo "<td align=right><font size=2> $row[3]</td></tr>\n";
|
||||
|
||||
|
||||
$call_seconds=0;
|
||||
$o++;
|
||||
}
|
||||
|
||||
|
||||
echo "</TABLE></center>\n";
|
||||
|
||||
|
||||
$ENDtime = date("U");
|
||||
|
||||
$RUNtime = ($ENDtime - $STARTtime);
|
||||
|
||||
echo "\n\n\n<br><br><br>\n\n";
|
||||
|
||||
|
||||
echo "<font size=0>\n\n\n<br><br><br>\nscript runtime: $RUNtime seconds</font>";
|
||||
|
||||
|
||||
?>
|
||||
|
||||
|
||||
</TD></TR><TABLE>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
<?
|
||||
|
||||
exit;
|
||||
|
||||
|
||||
|
||||
?>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,162 @@
|
||||
<?
|
||||
### remote_inbound.php
|
||||
###
|
||||
### Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
|
||||
###
|
||||
# the purpose of this script and webpage is to allow for remote or local users of the system to log in and grab phone calls that are coming inbound into the Asterisk server and being put in the parked_channels table while they hear a soundfile for a limited amount of time before being forwarded on to either a set extension or a voicemail box. This gives remote or local agents a way to grab calls without tying up their phone lines all day. The agent sees the refreshing screen of calls on park and when they want to take one they just click on it, and a small window opens that will allow them to grab the call and/or look up more information on the caller through the callerID that is given(if available)
|
||||
|
||||
require("dbconnect.php");
|
||||
|
||||
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
|
||||
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
|
||||
$PHP_SELF=$_SERVER['PHP_SELF'];
|
||||
$submit=$_GET["submit"]; if (!$submit) {$submit=$_POST["submit"];}
|
||||
$SUBMIT=$_GET["SUBMIT"]; if (!$SUBMIT) {$SUBMIT=$_POST["SUBMIT"];}
|
||||
|
||||
|
||||
$STARTtime = date("U");
|
||||
$TODAY = date("Y-m-d");
|
||||
$NOW_TIME = date("Y-m-d H:i:s");
|
||||
$popup_page = './inbound_popup.php';
|
||||
|
||||
$stmt="SELECT count(*) from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and active = 'Y' and status IN('ACTIVE','ADMIN');";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$auth=$row[0];
|
||||
|
||||
$fp = fopen ("./project_auth_entries.txt", "a");
|
||||
$date = date("r");
|
||||
$ip = getenv("REMOTE_ADDR");
|
||||
$browser = getenv("HTTP_USER_AGENT");
|
||||
|
||||
if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
|
||||
{
|
||||
Header("WWW-Authenticate: Basic realm=\"VICI-ASTERISK\"");
|
||||
Header("HTTP/1.0 401 Unauthorized");
|
||||
echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if($auth>0)
|
||||
{
|
||||
$office_no=strtoupper($PHP_AUTH_USER);
|
||||
$password=strtoupper($PHP_AUTH_PW);
|
||||
$stmt="SELECT fullname,dialplan_number from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'";
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$LOGfullname=$row[0];
|
||||
fwrite ($fp, "ASTERISK|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n");
|
||||
fclose($fp);
|
||||
|
||||
##### get server listing for dynamic pulldown
|
||||
$stmt="SELECT fullname,dialplan_number,server_ip from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'";
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$rsltx=mysql_query($stmt, $link);
|
||||
$rowx=mysql_fetch_row($rsltx);
|
||||
$fullname = $rowx[0];
|
||||
$dialplan_number = $rowx[1];
|
||||
$user_server_ip = $rowx[2];
|
||||
if ($DB) {echo "|$rowx[0]|$rowx[1]|$rowx[2]|\n";}
|
||||
}
|
||||
else
|
||||
{
|
||||
fwrite ($fp, "ASTERISK|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n");
|
||||
fclose($fp);
|
||||
}
|
||||
}
|
||||
|
||||
echo"<HTML><HEAD>\n";
|
||||
echo"<TITLE>ASTERISK REMOTE INBOUND: Main</TITLE></HEAD>\n";
|
||||
echo"<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=iso-8859-1\">\n";
|
||||
echo"<META HTTP-EQUIV=Refresh CONTENT=\"5; URL=$PHP_SELF\">\n";
|
||||
echo"</HEAD>\n";
|
||||
|
||||
?>
|
||||
|
||||
<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>
|
||||
<CENTER><FONT FACE="Courier" COLOR=BLACK SIZE=3>
|
||||
|
||||
<?
|
||||
|
||||
|
||||
echo "$NOW_TIME $PHP_AUTH_USER - $fullname - CALLS SENT TO: $dialplan_number<BR><BR>\n";
|
||||
|
||||
echo "Click on the channel below that you would like to have directed to your phone<BR><BR>\n";
|
||||
|
||||
echo "<PRE>\n";
|
||||
echo "CHANNEL SERVER CHANNEL_GROUP EXTENSION PARKED_BY PARKED_TIME \n";
|
||||
echo "----------------------------------------------------------------------------------------------\n";
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$stmt="SELECT count(*) from parked_channels where server_ip='$user_server_ip' order by parked_time";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$parked_count = $row[0];
|
||||
if ($parked_count > 0)
|
||||
{
|
||||
$stmt="SELECT * from parked_channels where server_ip='$user_server_ip' and channel_group LIKE \"IN_%\" order by parked_time";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$parked_to_print = mysql_num_rows($rslt);
|
||||
$i=0;
|
||||
while ($i < $parked_to_print)
|
||||
{
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$channel = sprintf("%-11s", $row[0]);
|
||||
$server = sprintf("%-14s", $row[1]);
|
||||
$channel_group = sprintf("%-16s", $row[2]);
|
||||
$extension = sprintf("%-13s", $row[3]);
|
||||
$parked_by = sprintf("%-21s", $row[4]);
|
||||
$parked_time = sprintf("%-19s", $row[5]);
|
||||
|
||||
echo "<A HREF=\"$popup_page?phone=$row[4]&channel=$row[0]&parked_time=$row[5]&server_ip=$user_server_ip&DB=\" target=\"_blank\">$channel</A>$server$channel_group$extension$parked_by$parked_time\n";
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "**********************************************************************************************\n";
|
||||
echo "**********************************************************************************************\n";
|
||||
echo "*************************************** NO PARKED CALLS **************************************\n";
|
||||
echo "**********************************************************************************************\n";
|
||||
echo "**********************************************************************************************\n";
|
||||
}
|
||||
|
||||
|
||||
$ENDtime = date("U");
|
||||
|
||||
$RUNtime = ($ENDtime - $STARTtime);
|
||||
|
||||
echo "</PRE>\n\n\n<br><br><br>\n\n";
|
||||
|
||||
|
||||
echo "<font size=0>\n\n\n<br><br><br>\nscript runtime: $RUNtime seconds</font>";
|
||||
|
||||
|
||||
?>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
<?
|
||||
|
||||
exit;
|
||||
|
||||
|
||||
|
||||
?>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
<?
|
||||
### test.php
|
||||
###
|
||||
### Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
|
||||
###
|
||||
|
||||
$STARTtime = date("U");
|
||||
$STARTdate = date("Y-m-d H:i:s");
|
||||
|
||||
|
||||
$link=mysql_connect("localhost", "cron", "1234");
|
||||
mysql_select_db("asterisk");
|
||||
|
||||
$stmt="SELECT * from phones;";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$auth=$row[0];
|
||||
|
||||
print "|$auth|\n";
|
||||
|
||||
exit;
|
||||
|
||||
|
||||
|
||||
?>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,400 @@
|
||||
<?
|
||||
# AST_inboundEXTstats.php
|
||||
#
|
||||
# Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
|
||||
#
|
||||
# CHANGES
|
||||
# 60421-1450 - check GET/POST vars lines with isset to not trigger PHP NOTICES
|
||||
# 60620-1322 - Added variable filtering to eliminate SQL injection attack threat
|
||||
# - Added required user/pass to gain access to this page
|
||||
#
|
||||
|
||||
require("dbconnect.php");
|
||||
|
||||
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
|
||||
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
|
||||
$PHP_SELF=$_SERVER['PHP_SELF'];
|
||||
if (isset($_GET["group"])) {$group=$_GET["group"];}
|
||||
elseif (isset($_POST["group"])) {$group=$_POST["group"];}
|
||||
if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];}
|
||||
elseif (isset($_POST["query_date"])) {$query_date=$_POST["query_date"];}
|
||||
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
|
||||
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
|
||||
if (isset($_GET["submit"])) {$submit=$_GET["submit"];}
|
||||
elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];}
|
||||
if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];}
|
||||
elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];}
|
||||
|
||||
$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
|
||||
$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
|
||||
|
||||
$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;";
|
||||
if ($DB) {echo "|$stmt|\n";}
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$auth=$row[0];
|
||||
|
||||
if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
|
||||
{
|
||||
Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\"");
|
||||
Header("HTTP/1.0 401 Unauthorized");
|
||||
echo "Unzulässiges Username/Kennwort:|$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$NOW_DATE = date("Y-m-d");
|
||||
$NOW_TIME = date("Y-m-d H:i:s");
|
||||
$STARTtime = date("U");
|
||||
if (!isset($query_date)) {$query_date = $NOW_DATE;}
|
||||
if (!isset($server_ip)) {$server_ip = '10.10.11.20';}
|
||||
|
||||
$stmt="select extension,full_number,inbound_name from inbound_numbers where server_ip='" . mysql_real_escape_string($server_ip) . "';";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$inbound_to_print = mysql_num_rows($rslt);
|
||||
$i=0;
|
||||
while ($i < $inbound_to_print)
|
||||
{
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$inbound[$i] =$row[0];
|
||||
$fullnum[$i] =$row[1];
|
||||
$inbname[$i] =$row[2];
|
||||
$i++;
|
||||
}
|
||||
?>
|
||||
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<STYLE type="text/css">
|
||||
<!--
|
||||
.green {color: white; background-color: green}
|
||||
.red {color: white; background-color: red}
|
||||
.blue {color: white; background-color: blue}
|
||||
.purple {color: white; background-color: purple}
|
||||
-->
|
||||
</STYLE>
|
||||
|
||||
<?
|
||||
echo"<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=iso-8859-1\">\n";
|
||||
#echo"<META HTTP-EQUIV=Refresh CONTENT=\"7; URL=$PHP_SELF?server_ip=$server_ip&DB=$DB\">\n";
|
||||
echo "<TITLE>ASTERISK: Inbound Anruf-Notfall</TITLE></HEAD><BODY BGCOLOR=WHITE>\n";
|
||||
echo "<FORM ACTION=\"$PHP_SELF\" METHOD=GET>\n";
|
||||
echo "<INPUT TYPE=HIDDEN NAME=server_ip VALUE=\"$server_ip\">\n";
|
||||
echo "<INPUT TYPE=TEXT NAME=query_date SIZE=10 MAXLENGTH=10 VALUE=\"$query_date\">\n";
|
||||
echo "<SELECT SIZE=1 NAME=group>\n";
|
||||
$o=0;
|
||||
while ($inbound_to_print > $o)
|
||||
{
|
||||
if ($inbound[$o] == $group) {echo "<option selected value=\"$inbound[$o]\">$fullnum[$o] - $inbname[$o]</option>\n";}
|
||||
else {echo "<option value=\"$inbound[$o]\">$fullnum[$o] - $inbname[$o]</option>\n";}
|
||||
$o++;
|
||||
}
|
||||
echo "</SELECT>\n";
|
||||
echo "<INPUT TYPE=Submit NAME=SUBMIT VALUE=SUBMIT>\n";
|
||||
echo "</FORM>\n\n";
|
||||
|
||||
echo "<PRE><FONT SIZE=2>\n\n";
|
||||
|
||||
|
||||
if (!$group)
|
||||
{
|
||||
echo "\n\n";
|
||||
echo "WÄHLEN Sie BITTE Eine ZAHL Vor UND DATUM OBEN UND KLICKEN REICHT Ein\n";
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
|
||||
|
||||
echo "ASTERISK: Inbound Anruf-Notfall $NOW_TIME\n";
|
||||
|
||||
echo "\n";
|
||||
echo "---------- TOTALS\n";
|
||||
|
||||
$extenSQL = "and extension='" . mysql_real_escape_string($group) . "'";
|
||||
if (eregi("\*",$group))
|
||||
{$extenSQL = "and extension LIKE \"%$group\"";}
|
||||
$stmt="select count(*),sum(length_in_sec) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " 00:00:01' and start_time <= '" . mysql_real_escape_string($query_date) . " 23:59:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$row=mysql_fetch_row($rslt);
|
||||
|
||||
$TOTALcalls = sprintf("%10s", $row[0]);
|
||||
$average_hold_seconds = ($row[1] / $row[0]);
|
||||
$average_hold_seconds = round($average_hold_seconds, 0);
|
||||
$average_hold_seconds = sprintf("%10s", $average_hold_seconds);
|
||||
|
||||
echo "Gesamtanrufe, die in diese Zahl kamen: $TOTALcalls\n";
|
||||
echo "Average Call Length(seconds) for all Calls: $average_hold_seconds\n";
|
||||
|
||||
echo "\n";
|
||||
echo "---------- DROPS\n";
|
||||
|
||||
$stmt="select count(*),sum(length_in_sec) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " 00:00:01' and start_time <= '" . mysql_real_escape_string($query_date) . " 23:59:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL and (length_in_sec <= 10 or length_in_sec is null);";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$row=mysql_fetch_row($rslt);
|
||||
|
||||
$DROPcalls = sprintf("%10s", $row[0]);
|
||||
$DROPpercent = (($DROPcalls / $TOTALcalls) * 100);
|
||||
$DROPpercent = round($DROPpercent, 0);
|
||||
|
||||
if ($row[0])
|
||||
{
|
||||
$average_hold_seconds = ($row[1] / $row[0]);
|
||||
$average_hold_seconds = round($average_hold_seconds, 0);
|
||||
$average_hold_seconds = sprintf("%10s", $average_hold_seconds);
|
||||
}
|
||||
else {$DROPpercent=0; $average_hold_seconds=0;}
|
||||
echo "Total DROP Calls: (less than 10 seconds) $DROPcalls $DROPpercent%\n";
|
||||
echo "Average Call Length(seconds) for DROP Calls: $average_hold_seconds\n";
|
||||
|
||||
|
||||
##############################
|
||||
######### CALLS STATS
|
||||
|
||||
echo "\n";
|
||||
echo "---------- CALL LISTINGS\n";
|
||||
echo "+----------------------+----------------------+--------+---------------------+\n";
|
||||
echo "| CALLERID | CALLERIDNAME | LENGTH | DATE TIME |\n";
|
||||
echo "+----------------------+----------------------+--------+---------------------+\n";
|
||||
|
||||
$stmt="select number_dialed,caller_code,length_in_sec,start_time from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " 00:00:01' and start_time <= '" . mysql_real_escape_string($query_date) . " 23:59:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$users_to_print = mysql_num_rows($rslt);
|
||||
$i=0;
|
||||
while ($i < $users_to_print)
|
||||
{
|
||||
$row=mysql_fetch_row($rslt);
|
||||
|
||||
$CID = sprintf("%-20s", $row[0]);
|
||||
$CIDname = sprintf("%-20s", $row[1]); while(strlen($full_name)>15) {$full_name = substr("$full_name", 0, -1);}
|
||||
$datetime = sprintf("%-19s", $row[3]);
|
||||
$USERavgTALK = $row[2];
|
||||
|
||||
$USERavgTALK_M = ($USERavgTALK / 60);
|
||||
$USERavgTALK_M = round($USERavgTALK_M, 2);
|
||||
$USERavgTALK_M_int = intval("$USERavgTALK_M");
|
||||
$USERavgTALK_S = ($USERavgTALK_M - $USERavgTALK_M_int);
|
||||
$USERavgTALK_S = ($USERavgTALK_S * 60);
|
||||
$USERavgTALK_S = round($USERavgTALK_S, 0);
|
||||
if ($USERavgTALK_S < 10) {$USERavgTALK_S = "0$USERavgTALK_S";}
|
||||
$USERavgTALK_MS = "$USERavgTALK_M_int:$USERavgTALK_S";
|
||||
$USERavgTALK_MS = sprintf("%6s", $USERavgTALK_MS);
|
||||
|
||||
echo "| $CID | $CIDname | $USERavgTALK_MS | $datetime |\n";
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
echo "+----------------------+----------------------+--------+---------------------+\n";
|
||||
|
||||
##############################
|
||||
######### TIME STATS
|
||||
|
||||
if ($output == 'FULL')
|
||||
{
|
||||
|
||||
echo "\n";
|
||||
echo "---------- TIME STATS\n";
|
||||
|
||||
echo "<FONT SIZE=0>\n";
|
||||
|
||||
$hi_hour_count=0;
|
||||
$last_full_record=0;
|
||||
$i=0;
|
||||
$h=0;
|
||||
while ($i <= 96)
|
||||
{
|
||||
$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:00:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:14:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$hour_count[$i] = $row[0];
|
||||
if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
|
||||
if ($hour_count[$i] > 0) {$last_full_record = $i;}
|
||||
$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:00:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:14:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL and (length_in_sec <= 10 or length_in_sec is null);";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$drop_count[$i] = $row[0];
|
||||
$i++;
|
||||
|
||||
|
||||
$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:15:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:29:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$hour_count[$i] = $row[0];
|
||||
if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
|
||||
if ($hour_count[$i] > 0) {$last_full_record = $i;}
|
||||
$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:15:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:29:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL and (length_in_sec <= 10 or length_in_sec is null);";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$drop_count[$i] = $row[0];
|
||||
$i++;
|
||||
|
||||
$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:30:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:44:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$hour_count[$i] = $row[0];
|
||||
if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
|
||||
if ($hour_count[$i] > 0) {$last_full_record = $i;}
|
||||
$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:30:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:44:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL and (length_in_sec <= 10 or length_in_sec is null);";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$drop_count[$i] = $row[0];
|
||||
$i++;
|
||||
|
||||
$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:45:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:59:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$hour_count[$i] = $row[0];
|
||||
if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
|
||||
if ($hour_count[$i] > 0) {$last_full_record = $i;}
|
||||
$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:45:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:59:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL and (length_in_sec <= 10 or length_in_sec is null);";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$drop_count[$i] = $row[0];
|
||||
$i++;
|
||||
$h++;
|
||||
}
|
||||
|
||||
$hour_multiplier = (100 / $hi_hour_count);
|
||||
#$hour_multiplier = round($hour_multiplier, 0);
|
||||
|
||||
echo "<!-- HICOUNT: $hi_hour_count|$hour_multiplier -->\n";
|
||||
echo "DIAGRAMM IN 15 MINUZIÖSEN STUFENSPRÜNGEN VON GESAMTANRUFEN\n";
|
||||
|
||||
$k=1;
|
||||
$Mk=0;
|
||||
$call_scale = '0';
|
||||
while ($k <= 102)
|
||||
{
|
||||
if ($Mk >= 5)
|
||||
{
|
||||
$Mk=0;
|
||||
$scale_num=($k / $hour_multiplier);
|
||||
$scale_num = round($scale_num, 0);
|
||||
$LENscale_num = (strlen($scale_num));
|
||||
$k = ($k + $LENscale_num);
|
||||
$call_scale .= "$scale_num";
|
||||
}
|
||||
else
|
||||
{
|
||||
$call_scale .= " ";
|
||||
$k++; $Mk++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
|
||||
#echo "| HOUR | GRAPH IN 15 MINUTE INCREMENTS OF TOTAL INCOMING CALLS FOR THIS GROUP | DROPS | TOTAL |\n";
|
||||
echo "| HOUR |$call_scale| DROPS | TOTAL |\n";
|
||||
echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
|
||||
|
||||
$ZZ = '00';
|
||||
$i=0;
|
||||
$h=4;
|
||||
$hour= -1;
|
||||
$no_lines_yet=1;
|
||||
|
||||
while ($i <= 96)
|
||||
{
|
||||
$char_counter=0;
|
||||
$time = ' ';
|
||||
if ($h >= 4)
|
||||
{
|
||||
$hour++;
|
||||
$h=0;
|
||||
if ($hour < 10) {$hour = "0$hour";}
|
||||
$time = "+$hour$ZZ+";
|
||||
}
|
||||
if ($h == 1) {$time = " 15 ";}
|
||||
if ($h == 2) {$time = " 30 ";}
|
||||
if ($h == 3) {$time = " 45 ";}
|
||||
$Ghour_count = $hour_count[$i];
|
||||
if ($Ghour_count < 1)
|
||||
{
|
||||
if ( ($no_lines_yet) or ($i > $last_full_record) )
|
||||
{
|
||||
$do_nothing=1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$hour_count[$i] = sprintf("%-5s", $hour_count[$i]);
|
||||
echo "|$time|";
|
||||
$k=0; while ($k <= 102) {echo " "; $k++;}
|
||||
echo "| $hour_count[$i] |\n";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$no_lines_yet=0;
|
||||
$Xhour_count = ($Ghour_count * $hour_multiplier);
|
||||
$Yhour_count = (99 - $Xhour_count);
|
||||
|
||||
$Gdrop_count = $drop_count[$i];
|
||||
if ($Gdrop_count < 1)
|
||||
{
|
||||
$hour_count[$i] = sprintf("%-5s", $hour_count[$i]);
|
||||
|
||||
echo "|$time|<SPAN class=\"green\">";
|
||||
$k=0; while ($k <= $Xhour_count) {echo "*"; $k++; $char_counter++;}
|
||||
echo "*X</SPAN>"; $char_counter++;
|
||||
$k=0; while ($k <= $Yhour_count) {echo " "; $k++; $char_counter++;}
|
||||
while ($char_counter <= 101) {echo " "; $char_counter++;}
|
||||
echo "| 0 | $hour_count[$i] |\n";
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$Xdrop_count = ($Gdrop_count * $hour_multiplier);
|
||||
|
||||
# if ($Xdrop_count >= $Xhour_count) {$Xdrop_count = ($Xdrop_count - 1);}
|
||||
|
||||
$XXhour_count = ( ($Xhour_count - $Xdrop_count) - 1 );
|
||||
|
||||
$hour_count[$i] = sprintf("%-5s", $hour_count[$i]);
|
||||
$drop_count[$i] = sprintf("%-5s", $drop_count[$i]);
|
||||
|
||||
echo "|$time|<SPAN class=\"red\">";
|
||||
$k=0; while ($k <= $Xdrop_count) {echo ">"; $k++; $char_counter++;}
|
||||
echo "D</SPAN><SPAN class=\"green\">"; $char_counter++;
|
||||
$k=0; while ($k <= $XXhour_count) {echo "*"; $k++; $char_counter++;}
|
||||
echo "X</SPAN>"; $char_counter++;
|
||||
$k=0; while ($k <= $Yhour_count) {echo " "; $k++; $char_counter++;}
|
||||
while ($char_counter <= 102) {echo " "; $char_counter++;}
|
||||
echo "| $drop_count[$i] | $hour_count[$i] |\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$i++;
|
||||
$h++;
|
||||
}
|
||||
|
||||
|
||||
echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
?>
|
||||
</PRE>
|
||||
|
||||
</BODY></HTML>
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,15 @@
|
||||
<?
|
||||
|
||||
$link=mysql_connect("localhost", "cron", "1234");
|
||||
mysql_select_db("asterisk");
|
||||
|
||||
$local_DEF = 'Local/';
|
||||
$conf_silent_prefix = '7';
|
||||
$local_AMP = '@';
|
||||
$ext_context = 'demo';
|
||||
$recording_exten = '8309';
|
||||
|
||||
$WeBServeRRooT = '/usr/local/apache2/htdocs';
|
||||
$WeBRooTWritablE = '1';
|
||||
|
||||
?>
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 492 B |
@@ -0,0 +1,228 @@
|
||||
<?
|
||||
### inbound_popup.php
|
||||
###
|
||||
### Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
|
||||
###
|
||||
# this is the inbound popup of a specific call that grabs the call and allows you to go and fetch info on that caller in the local CRM system.
|
||||
#
|
||||
# changes:
|
||||
# 60620-1329 - Added variable filtering to eliminate SQL injection attack threat
|
||||
# - Added required user/pass to gain access to this page
|
||||
#
|
||||
|
||||
require("dbconnect.php");
|
||||
|
||||
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
|
||||
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
|
||||
$PHP_SELF=$_SERVER['PHP_SELF'];
|
||||
if (isset($_GET["vendor_id"])) {$vendor_id=$_GET["vendor_id"];}
|
||||
elseif (isset($_POST["vendor_id"])) {$vendor_id=$_POST["vendor_id"];}
|
||||
if (isset($_GET["phone"])) {$phone=$_GET["phone"];}
|
||||
elseif (isset($_POST["phone"])) {$phone=$_POST["phone"];}
|
||||
if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];}
|
||||
elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];}
|
||||
if (isset($_GET["first_name"])) {$first_name=$_GET["first_name"];}
|
||||
elseif (isset($_POST["first_name"])) {$first_name=$_POST["first_name"];}
|
||||
if (isset($_GET["last_name"])) {$last_name=$_GET["last_name"];}
|
||||
elseif (isset($_POST["last_name"])) {$last_name=$_POST["last_name"];}
|
||||
if (isset($_GET["phone_number"])) {$phone_number=$_GET["phone_number"];}
|
||||
elseif (isset($_POST["phone_number"])) {$phone_number=$_POST["phone_number"];}
|
||||
if (isset($_GET["end_call"])) {$end_call=$_GET["end_call"];}
|
||||
elseif (isset($_POST["end_call"])) {$end_call=$_POST["end_call"];}
|
||||
if (isset($_GET["DB"])) {$DB=$_GET["DB"];}
|
||||
elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];}
|
||||
if (isset($_GET["dispo"])) {$dispo=$_GET["dispo"];}
|
||||
elseif (isset($_POST["dispo"])) {$dispo=$_POST["dispo"];}
|
||||
if (isset($_GET["list_id"])) {$list_id=$_GET["list_id"];}
|
||||
elseif (isset($_POST["list_id"])) {$list_id=$_POST["list_id"];}
|
||||
if (isset($_GET["campaign_id"])) {$campaign_id=$_GET["campaign_id"];}
|
||||
elseif (isset($_POST["campaign_id"])) {$campaign_id=$_POST["campaign_id"];}
|
||||
if (isset($_GET["phone_code"])) {$phone_code=$_GET["phone_code"];}
|
||||
elseif (isset($_POST["phone_code"])) {$phone_code=$_POST["phone_code"];}
|
||||
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
|
||||
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
|
||||
if (isset($_GET["extension"])) {$extension=$_GET["extension"];}
|
||||
elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];}
|
||||
if (isset($_GET["channel"])) {$channel=$_GET["channel"];}
|
||||
elseif (isset($_POST["channel"])) {$channel=$_POST["channel"];}
|
||||
if (isset($_GET["call_began"])) {$call_began=$_GET["call_began"];}
|
||||
elseif (isset($_POST["call_began"])) {$call_began=$_POST["call_began"];}
|
||||
if (isset($_GET["parked_time"])) {$parked_time=$_GET["parked_time"];}
|
||||
elseif (isset($_POST["parked_time"])) {$parked_time=$_POST["parked_time"];}
|
||||
if (isset($_GET["tsr"])) {$tsr=$_GET["tsr"];}
|
||||
elseif (isset($_POST["tsr"])) {$tsr=$_POST["tsr"];}
|
||||
if (isset($_GET["address1"])) {$address1=$_GET["address1"];}
|
||||
elseif (isset($_POST["address1"])) {$address1=$_POST["address1"];}
|
||||
if (isset($_GET["address2"])) {$address2=$_GET["address2"];}
|
||||
elseif (isset($_POST["address2"])) {$address2=$_POST["address2"];}
|
||||
if (isset($_GET["address3"])) {$address3=$_GET["address3"];}
|
||||
elseif (isset($_POST["address3"])) {$address3=$_POST["address3"];}
|
||||
if (isset($_GET["city"])) {$city=$_GET["city"];}
|
||||
elseif (isset($_POST["city"])) {$city=$_POST["city"];}
|
||||
if (isset($_GET["state"])) {$state=$_GET["state"];}
|
||||
elseif (isset($_POST["state"])) {$state=$_POST["state"];}
|
||||
if (isset($_GET["postal_code"])) {$postal_code=$_GET["postal_code"];}
|
||||
elseif (isset($_POST["postal_code"])) {$postal_code=$_POST["postal_code"];}
|
||||
if (isset($_GET["province"])) {$province=$_GET["province"];}
|
||||
elseif (isset($_POST["province"])) {$province=$_POST["province"];}
|
||||
if (isset($_GET["country_code"])) {$country_code=$_GET["country_code"];}
|
||||
elseif (isset($_POST["country_code"])) {$country_code=$_POST["country_code"];}
|
||||
if (isset($_GET["alt_phone"])) {$alt_phone=$_GET["alt_phone"];}
|
||||
elseif (isset($_POST["alt_phone"])) {$alt_phone=$_POST["alt_phone"];}
|
||||
if (isset($_GET["email"])) {$email=$_GET["email"];}
|
||||
elseif (isset($_POST["email"])) {$email=$_POST["email"];}
|
||||
if (isset($_GET["security"])) {$security=$_GET["security"];}
|
||||
elseif (isset($_POST["security"])) {$security=$_POST["security"];}
|
||||
if (isset($_GET["comments"])) {$comments=$_GET["comments"];}
|
||||
elseif (isset($_POST["comments"])) {$comments=$_POST["comments"];}
|
||||
if (isset($_GET["status"])) {$status=$_GET["status"];}
|
||||
elseif (isset($_POST["status"])) {$status=$_POST["status"];}
|
||||
if (isset($_GET["submit"])) {$submit=$_GET["submit"];}
|
||||
elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];}
|
||||
if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];}
|
||||
elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];}
|
||||
|
||||
$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
|
||||
$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
|
||||
|
||||
$STARTtime = date("U");
|
||||
$TODAY = date("Y-m-d");
|
||||
$NOW_TIME = date("Y-m-d H:i:s");
|
||||
$popup_page = './inbound_popup.php';
|
||||
$FILE_datetime = $STARTtime;
|
||||
|
||||
$ext_context = 'demo';
|
||||
if (!isset($begin_date)) {$begin_date = $TODAY;}
|
||||
if (!isset($end_date)) {$end_date = $TODAY;}
|
||||
|
||||
$stmt="SELECT count(*) from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and active = 'Y' and status IN('ACTIVE','ADMIN');";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$auth=$row[0];
|
||||
|
||||
$fp = fopen ("./project_auth_entries.txt", "a");
|
||||
$date = date("r");
|
||||
$ip = getenv("REMOTE_ADDR");
|
||||
$browser = getenv("HTTP_USER_AGENT");
|
||||
|
||||
if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
|
||||
{
|
||||
Header("WWW-Authenticate: Basic realm=\"VICI-ASTERISK\"");
|
||||
Header("HTTP/1.0 401 Unauthorized");
|
||||
echo "Unzulässiges Username/Kennwort:|$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if($auth>0)
|
||||
{
|
||||
$office_no=strtoupper($PHP_AUTH_USER);
|
||||
$password=strtoupper($PHP_AUTH_PW);
|
||||
$stmt="SELECT fullname,dialplan_number from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'";
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$LOGfullname=$row[0];
|
||||
fwrite ($fp, "ASTERISK|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n");
|
||||
fclose($fp);
|
||||
|
||||
##### get server listing for dynamic pulldown
|
||||
$stmt="SELECT fullname,dialplan_number,server_ip from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'";
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$rsltx=mysql_query($stmt, $link);
|
||||
$rowx=mysql_fetch_row($rsltx);
|
||||
$fullname = $rowx[0];
|
||||
$dialplan_number = $rowx[1];
|
||||
$user_server_ip = $rowx[2];
|
||||
if ($DB) {echo "|$rowx[0]|$rowx[1]|$rowx[2]|\n";}
|
||||
}
|
||||
else
|
||||
{
|
||||
fwrite ($fp, "ASTERISK|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n");
|
||||
fclose($fp);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<title>ASTERISK ENTFERNTINBOUND: Popup</title>
|
||||
</head>
|
||||
<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>
|
||||
<CENTER><FONT FACE="Courier" COLOR=BLACK SIZE=3>
|
||||
|
||||
<?
|
||||
|
||||
$stmt="SELECT count(*) from parked_channels where server_ip='$user_server_ip' and parked_time='" . mysql_real_escape_string($parked_time) . "' and channel='" . mysql_real_escape_string($channel) . "'";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$parked_count = $row[0];
|
||||
|
||||
if ($parked_count > 0)
|
||||
{
|
||||
|
||||
$stmt="DELETE from parked_channels where server_ip='$user_server_ip' and parked_time='" . mysql_real_escape_string($parked_time) . "' and channel='" . mysql_real_escape_string($channel) . "' LIMIT 1";
|
||||
if ($DB) {echo "|$stmt|\n";}
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
|
||||
$DTqueryCID = "RR$FILE_datetime$PHP_AUTH_USER";
|
||||
|
||||
### insert a NEW record to the vicidial_manager table to be processed
|
||||
$stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$user_server_ip','','Redirect','$DTqueryCID','Exten: $dialplan_number','Channel: " . mysql_real_escape_string($channel) . "','Context: $ext_context','Priority: 1','Callerid: $DTqueryCID','','','','','')";
|
||||
if ($DB) {echo "|$stmt|\n";}
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
|
||||
echo "Adressieren Sie den Befehl um, der für Führung gesendet wird $channel $NOW_TIME\n<BR><BR>\n";
|
||||
|
||||
|
||||
$url = 'https://10.10.10.15/internal/back_end_systems/cust_serv/index.php?Search=SEARCH&';
|
||||
$Suser = 'username=';
|
||||
$Spass = '&passwd=';
|
||||
$Sphone = '&phone=';
|
||||
|
||||
$newurl = "$url$Suser$PHP_AUTH_USER$Spass$PHP_AUTH_PW$Sphone$phone";
|
||||
if ( ($phone == 'unknown') or (strlen($phone)<9) )
|
||||
{$newurl = "$url$Suser$PHP_AUTH_USER$Spass$PHP_AUTH_PW";}
|
||||
|
||||
echo "<a href=\"$newurl\">Schauen Sie oben diesen Kunden im Kundendienst-System</a>\n<BR><BR>\n";
|
||||
|
||||
echo "<a href=\"$PHP_SELF\">Schließen Sie dieses Fenster</a>\n<BR><BR>\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "Adressieren Sie den Befehl um, der für Führung VERLASSEN wird $channel $NOW_TIME\n<BR><BR>\n";
|
||||
echo "<a href=\"$PHP_SELF\">Schließen Sie dieses Fenster</a>\n<BR><BR>\n";
|
||||
}
|
||||
|
||||
|
||||
|
||||
$ENDtime = date("U");
|
||||
|
||||
$RUNtime = ($ENDtime - $STARTtime);
|
||||
|
||||
echo "\n\n\n<br><br><br>\n\n";
|
||||
|
||||
|
||||
echo "<font size=0>\n\n\n<br><br><br>\nIndexlaufzeit: $RUNtime seconds</font>";
|
||||
|
||||
|
||||
?>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
<?
|
||||
|
||||
exit;
|
||||
|
||||
|
||||
|
||||
?>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,244 @@
|
||||
<?
|
||||
# phone_stats.php.php
|
||||
#
|
||||
# Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
|
||||
#
|
||||
#
|
||||
# changes:
|
||||
# 60620-1333 - Added variable filtering to eliminate SQL injection attack threat
|
||||
# - Added required user/pass to gain access to this page
|
||||
#
|
||||
|
||||
require("dbconnect.php");
|
||||
|
||||
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
|
||||
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
|
||||
$PHP_SELF=$_SERVER['PHP_SELF'];
|
||||
if (isset($_GET["group"])) {$group=$_GET["group"];}
|
||||
elseif (isset($_POST["group"])) {$group=$_POST["group"];}
|
||||
if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];}
|
||||
elseif (isset($_POST["query_date"])) {$query_date=$_POST["query_date"];}
|
||||
if (isset($_GET["begin_date"])) {$begin_date=$_GET["begin_date"];}
|
||||
elseif (isset($_POST["begin_date"])) {$begin_date=$_POST["begin_date"];}
|
||||
if (isset($_GET["end_date"])) {$end_date=$_GET["end_date"];}
|
||||
elseif (isset($_POST["end_date"])) {$end_date=$_POST["end_date"];}
|
||||
if (isset($_GET["extension"])) {$extension=$_GET["extension"];}
|
||||
elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];}
|
||||
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
|
||||
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
|
||||
if (isset($_GET["user"])) {$user=$_GET["user"];}
|
||||
elseif (isset($_POST["user"])) {$user=$_POST["user"];}
|
||||
if (isset($_GET["full_name"])) {$full_name=$_GET["full_name"];}
|
||||
elseif (isset($_POST["full_name"])) {$full_name=$_POST["full_name"];}
|
||||
if (isset($_GET["submit"])) {$submit=$_GET["submit"];}
|
||||
elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];}
|
||||
if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];}
|
||||
elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];}
|
||||
|
||||
$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
|
||||
$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
|
||||
|
||||
$STARTtime = date("U");
|
||||
$TODAY = date("Y-m-d");
|
||||
$admin_page = './admin.php';
|
||||
|
||||
if (!isset($begin_date)) {$begin_date = $TODAY;}
|
||||
if (!isset($end_date)) {$end_date = $TODAY;}
|
||||
|
||||
$stmt="SELECT count(*) from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and active = 'Y' and status='ADMIN';";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$auth=$row[0];
|
||||
|
||||
$fp = fopen ("./project_auth_entries.txt", "a");
|
||||
$date = date("r");
|
||||
$ip = getenv("REMOTE_ADDR");
|
||||
$browser = getenv("HTTP_USER_AGENT");
|
||||
|
||||
if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
|
||||
{
|
||||
Header("WWW-Authenticate: Basic realm=\"VICI-ASTERISK\"");
|
||||
Header("HTTP/1.0 401 Unauthorized");
|
||||
echo "Unzulässiges Username/Kennwort:|$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if($auth>0)
|
||||
{
|
||||
$office_no=strtoupper($PHP_AUTH_USER);
|
||||
$password=strtoupper($PHP_AUTH_PW);
|
||||
$stmt="SELECT fullname from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$LOGfullname=$row[0];
|
||||
fwrite ($fp, "ASTERISK|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n");
|
||||
fclose($fp);
|
||||
|
||||
##### get server listing for dynamic pulldown
|
||||
$stmt="SELECT fullname from phones where server_ip='$server_ip' and extension='$extension'";
|
||||
$rsltx=mysql_query($stmt, $link);
|
||||
$rowx=mysql_fetch_row($rsltx);
|
||||
$fullname = $row[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
fwrite ($fp, "ASTERISK|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n");
|
||||
fclose($fp);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<title>ASTERISK ADMIN: Telefon-Notfall</title>
|
||||
</head>
|
||||
<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>
|
||||
<CENTER>
|
||||
<TABLE WIDTH=620 BGCOLOR=#D9E6FE cellpadding=2 cellspacing=0><TR BGCOLOR=#015B91><TD ALIGN=LEFT><FONT FACE="ARIAL,HELVETICA" COLOR=WHITE SIZE=2><B> STERNCHEN ADMIN: Leitung</TD><TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA" COLOR=WHITE SIZE=2><B><? echo date("l F j, Y G:i:s A") ?> </TD></TR>
|
||||
<TR BGCOLOR=#F0F5FE><TD ALIGN=LEFT COLSPAN=2><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=1><B> <a href="<? echo $admin_page ?>"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=1>VERZEICHNEN SIE ALLE TELEFONE</a> | <a href="<? echo $admin_page ?>?ADD=1"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=1>ADDIEREN Sie Ein NEUES TELEFON</a> | <a href="<? echo $admin_page ?>?ADD=5"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=1>SUCHE NACH Einem TELEFON</a> | <a href="<? echo $admin_page ?>?ADD=11"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=1>ADDIEREN Sie Einen BEDIENER</a> | <a href="<? echo $admin_page ?>?ADD=10"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=1>VERZEICHNEN SIE ALLE BEDIENER</a></TD></TR>
|
||||
<TR BGCOLOR=#F0F5FE><TD ALIGN=LEFT COLSPAN=2><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=1><B> <a href="<? echo $admin_page ?>?ADD=100"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=1>ZEIGEN SIE ALLE KONFERENZEN</a> | <a href="<? echo $admin_page ?>?ADD=111"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=1>ADDIEREN Sie Eine NEUE KONFERENZ</a></TD></TR>
|
||||
|
||||
|
||||
|
||||
|
||||
<?
|
||||
|
||||
echo "<TR BGCOLOR=\"#F0F5FE\"><TD ALIGN=LEFT COLSPAN=2><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2><B> \n";
|
||||
|
||||
echo "<form action=$PHP_SELF method=POST>\n";
|
||||
echo "<input type=hidden name=extension value=\"$extension\">\n";
|
||||
echo "<input type=hidden name=server_ip value=\"$server_ip\">\n";
|
||||
echo "<input type=text name=begin_date value=\"$begin_date\" size=10 maxsize=10> to \n";
|
||||
echo "<input type=text name=end_date value=\"$end_date\" size=10 maxsize=10> \n";
|
||||
echo "<input type=submit name=submit value=submit>\n";
|
||||
|
||||
|
||||
echo " $user - $full_name\n";
|
||||
|
||||
echo "</B></TD></TR>\n";
|
||||
echo "<TR><TD ALIGN=LEFT COLSPAN=2>\n";
|
||||
|
||||
|
||||
$stmt="SELECT count(*),channel_group, sum(length_in_sec) from call_log where extension='$extension' and server_ip='$server_ip' and start_time >= '$begin_date 0:00:01' and start_time <= '$end_date 23:59:59' group by channel_group order by channel_group";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
$statuses_to_print = mysql_num_rows($rslt);
|
||||
# echo "|$stmt|\n";
|
||||
|
||||
echo "<br><center>\n";
|
||||
|
||||
echo "<B>ANRUF-ZEIT UND FÜHRUNGEN:</B>\n";
|
||||
|
||||
echo "<center><TABLE width=300 cellspacing=0 cellpadding=1>\n";
|
||||
echo "<tr><td><font size=2>KANALGRUPPE </td><td align=right><font size=2>ZÄHLIMPULS</td><td align=right><font size=2> HOURS:MINUTES</td></tr>\n";
|
||||
|
||||
$total_calls=0;
|
||||
$o=0;
|
||||
while ($statuses_to_print > $o) {
|
||||
$row=mysql_fetch_row($rslt);
|
||||
if (eregi("1$|3$|5$|7$|9$", $o))
|
||||
{$bgcolor='bgcolor="#B9CBFD"';}
|
||||
else
|
||||
{$bgcolor='bgcolor="#9BB9FB"';}
|
||||
|
||||
$call_seconds = $row[2];
|
||||
$call_hours = ($call_seconds / 3600);
|
||||
$call_hours = round($call_hours, 2);
|
||||
$call_hours_int = intval("$call_hours");
|
||||
$call_minutes = ($call_hours - $call_hours_int);
|
||||
$call_minutes = ($call_minutes * 60);
|
||||
$call_minutes_int = round($call_minutes, 0);
|
||||
if ($call_minutes_int < 10) {$call_minutes_int = "0$call_minutes_int";}
|
||||
|
||||
echo "<tr $bgcolor><td><font size=2>$row[1]</td>";
|
||||
echo "<td align=right><font size=2> $row[0]</td>\n";
|
||||
echo "<td align=right><font size=2> $call_hours_int:$call_minutes_int</td></tr>\n";
|
||||
$total_calls = ($total_calls + $row[0]);
|
||||
|
||||
$call_seconds=0;
|
||||
$o++;
|
||||
}
|
||||
|
||||
$stmt="SELECT sum(length_in_sec) from call_log where extension='$extension' and server_ip='$server_ip' and start_time >= '$begin_date 0:00:01' and start_time <= '$end_date 23:59:59'";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
$counts_to_print = mysql_num_rows($rslt);
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$call_seconds = $row[0];
|
||||
$call_hours = ($call_seconds / 3600);
|
||||
$call_hours = round($call_hours, 2);
|
||||
$call_hours_int = intval("$call_hours");
|
||||
$call_minutes = ($call_hours - $call_hours_int);
|
||||
$call_minutes = ($call_minutes * 60);
|
||||
$call_minutes_int = round($call_minutes, 0);
|
||||
if ($call_minutes_int < 10) {$call_minutes_int = "0$call_minutes_int";}
|
||||
# echo "|$stmt|\n";
|
||||
|
||||
echo "<tr><td><font size=2>GESAMTANRUFE</td><td align=right><font size=2> $total_calls</td><td align=right><font size=2> $call_hours_int:$call_minutes_int</td></tr>\n";
|
||||
echo "</TABLE></center>\n";
|
||||
echo "<br><br>\n";
|
||||
|
||||
echo "<center>\n";
|
||||
|
||||
echo "<B>ANRUFE DES LETZT-1000 FÜR DATUM-STRECKE:</B>\n";
|
||||
echo "<TABLE width=400 cellspacing=0 cellpadding=1>\n";
|
||||
echo "<tr><td><font size=2>ZAHL </td><td><font size=2>KANALGRUPPE </td><td align=right><font size=2>DATUM</td><td align=right><font size=2> LENGTH(MIN.)</td></tr>\n";
|
||||
|
||||
$stmt="SELECT number_dialed,channel_group,start_time,length_in_min from call_log where extension='$extension' and server_ip='$server_ip' and start_time >= '$begin_date 0:00:01' and start_time <= '$end_date 23:59:59' LIMIT 1000";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
$events_to_print = mysql_num_rows($rslt);
|
||||
# echo "|$stmt|\n";
|
||||
|
||||
$total_calls=0;
|
||||
$o=0;
|
||||
$event_start_seconds='';
|
||||
$event_stop_seconds='';
|
||||
while ($events_to_print > $o) {
|
||||
$row=mysql_fetch_row($rslt);
|
||||
if (eregi("1$|3$|5$|7$|9$", $o))
|
||||
{$bgcolor='bgcolor="#B9CBFD"';}
|
||||
else
|
||||
{$bgcolor='bgcolor="#9BB9FB"';}
|
||||
echo "<tr $bgcolor><td><font size=2>$row[0]</td>";
|
||||
echo "<td align=right><font size=2> $row[1]</td>\n";
|
||||
echo "<td align=right><font size=2> $row[2]</td>\n";
|
||||
echo "<td align=right><font size=2> $row[3]</td></tr>\n";
|
||||
|
||||
|
||||
$call_seconds=0;
|
||||
$o++;
|
||||
}
|
||||
|
||||
|
||||
echo "</TABLE></center>\n";
|
||||
|
||||
|
||||
$ENDtime = date("U");
|
||||
|
||||
$RUNtime = ($ENDtime - $STARTtime);
|
||||
|
||||
echo "\n\n\n<br><br><br>\n\n";
|
||||
|
||||
|
||||
echo "<font size=0>\n\n\n<br><br><br>\nIndexlaufzeit: $RUNtime seconds</font>";
|
||||
|
||||
|
||||
?>
|
||||
|
||||
|
||||
</TD></TR><TABLE>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
<?
|
||||
|
||||
exit;
|
||||
|
||||
|
||||
|
||||
?>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,162 @@
|
||||
<?
|
||||
### remote_inbound.php
|
||||
###
|
||||
### Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
|
||||
###
|
||||
# the purpose of this script and webpage is to allow for remote or local users of the system to log in and grab phone calls that are coming inbound into the Asterisk server and being put in the parked_channels table while they hear a soundfile for a limited amount of time before being forwarded on to either a set extension or a voicemail box. This gives remote or local agents a way to grab calls without tying up their phone lines all day. The agent sees the refreshing screen of calls on park and when they want to take one they just click on it, and a small window opens that will allow them to grab the call and/or look up more information on the caller through the callerID that is given(if available)
|
||||
|
||||
require("dbconnect.php");
|
||||
|
||||
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
|
||||
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
|
||||
$PHP_SELF=$_SERVER['PHP_SELF'];
|
||||
$submit=$_GET["submit"]; if (!$submit) {$submit=$_POST["submit"];}
|
||||
$SUBMIT=$_GET["SUBMIT"]; if (!$SUBMIT) {$SUBMIT=$_POST["SUBMIT"];}
|
||||
|
||||
|
||||
$STARTtime = date("U");
|
||||
$TODAY = date("Y-m-d");
|
||||
$NOW_TIME = date("Y-m-d H:i:s");
|
||||
$popup_page = './inbound_popup.php';
|
||||
|
||||
$stmt="SELECT count(*) from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and active = 'Y' and status IN('ACTIVE','ADMIN');";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$auth=$row[0];
|
||||
|
||||
$fp = fopen ("./project_auth_entries.txt", "a");
|
||||
$date = date("r");
|
||||
$ip = getenv("REMOTE_ADDR");
|
||||
$browser = getenv("HTTP_USER_AGENT");
|
||||
|
||||
if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
|
||||
{
|
||||
Header("WWW-Authenticate: Basic realm=\"VICI-ASTERISK\"");
|
||||
Header("HTTP/1.0 401 Unauthorized");
|
||||
echo "Unzulässiges Username/Kennwort:|$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if($auth>0)
|
||||
{
|
||||
$office_no=strtoupper($PHP_AUTH_USER);
|
||||
$password=strtoupper($PHP_AUTH_PW);
|
||||
$stmt="SELECT fullname,dialplan_number from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'";
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$LOGfullname=$row[0];
|
||||
fwrite ($fp, "ASTERISK|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n");
|
||||
fclose($fp);
|
||||
|
||||
##### get server listing for dynamic pulldown
|
||||
$stmt="SELECT fullname,dialplan_number,server_ip from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'";
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$rsltx=mysql_query($stmt, $link);
|
||||
$rowx=mysql_fetch_row($rsltx);
|
||||
$fullname = $rowx[0];
|
||||
$dialplan_number = $rowx[1];
|
||||
$user_server_ip = $rowx[2];
|
||||
if ($DB) {echo "|$rowx[0]|$rowx[1]|$rowx[2]|\n";}
|
||||
}
|
||||
else
|
||||
{
|
||||
fwrite ($fp, "ASTERISK|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n");
|
||||
fclose($fp);
|
||||
}
|
||||
}
|
||||
|
||||
echo"<HTML><HEAD>\n";
|
||||
echo"<TITLE>ASTERISK ENTFERNTINBOUND: Hauptsächlich</TITLE></HEAD>\n";
|
||||
echo"<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=iso-8859-1\">\n";
|
||||
echo"<META HTTP-EQUIV=Refresh CONTENT=\"5; URL=$PHP_SELF\">\n";
|
||||
echo"</HEAD>\n";
|
||||
|
||||
?>
|
||||
|
||||
<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>
|
||||
<CENTER><FONT FACE="Courier" COLOR=BLACK SIZE=3>
|
||||
|
||||
<?
|
||||
|
||||
|
||||
echo "$NOW_TIME $PHP_AUTH_USER - $fullname - ANRUFE GESCHICKT ZU: $dialplan_number<BR><BR>\n";
|
||||
|
||||
echo "Klicken Sie an die Führung unter der, die Sie auf Ihr Telefonverwiesen haben möchten<BR><BR>\n";
|
||||
|
||||
echo "<PRE>\n";
|
||||
echo "CHANNEL BEDIENER CHANNEL_GROUP EXTENSION PARKED_BY PARKED_TIME \n";
|
||||
echo "----------------------------------------------------------------------------------------------\n";
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$stmt="SELECT count(*) from parked_channels where server_ip='$user_server_ip' order by parked_time";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$parked_count = $row[0];
|
||||
if ($parked_count > 0)
|
||||
{
|
||||
$stmt="SELECT * from parked_channels where server_ip='$user_server_ip' and channel_group LIKE \"IN_%\" order by parked_time";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$parked_to_print = mysql_num_rows($rslt);
|
||||
$i=0;
|
||||
while ($i < $parked_to_print)
|
||||
{
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$channel = sprintf("%-11s", $row[0]);
|
||||
$server = sprintf("%-14s", $row[1]);
|
||||
$channel_group = sprintf("%-16s", $row[2]);
|
||||
$extension = sprintf("%-13s", $row[3]);
|
||||
$parked_by = sprintf("%-21s", $row[4]);
|
||||
$parked_time = sprintf("%-19s", $row[5]);
|
||||
|
||||
echo "<A HREF=\"$popup_page?phone=$row[4]&channel=$row[0]&parked_time=$row[5]&server_ip=$user_server_ip&DB=\" target=\"_blank\">$channel</A>$server$channel_group$extension$parked_by$parked_time\n";
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "**********************************************************************************************\n";
|
||||
echo "**********************************************************************************************\n";
|
||||
echo "*************************************** NO PARKED CALLS **************************************\n";
|
||||
echo "**********************************************************************************************\n";
|
||||
echo "**********************************************************************************************\n";
|
||||
}
|
||||
|
||||
|
||||
$ENDtime = date("U");
|
||||
|
||||
$RUNtime = ($ENDtime - $STARTtime);
|
||||
|
||||
echo "</PRE>\n\n\n<br><br><br>\n\n";
|
||||
|
||||
|
||||
echo "<font size=0>\n\n\n<br><br><br>\nIndexlaufzeit: $RUNtime seconds</font>";
|
||||
|
||||
|
||||
?>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
<?
|
||||
|
||||
exit;
|
||||
|
||||
|
||||
|
||||
?>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,400 @@
|
||||
<?
|
||||
# AST_inboundEXTstats.php
|
||||
#
|
||||
# Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
|
||||
#
|
||||
# CHANGES
|
||||
# 60421-1450 - check GET/POST vars lines with isset to not trigger PHP NOTICES
|
||||
# 60620-1322 - Added variable filtering to eliminate SQL injection attack threat
|
||||
# - Added required user/pass to gain access to this page
|
||||
#
|
||||
|
||||
require("dbconnect.php");
|
||||
|
||||
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
|
||||
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
|
||||
$PHP_SELF=$_SERVER['PHP_SELF'];
|
||||
if (isset($_GET["group"])) {$group=$_GET["group"];}
|
||||
elseif (isset($_POST["group"])) {$group=$_POST["group"];}
|
||||
if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];}
|
||||
elseif (isset($_POST["query_date"])) {$query_date=$_POST["query_date"];}
|
||||
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
|
||||
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
|
||||
if (isset($_GET["submit"])) {$submit=$_GET["submit"];}
|
||||
elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];}
|
||||
if (isset($_GET["ΕΠΙΒΕΒΑΙΩΣΗ"])) {$ΕΠΙΒΕΒΑΙΩΣΗ=$_GET["ΕΠΙΒΕΒΑΙΩΣΗ"];}
|
||||
elseif (isset($_POST["ΕΠΙΒΕΒΑΙΩΣΗ"])) {$ΕΠΙΒΕΒΑΙΩΣΗ=$_POST["ΕΠΙΒΕΒΑΙΩΣΗ"];}
|
||||
|
||||
$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
|
||||
$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
|
||||
|
||||
$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;";
|
||||
if ($DB) {echo "|$stmt|\n";}
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$auth=$row[0];
|
||||
|
||||
if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
|
||||
{
|
||||
Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\"");
|
||||
Header("HTTP/1.0 401 Unauthorized");
|
||||
echo "Ακυρο Ονομα Χρήστη/Κωδικός Πρόσβασης: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$NOW_DATE = date("Y-m-d");
|
||||
$NOW_TIME = date("Y-m-d H:i:s");
|
||||
$STARTtime = date("U");
|
||||
if (!isset($query_date)) {$query_date = $NOW_DATE;}
|
||||
if (!isset($server_ip)) {$server_ip = '10.10.11.20';}
|
||||
|
||||
$stmt="select extension,full_number,inbound_name from inbound_numbers where server_ip='" . mysql_real_escape_string($server_ip) . "';";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$inbound_to_print = mysql_num_rows($rslt);
|
||||
$i=0;
|
||||
while ($i < $inbound_to_print)
|
||||
{
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$inbound[$i] =$row[0];
|
||||
$fullnum[$i] =$row[1];
|
||||
$inbname[$i] =$row[2];
|
||||
$i++;
|
||||
}
|
||||
?>
|
||||
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<STYLE type="text/css">
|
||||
<!--
|
||||
.green {color: white; background-color: green}
|
||||
.red {color: white; background-color: red}
|
||||
.blue {color: white; background-color: blue}
|
||||
.purple {color: white; background-color: purple}
|
||||
-->
|
||||
</STYLE>
|
||||
|
||||
<?
|
||||
echo"<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=iso-8859-1\">\n";
|
||||
#echo"<META HTTP-EQUIV=Refresh CONTENT=\"7; URL=$PHP_SELF?server_ip=$server_ip&DB=$DB\">\n";
|
||||
echo "<TITLE>ASTERISK: Στατιστικά Εισερχομένων Κλησεων</TITLE></HEAD><BODY BGCOLOR=WHITE>\n";
|
||||
echo "<FORM ACTION=\"$PHP_SELF\" METHOD=GET>\n";
|
||||
echo "<INPUT TYPE=HIDDEN NAME=server_ip VALUE=\"$server_ip\">\n";
|
||||
echo "<INPUT TYPE=TEXT NAME=query_date SIZE=10 MAXLENGTH=10 VALUE=\"$query_date\">\n";
|
||||
echo "<SELECT SIZE=1 NAME=group>\n";
|
||||
$o=0;
|
||||
while ($inbound_to_print > $o)
|
||||
{
|
||||
if ($inbound[$o] == $group) {echo "<option selected value=\"$inbound[$o]\">$fullnum[$o] - $inbname[$o]</option>\n";}
|
||||
else {echo "<option value=\"$inbound[$o]\">$fullnum[$o] - $inbname[$o]</option>\n";}
|
||||
$o++;
|
||||
}
|
||||
echo "</SELECT>\n";
|
||||
echo "<INPUT TYPE=Submit NAME=ΕΠΙΒΕΒΑΙΩΣΗ VALUE=ΥΠΟΒΑΛΛΩ>\n";
|
||||
echo "</FORM>\n\n";
|
||||
|
||||
echo "<PRE><FONT SIZE=2>\n\n";
|
||||
|
||||
|
||||
if (!$group)
|
||||
{
|
||||
echo "\n\n";
|
||||
echo "ΠΑΡΑΚΑΛΩ ΕΠΙΛΕΞΤΕ ΕΝΑΝ ΑΡΙΘΜΟ ΚΑΙ ΗΜΕΡΟΜΗΝΙΑ ΑΝΩΤΕΡΩ, ΚΑΙ ΠΑΤΗΣΤΕ ΕΠΙΒΕΒΑΙΩΣΗ\n";
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
|
||||
|
||||
echo "ASTERISK: Στατιστικά Εισερχομένων Κλησεων $NOW_TIME\n";
|
||||
|
||||
echo "\n";
|
||||
echo "---------- TOTALS\n";
|
||||
|
||||
$extenSQL = "and extension='" . mysql_real_escape_string($group) . "'";
|
||||
if (eregi("\*",$group))
|
||||
{$extenSQL = "and extension LIKE \"%$group\"";}
|
||||
$stmt="select count(*),sum(length_in_sec) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " 00:00:01' and start_time <= '" . mysql_real_escape_string($query_date) . " 23:59:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$row=mysql_fetch_row($rslt);
|
||||
|
||||
$TOTALcalls = sprintf("%10s", $row[0]);
|
||||
$average_hold_seconds = ($row[1] / $row[0]);
|
||||
$average_hold_seconds = round($average_hold_seconds, 0);
|
||||
$average_hold_seconds = sprintf("%10s", $average_hold_seconds);
|
||||
|
||||
echo "Συνολικές κλήσεις που ήρθαν σε αυτό τον αριθμό: $TOTALcalls\n";
|
||||
echo "Average Call Length(seconds) for all Calls: $average_hold_seconds\n";
|
||||
|
||||
echo "\n";
|
||||
echo "---------- ΕΓΚΑΤΑΛ\n";
|
||||
|
||||
$stmt="select count(*),sum(length_in_sec) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " 00:00:01' and start_time <= '" . mysql_real_escape_string($query_date) . " 23:59:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL and (length_in_sec <= 10 or length_in_sec is null);";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$row=mysql_fetch_row($rslt);
|
||||
|
||||
$DROPcalls = sprintf("%10s", $row[0]);
|
||||
$DROPpercent = (($DROPcalls / $TOTALcalls) * 100);
|
||||
$DROPpercent = round($DROPpercent, 0);
|
||||
|
||||
if ($row[0])
|
||||
{
|
||||
$average_hold_seconds = ($row[1] / $row[0]);
|
||||
$average_hold_seconds = round($average_hold_seconds, 0);
|
||||
$average_hold_seconds = sprintf("%10s", $average_hold_seconds);
|
||||
}
|
||||
else {$DROPpercent=0; $average_hold_seconds=0;}
|
||||
echo "Total DROP Calls: (less than 10 seconds) $DROPcalls $DROPpercent%\n";
|
||||
echo "Average Call Length(seconds) for DROP Calls: $average_hold_seconds\n";
|
||||
|
||||
|
||||
##############################
|
||||
######### CALLS STATS
|
||||
|
||||
echo "\n";
|
||||
echo "---------- CALL LISTINGS\n";
|
||||
echo "+----------------------+----------------------+--------+---------------------+\n";
|
||||
echo "| CALLERID | CALLERIDNAME | LENGTH | DATE TIME |\n";
|
||||
echo "+----------------------+----------------------+--------+---------------------+\n";
|
||||
|
||||
$stmt="select number_dialed,caller_code,length_in_sec,start_time from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " 00:00:01' and start_time <= '" . mysql_real_escape_string($query_date) . " 23:59:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$users_to_print = mysql_num_rows($rslt);
|
||||
$i=0;
|
||||
while ($i < $users_to_print)
|
||||
{
|
||||
$row=mysql_fetch_row($rslt);
|
||||
|
||||
$CID = sprintf("%-20s", $row[0]);
|
||||
$CIDname = sprintf("%-20s", $row[1]); while(strlen($full_name)>15) {$full_name = substr("$full_name", 0, -1);}
|
||||
$datetime = sprintf("%-19s", $row[3]);
|
||||
$USERavgTALK = $row[2];
|
||||
|
||||
$USERavgTALK_M = ($USERavgTALK / 60);
|
||||
$USERavgTALK_M = round($USERavgTALK_M, 2);
|
||||
$USERavgTALK_M_int = intval("$USERavgTALK_M");
|
||||
$USERavgTALK_S = ($USERavgTALK_M - $USERavgTALK_M_int);
|
||||
$USERavgTALK_S = ($USERavgTALK_S * 60);
|
||||
$USERavgTALK_S = round($USERavgTALK_S, 0);
|
||||
if ($USERavgTALK_S < 10) {$USERavgTALK_S = "0$USERavgTALK_S";}
|
||||
$USERavgTALK_MS = "$USERavgTALK_M_int:$USERavgTALK_S";
|
||||
$USERavgTALK_MS = sprintf("%6s", $USERavgTALK_MS);
|
||||
|
||||
echo "| $CID | $CIDname | $USERavgTALK_MS | $datetime |\n";
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
echo "+----------------------+----------------------+--------+---------------------+\n";
|
||||
|
||||
##############################
|
||||
######### TIME STATS
|
||||
|
||||
if ($output == 'FULL')
|
||||
{
|
||||
|
||||
echo "\n";
|
||||
echo "---------- ΣΤΑΤΙΣΤΙΚΑ ΧΡΟΝΟΥ\n";
|
||||
|
||||
echo "<FONT SIZE=0>\n";
|
||||
|
||||
$hi_hour_count=0;
|
||||
$last_full_record=0;
|
||||
$i=0;
|
||||
$h=0;
|
||||
while ($i <= 96)
|
||||
{
|
||||
$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:00:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:14:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$hour_count[$i] = $row[0];
|
||||
if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
|
||||
if ($hour_count[$i] > 0) {$last_full_record = $i;}
|
||||
$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:00:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:14:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL and (length_in_sec <= 10 or length_in_sec is null);";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$drop_count[$i] = $row[0];
|
||||
$i++;
|
||||
|
||||
|
||||
$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:15:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:29:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$hour_count[$i] = $row[0];
|
||||
if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
|
||||
if ($hour_count[$i] > 0) {$last_full_record = $i;}
|
||||
$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:15:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:29:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL and (length_in_sec <= 10 or length_in_sec is null);";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$drop_count[$i] = $row[0];
|
||||
$i++;
|
||||
|
||||
$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:30:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:44:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$hour_count[$i] = $row[0];
|
||||
if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
|
||||
if ($hour_count[$i] > 0) {$last_full_record = $i;}
|
||||
$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:30:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:44:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL and (length_in_sec <= 10 or length_in_sec is null);";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$drop_count[$i] = $row[0];
|
||||
$i++;
|
||||
|
||||
$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:45:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:59:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$hour_count[$i] = $row[0];
|
||||
if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
|
||||
if ($hour_count[$i] > 0) {$last_full_record = $i;}
|
||||
$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:45:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:59:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL and (length_in_sec <= 10 or length_in_sec is null);";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$drop_count[$i] = $row[0];
|
||||
$i++;
|
||||
$h++;
|
||||
}
|
||||
|
||||
$hour_multiplier = (100 / $hi_hour_count);
|
||||
#$hour_multiplier = round($hour_multiplier, 0);
|
||||
|
||||
echo "<!-- HICOUNT: $hi_hour_count|$hour_multiplier -->\n";
|
||||
echo "ΓΡΑΦΙΚΗ ΠΑΡΑΣΤΑΣΗ ΜΕ 15ΛΕΠΤΕΣ ΑΥΞΗΣΕΙΣ ΤΩΝ ΣΥΝΟΛΙΚΩΝ ΚΛΗΣΕΩΝ\n";
|
||||
|
||||
$k=1;
|
||||
$Mk=0;
|
||||
$call_scale = '0';
|
||||
while ($k <= 102)
|
||||
{
|
||||
if ($Mk >= 5)
|
||||
{
|
||||
$Mk=0;
|
||||
$scale_num=($k / $hour_multiplier);
|
||||
$scale_num = round($scale_num, 0);
|
||||
$LENscale_num = (strlen($scale_num));
|
||||
$k = ($k + $LENscale_num);
|
||||
$call_scale .= "$scale_num";
|
||||
}
|
||||
else
|
||||
{
|
||||
$call_scale .= " ";
|
||||
$k++; $Mk++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
|
||||
#echo "| HOUR | GRAPH IN 15 MINUTE INCREMENTS OF TOTAL INCOMING CALLS FOR THIS GROUP | DROPS | TOTAL |\n";
|
||||
echo "| HOUR |$call_scale| DROPS | TOTAL |\n";
|
||||
echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
|
||||
|
||||
$ZZ = '00';
|
||||
$i=0;
|
||||
$h=4;
|
||||
$hour= -1;
|
||||
$no_lines_yet=1;
|
||||
|
||||
while ($i <= 96)
|
||||
{
|
||||
$char_counter=0;
|
||||
$time = ' ';
|
||||
if ($h >= 4)
|
||||
{
|
||||
$hour++;
|
||||
$h=0;
|
||||
if ($hour < 10) {$hour = "0$hour";}
|
||||
$time = "+$hour$ZZ+";
|
||||
}
|
||||
if ($h == 1) {$time = " 15 ";}
|
||||
if ($h == 2) {$time = " 30 ";}
|
||||
if ($h == 3) {$time = " 45 ";}
|
||||
$Ghour_count = $hour_count[$i];
|
||||
if ($Ghour_count < 1)
|
||||
{
|
||||
if ( ($no_lines_yet) or ($i > $last_full_record) )
|
||||
{
|
||||
$do_nothing=1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$hour_count[$i] = sprintf("%-5s", $hour_count[$i]);
|
||||
echo "|$time|";
|
||||
$k=0; while ($k <= 102) {echo " "; $k++;}
|
||||
echo "| $hour_count[$i] |\n";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$no_lines_yet=0;
|
||||
$Xhour_count = ($Ghour_count * $hour_multiplier);
|
||||
$Yhour_count = (99 - $Xhour_count);
|
||||
|
||||
$Gdrop_count = $drop_count[$i];
|
||||
if ($Gdrop_count < 1)
|
||||
{
|
||||
$hour_count[$i] = sprintf("%-5s", $hour_count[$i]);
|
||||
|
||||
echo "|$time|<SPAN class=\"green\">";
|
||||
$k=0; while ($k <= $Xhour_count) {echo "*"; $k++; $char_counter++;}
|
||||
echo "*X</SPAN>"; $char_counter++;
|
||||
$k=0; while ($k <= $Yhour_count) {echo " "; $k++; $char_counter++;}
|
||||
while ($char_counter <= 101) {echo " "; $char_counter++;}
|
||||
echo "| 0 | $hour_count[$i] |\n";
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$Xdrop_count = ($Gdrop_count * $hour_multiplier);
|
||||
|
||||
# if ($Xdrop_count >= $Xhour_count) {$Xdrop_count = ($Xdrop_count - 1);}
|
||||
|
||||
$XXhour_count = ( ($Xhour_count - $Xdrop_count) - 1 );
|
||||
|
||||
$hour_count[$i] = sprintf("%-5s", $hour_count[$i]);
|
||||
$drop_count[$i] = sprintf("%-5s", $drop_count[$i]);
|
||||
|
||||
echo "|$time|<SPAN class=\"red\">";
|
||||
$k=0; while ($k <= $Xdrop_count) {echo ">"; $k++; $char_counter++;}
|
||||
echo "D</SPAN><SPAN class=\"green\">"; $char_counter++;
|
||||
$k=0; while ($k <= $XXhour_count) {echo "*"; $k++; $char_counter++;}
|
||||
echo "X</SPAN>"; $char_counter++;
|
||||
$k=0; while ($k <= $Yhour_count) {echo " "; $k++; $char_counter++;}
|
||||
while ($char_counter <= 102) {echo " "; $char_counter++;}
|
||||
echo "| $drop_count[$i] | $hour_count[$i] |\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$i++;
|
||||
$h++;
|
||||
}
|
||||
|
||||
|
||||
echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
?>
|
||||
</PRE>
|
||||
|
||||
</BODY></HTML>
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,15 @@
|
||||
<?
|
||||
|
||||
$link=mysql_connect("localhost", "cron", "1234");
|
||||
mysql_select_db("asterisk");
|
||||
|
||||
$local_DEF = 'Local/';
|
||||
$conf_silent_prefix = '7';
|
||||
$local_AMP = '@';
|
||||
$ext_context = 'demo';
|
||||
$recording_exten = '8309';
|
||||
|
||||
$WeBServeRRooT = '/usr/local/apache2/htdocs';
|
||||
$WeBRooTWritablE = '1';
|
||||
|
||||
?>
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 492 B |
@@ -0,0 +1,228 @@
|
||||
<?
|
||||
### inbound_popup.php
|
||||
###
|
||||
### Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
|
||||
###
|
||||
# this is the inbound popup of a specific call that grabs the call and allows you to go and fetch info on that caller in the local CRM system.
|
||||
#
|
||||
# changes:
|
||||
# 60620-1329 - Added variable filtering to eliminate SQL injection attack threat
|
||||
# - Added required user/pass to gain access to this page
|
||||
#
|
||||
|
||||
require("dbconnect.php");
|
||||
|
||||
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
|
||||
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
|
||||
$PHP_SELF=$_SERVER['PHP_SELF'];
|
||||
if (isset($_GET["vendor_id"])) {$vendor_id=$_GET["vendor_id"];}
|
||||
elseif (isset($_POST["vendor_id"])) {$vendor_id=$_POST["vendor_id"];}
|
||||
if (isset($_GET["phone"])) {$phone=$_GET["phone"];}
|
||||
elseif (isset($_POST["phone"])) {$phone=$_POST["phone"];}
|
||||
if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];}
|
||||
elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];}
|
||||
if (isset($_GET["first_name"])) {$first_name=$_GET["first_name"];}
|
||||
elseif (isset($_POST["first_name"])) {$first_name=$_POST["first_name"];}
|
||||
if (isset($_GET["last_name"])) {$last_name=$_GET["last_name"];}
|
||||
elseif (isset($_POST["last_name"])) {$last_name=$_POST["last_name"];}
|
||||
if (isset($_GET["phone_number"])) {$phone_number=$_GET["phone_number"];}
|
||||
elseif (isset($_POST["phone_number"])) {$phone_number=$_POST["phone_number"];}
|
||||
if (isset($_GET["end_call"])) {$end_call=$_GET["end_call"];}
|
||||
elseif (isset($_POST["end_call"])) {$end_call=$_POST["end_call"];}
|
||||
if (isset($_GET["DB"])) {$DB=$_GET["DB"];}
|
||||
elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];}
|
||||
if (isset($_GET["dispo"])) {$dispo=$_GET["dispo"];}
|
||||
elseif (isset($_POST["dispo"])) {$dispo=$_POST["dispo"];}
|
||||
if (isset($_GET["list_id"])) {$list_id=$_GET["list_id"];}
|
||||
elseif (isset($_POST["list_id"])) {$list_id=$_POST["list_id"];}
|
||||
if (isset($_GET["campaign_id"])) {$campaign_id=$_GET["campaign_id"];}
|
||||
elseif (isset($_POST["campaign_id"])) {$campaign_id=$_POST["campaign_id"];}
|
||||
if (isset($_GET["phone_code"])) {$phone_code=$_GET["phone_code"];}
|
||||
elseif (isset($_POST["phone_code"])) {$phone_code=$_POST["phone_code"];}
|
||||
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
|
||||
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
|
||||
if (isset($_GET["extension"])) {$extension=$_GET["extension"];}
|
||||
elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];}
|
||||
if (isset($_GET["channel"])) {$channel=$_GET["channel"];}
|
||||
elseif (isset($_POST["channel"])) {$channel=$_POST["channel"];}
|
||||
if (isset($_GET["call_began"])) {$call_began=$_GET["call_began"];}
|
||||
elseif (isset($_POST["call_began"])) {$call_began=$_POST["call_began"];}
|
||||
if (isset($_GET["parked_time"])) {$parked_time=$_GET["parked_time"];}
|
||||
elseif (isset($_POST["parked_time"])) {$parked_time=$_POST["parked_time"];}
|
||||
if (isset($_GET["tsr"])) {$tsr=$_GET["tsr"];}
|
||||
elseif (isset($_POST["tsr"])) {$tsr=$_POST["tsr"];}
|
||||
if (isset($_GET["address1"])) {$address1=$_GET["address1"];}
|
||||
elseif (isset($_POST["address1"])) {$address1=$_POST["address1"];}
|
||||
if (isset($_GET["address2"])) {$address2=$_GET["address2"];}
|
||||
elseif (isset($_POST["address2"])) {$address2=$_POST["address2"];}
|
||||
if (isset($_GET["address3"])) {$address3=$_GET["address3"];}
|
||||
elseif (isset($_POST["address3"])) {$address3=$_POST["address3"];}
|
||||
if (isset($_GET["city"])) {$city=$_GET["city"];}
|
||||
elseif (isset($_POST["city"])) {$city=$_POST["city"];}
|
||||
if (isset($_GET["state"])) {$state=$_GET["state"];}
|
||||
elseif (isset($_POST["state"])) {$state=$_POST["state"];}
|
||||
if (isset($_GET["postal_code"])) {$postal_code=$_GET["postal_code"];}
|
||||
elseif (isset($_POST["postal_code"])) {$postal_code=$_POST["postal_code"];}
|
||||
if (isset($_GET["province"])) {$province=$_GET["province"];}
|
||||
elseif (isset($_POST["province"])) {$province=$_POST["province"];}
|
||||
if (isset($_GET["country_code"])) {$country_code=$_GET["country_code"];}
|
||||
elseif (isset($_POST["country_code"])) {$country_code=$_POST["country_code"];}
|
||||
if (isset($_GET["alt_phone"])) {$alt_phone=$_GET["alt_phone"];}
|
||||
elseif (isset($_POST["alt_phone"])) {$alt_phone=$_POST["alt_phone"];}
|
||||
if (isset($_GET["email"])) {$email=$_GET["email"];}
|
||||
elseif (isset($_POST["email"])) {$email=$_POST["email"];}
|
||||
if (isset($_GET["security"])) {$security=$_GET["security"];}
|
||||
elseif (isset($_POST["security"])) {$security=$_POST["security"];}
|
||||
if (isset($_GET["comments"])) {$comments=$_GET["comments"];}
|
||||
elseif (isset($_POST["comments"])) {$comments=$_POST["comments"];}
|
||||
if (isset($_GET["status"])) {$status=$_GET["status"];}
|
||||
elseif (isset($_POST["status"])) {$status=$_POST["status"];}
|
||||
if (isset($_GET["submit"])) {$submit=$_GET["submit"];}
|
||||
elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];}
|
||||
if (isset($_GET["ΕΠΙΒΕΒΑΙΩΣΗ"])) {$ΕΠΙΒΕΒΑΙΩΣΗ=$_GET["ΕΠΙΒΕΒΑΙΩΣΗ"];}
|
||||
elseif (isset($_POST["ΕΠΙΒΕΒΑΙΩΣΗ"])) {$ΕΠΙΒΕΒΑΙΩΣΗ=$_POST["ΕΠΙΒΕΒΑΙΩΣΗ"];}
|
||||
|
||||
$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
|
||||
$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
|
||||
|
||||
$STARTtime = date("U");
|
||||
$TODAY = date("Y-m-d");
|
||||
$NOW_TIME = date("Y-m-d H:i:s");
|
||||
$popup_page = './inbound_popup.php';
|
||||
$FILE_datetime = $STARTtime;
|
||||
|
||||
$ext_context = 'demo';
|
||||
if (!isset($begin_date)) {$begin_date = $TODAY;}
|
||||
if (!isset($end_date)) {$end_date = $TODAY;}
|
||||
|
||||
$stmt="SELECT count(*) from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and active = 'Y' and status IN('ACTIVE','ADMIN');";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$auth=$row[0];
|
||||
|
||||
$fp = fopen ("./project_auth_entries.txt", "a");
|
||||
$date = date("r");
|
||||
$ip = getenv("REMOTE_ADDR");
|
||||
$browser = getenv("HTTP_USER_AGENT");
|
||||
|
||||
if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
|
||||
{
|
||||
Header("WWW-Authenticate: Basic realm=\"VICI-ASTERISK\"");
|
||||
Header("HTTP/1.0 401 Unauthorized");
|
||||
echo "Ακυρο Ονομα Χρήστη/Κωδικός Πρόσβασης: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if($auth>0)
|
||||
{
|
||||
$office_no=strtoupper($PHP_AUTH_USER);
|
||||
$password=strtoupper($PHP_AUTH_PW);
|
||||
$stmt="SELECT fullname,dialplan_number from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'";
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$LOGfullname=$row[0];
|
||||
fwrite ($fp, "ASTERISK|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n");
|
||||
fclose($fp);
|
||||
|
||||
##### get server listing for dynamic pulldown
|
||||
$stmt="SELECT fullname,dialplan_number,server_ip from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'";
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$rsltx=mysql_query($stmt, $link);
|
||||
$rowx=mysql_fetch_row($rsltx);
|
||||
$fullname = $rowx[0];
|
||||
$dialplan_number = $rowx[1];
|
||||
$user_server_ip = $rowx[2];
|
||||
if ($DB) {echo "|$rowx[0]|$rowx[1]|$rowx[2]|\n";}
|
||||
}
|
||||
else
|
||||
{
|
||||
fwrite ($fp, "ASTERISK|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n");
|
||||
fclose($fp);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<title>ASTERISK ΑΠΟΜΑΚΡΥΣΜΕΝΟ ΕΙΣΕΡΧΟΜΕΝΟ: Υπερεμφανιζόμενο Παραθύρο</title>
|
||||
</head>
|
||||
<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>
|
||||
<CENTER><FONT FACE="Courier" COLOR=BLACK SIZE=3>
|
||||
|
||||
<?
|
||||
|
||||
$stmt="SELECT count(*) from parked_channels where server_ip='$user_server_ip' and parked_time='" . mysql_real_escape_string($parked_time) . "' and channel='" . mysql_real_escape_string($channel) . "'";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$parked_count = $row[0];
|
||||
|
||||
if ($parked_count > 0)
|
||||
{
|
||||
|
||||
$stmt="DELETE from parked_channels where server_ip='$user_server_ip' and parked_time='" . mysql_real_escape_string($parked_time) . "' and channel='" . mysql_real_escape_string($channel) . "' LIMIT 1";
|
||||
if ($DB) {echo "|$stmt|\n";}
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
|
||||
$DTqueryCID = "RR$FILE_datetime$PHP_AUTH_USER";
|
||||
|
||||
### insert a NEW record to the vicidial_manager table to be processed
|
||||
$stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$user_server_ip','','Redirect','$DTqueryCID','Exten: $dialplan_number','Channel: " . mysql_real_escape_string($channel) . "','Context: $ext_context','Priority: 1','Callerid: $DTqueryCID','','','','','')";
|
||||
if ($DB) {echo "|$stmt|\n";}
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
|
||||
echo "Η εντολή ανακατεύθυνσης στάλθηκε για το κανάλι $channel $NOW_TIME\n<BR><BR>\n";
|
||||
|
||||
|
||||
$url = 'https://10.10.10.15/internal/back_end_systems/cust_serv/index.php?Search=SEARCH&';
|
||||
$Suser = 'username=';
|
||||
$Spass = '&passwd=';
|
||||
$Sphone = '&phone=';
|
||||
|
||||
$newurl = "$url$Suser$PHP_AUTH_USER$Spass$PHP_AUTH_PW$Sphone$phone";
|
||||
if ( ($phone == 'unknown') or (strlen($phone)<9) )
|
||||
{$newurl = "$url$Suser$PHP_AUTH_USER$Spass$PHP_AUTH_PW";}
|
||||
|
||||
echo "<a href=\"$newurl\">Αναζήτηση του Πελάτη στο Σύστημα Εξυπηρέτησης Πελατών</a>\n<BR><BR>\n";
|
||||
|
||||
echo "<a href=\"$PHP_SELF\">Κλείσε αυτό το παράθυρο</a>\n<BR><BR>\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "Η εντολή ανακατεύθυνσης ΑΠΕΤΥΧΕ για το κανάλι $channel $NOW_TIME\n<BR><BR>\n";
|
||||
echo "<a href=\"$PHP_SELF\">Κλείσε αυτό το παράθυρο</a>\n<BR><BR>\n";
|
||||
}
|
||||
|
||||
|
||||
|
||||
$ENDtime = date("U");
|
||||
|
||||
$RUNtime = ($ENDtime - $STARTtime);
|
||||
|
||||
echo "\n\n\n<br><br><br>\n\n";
|
||||
|
||||
|
||||
echo "<font size=0>\n\n\n<br><br><br>\nχρόνος εκτέλεσης διαδικασίας: $RUNtime seconds</font>";
|
||||
|
||||
|
||||
?>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
<?
|
||||
|
||||
exit;
|
||||
|
||||
|
||||
|
||||
?>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,244 @@
|
||||
<?
|
||||
# phone_stats.php.php
|
||||
#
|
||||
# Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
|
||||
#
|
||||
#
|
||||
# changes:
|
||||
# 60620-1333 - Added variable filtering to eliminate SQL injection attack threat
|
||||
# - Added required user/pass to gain access to this page
|
||||
#
|
||||
|
||||
require("dbconnect.php");
|
||||
|
||||
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
|
||||
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
|
||||
$PHP_SELF=$_SERVER['PHP_SELF'];
|
||||
if (isset($_GET["group"])) {$group=$_GET["group"];}
|
||||
elseif (isset($_POST["group"])) {$group=$_POST["group"];}
|
||||
if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];}
|
||||
elseif (isset($_POST["query_date"])) {$query_date=$_POST["query_date"];}
|
||||
if (isset($_GET["begin_date"])) {$begin_date=$_GET["begin_date"];}
|
||||
elseif (isset($_POST["begin_date"])) {$begin_date=$_POST["begin_date"];}
|
||||
if (isset($_GET["end_date"])) {$end_date=$_GET["end_date"];}
|
||||
elseif (isset($_POST["end_date"])) {$end_date=$_POST["end_date"];}
|
||||
if (isset($_GET["extension"])) {$extension=$_GET["extension"];}
|
||||
elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];}
|
||||
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
|
||||
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
|
||||
if (isset($_GET["user"])) {$user=$_GET["user"];}
|
||||
elseif (isset($_POST["user"])) {$user=$_POST["user"];}
|
||||
if (isset($_GET["full_name"])) {$full_name=$_GET["full_name"];}
|
||||
elseif (isset($_POST["full_name"])) {$full_name=$_POST["full_name"];}
|
||||
if (isset($_GET["submit"])) {$submit=$_GET["submit"];}
|
||||
elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];}
|
||||
if (isset($_GET["ΕΠΙΒΕΒΑΙΩΣΗ"])) {$ΕΠΙΒΕΒΑΙΩΣΗ=$_GET["ΕΠΙΒΕΒΑΙΩΣΗ"];}
|
||||
elseif (isset($_POST["ΕΠΙΒΕΒΑΙΩΣΗ"])) {$ΕΠΙΒΕΒΑΙΩΣΗ=$_POST["ΕΠΙΒΕΒΑΙΩΣΗ"];}
|
||||
|
||||
$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
|
||||
$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
|
||||
|
||||
$STARTtime = date("U");
|
||||
$TODAY = date("Y-m-d");
|
||||
$admin_page = './admin.php';
|
||||
|
||||
if (!isset($begin_date)) {$begin_date = $TODAY;}
|
||||
if (!isset($end_date)) {$end_date = $TODAY;}
|
||||
|
||||
$stmt="SELECT count(*) from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and active = 'Y' and status='ADMIN';";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$auth=$row[0];
|
||||
|
||||
$fp = fopen ("./project_auth_entries.txt", "a");
|
||||
$date = date("r");
|
||||
$ip = getenv("REMOTE_ADDR");
|
||||
$browser = getenv("HTTP_USER_AGENT");
|
||||
|
||||
if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
|
||||
{
|
||||
Header("WWW-Authenticate: Basic realm=\"VICI-ASTERISK\"");
|
||||
Header("HTTP/1.0 401 Unauthorized");
|
||||
echo "Ακυρο Ονομα Χρήστη/Κωδικός Πρόσβασης: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if($auth>0)
|
||||
{
|
||||
$office_no=strtoupper($PHP_AUTH_USER);
|
||||
$password=strtoupper($PHP_AUTH_PW);
|
||||
$stmt="SELECT fullname from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$LOGfullname=$row[0];
|
||||
fwrite ($fp, "ASTERISK|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n");
|
||||
fclose($fp);
|
||||
|
||||
##### get server listing for dynamic pulldown
|
||||
$stmt="SELECT fullname from phones where server_ip='$server_ip' and extension='$extension'";
|
||||
$rsltx=mysql_query($stmt, $link);
|
||||
$rowx=mysql_fetch_row($rsltx);
|
||||
$fullname = $row[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
fwrite ($fp, "ASTERISK|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n");
|
||||
fclose($fp);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<title>ASTERISK ADMIN: Στατιστικά Τηλεφώνου</title>
|
||||
</head>
|
||||
<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>
|
||||
<CENTER>
|
||||
<TABLE WIDTH=620 BGCOLOR=#D9E6FE cellpadding=2 cellspacing=0><TR BGCOLOR=#015B91><TD ALIGN=LEFT><FONT FACE="ARIAL,HELVETICA" COLOR=WHITE SIZE=2><B> ΣΥΣΤΗΜΑ ΚΛΗΣΕΩΝ: Διαχείριση</TD><TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA" COLOR=WHITE SIZE=2><B><? echo date("l F j, Y G:i:s A") ?> </TD></TR>
|
||||
<TR BGCOLOR=#F0F5FE><TD ALIGN=LEFT COLSPAN=2><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=1><B> <a href="<? echo $admin_page ?>"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=1>ΛΙΣΤΑ ΤΗΛΕΦΩΝΩΝ</a> | <a href="<? echo $admin_page ?>?ADD=1"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=1>ΠΡΟΣΘΗΚΗ ΤΗΛΕΦΩΝΟΥ</a> | <a href="<? echo $admin_page ?>?ADD=5"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=1>ΑΝΑΖΗΤΗΣΗ ΤΗΛΕΦΩΝΟΥ</a> | <a href="<? echo $admin_page ?>?ADD=11"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=1>ΠΡΟΣΘΗΚΗ ΔΙΑΚΟΜΙΣΤΗ</a> | <a href="<? echo $admin_page ?>?ADD=10"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=1>ΛΙΣΤΑ ΔΙΑΚΟΜΙΣΤΩΝ</a></TD></TR>
|
||||
<TR BGCOLOR=#F0F5FE><TD ALIGN=LEFT COLSPAN=2><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=1><B> <a href="<? echo $admin_page ?>?ADD=100"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=1>ΕΜΦΑΝΙΣΗ ΣΥΝΔΙΑΛΕΞΕΩΝ</a> | <a href="<? echo $admin_page ?>?ADD=111"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=1>ΠΡΟΣΘΗΚΗ ΣΥΝΔΙΑΛΕΞΗΣ</a></TD></TR>
|
||||
|
||||
|
||||
|
||||
|
||||
<?
|
||||
|
||||
echo "<TR BGCOLOR=\"#F0F5FE\"><TD ALIGN=LEFT COLSPAN=2><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2><B> \n";
|
||||
|
||||
echo "<form action=$PHP_SELF method=POST>\n";
|
||||
echo "<input type=hidden name=extension value=\"$extension\">\n";
|
||||
echo "<input type=hidden name=server_ip value=\"$server_ip\">\n";
|
||||
echo "<input type=text name=begin_date value=\"$begin_date\" size=10 maxsize=10> to \n";
|
||||
echo "<input type=text name=end_date value=\"$end_date\" size=10 maxsize=10> \n";
|
||||
echo "<input type=submit name=submit value=submit>\n";
|
||||
|
||||
|
||||
echo " $user - $full_name\n";
|
||||
|
||||
echo "</B></TD></TR>\n";
|
||||
echo "<TR><TD ALIGN=LEFT COLSPAN=2>\n";
|
||||
|
||||
|
||||
$stmt="SELECT count(*),channel_group, sum(length_in_sec) from call_log where extension='$extension' and server_ip='$server_ip' and start_time >= '$begin_date 0:00:01' and start_time <= '$end_date 23:59:59' group by channel_group order by channel_group";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
$statuses_to_print = mysql_num_rows($rslt);
|
||||
# echo "|$stmt|\n";
|
||||
|
||||
echo "<br><center>\n";
|
||||
|
||||
echo "<B>ΧΡΟΝΟΣ ΟΜΙΛΙΑΣ ΚΑΙ ΚΑΝΑΛΙΑ:</B>\n";
|
||||
|
||||
echo "<center><TABLE width=300 cellspacing=0 cellpadding=1>\n";
|
||||
echo "<tr><td><font size=2>ΚΑΝΑΛΙ ΟΜΑΔΑΣ </td><td align=right><font size=2>ΚΑΤΑΜΕΤΡΗΣΗ</td><td align=right><font size=2> ΩΡΕΣ:ΛΕΠΤΑ</td></tr>\n";
|
||||
|
||||
$total_calls=0;
|
||||
$o=0;
|
||||
while ($statuses_to_print > $o) {
|
||||
$row=mysql_fetch_row($rslt);
|
||||
if (eregi("1$|3$|5$|7$|9$", $o))
|
||||
{$bgcolor='bgcolor="#B9CBFD"';}
|
||||
else
|
||||
{$bgcolor='bgcolor="#9BB9FB"';}
|
||||
|
||||
$call_seconds = $row[2];
|
||||
$call_hours = ($call_seconds / 3600);
|
||||
$call_hours = round($call_hours, 2);
|
||||
$call_hours_int = intval("$call_hours");
|
||||
$call_minutes = ($call_hours - $call_hours_int);
|
||||
$call_minutes = ($call_minutes * 60);
|
||||
$call_minutes_int = round($call_minutes, 0);
|
||||
if ($call_minutes_int < 10) {$call_minutes_int = "0$call_minutes_int";}
|
||||
|
||||
echo "<tr $bgcolor><td><font size=2>$row[1]</td>";
|
||||
echo "<td align=right><font size=2> $row[0]</td>\n";
|
||||
echo "<td align=right><font size=2> $call_hours_int:$call_minutes_int</td></tr>\n";
|
||||
$total_calls = ($total_calls + $row[0]);
|
||||
|
||||
$call_seconds=0;
|
||||
$o++;
|
||||
}
|
||||
|
||||
$stmt="SELECT sum(length_in_sec) from call_log where extension='$extension' and server_ip='$server_ip' and start_time >= '$begin_date 0:00:01' and start_time <= '$end_date 23:59:59'";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
$counts_to_print = mysql_num_rows($rslt);
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$call_seconds = $row[0];
|
||||
$call_hours = ($call_seconds / 3600);
|
||||
$call_hours = round($call_hours, 2);
|
||||
$call_hours_int = intval("$call_hours");
|
||||
$call_minutes = ($call_hours - $call_hours_int);
|
||||
$call_minutes = ($call_minutes * 60);
|
||||
$call_minutes_int = round($call_minutes, 0);
|
||||
if ($call_minutes_int < 10) {$call_minutes_int = "0$call_minutes_int";}
|
||||
# echo "|$stmt|\n";
|
||||
|
||||
echo "<tr><td><font size=2>ΣΥΝΟΛΙΚΕΣ ΚΛΗΣΕΙΣ</td><td align=right><font size=2> $total_calls</td><td align=right><font size=2> $call_hours_int:$call_minutes_int</td></tr>\n";
|
||||
echo "</TABLE></center>\n";
|
||||
echo "<br><br>\n";
|
||||
|
||||
echo "<center>\n";
|
||||
|
||||
echo "<B>ΤΕΛΕΥΤΑΙΕΣ 1000 ΚΛΗΣΕΙΣ ΓΙΑ ΤΟ ΔΙΑΣΤΗΜΑ ΗΜΕΡΟΜΗΝΙΑΣ:</B>\n";
|
||||
echo "<TABLE width=400 cellspacing=0 cellpadding=1>\n";
|
||||
echo "<tr><td><font size=2>ΑΡΙΘΜΟΣ </td><td><font size=2>ΚΑΝΑΛΙ ΟΜΑΔΑΣ </td><td align=right><font size=2> ΗΜΕΡΑ</td><td align=right><font size=2> LENGTH(MIN.)</td></tr>\n";
|
||||
|
||||
$stmt="SELECT number_dialed,channel_group,start_time,length_in_min from call_log where extension='$extension' and server_ip='$server_ip' and start_time >= '$begin_date 0:00:01' and start_time <= '$end_date 23:59:59' LIMIT 1000";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
$events_to_print = mysql_num_rows($rslt);
|
||||
# echo "|$stmt|\n";
|
||||
|
||||
$total_calls=0;
|
||||
$o=0;
|
||||
$event_start_seconds='';
|
||||
$event_stop_seconds='';
|
||||
while ($events_to_print > $o) {
|
||||
$row=mysql_fetch_row($rslt);
|
||||
if (eregi("1$|3$|5$|7$|9$", $o))
|
||||
{$bgcolor='bgcolor="#B9CBFD"';}
|
||||
else
|
||||
{$bgcolor='bgcolor="#9BB9FB"';}
|
||||
echo "<tr $bgcolor><td><font size=2>$row[0]</td>";
|
||||
echo "<td align=right><font size=2> $row[1]</td>\n";
|
||||
echo "<td align=right><font size=2> $row[2]</td>\n";
|
||||
echo "<td align=right><font size=2> $row[3]</td></tr>\n";
|
||||
|
||||
|
||||
$call_seconds=0;
|
||||
$o++;
|
||||
}
|
||||
|
||||
|
||||
echo "</TABLE></center>\n";
|
||||
|
||||
|
||||
$ENDtime = date("U");
|
||||
|
||||
$RUNtime = ($ENDtime - $STARTtime);
|
||||
|
||||
echo "\n\n\n<br><br><br>\n\n";
|
||||
|
||||
|
||||
echo "<font size=0>\n\n\n<br><br><br>\nχρόνος εκτέλεσης διαδικασίας: $RUNtime seconds</font>";
|
||||
|
||||
|
||||
?>
|
||||
|
||||
|
||||
</TD></TR><TABLE>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
<?
|
||||
|
||||
exit;
|
||||
|
||||
|
||||
|
||||
?>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,162 @@
|
||||
<?
|
||||
### remote_inbound.php
|
||||
###
|
||||
### Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
|
||||
###
|
||||
# the purpose of this script and webpage is to allow for remote or local users of the system to log in and grab phone calls that are coming inbound into the Asterisk server and being put in the parked_channels table while they hear a soundfile for a limited amount of time before being forwarded on to either a set extension or a voicemail box. This gives remote or local agents a way to grab calls without tying up their phone lines all day. The agent sees the refreshing screen of calls on park and when they want to take one they just click on it, and a small window opens that will allow them to grab the call and/or look up more information on the caller through the callerID that is given(if available)
|
||||
|
||||
require("dbconnect.php");
|
||||
|
||||
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
|
||||
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
|
||||
$PHP_SELF=$_SERVER['PHP_SELF'];
|
||||
$submit=$_GET["submit"]; if (!$submit) {$submit=$_POST["submit"];}
|
||||
$ΕΠΙΒΕΒΑΙΩΣΗ=$_GET["ΕΠΙΒΕΒΑΙΩΣΗ"]; if (!$ΕΠΙΒΕΒΑΙΩΣΗ) {$ΕΠΙΒΕΒΑΙΩΣΗ=$_POST["ΕΠΙΒΕΒΑΙΩΣΗ"];}
|
||||
|
||||
|
||||
$STARTtime = date("U");
|
||||
$TODAY = date("Y-m-d");
|
||||
$NOW_TIME = date("Y-m-d H:i:s");
|
||||
$popup_page = './inbound_popup.php';
|
||||
|
||||
$stmt="SELECT count(*) from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and active = 'Y' and status IN('ACTIVE','ADMIN');";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$auth=$row[0];
|
||||
|
||||
$fp = fopen ("./project_auth_entries.txt", "a");
|
||||
$date = date("r");
|
||||
$ip = getenv("REMOTE_ADDR");
|
||||
$browser = getenv("HTTP_USER_AGENT");
|
||||
|
||||
if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
|
||||
{
|
||||
Header("WWW-Authenticate: Basic realm=\"VICI-ASTERISK\"");
|
||||
Header("HTTP/1.0 401 Unauthorized");
|
||||
echo "Ακυρο Ονομα Χρήστη/Κωδικός Πρόσβασης: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if($auth>0)
|
||||
{
|
||||
$office_no=strtoupper($PHP_AUTH_USER);
|
||||
$password=strtoupper($PHP_AUTH_PW);
|
||||
$stmt="SELECT fullname,dialplan_number from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'";
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$LOGfullname=$row[0];
|
||||
fwrite ($fp, "ASTERISK|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n");
|
||||
fclose($fp);
|
||||
|
||||
##### get server listing for dynamic pulldown
|
||||
$stmt="SELECT fullname,dialplan_number,server_ip from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'";
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$rsltx=mysql_query($stmt, $link);
|
||||
$rowx=mysql_fetch_row($rsltx);
|
||||
$fullname = $rowx[0];
|
||||
$dialplan_number = $rowx[1];
|
||||
$user_server_ip = $rowx[2];
|
||||
if ($DB) {echo "|$rowx[0]|$rowx[1]|$rowx[2]|\n";}
|
||||
}
|
||||
else
|
||||
{
|
||||
fwrite ($fp, "ASTERISK|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n");
|
||||
fclose($fp);
|
||||
}
|
||||
}
|
||||
|
||||
echo"<HTML><HEAD>\n";
|
||||
echo"<TITLE>ASTERISK ΑΠΟΜΑΚΡΥΣΜΕΝΟ ΕΙΣΕΡΧΟΜΕΝΟ: Κύριο</TITLE></HEAD>\n";
|
||||
echo"<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=iso-8859-1\">\n";
|
||||
echo"<META HTTP-EQUIV=Refresh CONTENT=\"5; URL=$PHP_SELF\">\n";
|
||||
echo"</HEAD>\n";
|
||||
|
||||
?>
|
||||
|
||||
<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>
|
||||
<CENTER><FONT FACE="Courier" COLOR=BLACK SIZE=3>
|
||||
|
||||
<?
|
||||
|
||||
|
||||
echo "$NOW_TIME $PHP_AUTH_USER - $fullname - ΚΛΗΣΕΙΣ ΣΤΑΛΘΗΚΑΝ ΠΡΟΣ: $dialplan_number<BR><BR>\n";
|
||||
|
||||
echo "Πατήστε στο κανάλι παρακάτω, που θα επιθυμούσατε να έχετε κατευθύνει στο τηλέφωνό σας<BR><BR>\n";
|
||||
|
||||
echo "<PRE>\n";
|
||||
echo "CHANNEL ΔΙΑΚΟΜΙΣΤΗΣ CHANNEL_GROUP EXTENSION PARKED_BY PARKED_TIME \n";
|
||||
echo "----------------------------------------------------------------------------------------------\n";
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$stmt="SELECT count(*) from parked_channels where server_ip='$user_server_ip' order by parked_time";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$parked_count = $row[0];
|
||||
if ($parked_count > 0)
|
||||
{
|
||||
$stmt="SELECT * from parked_channels where server_ip='$user_server_ip' and channel_group LIKE \"IN_%\" order by parked_time";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$parked_to_print = mysql_num_rows($rslt);
|
||||
$i=0;
|
||||
while ($i < $parked_to_print)
|
||||
{
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$channel = sprintf("%-11s", $row[0]);
|
||||
$server = sprintf("%-14s", $row[1]);
|
||||
$channel_group = sprintf("%-16s", $row[2]);
|
||||
$extension = sprintf("%-13s", $row[3]);
|
||||
$parked_by = sprintf("%-21s", $row[4]);
|
||||
$parked_time = sprintf("%-19s", $row[5]);
|
||||
|
||||
echo "<A HREF=\"$popup_page?phone=$row[4]&channel=$row[0]&parked_time=$row[5]&server_ip=$user_server_ip&DB=\" target=\"_blank\">$channel</A>$server$channel_group$extension$parked_by$parked_time\n";
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "**********************************************************************************************\n";
|
||||
echo "**********************************************************************************************\n";
|
||||
echo "*************************************** NO PARKED CALLS **************************************\n";
|
||||
echo "**********************************************************************************************\n";
|
||||
echo "**********************************************************************************************\n";
|
||||
}
|
||||
|
||||
|
||||
$ENDtime = date("U");
|
||||
|
||||
$RUNtime = ($ENDtime - $STARTtime);
|
||||
|
||||
echo "</PRE>\n\n\n<br><br><br>\n\n";
|
||||
|
||||
|
||||
echo "<font size=0>\n\n\n<br><br><br>\nχρόνος εκτέλεσης διαδικασίας: $RUNtime seconds</font>";
|
||||
|
||||
|
||||
?>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
<?
|
||||
|
||||
exit;
|
||||
|
||||
|
||||
|
||||
?>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,400 @@
|
||||
<?
|
||||
# AST_inboundEXTstats.php
|
||||
#
|
||||
# Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
|
||||
#
|
||||
# CHANGES
|
||||
# 60421-1450 - check GET/POST vars lines with isset to not trigger PHP NOTICES
|
||||
# 60620-1322 - Added variable filtering to eliminate SQL injection attack threat
|
||||
# - Added required user/pass to gain access to this page
|
||||
#
|
||||
|
||||
require("dbconnect.php");
|
||||
|
||||
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
|
||||
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
|
||||
$PHP_SELF=$_SERVER['PHP_SELF'];
|
||||
if (isset($_GET["group"])) {$group=$_GET["group"];}
|
||||
elseif (isset($_POST["group"])) {$group=$_POST["group"];}
|
||||
if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];}
|
||||
elseif (isset($_POST["query_date"])) {$query_date=$_POST["query_date"];}
|
||||
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
|
||||
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
|
||||
if (isset($_GET["submit"])) {$submit=$_GET["submit"];}
|
||||
elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];}
|
||||
if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];}
|
||||
elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];}
|
||||
|
||||
$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
|
||||
$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
|
||||
|
||||
$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;";
|
||||
if ($DB) {echo "|$stmt|\n";}
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$auth=$row[0];
|
||||
|
||||
if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
|
||||
{
|
||||
Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\"");
|
||||
Header("HTTP/1.0 401 Unauthorized");
|
||||
echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$NOW_DATE = date("Y-m-d");
|
||||
$NOW_TIME = date("Y-m-d H:i:s");
|
||||
$STARTtime = date("U");
|
||||
if (!isset($query_date)) {$query_date = $NOW_DATE;}
|
||||
if (!isset($server_ip)) {$server_ip = '10.10.11.20';}
|
||||
|
||||
$stmt="select extension,full_number,inbound_name from inbound_numbers where server_ip='" . mysql_real_escape_string($server_ip) . "';";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$inbound_to_print = mysql_num_rows($rslt);
|
||||
$i=0;
|
||||
while ($i < $inbound_to_print)
|
||||
{
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$inbound[$i] =$row[0];
|
||||
$fullnum[$i] =$row[1];
|
||||
$inbname[$i] =$row[2];
|
||||
$i++;
|
||||
}
|
||||
?>
|
||||
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<STYLE type="text/css">
|
||||
<!--
|
||||
.green {color: white; background-color: green}
|
||||
.red {color: white; background-color: red}
|
||||
.blue {color: white; background-color: blue}
|
||||
.purple {color: white; background-color: purple}
|
||||
-->
|
||||
</STYLE>
|
||||
|
||||
<?
|
||||
echo"<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=iso-8859-1\">\n";
|
||||
#echo"<META HTTP-EQUIV=Refresh CONTENT=\"7; URL=$PHP_SELF?server_ip=$server_ip&DB=$DB\">\n";
|
||||
echo "<TITLE>ASTERISK: Inbound Calls Stats</TITLE></HEAD><BODY BGCOLOR=WHITE>\n";
|
||||
echo "<FORM ACTION=\"$PHP_SELF\" METHOD=GET>\n";
|
||||
echo "<INPUT TYPE=HIDDEN NAME=server_ip VALUE=\"$server_ip\">\n";
|
||||
echo "<INPUT TYPE=TEXT NAME=query_date SIZE=10 MAXLENGTH=10 VALUE=\"$query_date\">\n";
|
||||
echo "<SELECT SIZE=1 NAME=group>\n";
|
||||
$o=0;
|
||||
while ($inbound_to_print > $o)
|
||||
{
|
||||
if ($inbound[$o] == $group) {echo "<option selected value=\"$inbound[$o]\">$fullnum[$o] - $inbname[$o]</option>\n";}
|
||||
else {echo "<option value=\"$inbound[$o]\">$fullnum[$o] - $inbname[$o]</option>\n";}
|
||||
$o++;
|
||||
}
|
||||
echo "</SELECT>\n";
|
||||
echo "<INPUT TYPE=SUBMIT NAME=SUBMIT VALUE=SUBMIT>\n";
|
||||
echo "</FORM>\n\n";
|
||||
|
||||
echo "<PRE><FONT SIZE=2>\n\n";
|
||||
|
||||
|
||||
if (!$group)
|
||||
{
|
||||
echo "\n\n";
|
||||
echo "PLEASE SELECT A NUMBER AND DATE ABOVE AND CLICK SUBMIT\n";
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
|
||||
|
||||
echo "ASTERISK: Inbound Calls Stats $NOW_TIME\n";
|
||||
|
||||
echo "\n";
|
||||
echo "---------- TOTALS\n";
|
||||
|
||||
$extenSQL = "and extension='" . mysql_real_escape_string($group) . "'";
|
||||
if (eregi("\*",$group))
|
||||
{$extenSQL = "and extension LIKE \"%$group\"";}
|
||||
$stmt="select count(*),sum(length_in_sec) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " 00:00:01' and start_time <= '" . mysql_real_escape_string($query_date) . " 23:59:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$row=mysql_fetch_row($rslt);
|
||||
|
||||
$TOTALcalls = sprintf("%10s", $row[0]);
|
||||
$average_hold_seconds = ($row[1] / $row[0]);
|
||||
$average_hold_seconds = round($average_hold_seconds, 0);
|
||||
$average_hold_seconds = sprintf("%10s", $average_hold_seconds);
|
||||
|
||||
echo "Total Calls That came into this number: $TOTALcalls\n";
|
||||
echo "Average Call Length(seconds) for all Calls: $average_hold_seconds\n";
|
||||
|
||||
echo "\n";
|
||||
echo "---------- DROPS\n";
|
||||
|
||||
$stmt="select count(*),sum(length_in_sec) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " 00:00:01' and start_time <= '" . mysql_real_escape_string($query_date) . " 23:59:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL and (length_in_sec <= 10 or length_in_sec is null);";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$row=mysql_fetch_row($rslt);
|
||||
|
||||
$DROPcalls = sprintf("%10s", $row[0]);
|
||||
$DROPpercent = (($DROPcalls / $TOTALcalls) * 100);
|
||||
$DROPpercent = round($DROPpercent, 0);
|
||||
|
||||
if ($row[0])
|
||||
{
|
||||
$average_hold_seconds = ($row[1] / $row[0]);
|
||||
$average_hold_seconds = round($average_hold_seconds, 0);
|
||||
$average_hold_seconds = sprintf("%10s", $average_hold_seconds);
|
||||
}
|
||||
else {$DROPpercent=0; $average_hold_seconds=0;}
|
||||
echo "Total DROP Calls: (less than 10 seconds) $DROPcalls $DROPpercent%\n";
|
||||
echo "Average Call Length(seconds) for DROP Calls: $average_hold_seconds\n";
|
||||
|
||||
|
||||
##############################
|
||||
######### CALLS STATS
|
||||
|
||||
echo "\n";
|
||||
echo "---------- CALL LISTINGS\n";
|
||||
echo "+----------------------+----------------------+--------+---------------------+\n";
|
||||
echo "| CALLERID | CALLERIDNAME | LENGTH | DATE TIME |\n";
|
||||
echo "+----------------------+----------------------+--------+---------------------+\n";
|
||||
|
||||
$stmt="select number_dialed,caller_code,length_in_sec,start_time from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " 00:00:01' and start_time <= '" . mysql_real_escape_string($query_date) . " 23:59:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$users_to_print = mysql_num_rows($rslt);
|
||||
$i=0;
|
||||
while ($i < $users_to_print)
|
||||
{
|
||||
$row=mysql_fetch_row($rslt);
|
||||
|
||||
$CID = sprintf("%-20s", $row[0]);
|
||||
$CIDname = sprintf("%-20s", $row[1]); while(strlen($full_name)>15) {$full_name = substr("$full_name", 0, -1);}
|
||||
$datetime = sprintf("%-19s", $row[3]);
|
||||
$USERavgTALK = $row[2];
|
||||
|
||||
$USERavgTALK_M = ($USERavgTALK / 60);
|
||||
$USERavgTALK_M = round($USERavgTALK_M, 2);
|
||||
$USERavgTALK_M_int = intval("$USERavgTALK_M");
|
||||
$USERavgTALK_S = ($USERavgTALK_M - $USERavgTALK_M_int);
|
||||
$USERavgTALK_S = ($USERavgTALK_S * 60);
|
||||
$USERavgTALK_S = round($USERavgTALK_S, 0);
|
||||
if ($USERavgTALK_S < 10) {$USERavgTALK_S = "0$USERavgTALK_S";}
|
||||
$USERavgTALK_MS = "$USERavgTALK_M_int:$USERavgTALK_S";
|
||||
$USERavgTALK_MS = sprintf("%6s", $USERavgTALK_MS);
|
||||
|
||||
echo "| $CID | $CIDname | $USERavgTALK_MS | $datetime |\n";
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
echo "+----------------------+----------------------+--------+---------------------+\n";
|
||||
|
||||
##############################
|
||||
######### TIME STATS
|
||||
|
||||
if ($output == 'FULL')
|
||||
{
|
||||
|
||||
echo "\n";
|
||||
echo "---------- TIME STATS\n";
|
||||
|
||||
echo "<FONT SIZE=0>\n";
|
||||
|
||||
$hi_hour_count=0;
|
||||
$last_full_record=0;
|
||||
$i=0;
|
||||
$h=0;
|
||||
while ($i <= 96)
|
||||
{
|
||||
$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:00:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:14:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$hour_count[$i] = $row[0];
|
||||
if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
|
||||
if ($hour_count[$i] > 0) {$last_full_record = $i;}
|
||||
$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:00:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:14:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL and (length_in_sec <= 10 or length_in_sec is null);";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$drop_count[$i] = $row[0];
|
||||
$i++;
|
||||
|
||||
|
||||
$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:15:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:29:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$hour_count[$i] = $row[0];
|
||||
if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
|
||||
if ($hour_count[$i] > 0) {$last_full_record = $i;}
|
||||
$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:15:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:29:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL and (length_in_sec <= 10 or length_in_sec is null);";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$drop_count[$i] = $row[0];
|
||||
$i++;
|
||||
|
||||
$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:30:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:44:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$hour_count[$i] = $row[0];
|
||||
if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
|
||||
if ($hour_count[$i] > 0) {$last_full_record = $i;}
|
||||
$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:30:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:44:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL and (length_in_sec <= 10 or length_in_sec is null);";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$drop_count[$i] = $row[0];
|
||||
$i++;
|
||||
|
||||
$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:45:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:59:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$hour_count[$i] = $row[0];
|
||||
if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
|
||||
if ($hour_count[$i] > 0) {$last_full_record = $i;}
|
||||
$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:45:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:59:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL and (length_in_sec <= 10 or length_in_sec is null);";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$drop_count[$i] = $row[0];
|
||||
$i++;
|
||||
$h++;
|
||||
}
|
||||
|
||||
$hour_multiplier = (100 / $hi_hour_count);
|
||||
#$hour_multiplier = round($hour_multiplier, 0);
|
||||
|
||||
echo "<!-- HICOUNT: $hi_hour_count|$hour_multiplier -->\n";
|
||||
echo "GRAPH IN 15 MINUTE INCREMENTS OF TOTAL CALLS\n";
|
||||
|
||||
$k=1;
|
||||
$Mk=0;
|
||||
$call_scale = '0';
|
||||
while ($k <= 102)
|
||||
{
|
||||
if ($Mk >= 5)
|
||||
{
|
||||
$Mk=0;
|
||||
$scale_num=($k / $hour_multiplier);
|
||||
$scale_num = round($scale_num, 0);
|
||||
$LENscale_num = (strlen($scale_num));
|
||||
$k = ($k + $LENscale_num);
|
||||
$call_scale .= "$scale_num";
|
||||
}
|
||||
else
|
||||
{
|
||||
$call_scale .= " ";
|
||||
$k++; $Mk++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
|
||||
#echo "| HOUR | GRAPH IN 15 MINUTE INCREMENTS OF TOTAL INCOMING CALLS FOR THIS GROUP | DROPS | TOTAL |\n";
|
||||
echo "| HOUR |$call_scale| DROPS | TOTAL |\n";
|
||||
echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
|
||||
|
||||
$ZZ = '00';
|
||||
$i=0;
|
||||
$h=4;
|
||||
$hour= -1;
|
||||
$no_lines_yet=1;
|
||||
|
||||
while ($i <= 96)
|
||||
{
|
||||
$char_counter=0;
|
||||
$time = ' ';
|
||||
if ($h >= 4)
|
||||
{
|
||||
$hour++;
|
||||
$h=0;
|
||||
if ($hour < 10) {$hour = "0$hour";}
|
||||
$time = "+$hour$ZZ+";
|
||||
}
|
||||
if ($h == 1) {$time = " 15 ";}
|
||||
if ($h == 2) {$time = " 30 ";}
|
||||
if ($h == 3) {$time = " 45 ";}
|
||||
$Ghour_count = $hour_count[$i];
|
||||
if ($Ghour_count < 1)
|
||||
{
|
||||
if ( ($no_lines_yet) or ($i > $last_full_record) )
|
||||
{
|
||||
$do_nothing=1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$hour_count[$i] = sprintf("%-5s", $hour_count[$i]);
|
||||
echo "|$time|";
|
||||
$k=0; while ($k <= 102) {echo " "; $k++;}
|
||||
echo "| $hour_count[$i] |\n";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$no_lines_yet=0;
|
||||
$Xhour_count = ($Ghour_count * $hour_multiplier);
|
||||
$Yhour_count = (99 - $Xhour_count);
|
||||
|
||||
$Gdrop_count = $drop_count[$i];
|
||||
if ($Gdrop_count < 1)
|
||||
{
|
||||
$hour_count[$i] = sprintf("%-5s", $hour_count[$i]);
|
||||
|
||||
echo "|$time|<SPAN class=\"green\">";
|
||||
$k=0; while ($k <= $Xhour_count) {echo "*"; $k++; $char_counter++;}
|
||||
echo "*X</SPAN>"; $char_counter++;
|
||||
$k=0; while ($k <= $Yhour_count) {echo " "; $k++; $char_counter++;}
|
||||
while ($char_counter <= 101) {echo " "; $char_counter++;}
|
||||
echo "| 0 | $hour_count[$i] |\n";
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$Xdrop_count = ($Gdrop_count * $hour_multiplier);
|
||||
|
||||
# if ($Xdrop_count >= $Xhour_count) {$Xdrop_count = ($Xdrop_count - 1);}
|
||||
|
||||
$XXhour_count = ( ($Xhour_count - $Xdrop_count) - 1 );
|
||||
|
||||
$hour_count[$i] = sprintf("%-5s", $hour_count[$i]);
|
||||
$drop_count[$i] = sprintf("%-5s", $drop_count[$i]);
|
||||
|
||||
echo "|$time|<SPAN class=\"red\">";
|
||||
$k=0; while ($k <= $Xdrop_count) {echo ">"; $k++; $char_counter++;}
|
||||
echo "D</SPAN><SPAN class=\"green\">"; $char_counter++;
|
||||
$k=0; while ($k <= $XXhour_count) {echo "*"; $k++; $char_counter++;}
|
||||
echo "X</SPAN>"; $char_counter++;
|
||||
$k=0; while ($k <= $Yhour_count) {echo " "; $k++; $char_counter++;}
|
||||
while ($char_counter <= 102) {echo " "; $char_counter++;}
|
||||
echo "| $drop_count[$i] | $hour_count[$i] |\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$i++;
|
||||
$h++;
|
||||
}
|
||||
|
||||
|
||||
echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
?>
|
||||
</PRE>
|
||||
|
||||
</BODY></HTML>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user