diff --git a/agc_2-X/trunk/UPGRADE b/agc_2-X/trunk/UPGRADE index 45e38cb4..d81f5d27 100644 --- a/agc_2-X/trunk/UPGRADE +++ b/agc_2-X/trunk/UPGRADE @@ -175,6 +175,16 @@ OTHER CHANGES: allows you to prevent the use of a status by an agent if they have talked to a customer less than X seconds or more than Y seconds. +43. Added the system setting USA-Canada Phone Number Dialcode Fix which will + trigger a process that will run at the Timeclock End of Day that will + check all phone numbers to populate the dial code, or phone code, field + with a 1 if it is missing as well as remove a leading 1 from the phone + number field if it is present. + +44. Added --lstn-buffer option to keepalive script to run special enhanced + buffer version of the Listen process. Requires newer Net::Telnet perl + module version. + diff --git a/agc_2-X/trunk/bin/ADMIN_keepalive_ALL.pl b/agc_2-X/trunk/bin/ADMIN_keepalive_ALL.pl index 771605eb..c96d1ee9 100644 --- a/agc_2-X/trunk/bin/ADMIN_keepalive_ALL.pl +++ b/agc_2-X/trunk/bin/ADMIN_keepalive_ALL.pl @@ -101,9 +101,10 @@ # 150307-1738 - Added custom meetme enter sounds(only works with Asterisk 1.8) # 150724-0835 - Added purge of vicidial_ajax_log records older than 7 days to end of day process # 150804-0919 - Added whisper extensions +# 151031-0931 - Added usacan_phone_dialcode_fix feature at timeclock-end-of-day, added -lstn-buffer option # -$build = '150804-0919'; +$build = '151031-0931'; $DB=0; # Debug flag @@ -190,6 +191,7 @@ if (length($ARGV[0])>1) print " [-adfill-delay=X] = setting delay milliseconds on auto-dial FILL process\n"; print " [-fill-staggered] = enable experimental staggered auto-dial FILL process\n"; print " [-cu3way] = keepalive for the optional 3way conference checker\n"; + print " [-lstn-buffer] = use special enhanced telnet buffer listen process\n"; print " [-cu3way-delay=X] = setting delay seconds on 3way conference checker\n"; print " [-debug] = verbose debug messages\n"; print " [-debugX] = Extra-verbose debug messages\n"; @@ -258,6 +260,11 @@ if (length($ARGV[0])>1) $cu3way=1; if ($DB > 0) {print "\n----- cu3way ENABLED -----\n\n";} } + if ($args =~ /-lstn-buffer/i) + { + $lstn_buffer=1; + if ($DB > 0) {print "\n----- lstn_buffer ENABLED -----\n\n";} + } if ($args =~ /-cu3way-delay=/i) # CLI defined delay { @CLIvarARY = split(/-cu3way-delay=/,$args); @@ -667,7 +674,10 @@ else { 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 $PATHhome/AST_manager_listen.pl`; + if ($lstn_buffer > 0) + {`/usr/bin/screen -d -m -S ASTlisten $PATHhome/AST_manager_listenBUFFER.pl`;} + else + {`/usr/bin/screen -d -m -S ASTlisten $PATHhome/AST_manager_listen.pl`;} } if ( ($AST_VDauto_dial > 0) && ($runningAST_VDauto_dial < 1) ) { @@ -800,7 +810,7 @@ $sthA->finish(); if ($timeclock_end_of_day_NOW > 0) { - $stmtA = "SELECT agents_calls_reset from system_settings;"; + $stmtA = "SELECT agents_calls_reset,usacan_phone_dialcode_fix from system_settings;"; if ($DB) {print "|$stmtA|\n";} $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; @@ -808,7 +818,8 @@ if ($timeclock_end_of_day_NOW > 0) if ($SSsel_ct > 0) { @aryA = $sthA->fetchrow_array; - $agents_calls_reset = $aryA[0]; + $agents_calls_reset = $aryA[0]; + $usacan_phone_dialcode_fix = $aryA[1]; } $sthA->finish(); @@ -1270,7 +1281,6 @@ if ($timeclock_end_of_day_NOW > 0) ##### END ra stats end of day process ##### - ##### BEGIN vicidial_ajax_log end of day process removing records older than 7 days ##### $stmtA = "DELETE from vicidial_ajax_log where db_time < \"$SDSQLdate\";"; if($DBX){print STDERR "\n|$stmtA|\n";} @@ -1288,6 +1298,29 @@ if ($timeclock_end_of_day_NOW > 0) ##### END vicidial_ajax_log end of day process removing records older than 7 days ##### + ##### BEGIN usacan_phone_dialcode_fix funciton ##### + if ($usacan_phone_dialcode_fix > 0) + { + $stmtA = "UPDATE vicidial_list SET phone_code='1' where phone_code!='1';"; + if($DBX){print STDERR "\n|$stmtA|\n";} + $PCaffected_rows = $dbhA->do($stmtA); + if($DB){print STDERR "\n|$PCaffected_rows vicidial_list.phone_code entries set to 1|\n";} + + $stmtA = "UPDATE vicidial_list SET phone_number = TRIM(LEADING '1' from phone_number) where char_length(phone_number) > 10 and phone_number LIKE \"1%\";"; + if($DBX){print STDERR "\n|$stmtA|\n";} + $PNaffected_rows = $dbhA->do($stmtA); + if($DB){print STDERR "\n|$PNaffected_rows vicidial_list phone_number leading 1 entries trimmed|\n";} + + if ( ($PCaffected_rows > 0) or ($PNaffected_rows > 0) ) + { + if ($DB) {print "restarting Asterisk process...\n";} + $stmtA="INSERT INTO vicidial_admin_log set event_date=NOW(), user='VDAD', ip_address='1.1.1.1', event_section='SERVERS', event_type='MODIFY', record_id='leads', event_code='USACAN PHONE DIALCODE FIX', event_sql='', event_notes='$PCaffected_rows vicidial_list.phone_code entries set to 1|$PNaffected_rows vicidial_list phone_number leading 1 entries trimmed|';"; + $Laffected_rows = $dbhA->do($stmtA); + if ($DBX) {print "Admin log of USACAN phone code fix: |$Laffected_rows|$stmtA|\n";} + } + } + ##### END usacan_phone_dialcode_fix funciton ##### + $dbhC = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VARDB_custom_user", "$VARDB_custom_pass") or die "Couldn't connect to database: " . DBI->errstr; diff --git a/agc_2-X/trunk/bin/AST_manager_listen.pl b/agc_2-X/trunk/bin/AST_manager_listen.pl index a30756cf..641e0712 100644 --- a/agc_2-X/trunk/bin/AST_manager_listen.pl +++ b/agc_2-X/trunk/bin/AST_manager_listen.pl @@ -46,6 +46,7 @@ # 141219-1137 - Change to keepalive processes to not run at busy times and not drop buffer # 150610-1200 - Added support for AMI version 1.3 # 150709-1506 - Added DTMF logging for Asterisk 1.8 and higher +# 151031-0918 - Added better capture of errors in telnet connection, other small fixes # # constants @@ -253,6 +254,14 @@ while($one_day_interval > 0) $read_input_buf = $tn->get(Errmode => Return, Timeout => 1,); $input_buf_length = length($read_input_buf); $msg = $tn->errmsg; + if (($msg =~ /read timed-out/i) || ( $msg eq '' )) + { + # This is normal + } + else + { + print "ERRMSG: |$msg|\n"; + } if ($msg =~ /filehandle isn\'t open/i) { $endless_loop=0; @@ -833,7 +842,10 @@ while($one_day_interval > 0) { $keepalive_skips=0; @keepalive_output = $tn->cmd(String => "Action: Command\nCommand: show uptime\n\n", Prompt => '/--END COMMAND--.*/', Errmode => Return, Timeout => 1); - if($DB){print "keepalive length: $#keepalive_output|$now_date\n";} + $msg = $tn->errmsg; + $buf_ref = $tn->buffer; + $buf_len = length( $$buf_ref ); + if($DB){print "keepalive length: $#keepalive_output|$now_date|$msg|$buf_len|\n";} if($DB){print "+++++++++++++++++++++++++++++++sending keepalive transmit line: $keepalive_sec seconds $endless_loop|$now_date|$last_update|\n";} @@ -845,16 +857,19 @@ while($one_day_interval > 0) } $manager_string="PROCESS: keepalive length: $#keepalive_output|$k|$now_date"; &manager_output_logger; + $last_keepalive_epoch = time(); } else { $keepalive_skips++; - if($DB){print "-------------------------------no keepalive transmit necessary: $keepalive_sec seconds($keepalive_skips in a row) $endless_loop|$now_date|$last_update|\n";} + $buf_ref = $tn->buffer; + $buf_len = length( $$buf_ref ); + if($DB){print "-------------------------------no keepalive transmit necessary: $keepalive_sec seconds($keepalive_skips in a row) $endless_loop|$now_date|$last_update|$buf_len|\n";} $manager_string="PROCESS: keepalive skip: $keepalive_sec seconds($keepalive_skips in a row)|$now_date"; &manager_output_logger; } - $last_keepalive_epoch = time(); + #$last_keepalive_epoch = time(); $keepalive_count_loop=0; } } @@ -873,6 +888,14 @@ while($one_day_interval > 0) $read_input_buf = $tn->get(Errmode => Return, Timeout => 1,); $input_buf_length = length($read_input_buf); $msg = $tn->errmsg; + if (($msg =~ /read timed-out/i) || ( $msg eq '' )) + { + # This is normal + } + else + { + print "ERRMSG: |$msg|\n"; + } if ($msg =~ /filehandle isn\'t open/i) { $endless_loop=0; @@ -1361,7 +1384,10 @@ while($one_day_interval > 0) { $keepalive_skips=0; @keepalive_output = $tn->cmd(String => "Action: Command\nCommand: core show uptime\n\n", Prompt => '/--END COMMAND--.*/', Errmode => Return, Timeout => 1); - if($DB){print "keepalive length: $#keepalive_output|$now_date\n";} + $msg = $tn->errmsg; + $buf_ref = $tn->buffer; + $buf_len = length( $$buf_ref ); + if($DB){print "keepalive length: $#keepalive_output|$now_date|$msg|$buf_len|\n";} if($DB){print "+++++++++++++++++++++++++++++++sending keepalive transmit line: $keepalive_sec seconds $endless_loop|$now_date|$last_update|\n";} @@ -1373,16 +1399,19 @@ while($one_day_interval > 0) } $manager_string="PROCESS: keepalive length: $#keepalive_output|$k|$now_date"; &manager_output_logger; + $last_keepalive_epoch = time(); } else { $keepalive_skips++; - if($DB){print "-------------------------------no keepalive transmit necessary: $keepalive_sec seconds($keepalive_skips in a row) $endless_loop|$now_date|$last_update|\n";} + $buf_ref = $tn->buffer; + $buf_len = length( $$buf_ref ); + if($DB){print "-------------------------------no keepalive transmit necessary: $keepalive_sec seconds($keepalive_skips in a row) $endless_loop|$now_date|$last_update|$buf_len|\n";} $manager_string="PROCESS: keepalive skip: $keepalive_sec seconds($keepalive_skips in a row)|$now_date"; &manager_output_logger; } - $last_keepalive_epoch = time(); + #$last_keepalive_epoch = time(); $keepalive_count_loop=0; } diff --git a/agc_2-X/trunk/bin/AST_manager_listenBUFFER.pl b/agc_2-X/trunk/bin/AST_manager_listenBUFFER.pl new file mode 100644 index 00000000..42024dd4 --- /dev/null +++ b/agc_2-X/trunk/bin/AST_manager_listenBUFFER.pl @@ -0,0 +1,1556 @@ +#!/usr/bin/perl +# +# AST_manager_listenBUFFER.pl version 2.12 +# +# 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. This program is run by +# the ADMIN_keepalive_ALL.pl script, which makes sure it is always running in a +# screen, provided that the astguiclient.conf keepalive setting "2" is set. +# +# Copyright (C) 2015 Matt Florell LICENSE: AGPLv2 +# +# 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.4 support for different output +# 60718-0909 - changed to DBI by Marin Blu +# 60718-0955 - changed to use /etc/astguiclient.conf for configs +# 60720-1142 - added keepalive to MySQL connection every 50 seconds +# 60814-1733 - added option for no logging to file +# 60906-1714 - added updating for special vicidial conference calls +# 71129-2004 - Fixed SQL error +# 100416-0635 - Added fix for extension append feature +# 100625-1220 - Added waitfors after logout to fix broken pipe errors in asterisk +# 100903-0041 - Changed lead_id max length to 10 digits +# 130108-1705 - Changes for Asterisk 1.8 compatibility +# 130412-1216 - Added sip hangup cause logging from new patch AMI event +# 130418-1946 - Changed asterisk 1.8 compatibility for CPD and SIP Hangup +# 140524-0900 - Fixed issue with consultative agent transfers in Asterisk 1.8 +# 141113-1605 - Added concurrency check +# 141124-2309 - Fixed Fhour variable bug +# 141219-1137 - Change to keepalive processes to not run at busy times and not drop buffer +# 150610-1200 - Added support for AMI version 1.3 +# 150709-1506 - Added DTMF logging for Asterisk 1.8 and higher +# 151031-0651 - Added perl telnet buffer options, requires newer versions of Net::Telnet CPAN module +# + +# constants +$DB=1; # Debug flag, set to 0 for no debug messages, lots of output +$US='__'; +$MT[0]=''; +$vdcl_update=0; +$vddl_update=0; +$run_check=1; # concurrency check +$last_keepalive_epoch = time(); +$keepalive_skips=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"; + print " [--test] = test\n"; + print " [--debug] = verbose debug messages\n"; + print " [--debugX] = Extra-verbose debug messages\n"; + print " [--help] = this screen\n"; + print "\n"; + exit; + } + else + { + if ($args =~ /--debug/i) + { + $DB=1; # Debug flag + print "\n----- DEBUGGING ENABLED -----\n\n"; + } + if ($args =~ /--debugX/i) + { + $DBX=1; + print "\n----- SUPER-DUPER DEBUGGING -----\n\n"; + } + if ($args =~ /--test/i) + { + $TEST=1; + $T=1; + } + } + } +else + { + # print "no command line options set\n"; + } +### end parsing run-time options ### + +# default path to astguiclient configuration file: +$PATHconf = '/etc/astguiclient.conf'; + +open(conf, "$PATHconf") || die "can't open $PATHconf: $!\n"; +@conf = ; +close(conf); +$i=0; +foreach(@conf) + { + $line = $conf[$i]; + $line =~ s/ |>|\n|\r|\t|\#.*|;.*//gi; + if ( ($line =~ /^PATHhome/) && ($CLIhome < 1) ) + {$PATHhome = $line; $PATHhome =~ s/.*=//gi;} + if ( ($line =~ /^PATHlogs/) && ($CLIlogs < 1) ) + {$PATHlogs = $line; $PATHlogs =~ s/.*=//gi;} + if ( ($line =~ /^PATHagi/) && ($CLIagi < 1) ) + {$PATHagi = $line; $PATHagi =~ s/.*=//gi;} + if ( ($line =~ /^PATHweb/) && ($CLIweb < 1) ) + {$PATHweb = $line; $PATHweb =~ s/.*=//gi;} + if ( ($line =~ /^PATHsounds/) && ($CLIsounds < 1) ) + {$PATHsounds = $line; $PATHsounds =~ s/.*=//gi;} + if ( ($line =~ /^PATHmonitor/) && ($CLImonitor < 1) ) + {$PATHmonitor = $line; $PATHmonitor =~ s/.*=//gi;} + if ( ($line =~ /^VARserver_ip/) && ($CLIserver_ip < 1) ) + {$VARserver_ip = $line; $VARserver_ip =~ s/.*=//gi;} + if ( ($line =~ /^VARDB_server/) && ($CLIDB_server < 1) ) + {$VARDB_server = $line; $VARDB_server =~ s/.*=//gi;} + if ( ($line =~ /^VARDB_database/) && ($CLIDB_database < 1) ) + {$VARDB_database = $line; $VARDB_database =~ s/.*=//gi;} + if ( ($line =~ /^VARDB_user/) && ($CLIDB_user < 1) ) + {$VARDB_user = $line; $VARDB_user =~ s/.*=//gi;} + if ( ($line =~ /^VARDB_pass/) && ($CLIDB_pass < 1) ) + {$VARDB_pass = $line; $VARDB_pass =~ s/.*=//gi;} + if ( ($line =~ /^VARDB_port/) && ($CLIDB_port < 1) ) + {$VARDB_port = $line; $VARDB_port =~ s/.*=//gi;} + $i++; + } + +# Customized Variables +$server_ip = $VARserver_ip; # Asterisk server IP + +if (!$VARDB_port) {$VARDB_port='3306';} + + &get_time_now; + +#use lib './lib', '../lib'; +use Time::HiRes ('gettimeofday','usleep','sleep'); # necessary to have perl sleep command of less than one second +use DBI; +use Net::Telnet (); + +$dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass") +or die "Couldn't connect to database: " . DBI->errstr; + +### Grab Server values from the database +$stmtA = "SELECT telnet_host,telnet_port,ASTmgrUSERNAME,ASTmgrSECRET,ASTmgrUSERNAMEupdate,ASTmgrUSERNAMElisten,ASTmgrUSERNAMEsend,max_vicidial_trunks,answer_transfer_agent,local_gmt,ext_context,vd_server_logs,asterisk_version FROM servers where server_ip = '$server_ip';"; +$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; +$sthA->execute or die "executing: $stmtA ", $dbhA->errstr; +$sthArows=$sthA->rows; +if ($sthArows > 0) + { + @aryA = $sthA->fetchrow_array; + $DBtelnet_host = $aryA[0]; + $DBtelnet_port = $aryA[1]; + $DBASTmgrUSERNAME = $aryA[2]; + $DBASTmgrSECRET = $aryA[3]; + $DBASTmgrUSERNAMEupdate = $aryA[4]; + $DBASTmgrUSERNAMElisten = $aryA[5]; + $DBASTmgrUSERNAMEsend = $aryA[6]; + $DBmax_vicidial_trunks = $aryA[7]; + $DBanswer_transfer_agent= $aryA[8]; + $DBSERVER_GMT = $aryA[9]; + $DBext_context = $aryA[10]; + $DBvd_server_logs = $aryA[11]; + $asterisk_version = $aryA[12]; + 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 ($DBvd_server_logs =~ /Y/) {$SYSLOG = '1';} + else {$SYSLOG = '0';} + } +$sthA->finish(); + +if (!$telnet_port) {$telnet_port = '5038';} + + $event_string='LOGGED INTO MYSQL SERVER ON 1 CONNECTION|'; + &event_logger; + +### concurrency check (SCREEN uses script path, so check for more than 2 entries) +if ($run_check > 0) + { + my $grepout = `/bin/ps ax | grep $0 | grep -v grep | grep -v '/bin/sh'`; + my $grepnum=0; + $grepnum++ while ($grepout =~ m/\n/g); + if ($grepnum > 2) + { + if ($DB) {print "I am not alone! Another $0 is running! Exiting...\n";} + $event_string = "I am not alone! Another $0 is running! Exiting..."; + &event_logger; + exit; + } + } + +$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 => '', + Max_buffer_length => 4*1024*1024, ); +# $LItelnetlog = "$PATHlogs/listen_telnet_log.txt"; # uncomment for telnet log +# $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('/[0123]\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 + + %ast_ver_str = parse_asterisk_version($asterisk_version); + if (( $ast_ver_str{major} = 1 ) && ($ast_ver_str{minor} < 6)) + { + ### BEGIN manager event handling for asterisk version < 1.6 + while($endless_loop > 0) + { + ### sleep for 10 hundredths of a second(one tenth 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 =~ /read timed-out/i) || ( $msg eq '' )) + { + # This is normal + } + else + { + print "ERRMSG: |$msg|\n"; + } + 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";} + if ($endless_loop =~ /00$|50$/) + { + $input_buf = "$input_buf$keepalive_lines$read_input_buf"; + $input_buf =~ s/\n\n\n/\n\n/gi; + $keepalive_lines=''; + } + else + {$input_buf = "$input_buf$read_input_buf";} + } + else + { + $partial=0; + $partial_input_buf=''; + @input_lines=@MT; + + 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++; + } + + if ($endless_loop =~ /00$|50$/) + { + $input_buf = "$input_buf$keepalive_lines$read_input_buf"; + $input_buf =~ s/\n\n\n/\n\n/gi; + $keepalive_lines=''; + } + else + {$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) + { + ##### look for special vicidial conference call event ##### + if ( ($input_lines[$ILcount] =~ /CallerIDName: DCagcW/) && ($input_lines[$ILcount] =~ /Event: Dial|State: Up/) ) + { + ### BEGIN 1.2.X tree versions + $input_lines[$ILcount] =~ s/^\n|^\n\n//gi; + @command_line=split(/\n/, $input_lines[$ILcount]); + + if ($input_lines[$ILcount] =~ /Event: Dial/) + { + if ($command_line[3] =~ /Destination: /i) + { + $channel = $command_line[3]; + $channel =~ s/Destination: |\s*$//gi; + $callid = $command_line[5]; + $callid =~ s/CallerIDName: |\s*$//gi; + $callid =~ s/^\"//gi; $callid =~ s/\".*$//gi; + if ($callid =~ /\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S/) {$callid =~ s/ .*//gi;} + $uniqueid = $command_line[6]; + $uniqueid =~ s/SrcUniqueID: |\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"; + my $affected_rows = $dbhA->do($stmtA); + if($DB){print "|$affected_rows Conference DIALs updated|\n";} + } + } + } + if ($input_lines[$ILcount] =~ /State: Up/) + { + if ($command_line[2] =~ /Channel: /i) + { + $channel = $command_line[2]; + $channel =~ s/Channel: |\s*$//gi; + $callid = $command_line[5]; + $callid =~ s/CallerIDName: |\s*$//gi; + $callid =~ s/^\"//gi; $callid =~ s/\".*$//gi; + if ($callid =~ /\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S/) {$callid =~ s/ .*//gi;} + $uniqueid = $command_line[6]; + $uniqueid =~ s/SrcUniqueID: |\s*$//gi; + $stmtA = "UPDATE vicidial_manager set status='UPDATED', channel='$channel', uniqueid = '$uniqueid' where server_ip = '$server_ip' and callerid = '$callid' and status='SENT';"; + print STDERR "|$stmtA|\n"; + my $affected_rows = $dbhA->do($stmtA); + if($DB){print "|$affected_rows Conference DIALs updated|\n";} + } + } + ### END 1.2.X tree versions + } + + ##### parse through all other important events ##### + if ( ($input_lines[$ILcount] =~ /State: Ringing|State: Up|State: Dialing|Event: Newstate|Event: Hangup|Event: Newcallerid|Event: Shutdown|Event: CPD-Result|Event: SIP-Hangup-Cause/) && ($input_lines[$ILcount] !~ /ZOMBIE/) ) + { + $input_lines[$ILcount] =~ s/^\n|^\n\n//gi; + @command_line=split(/\n/, $input_lines[$ILcount]); + + if($DB) + { + ### Pring the command_line structure to easily see where elements are + $cmd_counter = 0; + foreach ( @command_line ) + { + print "command_line[$cmd_counter] = $_\n"; + $cmd_counter++; + } + print "\n"; + } + + 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/) + { + ### post 2005-08-07 CVS and Asterisk 1.8 -- added Privilege line + if ( ($command_line[2] =~ /^Channel: /i) && ($command_line[3] =~ /^Uniqueid: /i) ) + { + $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' and callerid NOT LIKE \"DCagcW%\";"; + + if ( ($channel !~ /local/i) && ($channel !~ /CXFER/i) ) + { + print STDERR "|$stmtA|\n"; + my $affected_rows = $dbhA->do($stmtA); + if($DB){print "|$affected_rows HANGUPS updated|\n";} + } + else + { + print STDERR "Ignoring CXFER Local Hangup: |$channel|$server_ip|$uniqueid|$command_line[5]|\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' and callerid NOT LIKE \"DCagcW%\";"; + + print STDERR "|$stmtA|\n"; + my $affected_rows = $dbhA->do($stmtA); + 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' and callerid NOT LIKE \"DCagcW%\";"; + + print STDERR "|$stmtA|\n"; + my $affected_rows = $dbhA->do($stmtA); + 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; + if ($callid =~ /\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S/) {$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"; + my $affected_rows = $dbhA->do($stmtA); + + 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; + if ($callid =~ /\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S/) {$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"; + my $affected_rows = $dbhA->do($stmtA); + 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; + if ($callid =~ /\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S/) {$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"; + my $affected_rows = $dbhA->do($stmtA); + 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; + if ($callid =~ /\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S/) {$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"; + my $affected_rows = $dbhA->do($stmtA); + 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; + if ($callid =~ /\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S/) {$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"; + my $affected_rows = $dbhA->do($stmtA); + 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; + if ($callid =~ /\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S/) {$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"; + my $affected_rows = $dbhA->do($stmtA); + 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; + if ($callid =~ /\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S/) {$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"; + my $affected_rows = $dbhA->do($stmtA); + 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; + if ($callid =~ /\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S/) {$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"; + my $affected_rows = $dbhA->do($stmtA); + 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; + if ($callid =~ /\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S/) {$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"; + my $affected_rows = $dbhA->do($stmtA); + 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/CallerIDName: |\s*$//gi; + $callid =~ s/^\"//gi; $callid =~ s/\".*$//gi; + if ($callid =~ /\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S/) {$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"; + my $affected_rows = $dbhA->do($stmtA); + if($DB){print "|$affected_rows RINGINGs updated|\n";} + } + } + ### post Asterisk 1.8 - Consultative XFER - Added 2014-05-24 + if ( ($command_line[2] =~ /^Channel: /i) && ($command_line[5] =~ /^Uniqueid: /i) && ($command_line[4] =~ /^CallerIDName: DC/i) ) + { + $channel = $command_line[2]; + $channel =~ s/Channel: |\s*$//gi; + $callid = $command_line[4]; + # $callid =~ s/Callerid: |\s*$//gi; + $callid =~ s/CallerIDName: |\s*$//gi; + $callid =~ s/^\"//gi; $callid =~ s/\".*$//gi; + if ($callid =~ /\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S/) {$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"; + my $affected_rows = $dbhA->do($stmtA); + if($DB){print "|$affected_rows Consultative XFERs updated|\n";} + } + } + # if ( ($command_line[2] =~ /^Channel: /i) && ($command_line[5] =~ /^Uniqueid: /i) ) ### post 2006-06-21 SVN -- Changed from CallerID to CallerIDName + # { + # $channel = $command_line[2]; + # $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"; + # my $affected_rows = $dbhA->do($stmtA); + # if($DB){print "|$affected_rows RINGINGs updated|\n";} + # } + # } + } + if ($input_lines[$ILcount] =~ /Event: CPD-Result/) + { + # Event: CPD-Result + # Privilege: system,all + # ChannelDriver: SIP + # Channel: SIP/paraxip-out-08291448 + # CallerIDName: V0202034729000030735 + # Uniqueid: 1233564450.141 + # Result: Answering-Machine + if ( ($command_line[3] =~ /^Channel: /i) && ($command_line[5] =~ /^Uniqueid: /i) ) + { + &get_time_now; + + $channel = $command_line[3]; + $channel =~ s/Channel: |\s*$//gi; + $callid = $command_line[4]; + $callid =~ s/CallerIDName: |\s*$//gi; + $callid =~ s/^\"//gi; $callid =~ s/\".*$//gi; + if ($callid =~ /\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S/) {$callid =~ s/ .*//gi;} + $uniqueid = $command_line[5]; + $uniqueid =~ s/Uniqueid: |\s*$//gi; + $result = $command_line[6]; + $result =~ s/Result: |\s*$//gi; + if (length($result)>0) + { + # 2011-03-22 13:22:12.123 (1277187888 123 456) + # ALTER TABLE vicidial_cpd_log ADD hires_time VARCHAR(26) default ''; + # ($s_hires, $usec) = gettimeofday(); # get seconds and microseconds since the epoch + # $usec = sprintf("%06s", $usec); + # $HRmsec = substr($usec, -6); + # ($HRsec,$HRmin,$HRhour,$HRmday,$HRmon,$HRyear,$HRwday,$HRyday,$HRisdst) = localtime($s_hires); + # $HRyear = ($HRyear + 1900); + # $HRmon++; + # if ($HRmon < 10) {$HRmon = "0$HRmon";} + # if ($HRmday < 10) {$HRmday = "0$HRmday";} + # if ($HRhour < 10) {$HRFhour = "0$HRhour";} + # if ($HRmin < 10) {$HRmin = "0$HRmin";} + # if ($HRsec < 10) {$HRsec = "0$HRsec";} + # $HRnow_date = "$HRyear-$HRmon-$HRmday $HRhour:$HRmin:$HRsec.$HRmsec"; + + $lead_id = substr($callid, 10, 10); + $lead_id = ($lead_id + 0); + # $stmtA = "INSERT INTO vicidial_cpd_log set channel='$channel', uniqueid='$uniqueid', callerid='$callid', server_ip='$server_ip', lead_id='$lead_id', event_date='$now_date', result='$result', hires_time='$HRnow_date';"; + $stmtA = "INSERT INTO vicidial_cpd_log set channel='$channel', uniqueid='$uniqueid', callerid='$callid', server_ip='$server_ip', lead_id='$lead_id', event_date='$now_date', result='$result';"; + print STDERR "|$stmtA|\n"; + my $affected_rows = $dbhA->do($stmtA); + if($DB){print "|$affected_rows CPD_log inserted|$HRnow_date|$s_hires|$usec|\n";} + } + } + } + if ($input_lines[$ILcount] =~ /Event: SIP-Hangup-Cause/) + { + # Event: SIP-Hangup-Cause + # Privilege: system,all + # ChannelDriver: SIP + # Channel: SIP/paraxip-out-08291448 + # CallerIDName: M4121149450000795193 + # Uniqueid: 1233564450.141 + # Result: 603 + if ( ($command_line[3] =~ /^Channel: /i) && ($command_line[5] =~ /^Uniqueid: /i) ) + { + &get_time_now; + + $channel = $command_line[3]; + $channel =~ s/Channel: |\s*$//gi; + $callid = $command_line[4]; + $callid =~ s/CallerIDName: |\s*$//gi; + $callid =~ s/^\"//gi; $callid =~ s/\".*$//gi; + if ($callid =~ /\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S/) {$callid =~ s/ .*//gi;} + $uniqueid = $command_line[5]; + $uniqueid =~ s/Uniqueid: |\s*$//gi; + $result = $command_line[6]; + $result =~ s/Result: |\s*$//gi; + @result_details=split(/\|/, $result); + if ( (length($result)>0) && ($result_details[0] !~ /^407/) ) + { + $lead_id = substr($callid, 10, 10); + $lead_id = ($lead_id + 0); + $beginUNIQUEID = $uniqueid; + $beginUNIQUEID =~ s/\..*//gi; + $stmtA = "UPDATE vicidial_dial_log SET sip_hangup_cause='$result_details[0]',sip_hangup_reason='$result_details[1]',uniqueid='$uniqueid' where caller_code='$callid' and server_ip='$server_ip' and lead_id='$lead_id';"; + print STDERR "|$stmtA|\n"; + my $affected_rows = $dbhA->do($stmtA); + if($DB){print "|$affected_rows dial_log updated|$callid|$server_ip|$result|\n";} + $vddl_update = ($vddl_update + $affected_rows); + + $preCtarget = ($beginUNIQUEID - 180); # 180 seconds before call start + ($preCsec,$preCmin,$preChour,$preCmday,$preCmon,$preCyear,$preCwday,$preCyday,$preCisdst) = localtime($preCtarget); + $preCyear = ($preCyear + 1900); + $preCmon++; + if ($preCmon < 10) {$preCmon = "0$preCmon";} + if ($preCmday < 10) {$preCmday = "0$preCmday";} + if ($preChour < 10) {$preChour = "0$preChour";} + if ($preCmin < 10) {$preCmin = "0$preCmin";} + if ($preCsec < 10) {$preCsec = "0$preCsec";} + $preCSQLdate = "$preCyear-$preCmon-$preCmday $preChour:$preCmin:$preCsec"; + + $postCtarget = ($beginUNIQUEID + 10); # 10 seconds after call start + ($postCsec,$postCmin,$postChour,$postCmday,$postCmon,$postCyear,$postCwday,$postCyday,$postCisdst) = localtime($postCtarget); + $postCyear = ($postCyear + 1900); + $postCmon++; + if ($postCmon < 10) {$postCmon = "0$postCmon";} + if ($postCmday < 10) {$postCmday = "0$postCmday";} + if ($postChour < 10) {$postChour = "0$postChour";} + if ($postCmin < 10) {$postCmin = "0$postCmin";} + if ($postCsec < 10) {$postCsec = "0$postCsec";} + $postCSQLdate = "$postCyear-$postCmon-$postCmday $postChour:$postCmin:$postCsec"; + + $stmtA = "UPDATE vicidial_carrier_log SET sip_hangup_cause='$result_details[0]',sip_hangup_reason='$result_details[1]' where server_ip='$server_ip' and caller_code='$callid' and lead_id='$lead_id' and call_date > \"$preCSQLdate\" and call_date < \"$postCSQLdate\" order by call_date desc limit 1;"; + print STDERR "|$stmtA|\n"; + my $affected_rows = $dbhA->do($stmtA); + if($DB){print "|$affected_rows carrier_log updated|$callid|$server_ip|$uniqueid|$result_details[0]|$result_details[1]|\n";} + $vdcl_update = ($vdcl_update + $affected_rows); + } + } + } + } + $ILcount++; + } + } + + + $endless_loop--; + $keepalive_count_loop++; + + if($DB){print STDERR " loop counter: |$endless_loop|$keepalive_count_loop| |$vddl_update|$vdcl_update|\r";} + + ### putting a blank file called "sendmgr.kill" in a directory will automatically safely kill this program + if ( (-e "$PATHhome/listenmgr.kill") or ($sendonlyone) ) + { + unlink("$PATHhome/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 + ### Also, keep the MySQL connection alive by selecting the server_updater time for this server + if ($endless_loop =~ /00$|50$/) + { + $keepalive_lines=''; + + &get_time_now; + + ### Grab Server values from the database + $stmtA = "SELECT vd_server_logs FROM servers where server_ip = '$VARserver_ip';"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + if ($sthArows > 0) + { + @aryA = $sthA->fetchrow_array; + $DBvd_server_logs = $aryA[0]; + if ($DBvd_server_logs =~ /Y/) {$SYSLOG = '1';} + else {$SYSLOG = '0';} + } + $sthA->finish(); + + ### Grab Server values to keep DB connection alive + $stmtA = "SELECT last_update FROM server_updater where server_ip = '$server_ip';"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + @aryA = $sthA->fetchrow_array; + $last_update = $aryA[0]; + $sthA->finish(); + + $keepalive_epoch = time(); + $keepalive_sec = ($keepalive_epoch - $last_keepalive_epoch); + if ($keepalive_sec > 40) + { + $keepalive_skips=0; + @keepalive_output = $tn->cmd(String => "Action: Command\nCommand: show uptime\n\n", Prompt => '/--END COMMAND--.*/', Errmode => Return, Timeout => 1); + $msg = $tn->errmsg; + $buf_ref = $tn->buffer; + $buf_len = length( $$buf_ref ); + if($DB){print "keepalive length: $#keepalive_output|$now_date|$msg|$buf_len|\n";} + + if($DB){print "+++++++++++++++++++++++++++++++sending keepalive transmit line: $keepalive_sec seconds $endless_loop|$now_date|$last_update|\n";} + + $k=0; + foreach(@keepalive_output) + { + $keepalive_lines .= "$keepalive_output[$k]"; + $k++; + } + $manager_string="PROCESS: keepalive length: $#keepalive_output|$k|$now_date"; + &manager_output_logger; + $last_keepalive_epoch = time(); + } + else + { + $keepalive_skips++; + $buf_ref = $tn->buffer; + $buf_len = length( $$buf_ref ); + if($DB){print "-------------------------------no keepalive transmit necessary: $keepalive_sec seconds($keepalive_skips in a row) $endless_loop|$now_date|$last_update|$buf_len|\n";} + + $manager_string="PROCESS: keepalive skip: $keepalive_sec seconds($keepalive_skips in a row)|$now_date"; + &manager_output_logger; + } + #$last_keepalive_epoch = time(); + $keepalive_count_loop=0; + } + } + ### END manager event handling for asterisk version < 1.6 + } + else + { + ### BEGIN manager event handling for asterisk version >= 1.6 + + 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 =~ /read timed-out/i) || ( $msg eq '' )) + { + # This is normal + } + else + { + print "ERRMSG: |$msg|\n"; + } + 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";} + if ($endless_loop =~ /00$|50$/) + { + $input_buf = "$input_buf$keepalive_lines$read_input_buf"; + $input_buf =~ s/\n\n\n/\n\n/gi; + $keepalive_lines=''; + } + else + {$input_buf = "$input_buf$read_input_buf";} + } + else + { + $partial=0; + $partial_input_buf=''; + @input_lines=@MT; + + 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++; + } + + if ($endless_loop =~ /00$|50$/) + { + $input_buf = "$input_buf$keepalive_lines$read_input_buf"; + $input_buf =~ s/\n\n\n/\n\n/gi; + $keepalive_lines=''; + } + else + {$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) + { + ##### look for special vicidial conference call event ##### + if ( ($input_lines[$ILcount] =~ /CallerIDName: DCagcW/) && ($input_lines[$ILcount] =~ /Event: Dial|ChannelStateDesc: Up/) ) + { + $input_lines[$ILcount] =~ s/^\n|^\n\n//gi; + @command_line=split(/\n/, $input_lines[$ILcount]); + + $cmd_counter = 0; + foreach ( @command_line ) + { + print "command_line[$cmd_counter] = $_\n"; + $cmd_counter++; + } + print "\n"; + + if ($input_lines[$ILcount] =~ /Event: Dial/) + { + if ($command_line[4] =~ /Destination: /i) + { + $channel = $command_line[4]; + $channel =~ s/Destination: |\s*$//gi; + $callid = $command_line[6]; + $callid =~ s/CallerIDName: |\s*$//gi; + $callid =~ s/^\"//gi; $callid =~ s/\".*$//gi; + if ($callid =~ /\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S/) {$callid =~ s/ .*//gi;} + $uniqueid = $command_line[6]; + $uniqueid =~ s/SrcUniqueID: |\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"; + my $affected_rows = $dbhA->do($stmtA); + if($DB){print "|$affected_rows Conference DIALs updated|\n";} + } + } + } + if ($input_lines[$ILcount] =~ /ChannelStateDesc: Up/) + { + if ($command_line[2] =~ /Channel: /i) + { + $channel = $command_line[2]; + $channel =~ s/Channel: |\s*$//gi; + $callid = $command_line[6]; + $callid =~ s/CallerIDName: |\s*$//gi; + $callid =~ s/^\"//gi; $callid =~ s/\".*$//gi; + if ($callid =~ /\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S/) {$callid =~ s/ .*//gi;} + $uniqueid = $command_line[9]; + $uniqueid =~ s/SrcUniqueID: |\s*$//gi; + $stmtA = "UPDATE vicidial_manager set status='UPDATED', channel='$channel', uniqueid = '$uniqueid' where server_ip = '$server_ip' and callerid = '$callid' and status='SENT';"; + print STDERR "|$stmtA|\n"; + my $affected_rows = $dbhA->do($stmtA); + if($DB){print "|$affected_rows Conference DIALs updated|\n";} + } + } + } + + ##### parse through all other important events ##### + if ( ($input_lines[$ILcount] =~ /Event: Newstate|Event: Hangup|Event: NewCallerid|Event: Shutdown|Event: CPD-Result|Event: SIP-Hangup-Cause|Event: DTMF/) && ($input_lines[$ILcount] !~ /ZOMBIE/) ) + { + $input_lines[$ILcount] =~ s/^\n|^\n\n//gi; + @command_line=split(/\n/, $input_lines[$ILcount]); + + if($DB) + { + ### Pring the command_line structure to easily see where elements are + $cmd_counter = 0; + foreach ( @command_line ) + { + print "command_line[$cmd_counter] = $_\n"; + $cmd_counter++; + } + print "\n"; + } + + ### Event: Shutdown + 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; + } + + ### Event: Hangup + if ($input_lines[$ILcount] =~ /Event: Hangup/) + { + if ( ($command_line[2] =~ /^Channel: /i) && ($command_line[3] =~ /^Uniqueid: /i) ) + { + $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' and callerid NOT LIKE \"DCagcW%\";"; + if ( ($channel !~ /local/i) && ($channel !~ /CXFER/i) ) + { + print STDERR "|$stmtA|\n"; + my $affected_rows = $dbhA->do($stmtA); + if($DB){print "|$affected_rows HANGUPS updated|\n";} + } + else + { + print STDERR "Ignoring CXFER Local Hangup: |$channel|$server_ip|$uniqueid|$command_line[5]|\n"; + } + } + } + + ### Event: Newstate + if ($input_lines[$ILcount] =~ /Event: Newstate/) + { + if ( ($command_line[2] =~ /^Channel: /i) && ($command_line[6] =~ /^CallerIDName: /i) ) + { + $channel = $command_line[2]; + $channel =~ s/Channel: |\s*$//gi; + $state = $command_line[4]; + $state =~ s/ChannelStateDesc: |\s*$//gi; + $callid = $command_line[6]; + $callid =~ s/CallerIDName: |\s*$//gi; + $callid =~ s/^\"//gi; # remove leading quotes + $callid =~ s/\".*$//gi; # remove trailing quotes and anything else + if ($callid =~ /\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S/) {$callid =~ s/ .*//gi;} # remove everything after the space for Orex + $uniqueid = $command_line[9]; + $uniqueid =~ s/Uniqueid: |\s*$//gi; + + ### ChannelStateDesc = Dialing + if ($state =~ /Dialing/) + { + $stmtA = "UPDATE vicidial_manager set status='SENT', channel='$channel', uniqueid = '$uniqueid' where server_ip = '$server_ip' and callerid = '$callid'"; + print STDERR "|$stmtA|\n"; + my $affected_rows = $dbhA->do($stmtA); + if($DB){print "|$affected_rows DIALINGs updated|\n";} + } + + ### ChannelStateDesc = Ringing or Up + if ($state =~ /Ringing|Up/) + { + $stmtA = "UPDATE vicidial_manager set status='UPDATED', channel='$channel', uniqueid = '$uniqueid' where server_ip = '$server_ip' and callerid = '$callid'"; + print STDERR "|$stmtA|\n"; + if ($channel !~ /local/i) + { + print STDERR "|$channel|NON LOCAL CHANNEL >>>> EXECUTING ABOVE STATMENT|\n"; + my $affected_rows = $dbhA->do($stmtA); + if($DB){print "|$affected_rows RINGINGs updated|\n";} + } + else + { + print STDERR "|$channel|LOCAL CHANNEL >>>> ABOVE STATMENT IGNORED|\n"; + } + } + } + } + + ### Event: NewCallerid + if ($input_lines[$ILcount] =~ /Event: NewCallerid/) + { + if ( ($command_line[2] =~ /^Channel: /i) && ($command_line[5] =~ /^Uniqueid: /i) ) + { + $channel = $command_line[2]; + $channel =~ s/Channel: |\s*$//gi; + $callid = $command_line[4]; + $callid =~ s/CallerIDName: |\s*$//gi; + $callid =~ s/^\"//gi; # remove leading quotes + $callid =~ s/\".*$//gi; # remove trailing quotes and anything else + if ($callid =~ /\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S/) {$callid =~ s/ .*//gi;} # remove everything after the space for Orex + $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"; + my $affected_rows = $dbhA->do($stmtA); + if($DB){print "|$affected_rows RINGINGs updated|\n";} + } + } + } + + ### Event: DTMF + if ($input_lines[$ILcount] =~ /Event: DTMF/) + { + if ( ($command_line[2] =~ /^Channel: /i) && ($command_line[3] =~ /^Uniqueid: /i) ) + { + # get the event info + $channel = $command_line[2]; + $channel =~ s/Channel: |\s*$//gi; + $uniqueid = $command_line[3]; + $uniqueid =~ s/Uniqueid: |\s*$//gi; + $digit = $command_line[4]; + $digit =~ s/Digit: |\s*$//gi; + $direction = $command_line[5]; + $direction =~ s/Direction: |\s*$//gi; + $begin = $command_line[6]; + $begin =~ s/Begin: |\s*$//gi; + $end = $command_line[7]; + $end =~ s/End: |\s*$//gi; + + # set the state + $state = ''; + if ($begin eq 'Yes') {$state = 'Begin';} + else + { + if ($end eq 'Yes') {$state = 'End';} + } + + # log it to the DB and file + $stmtA = "INSERT INTO vicidial_dtmf_log SET dtmf_time=NOW(),channel='$channel',server_ip='$server_ip',uniqueid='$uniqueid',digit='$digit',direction='$direction',state='$state'"; + print STDERR "|$stmtA|\n"; + my $affected_rows = $dbhA->do($stmtA); + + ($s_hires, $usec) = gettimeofday(); # get seconds and microseconds since the epoch + $usec = sprintf("%06s", $usec); + $HRmsec = substr($usec, -6); + ($HRsec,$HRmin,$HRhour,$HRmday,$HRmon,$HRyear,$HRwday,$HRyday,$HRisdst) = localtime($s_hires); + $HRyear = ($HRyear + 1900); + $HRmon++; + if ($HRmon < 10) {$HRmon = "0$HRmon";} + if ($HRmday < 10) {$HRmday = "0$HRmday";} + if ($HRhour < 10) {$HRFhour = "0$HRhour";} + if ($HRmin < 10) {$HRmin = "0$HRmin";} + if ($HRsec < 10) {$HRsec = "0$HRsec";} + $HRnow_date = "$HRyear-$HRmon-$HRmday $HRhour:$HRmin:$HRsec.$HRmsec"; + if($DB){print "|$affected_rows vicidial_dtmf inserted|$HRnow_date|$s_hires|$usec|\n";} + + $dtmf_string = "$HRnow_date|$s_hires|$usec|$channel|$uniqueid|$digit|$direction|$state"; + &dtmf_logger; + } + } + + ### Event: CPD-Result + if ($input_lines[$ILcount] =~ /Event: CPD-Result/) + { + # Event: CPD-Result + # Privilege: system,all + # ChannelDriver: SIP + # Channel: SIP/paraxip-out-08291448 + # CallerIDName: V0202034729000030735 + # Uniqueid: 1233564450.141 + # Result: Answering-Machine + if ( ($command_line[3] =~ /^Channel: /i) && ($command_line[5] =~ /^Uniqueid: /i) ) + { + &get_time_now; + + $channel = $command_line[3]; + $channel =~ s/Channel: |\s*$//gi; + $callid = $command_line[4]; + $callid =~ s/CallerIDName: |\s*$//gi; + $callid =~ s/^\"//gi; # remove leading quotes + $callid =~ s/\".*$//gi; # remove trailing quotes and anything else + if ($callid =~ /\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S/) {$callid =~ s/ .*//gi;} # remove everything after the space for Orex + $uniqueid = $command_line[5]; + $uniqueid =~ s/Uniqueid: |\s*$//gi; + + # Pulled from the CPD-Result SIP Header + $cpd_result = $command_line[6]; + $cpd_result =~ s/CPDResult: |\s*$//gi; + + # Pulled from the X-Netborder-Detailed-CPD-Result-v2-0 SIP Header + $cpd_detailed_result = $command_line[7]; + $cpd_detailed_result =~ s/CPDDetailedResult: |\s*$//gi; + + # Pulled from the X-Netborder-Call-ID SIP Header + $cpd_call_id = $command_line[8]; + $cpd_call_id =~ s/CPDCallID: |\s*$//gi; + + # Pulled from the X-Netborder-Cpa-Reference-ID SIP Header + $cpd_ref_id = $command_line[9]; + $cpd_ref_id =~ s/CPDReferenceID: |\s*$//gi; + + # Pulled from the X-Netborder-Cpa-Campaign-Name SIP Header + $cpd_camp_name = $command_line[10]; + $cpd_camp_name =~ s/CPDCampaignName: |\s*$//gi; + + print STDERR "|cpd_result = $cpd_result|cpd_detailed_result = $cpd_detailed_result|cpd_call_id = $cpd_call_id|cpd_ref_id = $cpd_ref_id|cpd_camp_name = $cpd_camp_name|\n"; + + if (length($cpd_result)>0) + { + # 2011-03-22 13:22:12.123 (1277187888 123 456) + # ALTER TABLE vicidial_cpd_log ADD hires_time VARCHAR(26) default ''; + # ($s_hires, $usec) = gettimeofday(); # get seconds and microseconds since the epoch + # $usec = sprintf("%06s", $usec); + # $HRmsec = substr($usec, -6); + # ($HRsec,$HRmin,$HRhour,$HRmday,$HRmon,$HRyear,$HRwday,$HRyday,$HRisdst) = localtime($s_hires); + # $HRyear = ($HRyear + 1900); + # $HRmon++; + # if ($HRmon < 10) {$HRmon = "0$HRmon";} + # if ($HRmday < 10) {$HRmday = "0$HRmday";} + # if ($HRhour < 10) {$HRFhour = "0$HRhour";} + # if ($HRmin < 10) {$HRmin = "0$HRmin";} + # if ($HRsec < 10) {$HRsec = "0$HRsec";} + # $HRnow_date = "$HRyear-$HRmon-$HRmday $HRhour:$HRmin:$HRsec.$HRmsec"; + + $lead_id = substr($callid, 10, 10); + $lead_id = ($lead_id + 0); + # $stmtA = "INSERT INTO vicidial_cpd_log set channel='$channel', uniqueid='$uniqueid', callerid='$callid', server_ip='$server_ip', lead_id='$lead_id', event_date='$now_date', result='$cpd_result', hires_time='$HRnow_date';"; + + # TODO change the cpd log and this insert to include the new SIP Headers for 2.0 CPD + $stmtA = "INSERT INTO vicidial_cpd_log set channel='$channel', uniqueid='$uniqueid', callerid='$callid', server_ip='$server_ip', lead_id='$lead_id', event_date='$now_date', result='$cpd_result';"; + print STDERR "|$stmtA|\n"; + my $affected_rows = $dbhA->do($stmtA); + if($DB){print "|$affected_rows CPD_log inserted|$HRnow_date|$s_hires|$usec|\n";} + } + } + } + if ($input_lines[$ILcount] =~ /Event: SIP-Hangup-Cause/) + { + # Event: SIP-Hangup-Cause + # Privilege: system,all + # ChannelDriver: SIP + # Channel: SIP/paraxip-out-08291448 + # CallerIDName: M4121149450000795193 + # Uniqueid: 1233564450.141 + # Result: 603 + if ( ($command_line[3] =~ /^Channel: /i) && ($command_line[5] =~ /^Uniqueid: /i) ) + { + &get_time_now; + + $channel = $command_line[3]; + $channel =~ s/Channel: |\s*$//gi; + $callid = $command_line[4]; + $callid =~ s/CallerIDName: |\s*$//gi; + $callid =~ s/^\"//gi; $callid =~ s/\".*$//gi; + if ($callid =~ /\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S/) {$callid =~ s/ .*//gi;} + $uniqueid = $command_line[5]; + $uniqueid =~ s/Uniqueid: |\s*$//gi; + $result = $command_line[6]; + $result =~ s/Result: |\s*$//gi; + @result_details=split(/\|/, $result); + if ( (length($result)>0) && ($result_details[0] !~ /^407/) ) + { + $lead_id = substr($callid, 10, 10); + $lead_id = ($lead_id + 0); + $beginUNIQUEID = $uniqueid; + $beginUNIQUEID =~ s/\..*//gi; + $stmtA = "UPDATE vicidial_dial_log SET sip_hangup_cause='$result_details[0]',sip_hangup_reason='$result_details[1]',uniqueid='$uniqueid' where caller_code='$callid' and server_ip='$server_ip' and lead_id='$lead_id';"; + print STDERR "|$stmtA|\n"; + my $affected_rows = $dbhA->do($stmtA); + if($DB){print "|$affected_rows dial_log updated|$callid|$server_ip|$result|\n";} + $vddl_update = ($vddl_update + $affected_rows); + + $preCtarget = ($beginUNIQUEID - 180); # 180 seconds before call start + ($preCsec,$preCmin,$preChour,$preCmday,$preCmon,$preCyear,$preCwday,$preCyday,$preCisdst) = localtime($preCtarget); + $preCyear = ($preCyear + 1900); + $preCmon++; + if ($preCmon < 10) {$preCmon = "0$preCmon";} + if ($preCmday < 10) {$preCmday = "0$preCmday";} + if ($preChour < 10) {$preChour = "0$preChour";} + if ($preCmin < 10) {$preCmin = "0$preCmin";} + if ($preCsec < 10) {$preCsec = "0$preCsec";} + $preCSQLdate = "$preCyear-$preCmon-$preCmday $preChour:$preCmin:$preCsec"; + + $postCtarget = ($beginUNIQUEID + 10); # 10 seconds after call start + ($postCsec,$postCmin,$postChour,$postCmday,$postCmon,$postCyear,$postCwday,$postCyday,$postCisdst) = localtime($postCtarget); + $postCyear = ($postCyear + 1900); + $postCmon++; + if ($postCmon < 10) {$postCmon = "0$postCmon";} + if ($postCmday < 10) {$postCmday = "0$postCmday";} + if ($postChour < 10) {$postChour = "0$postChour";} + if ($postCmin < 10) {$postCmin = "0$postCmin";} + if ($postCsec < 10) {$postCsec = "0$postCsec";} + $postCSQLdate = "$postCyear-$postCmon-$postCmday $postChour:$postCmin:$postCsec"; + + $stmtA = "UPDATE vicidial_carrier_log SET sip_hangup_cause='$result_details[0]',sip_hangup_reason='$result_details[1]' where server_ip='$server_ip' and caller_code='$callid' and lead_id='$lead_id' and call_date > \"$preCSQLdate\" and call_date < \"$postCSQLdate\" order by call_date desc limit 1;"; + print STDERR "|$stmtA|\n"; + my $affected_rows = $dbhA->do($stmtA); + if($DB){print "|$affected_rows carrier_log updated|$callid|$server_ip|$uniqueid|$result_details[0]|$result_details[1]|\n";} + $vdcl_update = ($vdcl_update + $affected_rows); + } + } + } + } + $ILcount++; + } + } + + + $endless_loop--; + $keepalive_count_loop++; + + if($DB){print STDERR " loop counter: |$endless_loop|$keepalive_count_loop| |$vddl_update|$vdcl_update|\r";} + + ### putting a blank file called "sendmgr.kill" in a directory will automatically safely kill this program + if ( (-e "$PATHhome/listenmgr.kill") or ($sendonlyone) ) + { + unlink("$PATHhome/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 + ### Also, keep the MySQL connection alive by selecting the server_updater time for this server + if ($endless_loop =~ /00$|50$/) + { + $keepalive_lines=''; + + &get_time_now; + + ### Grab Server values from the database + $stmtA = "SELECT vd_server_logs FROM servers where server_ip = '$VARserver_ip';"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + if ($sthArows > 0) + { + @aryA = $sthA->fetchrow_array; + $DBvd_server_logs = $aryA[0]; + if ($DBvd_server_logs =~ /Y/) {$SYSLOG = '1';} + else {$SYSLOG = '0';} + } + $sthA->finish(); + + ### Grab Server values to keep DB connection alive + $stmtA = "SELECT last_update FROM server_updater where server_ip = '$server_ip';"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + @aryA = $sthA->fetchrow_array; + $last_update = $aryA[0]; + $sthA->finish(); + + $keepalive_epoch = time(); + $keepalive_sec = ($keepalive_epoch - $last_keepalive_epoch); + if ($keepalive_sec > 40) + { + $keepalive_skips=0; + @keepalive_output = $tn->cmd(String => "Action: Command\nCommand: core show uptime\n\n", Prompt => '/--END COMMAND--.*/', Errmode => Return, Timeout => 1); + $msg = $tn->errmsg; + $buf_ref = $tn->buffer; + $buf_len = length( $$buf_ref ); + if($DB){print "keepalive length: $#keepalive_output|$now_date|$msg|$buf_len|\n";} + + if($DB){print "+++++++++++++++++++++++++++++++sending keepalive transmit line: $keepalive_sec seconds $endless_loop|$now_date|$last_update|\n";} + + $k=0; + foreach(@keepalive_output) + { + $keepalive_lines .= "$keepalive_output[$k]"; + $k++; + } + $manager_string="PROCESS: keepalive length: $#keepalive_output|$k|$now_date"; + &manager_output_logger; + $last_keepalive_epoch = time(); + } + else + { + $keepalive_skips++; + $buf_ref = $tn->buffer; + $buf_len = length( $$buf_ref ); + if($DB){print "-------------------------------no keepalive transmit necessary: $keepalive_sec seconds($keepalive_skips in a row) $endless_loop|$now_date|$last_update|$buf_len|\n";} + + $manager_string="PROCESS: keepalive skip: $keepalive_sec seconds($keepalive_skips in a row)|$now_date"; + &manager_output_logger; + } + #$last_keepalive_epoch = time(); + + $keepalive_count_loop=0; + } + } + ### END manager event handling for asterisk version >= 1.6 + } + + + + 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); + + $tn->buffer_empty; + $tn->waitfor(Match => '/Message:.*\n\n/', Timeout => 10); + $ok = $tn->close; + + $one_day_interval--; + } + +$event_string='CLOSING DB CONNECTION|'; +&event_logger; + + +$dbhA->disconnect(); + + +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) {$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"; + $action_log_date = "$year-$mon-$mday"; + } + + + + + +sub event_logger + { + if ($SYSLOG) + { + ### open the log file for writing ### + open(Lout, ">>$PATHlogs/listen_process.$action_log_date") + || die "Can't open $PATHlogs/listen_process.$action_log_date: $!\n"; + print Lout "$now_date|$event_string|\n"; + close(Lout); + } + $event_string=''; + } + + + + +sub manager_output_logger + { + if ($SYSLOG) + { + open(MOout, ">>$PATHlogs/listen.$action_log_date") + || die "Can't open $PATHlogs/listen.$action_log_date: $!\n"; + print MOout "$now_date|$manager_string|\n"; + close(MOout); + } + } + +sub dtmf_logger + { + if ($SYSLOG) + { + open(Dout, ">>$PATHlogs/dtmf.$action_log_date") + || die "Can't open $PATHlogs/dttmf.$action_log_date: $!\n"; + print Dout "|$dtmf_string|\n"; + close(Dout); + } + } + +# subroutine to parse the asterisk version +# and return a hash with the various part +sub parse_asterisk_version + { + # grab the arguments + my $ast_ver_str = $_[0]; + + # get everything after the - and put it in $ast_ver_postfix + my @hyphen_parts = split( /-/ , $ast_ver_str ); + + my $ast_ver_postfix = $hyphen_parts[1]; + + # now split everything before the - up by the . + my @dot_parts = split( /\./ , $hyphen_parts[0] ); + + my %ast_ver_hash; + + if ( $dot_parts[0] <= 1 ) + { + %ast_ver_hash = ( + "major" => $dot_parts[0], + "minor" => $dot_parts[1], + "build" => $dot_parts[2], + "revision" => $dot_parts[3], + "postfix" => $ast_ver_postfix + ); + } + + # digium dropped the 1 from asterisk 10 but we still need it + if ( $dot_parts[0] > 1 ) + { + %ast_ver_hash = ( + "major" => 1, + "minor" => $dot_parts[0], + "build" => $dot_parts[1], + "revision" => $dot_parts[2], + "postfix" => $ast_ver_postfix + ); + } + + return ( %ast_ver_hash ); + } diff --git a/agc_2-X/trunk/extras/MySQL_AST_CREATE_tables.sql b/agc_2-X/trunk/extras/MySQL_AST_CREATE_tables.sql index 07f8b8bd..7eee9cf1 100644 --- a/agc_2-X/trunk/extras/MySQL_AST_CREATE_tables.sql +++ b/agc_2-X/trunk/extras/MySQL_AST_CREATE_tables.sql @@ -1620,7 +1620,8 @@ agent_debug_logging VARCHAR(20) default '0', default_language VARCHAR(100) default 'default English', agent_whisper_enabled ENUM('0','1') default '0', user_hide_realtime_enabled ENUM('0','1') default '0', -custom_reports_use_slave_db VARCHAR(2000) default '' +custom_reports_use_slave_db VARCHAR(2000) default '', +usacan_phone_dialcode_fix ENUM('0','1') default '0' ) ENGINE=MyISAM; CREATE TABLE vicidial_campaigns_list_mix ( @@ -3603,4 +3604,4 @@ UPDATE vicidial_configuration set value='1766' where name='qc_database_version'; UPDATE system_settings set vdc_agent_api_active='1'; -UPDATE system_settings SET db_schema_version='1433',db_schema_update_date=NOW(),reload_timestamp=NOW(); +UPDATE system_settings SET db_schema_version='1434',db_schema_update_date=NOW(),reload_timestamp=NOW(); diff --git a/agc_2-X/trunk/extras/upgrade_2.12.sql b/agc_2-X/trunk/extras/upgrade_2.12.sql index 39f59f4b..f4382915 100644 --- a/agc_2-X/trunk/extras/upgrade_2.12.sql +++ b/agc_2-X/trunk/extras/upgrade_2.12.sql @@ -340,3 +340,7 @@ UNIQUE KEY custom_report_name_key (report_name) ) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; UPDATE system_settings SET db_schema_version='1433',db_schema_update_date=NOW() where db_schema_version < 1433; + +ALTER TABLE system_settings ADD usacan_phone_dialcode_fix ENUM('0','1') default '0'; + +UPDATE system_settings SET db_schema_version='1434',db_schema_update_date=NOW() where db_schema_version < 1434; diff --git a/agc_2-X/trunk/www/vicidial/admin.php b/agc_2-X/trunk/www/vicidial/admin.php index e380bb4f..3c19c730 100644 --- a/agc_2-X/trunk/www/vicidial/admin.php +++ b/agc_2-X/trunk/www/vicidial/admin.php @@ -1994,6 +1994,8 @@ if (isset($_GET["min_sec"])) {$min_sec=$_GET["min_sec"];} elseif (isset($_POST["min_sec"])) {$min_sec=$_POST["min_sec"];} if (isset($_GET["max_sec"])) {$max_sec=$_GET["max_sec"];} elseif (isset($_POST["max_sec"])) {$max_sec=$_POST["max_sec"];} +if (isset($_GET["usacan_phone_dialcode_fix"])) {$usacan_phone_dialcode_fix=$_GET["usacan_phone_dialcode_fix"];} + elseif (isset($_POST["usacan_phone_dialcode_fix"])) {$usacan_phone_dialcode_fix=$_POST["usacan_phone_dialcode_fix"];} if (isset($script_id)) {$script_id= strtoupper($script_id);} @@ -2356,6 +2358,7 @@ if ($non_latin < 1) $user_hide_realtime = preg_replace('/[^0-9]/','',$user_hide_realtime); $min_sec = preg_replace('/[^0-9]/','',$min_sec); $max_sec = preg_replace('/[^0-9]/','',$max_sec); + $usacan_phone_dialcode_fix = preg_replace('/[^0-9]/','',$usacan_phone_dialcode_fix); $drop_call_seconds = preg_replace('/[^-0-9]/','',$drop_call_seconds); $timer_alt_seconds = preg_replace('/[^-0-9]/','',$timer_alt_seconds); @@ -3621,12 +3624,13 @@ else # 150928-1817 - Added DNC logging and DNC phone number log search # 151007-2224 - Added links and lists for DIDs and Call Menus in use in sections, Issue #835 # 151022-1404 - Added status groups admin, Added custom reports display and admin +# 151030-0636 - Added usacan_phone_dialcode_fix system setting option, executed by keepalive at timeclock end of day # # make sure you have added a user to the vicidial_users MySQL table with at least user_level 9 to access this page the first time -$admin_version = '2.12-516a'; -$build = '151022-1404'; +$admin_version = '2.12-517a'; +$build = '151030-0636'; $STARTtime = date("U"); $SQLdate = date("Y-m-d H:i:s"); @@ -15470,7 +15474,7 @@ if ($ADD==411111111111111) $custom_reports_slave_SQL=",custom_reports_use_slave_db='$custom_reports_slave_SQL'"; } - $stmt="UPDATE system_settings set use_non_latin='$use_non_latin',webroot_writable='$webroot_writable',enable_queuemetrics_logging='$enable_queuemetrics_logging',queuemetrics_server_ip='$queuemetrics_server_ip',queuemetrics_dbname='$queuemetrics_dbname',queuemetrics_login='$queuemetrics_login',queuemetrics_pass='$queuemetrics_pass',queuemetrics_url='$queuemetrics_url',queuemetrics_log_id='$queuemetrics_log_id',queuemetrics_eq_prepend='$queuemetrics_eq_prepend',vicidial_agent_disable='$vicidial_agent_disable',allow_sipsak_messages='$allow_sipsak_messages',admin_home_url='$admin_home_url',enable_agc_xfer_log='$enable_agc_xfer_log',timeclock_end_of_day='$timeclock_end_of_day',vdc_header_date_format='$vdc_header_date_format',vdc_customer_date_format='$vdc_customer_date_format',vdc_header_phone_format='$vdc_header_phone_format',vdc_agent_api_active='$vdc_agent_api_active',enable_vtiger_integration='$enable_vtiger_integration',vtiger_server_ip='$vtiger_server_ip',vtiger_dbname='$vtiger_dbname',vtiger_login='$vtiger_login',vtiger_pass='$vtiger_pass',vtiger_url='$vtiger_url',qc_features_active='$qc_features_active',outbound_autodial_active='$outbound_autodial_active',outbound_calls_per_second='$outbound_calls_per_second',enable_tts_integration='$enable_tts_integration',agentonly_callback_campaign_lock='$agentonly_callback_campaign_lock',sounds_central_control_active='$sounds_central_control_active',sounds_web_server='$sounds_web_server',sounds_web_directory='$sounds_web_directory',active_voicemail_server='$active_voicemail_server',auto_dial_limit='$auto_dial_limit',user_territories_active='$user_territories_active',allow_custom_dialplan='$allow_custom_dialplan',enable_second_webform='$enable_second_webform',default_webphone='$default_webphone',default_external_server_ip='$default_external_server_ip',webphone_url='" . mysqli_real_escape_string($link, $webphone_url) . "',enable_agc_dispo_log='$enable_agc_dispo_log',queuemetrics_loginout='$queuemetrics_loginout',callcard_enabled='$callcard_enabled',queuemetrics_callstatus='$queuemetrics_callstatus',default_codecs='$default_codecs',admin_web_directory='$admin_web_directory',label_title='$label_title',label_first_name='$label_first_name',label_middle_initial='$label_middle_initial',label_last_name='$label_last_name',label_address1='$label_address1',label_address2='$label_address2',label_address3='$label_address3',label_city='$label_city',label_state='$label_state',label_province='$label_province',label_postal_code='$label_postal_code',label_vendor_lead_code='$label_vendor_lead_code',label_gender='$label_gender',label_phone_number='$label_phone_number',label_phone_code='$label_phone_code',label_alt_phone='$label_alt_phone',label_security_phrase='$label_security_phrase',label_email='$label_email',label_comments='$label_comments',custom_fields_enabled='$custom_fields_enabled',slave_db_server='$slave_db_server',reports_use_slave_db='$reports_use_slave_db'$custom_reports_slave_SQL,webphone_systemkey='$webphone_systemkey',first_login_trigger='$first_login_trigger',default_phone_registration_password='$default_phone_registration_password',default_phone_login_password='$default_phone_login_password',default_server_password='$default_server_password',admin_modify_refresh='$admin_modify_refresh',nocache_admin='$nocache_admin',generate_cross_server_exten='$generate_cross_server_exten',queuemetrics_addmember_enabled='$queuemetrics_addmember_enabled',queuemetrics_dispo_pause='$queuemetrics_dispo_pause',label_hide_field_logs='$label_hide_field_logs',queuemetrics_pe_phone_append='$queuemetrics_pe_phone_append',test_campaign_calls='$test_campaign_calls',agents_calls_reset='$agents_calls_reset',default_voicemail_timezone='$default_voicemail_timezone',default_local_gmt='$default_local_gmt',noanswer_log='$noanswer_log',alt_log_server_ip='$alt_log_server_ip',alt_log_dbname='$alt_log_dbname',alt_log_login='$alt_log_login',alt_log_pass='$alt_log_pass',tables_use_alt_log_db='$tables_use_alt_log_db',did_agent_log='$did_agent_log',campaign_cid_areacodes_enabled='$campaign_cid_areacodes_enabled',pllb_grouping_limit='$pllb_grouping_limit',did_ra_extensions_enabled='$did_ra_extensions_enabled',expanded_list_stats='$expanded_list_stats',contacts_enabled='$contacts_enabled',call_menu_qualify_enabled='$call_menu_qualify_enabled',admin_list_counts='$admin_list_counts',allow_voicemail_greeting='$allow_voicemail_greeting',queuemetrics_socket='$queuemetrics_socket',queuemetrics_socket_url='$queuemetrics_socket_url',enhanced_disconnect_logging='$enhanced_disconnect_logging',allow_emails='$allow_emails',level_8_disable_add='$level_8_disable_add',queuemetrics_record_hold='$queuemetrics_record_hold',country_code_list_stats='$country_code_list_stats',queuemetrics_pause_type='$queuemetrics_pause_type',frozen_server_call_clear='$frozen_server_call_clear',callback_time_24hour='$callback_time_24hour',enable_languages='$enable_languages',language_method='$language_method',meetme_enter_login_filename='$meetme_enter_login_filename',meetme_enter_leave3way_filename='$meetme_enter_leave3way_filename',enable_did_entry_list_id='$enable_did_entry_list_id',enable_third_webform='$enable_third_webform',allow_chats='$allow_chats',chat_url='$chat_url',chat_timeout='$chat_timeout',agent_debug_logging='$agent_debug_logging',default_language='$default_language',agent_whisper_enabled='$agent_whisper_enabled',user_hide_realtime_enabled='$user_hide_realtime_enabled'$custom_dialplanSQL;"; + $stmt="UPDATE system_settings set use_non_latin='$use_non_latin',webroot_writable='$webroot_writable',enable_queuemetrics_logging='$enable_queuemetrics_logging',queuemetrics_server_ip='$queuemetrics_server_ip',queuemetrics_dbname='$queuemetrics_dbname',queuemetrics_login='$queuemetrics_login',queuemetrics_pass='$queuemetrics_pass',queuemetrics_url='$queuemetrics_url',queuemetrics_log_id='$queuemetrics_log_id',queuemetrics_eq_prepend='$queuemetrics_eq_prepend',vicidial_agent_disable='$vicidial_agent_disable',allow_sipsak_messages='$allow_sipsak_messages',admin_home_url='$admin_home_url',enable_agc_xfer_log='$enable_agc_xfer_log',timeclock_end_of_day='$timeclock_end_of_day',vdc_header_date_format='$vdc_header_date_format',vdc_customer_date_format='$vdc_customer_date_format',vdc_header_phone_format='$vdc_header_phone_format',vdc_agent_api_active='$vdc_agent_api_active',enable_vtiger_integration='$enable_vtiger_integration',vtiger_server_ip='$vtiger_server_ip',vtiger_dbname='$vtiger_dbname',vtiger_login='$vtiger_login',vtiger_pass='$vtiger_pass',vtiger_url='$vtiger_url',qc_features_active='$qc_features_active',outbound_autodial_active='$outbound_autodial_active',outbound_calls_per_second='$outbound_calls_per_second',enable_tts_integration='$enable_tts_integration',agentonly_callback_campaign_lock='$agentonly_callback_campaign_lock',sounds_central_control_active='$sounds_central_control_active',sounds_web_server='$sounds_web_server',sounds_web_directory='$sounds_web_directory',active_voicemail_server='$active_voicemail_server',auto_dial_limit='$auto_dial_limit',user_territories_active='$user_territories_active',allow_custom_dialplan='$allow_custom_dialplan',enable_second_webform='$enable_second_webform',default_webphone='$default_webphone',default_external_server_ip='$default_external_server_ip',webphone_url='" . mysqli_real_escape_string($link, $webphone_url) . "',enable_agc_dispo_log='$enable_agc_dispo_log',queuemetrics_loginout='$queuemetrics_loginout',callcard_enabled='$callcard_enabled',queuemetrics_callstatus='$queuemetrics_callstatus',default_codecs='$default_codecs',admin_web_directory='$admin_web_directory',label_title='$label_title',label_first_name='$label_first_name',label_middle_initial='$label_middle_initial',label_last_name='$label_last_name',label_address1='$label_address1',label_address2='$label_address2',label_address3='$label_address3',label_city='$label_city',label_state='$label_state',label_province='$label_province',label_postal_code='$label_postal_code',label_vendor_lead_code='$label_vendor_lead_code',label_gender='$label_gender',label_phone_number='$label_phone_number',label_phone_code='$label_phone_code',label_alt_phone='$label_alt_phone',label_security_phrase='$label_security_phrase',label_email='$label_email',label_comments='$label_comments',custom_fields_enabled='$custom_fields_enabled',slave_db_server='$slave_db_server',reports_use_slave_db='$reports_use_slave_db'$custom_reports_slave_SQL,webphone_systemkey='$webphone_systemkey',first_login_trigger='$first_login_trigger',default_phone_registration_password='$default_phone_registration_password',default_phone_login_password='$default_phone_login_password',default_server_password='$default_server_password',admin_modify_refresh='$admin_modify_refresh',nocache_admin='$nocache_admin',generate_cross_server_exten='$generate_cross_server_exten',queuemetrics_addmember_enabled='$queuemetrics_addmember_enabled',queuemetrics_dispo_pause='$queuemetrics_dispo_pause',label_hide_field_logs='$label_hide_field_logs',queuemetrics_pe_phone_append='$queuemetrics_pe_phone_append',test_campaign_calls='$test_campaign_calls',agents_calls_reset='$agents_calls_reset',default_voicemail_timezone='$default_voicemail_timezone',default_local_gmt='$default_local_gmt',noanswer_log='$noanswer_log',alt_log_server_ip='$alt_log_server_ip',alt_log_dbname='$alt_log_dbname',alt_log_login='$alt_log_login',alt_log_pass='$alt_log_pass',tables_use_alt_log_db='$tables_use_alt_log_db',did_agent_log='$did_agent_log',campaign_cid_areacodes_enabled='$campaign_cid_areacodes_enabled',pllb_grouping_limit='$pllb_grouping_limit',did_ra_extensions_enabled='$did_ra_extensions_enabled',expanded_list_stats='$expanded_list_stats',contacts_enabled='$contacts_enabled',call_menu_qualify_enabled='$call_menu_qualify_enabled',admin_list_counts='$admin_list_counts',allow_voicemail_greeting='$allow_voicemail_greeting',queuemetrics_socket='$queuemetrics_socket',queuemetrics_socket_url='$queuemetrics_socket_url',enhanced_disconnect_logging='$enhanced_disconnect_logging',allow_emails='$allow_emails',level_8_disable_add='$level_8_disable_add',queuemetrics_record_hold='$queuemetrics_record_hold',country_code_list_stats='$country_code_list_stats',queuemetrics_pause_type='$queuemetrics_pause_type',frozen_server_call_clear='$frozen_server_call_clear',callback_time_24hour='$callback_time_24hour',enable_languages='$enable_languages',language_method='$language_method',meetme_enter_login_filename='$meetme_enter_login_filename',meetme_enter_leave3way_filename='$meetme_enter_leave3way_filename',enable_did_entry_list_id='$enable_did_entry_list_id',enable_third_webform='$enable_third_webform',allow_chats='$allow_chats',chat_url='$chat_url',chat_timeout='$chat_timeout',agent_debug_logging='$agent_debug_logging',default_language='$default_language',agent_whisper_enabled='$agent_whisper_enabled',user_hide_realtime_enabled='$user_hide_realtime_enabled',usacan_phone_dialcode_fix='$usacan_phone_dialcode_fix'$custom_dialplanSQL;"; $rslt=mysql_to_mysqli($stmt, $link); if ( ($meetme_enter_login_filename != $SSmeetme_enter_login_filename) or ($meetme_enter_leave3way_filename != $SSmeetme_enter_leave3way_filename) ) @@ -31664,7 +31668,7 @@ if ($ADD==311111111111111) $ALLagent_count = $rowx[2]; } - $stmt="SELECT version,install_date,use_non_latin,webroot_writable,enable_queuemetrics_logging,queuemetrics_server_ip,queuemetrics_dbname,queuemetrics_login,queuemetrics_pass,queuemetrics_url,queuemetrics_log_id,queuemetrics_eq_prepend,vicidial_agent_disable,allow_sipsak_messages,admin_home_url,enable_agc_xfer_log,db_schema_version,auto_user_add_value,timeclock_end_of_day,timeclock_last_reset_date,vdc_header_date_format,vdc_customer_date_format,vdc_header_phone_format,vdc_agent_api_active,qc_last_pull_time,enable_vtiger_integration,vtiger_server_ip,vtiger_dbname,vtiger_login,vtiger_pass,vtiger_url,qc_features_active,outbound_autodial_active,outbound_calls_per_second,enable_tts_integration,agentonly_callback_campaign_lock,sounds_central_control_active,sounds_web_server,sounds_web_directory,active_voicemail_server,auto_dial_limit,user_territories_active,allow_custom_dialplan,db_schema_update_date,enable_second_webform,default_webphone,default_external_server_ip,webphone_url,enable_agc_dispo_log,custom_dialplan_entry,queuemetrics_loginout,callcard_enabled,queuemetrics_callstatus,default_codecs,admin_web_directory,label_title,label_first_name,label_middle_initial,label_last_name,label_address1,label_address2,label_address3,label_city,label_state,label_province,label_postal_code,label_vendor_lead_code,label_gender,label_phone_number,label_phone_code,label_alt_phone,label_security_phrase,label_email,label_comments,custom_fields_enabled,slave_db_server,reports_use_slave_db,webphone_systemkey,first_login_trigger,default_phone_registration_password,default_phone_login_password,default_server_password,admin_modify_refresh,nocache_admin,generate_cross_server_exten,queuemetrics_addmember_enabled,queuemetrics_dispo_pause,label_hide_field_logs,queuemetrics_pe_phone_append,test_campaign_calls,agents_calls_reset,default_voicemail_timezone,default_local_gmt,noanswer_log,alt_log_server_ip,alt_log_dbname,alt_log_login,alt_log_pass,tables_use_alt_log_db,did_agent_log,campaign_cid_areacodes_enabled,pllb_grouping_limit,did_ra_extensions_enabled,expanded_list_stats,contacts_enabled,call_menu_qualify_enabled,admin_list_counts,allow_voicemail_greeting,svn_revision,queuemetrics_socket,queuemetrics_socket_url,enhanced_disconnect_logging,allow_emails,level_8_disable_add,pass_hash_enabled,pass_key,pass_cost,disable_auto_dial,queuemetrics_record_hold,country_code_list_stats,reload_timestamp,queuemetrics_pause_type,frozen_server_call_clear,callback_time_24hour,allow_chats,chat_url,chat_timeout,enable_languages,language_method,meetme_enter_login_filename,meetme_enter_leave3way_filename,enable_did_entry_list_id,enable_third_webform,agent_debug_logging,default_language,agent_whisper_enabled,user_hide_realtime_enabled from system_settings;"; + $stmt="SELECT version,install_date,use_non_latin,webroot_writable,enable_queuemetrics_logging,queuemetrics_server_ip,queuemetrics_dbname,queuemetrics_login,queuemetrics_pass,queuemetrics_url,queuemetrics_log_id,queuemetrics_eq_prepend,vicidial_agent_disable,allow_sipsak_messages,admin_home_url,enable_agc_xfer_log,db_schema_version,auto_user_add_value,timeclock_end_of_day,timeclock_last_reset_date,vdc_header_date_format,vdc_customer_date_format,vdc_header_phone_format,vdc_agent_api_active,qc_last_pull_time,enable_vtiger_integration,vtiger_server_ip,vtiger_dbname,vtiger_login,vtiger_pass,vtiger_url,qc_features_active,outbound_autodial_active,outbound_calls_per_second,enable_tts_integration,agentonly_callback_campaign_lock,sounds_central_control_active,sounds_web_server,sounds_web_directory,active_voicemail_server,auto_dial_limit,user_territories_active,allow_custom_dialplan,db_schema_update_date,enable_second_webform,default_webphone,default_external_server_ip,webphone_url,enable_agc_dispo_log,custom_dialplan_entry,queuemetrics_loginout,callcard_enabled,queuemetrics_callstatus,default_codecs,admin_web_directory,label_title,label_first_name,label_middle_initial,label_last_name,label_address1,label_address2,label_address3,label_city,label_state,label_province,label_postal_code,label_vendor_lead_code,label_gender,label_phone_number,label_phone_code,label_alt_phone,label_security_phrase,label_email,label_comments,custom_fields_enabled,slave_db_server,reports_use_slave_db,webphone_systemkey,first_login_trigger,default_phone_registration_password,default_phone_login_password,default_server_password,admin_modify_refresh,nocache_admin,generate_cross_server_exten,queuemetrics_addmember_enabled,queuemetrics_dispo_pause,label_hide_field_logs,queuemetrics_pe_phone_append,test_campaign_calls,agents_calls_reset,default_voicemail_timezone,default_local_gmt,noanswer_log,alt_log_server_ip,alt_log_dbname,alt_log_login,alt_log_pass,tables_use_alt_log_db,did_agent_log,campaign_cid_areacodes_enabled,pllb_grouping_limit,did_ra_extensions_enabled,expanded_list_stats,contacts_enabled,call_menu_qualify_enabled,admin_list_counts,allow_voicemail_greeting,svn_revision,queuemetrics_socket,queuemetrics_socket_url,enhanced_disconnect_logging,allow_emails,level_8_disable_add,pass_hash_enabled,pass_key,pass_cost,disable_auto_dial,queuemetrics_record_hold,country_code_list_stats,reload_timestamp,queuemetrics_pause_type,frozen_server_call_clear,callback_time_24hour,allow_chats,chat_url,chat_timeout,enable_languages,language_method,meetme_enter_login_filename,meetme_enter_leave3way_filename,enable_did_entry_list_id,enable_third_webform,agent_debug_logging,default_language,agent_whisper_enabled,user_hide_realtime_enabled,usacan_phone_dialcode_fix from system_settings;"; $rslt=mysql_to_mysqli($stmt, $link); $row=mysqli_fetch_row($rslt); $version = $row[0]; @@ -31804,6 +31808,7 @@ if ($ADD==311111111111111) $default_language = $row[134]; $agent_whisper_enabled = $row[135]; $user_hide_realtime_enabled = $row[136]; + $usacan_phone_dialcode_fix = $row[137]; if ($pass_hash_enabled > 0) {$pass_hash_enabled = 'ENABLED';} else {$pass_hash_enabled = 'DISABLED';} @@ -32021,6 +32026,8 @@ if ($ADD==311111111111111) echo ""._QXZ("Generate Cross-Server Phone Extensions").": $NWB#settings-generate_cross_server_exten$NWE\n"; + echo ""._QXZ("USA-Canada Phone Number Dialcode Fix").": $NWB#settings-usacan_phone_dialcode_fix$NWE\n"; + echo ""._QXZ("User Territories Active").": $NWB#settings-user_territories_active$NWE\n"; echo ""._QXZ("Enable Second Webform").": $NWB#settings-enable_second_webform$NWE\n"; diff --git a/agc_2-X/trunk/www/vicidial/help.php b/agc_2-X/trunk/www/vicidial/help.php index 6ad01573..00add988 100644 --- a/agc_2-X/trunk/www/vicidial/help.php +++ b/agc_2-X/trunk/www/vicidial/help.php @@ -64,6 +64,7 @@ # 150926-1058 - Added did_carrier_description # 151006-0935 - Updated campaign_cid_areacodes entry # 151020-0704 - Added Status Groups and Custom Reports entries +# 151030-0639 - Added usacan_phone_dialcode_fix entry # @@ -4813,6 +4814,11 @@ FR_SPAC 00 00 00 00 00 - - +
+ +
+ - +