fixes for database deadlocks added to vicidial agent interface scripts

added mysql logging to AGI VDAD scripts

git-svn-id: svn://192.168.202.10@996 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
mattf
2008-11-05 09:53:23 +00:00
parent ea1ab3b7f4
commit b1dfbd1a0b
9 changed files with 710 additions and 377 deletions
+139 -10
View File
@@ -88,6 +88,7 @@
# 81021-2315 - Changed and add queue_log logging
# 81024-0006 - Changed LOOKUP to insert new lead if phone_number < 3 digits, changed queue_sec calculation
# 81104-0301 - Changed code to alter callerIDnumber for remote agents to the number of the caller
# 81105-0248 - Added MySQL error logging
#
$script = 'agi-VDAD_ALL_inbound.agi';
@@ -96,6 +97,9 @@ $dtmf_silent_prefix = '7';
$DROP_TIME = 720; ### default number of seconds to wait until you drop a waiting call
$start_moh=1;
$at='@';
$mel=1; # Mysql Error Log enabled = 1
$mysql_log_count=103;
$one_mysql_log=0;
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
@@ -173,6 +177,7 @@ if (!$VARDB_port) {$VARDB_port='3306';}
if (!$AGILOGfile) {$AGILOGfile = "$PATHlogs/agiout.$year-$mon-$mday";}
if (!$PRSLOGfile) {$PRSLOGfile = "$PATHlogs/prsout.$year-$mon-$mday";}
if (!$PRSTESTfile) {$PRSTESTfile = "$PATHlogs/prstest.$year-$mon-$mday";}
if (!$ERRLOGfile) {$ERRLOGfile = "$PATHlogs/MySQLerror.$year-$mon-$mday";}
use DBI;
use Time::HiRes ('gettimeofday','usleep','sleep'); # necessary to have perl sleep command of less than one second
@@ -187,6 +192,7 @@ $stmtA = "SELECT agi_output,local_gmt FROM servers where server_ip = '$VARserver
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$dbhP=$dbhA; $mysql_count='02001'; $MEL_aff_rows=$sthArows; &mysql_error_logging;
$rec_count=0;
while ($sthArows > $rec_count)
{
@@ -278,6 +284,7 @@ if ($extension =~ /^999\d\d\*/)
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$dbhP=$dbhA; $mysql_count='02002'; $MEL_aff_rows=$sthArows; &mysql_error_logging;
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
@@ -376,6 +383,7 @@ if ($channel =~ /Local/i)
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$dbhP=$dbhA; $mysql_count='02003'; $MEL_aff_rows=$sthArows; &mysql_error_logging;
$rec_count=0;
while ($sthArows > $rec_count)
{
@@ -405,6 +413,7 @@ $stmtA = "SELECT voicemail_dump_exten,ext_context,answer_transfer_agent,local_gm
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$dbhP=$dbhA; $mysql_count='02004'; $MEL_aff_rows=$sthArows; &mysql_error_logging;
while ($sthArows > $cbc)
{
@aryA = $sthA->fetchrow_array;
@@ -433,6 +442,7 @@ $stmtA = "SELECT call_time_id,after_hours_action,after_hours_message_filename,af
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$dbhP=$dbhA; $mysql_count='02005'; $MEL_aff_rows=$sthArows; &mysql_error_logging;
while ($sthArows > $cbc)
{
@aryA = $sthA->fetchrow_array;
@@ -490,6 +500,7 @@ $stmtA = "SELECT ct_default_start,ct_default_stop $daySQL FROM vicidial_call_tim
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$dbhP=$dbhA; $mysql_count='02006'; $MEL_aff_rows=$sthArows; &mysql_error_logging;
@aryA = $sthA->fetchrow_array;
$ct_default_start = "$aryA[0]";
$ct_default_stop = "$aryA[1]";
@@ -517,11 +528,13 @@ if ($call_handle_method =~ /LOOKUP/)
### insert a record into the vicidial_list table
$stmtA = "INSERT INTO vicidial_list (entry_date,modify_date,status,user,vendor_lead_code,source_id,list_id,called_since_last_reset,phone_code,phone_number,security_phrase,called_count,gmt_offset_now,comments) values('$SQLdate','$tsSQLdate','INBND','$fronter','$inbound_number','VDCL','$list_id','Y','$phone_code','$phone_number','$channel_group','1','$local_gmt','$VLcomments');";
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='02007'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
$cbc=0;
$stmtB = "select LAST_INSERT_ID() LIMIT 1;";
$sthA = $dbhA->prepare($stmtB) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$dbhP=$dbhA; $stmtA=$stmtB; $mysql_count='02008'; $MEL_aff_rows=$sthArows; &mysql_error_logging;
while ($sthArows > $cbc)
{
@aryA = $sthA->fetchrow_array;
@@ -548,6 +561,7 @@ if ($call_handle_method =~ /LOOKUP/)
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$dbhP=$dbhA; $mysql_count='02009'; $MEL_aff_rows=$sthArows; &mysql_error_logging;
while ($sthArows > $cbc)
{
@aryA = $sthA->fetchrow_array;
@@ -568,6 +582,7 @@ if ($call_handle_method =~ /LOOKUP/)
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$dbhP=$dbhA; $mysql_count='02010'; $MEL_aff_rows=$sthArows; &mysql_error_logging;
if ($sthArows > 0)
{
$rec_countCUSTDATA=0;
@@ -586,11 +601,13 @@ if ($call_handle_method =~ /LOOKUP/)
### insert a record into the vicidial_list table
$stmtA = "INSERT INTO vicidial_list (entry_date,modify_date,status,user,vendor_lead_code,source_id,list_id,called_since_last_reset,phone_code,phone_number,security_phrase,called_count,gmt_offset_now,comments) values('$SQLdate','$tsSQLdate','INBND','$fronter','$inbound_number','VDCL','$list_id','Y','$phone_code','$phone_number','$channel_group','1','$local_gmt','$VLcomments');";
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='02011'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
$cbc=0;
$stmtB = "select LAST_INSERT_ID() LIMIT 1;";
$sthA = $dbhA->prepare($stmtB) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$dbhP=$dbhA; $stmtA=$stmtB; $mysql_count='02012'; $MEL_aff_rows=$sthArows; &mysql_error_logging;
while ($sthArows > $cbc)
{
@aryA = $sthA->fetchrow_array;
@@ -614,6 +631,7 @@ else
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$dbhP=$dbhA; $mysql_count='02013'; $MEL_aff_rows=$sthArows; &mysql_error_logging;
while ($sthArows > $cbc)
{
@aryA = $sthA->fetchrow_array;
@@ -632,11 +650,13 @@ else
### insert a record into the vicidial_list table if no record was found above
$stmtA = "INSERT INTO vicidial_list (entry_date,modify_date,status,user,vendor_lead_code,source_id,list_id,called_since_last_reset,phone_code,phone_number,security_phrase,called_count,gmt_offset_now,comments) values('$SQLdate','$tsSQLdate','INBND','$fronter','$inbound_number','VDCL','$list_id','Y','$phone_code','$phone_number','$channel_group','1','-5.00','$VLcomments');";
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='02014'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
$cbc=0;
$stmtA = "select LAST_INSERT_ID() LIMIT 1;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$dbhP=$dbhA; $mysql_count='02015'; $MEL_aff_rows=$sthArows; &mysql_error_logging;
while ($sthArows > $cbc)
{
@aryA = $sthA->fetchrow_array;
@@ -656,10 +676,12 @@ if ( ($hm < $ct_default_start) || ($hm > $ct_default_stop) )
$stmtA = "INSERT INTO vicidial_closer_log set status='DROP',start_epoch='$now_date_epoch',end_epoch='$now_date_epoch',length_in_sec='1',queue_seconds='0',lead_id = '$insert_lead_id',campaign_id='$channel_group',user='VDCL',list_id='$list_id',call_date='$now_date',phone_code='$phone_code',phone_number='$phone_number',comments='AFTER HOURS DROP',term_reason='AFTERHOURS',uniqueid='$uniqueid';";
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='02016'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
$stmtB = "select LAST_INSERT_ID() LIMIT 1;";
$sthA = $dbhA->prepare($stmtB) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtB ", $dbhA->errstr;
$sthArows=$sthA->rows;
$dbhP=$dbhA; $stmtA=$stmtB; $mysql_count='02017'; $MEL_aff_rows=$sthArows; &mysql_error_logging;
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
@@ -671,10 +693,12 @@ if ( ($hm < $ct_default_start) || ($hm > $ct_default_stop) )
$stmtA = "UPDATE vicidial_list set status='DROP' where lead_id = '$insert_lead_id';";
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='02018'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
if ($AGILOG) {$agi_string = "-- VDCL vl update: |$affected_rows|$insert_lead_id|\n|$stmtA|"; &agi_output;}
$stmtA = "DELETE FROM vicidial_auto_calls where callerid='$callerid' and server_ip='$VARserver_ip' order by call_time desc limit 1;";
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='02019'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
if ($AGILOG) {$agi_string = "-- VDCL vac record deleted: |$affected_rows| $VDADcampaign|"; &agi_output;}
if ($after_hours_action =~ /EXTENSION|VOICEMAIL|IN_GROUP/)
@@ -716,6 +740,7 @@ if ( ($hm < $ct_default_start) || ($hm > $ct_default_stop) )
### insert a NEW record to the vicidial_manager table to hangup the channel
$stmtA = "INSERT INTO vicidial_manager values('','','$SQLdate','NEW','N','$VARserver_ip','','Hangup','$VHqueryCID','Channel: $channel','','','','','','','','','')";
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='02020'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
if ($AGILOG) {$agi_string = "-- VDCL call_hungup after hours: |$VHqueryCID|$VDADconf_exten|$channel|insert to vicidial_manager"; &agi_output;}
}
if ($after_hours_action =~ /MESSAGE/)
@@ -728,6 +753,7 @@ if ( ($hm < $ct_default_start) || ($hm > $ct_default_stop) )
### insert a NEW record to the vicidial_manager table to hangup the channel
$stmtA = "INSERT INTO vicidial_manager values('','','$SQLdate','NEW','N','$VARserver_ip','','Hangup','$VHqueryCID','Channel: $channel','','','','','','','','','')";
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='02021'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
if ($AGILOG) {$agi_string = "-- VDCL call_hungup after hours: |$VHqueryCID|$VDADconf_exten|$channel|insert to vicidial_manager"; &agi_output;}
}
@@ -758,6 +784,7 @@ $stmtA = "SELECT campaign_id FROM vicidial_campaigns where active='Y' and campai
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$dbhP=$dbhA; $mysql_count='02022'; $MEL_aff_rows=$sthArows; &mysql_error_logging;
while ($sthArows > $vci)
{
@aryA = $sthA->fetchrow_array;
@@ -783,6 +810,7 @@ if ($call_handle_method =~ /DIGITID$/)
$stmtA = "INSERT INTO vicidial_log (uniqueid,lead_id,campaign_id,call_date,start_epoch,status,phone_code,phone_number,user,processed) values('$uniqueid','$insert_lead_id','$channel_group','$SQLdate','$now_date_epoch','XFER','$phone_code','$phone_number','$fronter','N')";
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='02023'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
if ($AGILOG) {$agi_string = "-- VDAD : |$insert_lead_id|$fronter|insert to vicidial_log: $uniqueid"; &agi_output;}
}
$insert_xfer_id=0;
@@ -791,10 +819,12 @@ if ($call_handle_method =~ /CLOSER|DIGITID$/)
$stmtA = "INSERT INTO vicidial_xfer_log (lead_id,campaign_id,call_date,phone_code,phone_number,user,closer) values('$insert_lead_id','$channel_group','$SQLdate','$phone_code','$phone_number','$fronter','VDXL')";
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='02024'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
$stmtB = "select LAST_INSERT_ID() LIMIT 1;";
$sthA = $dbhA->prepare($stmtB) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtB ", $dbhA->errstr;
$sthArows=$sthA->rows;
$dbhP=$dbhA; $stmtA=$stmtB; $mysql_count='02025'; $MEL_aff_rows=$sthArows; &mysql_error_logging;
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
@@ -812,6 +842,7 @@ $stmtA = "SELECT enable_queuemetrics_logging,queuemetrics_server_ip,queuemetrics
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$dbhP=$dbhA; $mysql_count='02026'; $MEL_aff_rows=$sthArows; &mysql_error_logging;
$rec_count=0;
while ($sthArows > $rec_count)
{
@@ -838,6 +869,7 @@ if ($enable_queuemetrics_logging > 0)
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$dbhP=$dbhA; $mysql_count='02027'; $MEL_aff_rows=$sthArows; &mysql_error_logging;
$rec_count=0;
while ($sthArows > $rec_count)
{
@@ -857,7 +889,7 @@ if ($enable_queuemetrics_logging > 0)
$stmtB = "INSERT INTO queue_log SET partition='P01',time_id='$now_date_epoch',call_id='$YqueryCID',queue='$channel_group',agent='NONE',verb='ENTERQUEUE',data2='$data2',serverid='$queuemetrics_log_id';";
$Baffected_rows = $dbhB->do($stmtB);
$dbhP=$dbhB; $stmtA=$stmtB; $mysql_count='02028'; $MEL_aff_rows=$Baffected_rows; &mysql_error_logging;
$dbhB->disconnect();
}
@@ -867,6 +899,7 @@ $stmtA = "select auto_call_id from vicidial_auto_calls where uniqueid='$uniqueid
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$dbhP=$dbhA; $mysql_count='02029'; $MEL_aff_rows=$sthArows; &mysql_error_logging;
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
@@ -876,6 +909,7 @@ if ($sthArows > 0)
$stmtA = "UPDATE vicidial_auto_calls SET campaign_id='$channel_group',status='LIVE',lead_id='$insert_lead_id',callerid='$callerid',channel='$channel',phone_code='$phone_code',phone_number='$phone_number',call_time='$SQLdate',call_type='IN',stage='LIVE-0',queue_priority='$queue_priority' WHERE auto_call_id='$auto_call_id';";
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
$Uaffected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='02029'; $MEL_aff_rows=$Uaffected_rows; &mysql_error_logging;
}
$sthA->finish();
@@ -885,15 +919,18 @@ if ($Uaffected_rows < 1)
$stmtA = "INSERT INTO vicidial_auto_calls (server_ip,campaign_id,status,lead_id,uniqueid,callerid,channel,phone_code,phone_number,call_time,call_type,stage,queue_priority) values('$VARserver_ip','$channel_group','LIVE','$insert_lead_id','$uniqueid','$callerid','$channel','$phone_code','$phone_number','$SQLdate','IN','LIVE-0','$queue_priority')";
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='02030'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
}
$stmtA = "INSERT INTO vicidial_closer_log (lead_id,campaign_id,call_date,start_epoch,status,phone_code,phone_number,user,processed,xfercallid,uniqueid) values('$insert_lead_id','$channel_group','$SQLdate','$now_date_epoch','QUEUE','$phone_code','$phone_number','VDCL','N','$insert_xfer_id','$uniqueid')";
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='02031'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
$stmtB = "select LAST_INSERT_ID() LIMIT 1;";
$sthA = $dbhA->prepare($stmtB) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtB ", $dbhA->errstr;
$sthArows=$sthA->rows;
$dbhP=$dbhA; $stmtA=$stmtB; $mysql_count='02032'; $MEL_aff_rows=$sthArows; &mysql_error_logging;
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
@@ -954,6 +991,7 @@ $stmtA = "SELECT campaign_id FROM vicidial_campaigns where active='Y' and campai
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$dbhP=$dbhA; $mysql_count='02033'; $MEL_aff_rows=$sthArows; &mysql_error_logging;
while ($sthArows > $vci)
{
@aryA = $sthA->fetchrow_array;
@@ -973,6 +1011,7 @@ if ($agent_search_method =~ /^SO|^LO/)
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$dbhP=$dbhA; $mysql_count='02034'; $MEL_aff_rows=$sthArows; &mysql_error_logging;
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
@@ -990,6 +1029,7 @@ if ($agent_search_method =~ /^SO|^LO/)
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$dbhP=$dbhA; $mysql_count='02035'; $MEL_aff_rows=$sthArows; &mysql_error_logging;
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
@@ -1010,6 +1050,7 @@ if ($agent_search_method =~ /^SO|^LO/)
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$dbhP=$dbhA; $mysql_count='02036'; $MEL_aff_rows=$sthArows; &mysql_error_logging;
$dbc=0;
$qp_groupWAIT='';
while ($sthArows > $dbc)
@@ -1036,16 +1077,18 @@ if ($agent_search_method =~ /^SO|^LO/)
{
$stmtA = "LOCK TABLES vicidial_live_agents WRITE, vicidial_live_inbound_agents WRITE;";
my $LOCKaffected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='02037'; $MEL_aff_rows=$LOCKaffected_rows; &mysql_error_logging;
$stmtA = "SELECT vicidial_live_agents.conf_exten,vicidial_live_agents.user,vicidial_live_agents.extension from vicidial_live_agents JOIN vicidial_live_inbound_agents ON vicidial_live_agents.user=vicidial_live_inbound_agents.user WHERE status IN('CLOSER','READY') and server_ip='$VARserver_ip' and vicidial_live_inbound_agents.group_id='$channel_group' and last_update_time > '$BDtsSQLdate' $qp_groupWAIT_aco_SQL $qp_groupWAIT_camp_SQL $agent_call_order limit 1;";
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$dbhP=$dbhA; $mysql_count='02038'; $MEL_aff_rows=$sthArows; &mysql_error_logging;
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
$VDADconf_exten = "$aryA[0]";
$VDADuser = "$aryA[1]";
$VDADextension = "$aryA[2]";
@@ -1056,6 +1099,7 @@ if ($agent_search_method =~ /^SO|^LO/)
{
$stmtA = "UPDATE vicidial_live_agents set status='QUEUE',lead_id='$insert_lead_id',uniqueid='$unique_id', channel='$channel', callerid='$callerid',comments='INBOUND' where user='$VDADuser';";
my $affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='02039'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
$found_agents=$affected_rows;
}
else
@@ -1065,11 +1109,13 @@ if ($agent_search_method =~ /^SO|^LO/)
$stmtA = "UNLOCK TABLES;";
my $LOCKaffected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='02040'; $MEL_aff_rows=$LOCKaffected_rows; &mysql_error_logging;
}
else
{
$stmtA = "UPDATE vicidial_live_agents set status='QUEUE',lead_id='$insert_lead_id',uniqueid='$unique_id', channel='$channel', callerid='$callerid',comments='INBOUND' where status IN('CLOSER','READY') and server_ip='$VARserver_ip' and campaign_id IN($INBOUNDcampsSQL) and closer_campaigns LIKE \"% $channel_group %\" and last_update_time > '$BDtsSQLdate' $qp_groupWAIT_SQL $qp_groupWAIT_camp_SQL $agent_call_order limit 1;";
my $affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='02041'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
$found_agents=$affected_rows;
}
if ($AGILOG) {$agi_string = "-- VDAD get agent: |$affected_rows|$channel_group|$stmtA|"; &agi_output;}
@@ -1083,6 +1129,7 @@ if ($agent_search_method =~ /^SO|^LO/)
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$dbhP=$dbhA; $mysql_count='02042'; $MEL_aff_rows=$sthArows; &mysql_error_logging;
$rec_countCUSTDATA=0;
while ($sthArows > $cbc)
{
@@ -1099,11 +1146,13 @@ if ($agent_search_method =~ /^SO|^LO/)
$stmtA = "UPDATE vicidial_auto_calls set status='CLOSER', stage='CLOSER-$drop_timer' where callerid='$callerid';";
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='02043'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
if ($AGILOG) {$agi_string = "-- VDCL XFER : |$affected_rows|$callerid\n|$stmtA|"; &agi_output;}
if ($affected_rows < 1)
{
$stmtA = "INSERT INTO vicidial_auto_calls (server_ip,campaign_id,status,lead_id,uniqueid,callerid,channel,phone_code,phone_number,call_time,call_type,stage,queue_priority) values('$VARserver_ip','$channel_group','CLOSER','$insert_lead_id','$uniqueid','$callerid','$channel','$phone_code','$phone_number','$SQLdate','IN','CLOSER-$drop_timer','$queue_priority')";
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='02044'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
if ($AGILOG) {$agi_string = "$affected_rows|VDAC-reinsert|$stmtA|"; &agi_output;}
}
@@ -1117,6 +1166,7 @@ if ($agent_search_method =~ /^SO|^LO/)
$stmtB = "INSERT INTO queue_log SET partition='P01',time_id='$now_date_epoch',call_id='$YqueryCID',queue='$channel_group',agent='Agent/$VDADuser',verb='CONNECT',data1='$drop_timer',serverid='$queuemetrics_log_id';";
$Baffected_rows = $dbhB->do($stmtB);
$dbhP=$dbhB; $stmtA=$stmtB; $mysql_count='02045'; $MEL_aff_rows=$Baffected_rows; &mysql_error_logging;
$dbhB->disconnect();
}
@@ -1125,11 +1175,13 @@ if ($agent_search_method =~ /^SO|^LO/)
{
$stmtA = "UPDATE vicidial_xfer_log set closer='$VDADuser' where lead_id = '$insert_lead_id' order by call_date desc limit 1;";
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='02046'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
if ($AGILOG) {$agi_string = "-- VDXL XFER vicidial_xfer_log update: |$affected_rows|$insert_lead_id|$VDADuser\n|$stmtA|"; &agi_output;}
}
$stmtA = "UPDATE vicidial_closer_log set user='$VDADuser' where lead_id='$insert_lead_id' order by call_date desc limit 1;";
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='02047'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
if ($AGILOG) {$agi_string = "-- closer log : |$affected_rows|$insert_lead_id|$insert_close_id|\n|$stmtA|"; &agi_output;}
### if agent alert exten is not disabled, then trigger the alert and wait
@@ -1140,6 +1192,7 @@ if ($agent_search_method =~ /^SO|^LO/)
### insert a NEW record to the vicidial_manager table to play the alert message to the agent
$stmtA = "INSERT INTO vicidial_manager values('','','$SQLdate','NEW','N','$VARserver_ip','','Originate','$VHqueryCID','Exten: $agent_alert_exten','Context: $ext_context','Channel: Local/$dtmf_silent_prefix$VDADconf_exten$at$ext_context','Priority: 1','Callerid: $CIDstring','Timeout: 10','','','','')";
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='02048'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
if ($AGILOG) {$agi_string = "-- VDCL agent alert: |$VHqueryCID|7$VDADconf_exten|$channel|insert to vicidial_manager"; &agi_output;}
usleep(1 * $agent_alert_delay * 1000);
@@ -1158,6 +1211,7 @@ if ($agent_search_method =~ /^SO|^LO/)
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$dbhP=$dbhA; $mysql_count='02049'; $MEL_aff_rows=$sthArows; &mysql_error_logging;
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
@@ -1169,9 +1223,11 @@ if ($agent_search_method =~ /^SO|^LO/)
if ($sthArows > 0)
{
$stmtA = "UPDATE vicidial_live_inbound_agents set calls_today='$calls_today' WHERE user='$VDADuser' and group_id='$channel_group';";
my $affected_rows = $dbhA->do($stmtA);
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='02050'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
$stmtA = "UPDATE vicidial_inbound_group_agents set calls_today='$calls_today' WHERE user='$VDADuser' and group_id='$channel_group';";
my $affected_rows = $dbhA->do($stmtA);
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='02051'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
if ($AGILOG) {$agi_string = "-- VDLIA agent calls: |$calls_today|$VDADuser|$channel_group|"; &agi_output;}
}
@@ -1206,6 +1262,7 @@ if ($agent_search_method =~ /^SO|^LO/)
$stmtA = "UPDATE vicidial_closer_log set queue_seconds='$drop_timer' where lead_id = '$insert_lead_id' and call_date='$SQLdate';";
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='02052'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
if ($AGILOG) {$agi_string = "-- VDCL vcl update: |$affected_rows|$insert_lead_id|$insert_close_id|\n|$stmtA|"; &agi_output;}
print "SET CONTEXT $ext_context\n";
@@ -1238,6 +1295,7 @@ if ($agent_search_method =~ /^SO|^LO/)
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$dbhP=$dbhA; $mysql_count='02053'; $MEL_aff_rows=$sthArows; &mysql_error_logging;
$r=0;
$agi_string="\n";
while ($sthArows > $r)
@@ -1266,6 +1324,7 @@ if ($agent_search_method =~ /^LO|^LB/)
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$dbhP=$dbhA; $mysql_count='02054'; $MEL_aff_rows=$sthArows; &mysql_error_logging;
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
@@ -1283,6 +1342,7 @@ if ($agent_search_method =~ /^LO|^LB/)
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$dbhP=$dbhA; $mysql_count='02055'; $MEL_aff_rows=$sthArows; &mysql_error_logging;
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
@@ -1303,6 +1363,7 @@ if ($agent_search_method =~ /^LO|^LB/)
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$dbhP=$dbhA; $mysql_count='02056'; $MEL_aff_rows=$sthArows; &mysql_error_logging;
$dbc=0;
$qp_groupWAIT='';
while ($sthArows > $dbc)
@@ -1331,6 +1392,7 @@ if ($agent_search_method =~ /^LO|^LB/)
{
$stmtA = "LOCK TABLES vicidial_live_agents WRITE, vicidial_live_inbound_agents WRITE;";
my $LOCKaffected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='02057'; $MEL_aff_rows=$LOCKaffected_rows; &mysql_error_logging;
$stmtA = "SELECT vicidial_live_agents.conf_exten,vicidial_live_agents.user,vicidial_live_agents.extension,vicidial_live_agents.server_ip from vicidial_live_agents JOIN vicidial_live_inbound_agents ON vicidial_live_agents.user=vicidial_live_inbound_agents.user WHERE status IN('CLOSER','READY') and vicidial_live_inbound_agents.group_id='$channel_group' and last_update_time > '$BDtsSQLdate' $qp_groupWAIT_aco_SQL $qp_groupWAIT_camp_SQL $agent_call_order limit 1;";
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
@@ -1338,6 +1400,8 @@ if ($agent_search_method =~ /^LO|^LB/)
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$rec_countCUSTDATA=0;
$dbhP=$dbhA; $mysql_count='02058'; $MEL_aff_rows=$sthArows; &mysql_error_logging;
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
@@ -1353,6 +1417,7 @@ if ($agent_search_method =~ /^LO|^LB/)
{
$stmtA = "UPDATE vicidial_live_agents set status='QUEUE',lead_id='$insert_lead_id',uniqueid='$unique_id', channel='$channel', callerid='$callerid', call_server_ip='$VARserver_ip',comments='INBOUND' where user='$VDADuser';";
my $affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='02059'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
$found_agents=$affected_rows;
}
else
@@ -1362,11 +1427,13 @@ if ($agent_search_method =~ /^LO|^LB/)
$stmtA = "UNLOCK TABLES;";
my $LOCKaffected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='02060'; $MEL_aff_rows=$LOCKaffected_rows; &mysql_error_logging;
}
else
{
$stmtA = "UPDATE vicidial_live_agents set status='QUEUE',lead_id='$insert_lead_id',uniqueid='$unique_id', channel='$channel', callerid='$callerid', call_server_ip='$VARserver_ip',comments='INBOUND' where status IN('CLOSER','READY') and campaign_id IN($INBOUNDcampsSQL) and closer_campaigns LIKE \"% $channel_group %\" and last_update_time > '$BDtsSQLdate' $qp_groupWAIT_SQL $qp_groupWAIT_camp_SQL $agent_call_order limit 1;";
my $affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='02061'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
$found_agents=$affected_rows;
if ($AGILOG) {$agi_string = "$affected_rows|$stmtA|"; &agi_output;}
}
@@ -1381,6 +1448,7 @@ if ($agent_search_method =~ /^LO|^LB/)
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$dbhP=$dbhA; $mysql_count='02062'; $MEL_aff_rows=$sthArows; &mysql_error_logging;
$rec_countCUSTDATA=0;
while ($sthArows > $cbc)
{
@@ -1394,12 +1462,14 @@ if ($agent_search_method =~ /^LO|^LB/)
$sthA->finish();
}
$stmtA = "UPDATE vicidial_auto_calls set status='CLOSER', stage='CLOSER-$drop_timer' where callerid='$callerid';";
my $affected_rows = $dbhA->do($stmtA);
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='02063'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
if ($AGILOG) {$agi_string = "-- VDCL XFER REMOTE: |$affected_rows|update of vac table: $callerid\n|$stmtA|"; &agi_output;}
if ($affected_rows < 1)
{
$stmtA = "INSERT INTO vicidial_auto_calls (server_ip,campaign_id,status,lead_id,uniqueid,callerid,channel,phone_code,phone_number,call_time,call_type,stage,queue_priority) values('$VARserver_ip','$channel_group','CLOSER','$insert_lead_id','$uniqueid','$callerid','$channel','$phone_code','$phone_number','$SQLdate','IN','CLOSER-$drop_timer','$queue_priority')";
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='02064'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
if ($AGILOG) {$agi_string = "$affected_rows|VDAC-reinsert|$stmtA|"; &agi_output;}
}
@@ -1413,16 +1483,19 @@ if ($agent_search_method =~ /^LO|^LB/)
$stmtB = "INSERT INTO queue_log SET partition='P01',time_id='$now_date_epoch',call_id='$YqueryCID',queue='$channel_group',agent='Agent/$VDADuser',verb='CONNECT',data1='$drop_timer',serverid='$queuemetrics_log_id';";
$Baffected_rows = $dbhB->do($stmtB);
$dbhP=$dbhB; $stmtA=$stmtB; $mysql_count='02065'; $MEL_aff_rows=$Baffected_rows; &mysql_error_logging;
$dbhB->disconnect();
}
$stmtA = "UPDATE vicidial_xfer_log set closer='$VDADuser' where lead_id = '$insert_lead_id' order by call_date desc limit 1;";
my $affected_rows = $dbhA->do($stmtA);
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='02066'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
if ($AGILOG) {$agi_string = "-- VDXL vicidial_xfer_log update: |$affected_rows|$insert_lead_id|$VDADuser\n|$stmtA|"; &agi_output;}
$stmtA = "UPDATE vicidial_closer_log set user='$VDADuser' where lead_id='$insert_lead_id' order by call_date desc limit 1;";
my $affected_rows = $dbhA->do($stmtA);
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='02067'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
if ($AGILOG) {$agi_string = "-- closer log : |$affected_rows|update of vcl table: $insert_lead_id\n|$stmtA|"; &agi_output;}
### format the remote server dialstring to get the call to the overflow agent meetme room
@@ -1447,6 +1520,7 @@ if ($agent_search_method =~ /^LO|^LB/)
### insert a NEW record to the vicidial_manager table to play the alert message to the agent
$stmtA = "INSERT INTO vicidial_manager values('','','$SQLdate','NEW','N','$VARserver_ip','','Originate','$VHqueryCID','Exten: $agent_alert_exten','Context: $ext_context','Channel: Local/$alertVDADremDIALstr$at$ext_context','Priority: 1','Callerid: $CIDstring','Timeout: 10','','','','')";
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='02068'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
if ($AGILOG) {$agi_string = "-- VDCL agent alert: |$VHqueryCID|$alertVDADremDIALstr|$channel|insert to vicidial_manager"; &agi_output;}
usleep(1 * $agent_alert_delay * 1000);
@@ -1465,6 +1539,7 @@ if ($agent_search_method =~ /^LO|^LB/)
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$dbhP=$dbhA; $mysql_count='02069'; $MEL_aff_rows=$sthArows; &mysql_error_logging;
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
@@ -1476,9 +1551,11 @@ if ($agent_search_method =~ /^LO|^LB/)
if ($sthArows > 0)
{
$stmtA = "UPDATE vicidial_live_inbound_agents set calls_today='$calls_today' WHERE user='$VDADuser' and group_id='$channel_group';";
my $affected_rows = $dbhA->do($stmtA);
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='02070'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
$stmtA = "UPDATE vicidial_inbound_group_agents set calls_today='$calls_today' WHERE user='$VDADuser' and group_id='$channel_group';";
my $affected_rows = $dbhA->do($stmtA);
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='02071'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
if ($AGILOG) {$agi_string = "-- VDLIA agent calls: |$calls_today|$VDADuser|$channel_group|"; &agi_output;}
}
@@ -1513,6 +1590,7 @@ if ($agent_search_method =~ /^LO|^LB/)
$stmtA = "UPDATE vicidial_closer_log set queue_seconds='$drop_timer' where lead_id = '$insert_lead_id' and call_date='$SQLdate';";
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='02072'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
if ($AGILOG) {$agi_string = "-- VDCL vcl update: |$affected_rows|$insert_lead_id|\n|$stmtA|"; &agi_output;}
print "SET CONTEXT $ext_context\n";
@@ -1544,6 +1622,7 @@ if ($agent_search_method =~ /^LO|^LB/)
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$dbhP=$dbhA; $mysql_count='02073'; $MEL_aff_rows=$sthArows; &mysql_error_logging;
$r=0;
$agi_string="\n";
while ($sthArows > $r)
@@ -1580,6 +1659,7 @@ if ($hold_recall_xfer_group !~ /NONE/)
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$dbhP=$dbhA; $mysql_count='02074'; $MEL_aff_rows=$sthArows; &mysql_error_logging;
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
@@ -1600,16 +1680,19 @@ if ($hold_recall_xfer_group !~ /NONE/)
$stmtA = "DELETE FROM vicidial_auto_calls where callerid='$callerid' and server_ip='$VARserver_ip' order by call_time desc limit 1;";
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='02075'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
if ($AGILOG) {$agi_string = "-- VDCL vac record deleted: |$affected_rows| $VDADcampaign|"; &agi_output;}
if ($drop_seconds < 1) {$drop_seconds = $drop_timer;}
$stmtA = "UPDATE vicidial_closer_log set status='HXFER',end_epoch='$now_date_epoch',length_in_sec='$drop_seconds',queue_seconds='$drop_seconds',term_reason='HOLDRECALLXFER' where lead_id = '$insert_lead_id' order by start_epoch desc limit 1;";
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='02076'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
if ($AGILOG) {$agi_string = "-- VDCL vcl update: |$affected_rows|$insert_lead_id|\n|$stmtA|"; &agi_output;}
$stmtA = "UPDATE vicidial_list set status='HXFER' where lead_id = '$insert_lead_id';";
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='02077'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
if ($AGILOG) {$agi_string = "-- VDCL vl update: |$affected_rows|$insert_lead_id|\n|$stmtA|"; &agi_output;}
if ($enable_queuemetrics_logging > 0)
@@ -1626,9 +1709,11 @@ if ($hold_recall_xfer_group !~ /NONE/)
$stmtB = "INSERT INTO queue_log SET partition='P01',time_id='$now_date_epoch',call_id='$YqueryCID',queue='$channel_group',agent='NONE',verb='EXITWITHKEY',data1='3',data2='$place',serverid='$queuemetrics_log_id';";
$Baffected_rows = $dbhB->do($stmtB);
$dbhP=$dbhB; $stmtA=$stmtB; $mysql_count='02078'; $MEL_aff_rows=$Baffected_rows; &mysql_error_logging;
$stmtB = "INSERT INTO queue_log SET partition='P01',time_id='$now_date_epoch',call_id='$YqueryCID',queue='$channel_group',agent='NONE',verb='CALLSTATUS',data1='HXFER',serverid='$queuemetrics_log_id';";
$Baffected_rows = $dbhB->do($stmtB);
$dbhP=$dbhB; $stmtA=$stmtB; $mysql_count='02079'; $MEL_aff_rows=$Baffected_rows; &mysql_error_logging;
$dbhB->disconnect();
}
@@ -1665,6 +1750,7 @@ if ($if_wait_play_welcome > 0)
$stmtA = "UPDATE vicidial_auto_calls set last_update_time='$FDtsSQLdate' where callerid='$callerid' order by call_time desc limit 1;";
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='02080'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
if ($AGILOG) {$agi_string = "-- VDAC posttime record: |$affected_rows|$FDtsSQLdate|$callerid|"; &agi_output;}
$AGI->stream_file('sip-silence'); # stop music-on-hold process
@@ -1689,6 +1775,7 @@ if ( ($hold_message_counter > $prompt_interval) && ($prompt_interval > 0) )
$stmtA = "UPDATE vicidial_auto_calls set last_update_time='$FDtsSQLdate' where callerid='$callerid' order by call_time desc limit 1;";
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='02081'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
if ($AGILOG) {$agi_string = "-- VDAC posttime record: |$affected_rows|$FDtsSQLdate|$callerid|"; &agi_output;}
$AGI->stream_file('sip-silence'); # stop music-on-hold process
@@ -1726,6 +1813,7 @@ if ( ($start_place_in_line > 0) && ($moh_delay == '1') )
$stmtA = "UPDATE vicidial_auto_calls set last_update_time='$FDtsSQLdate' where callerid='$callerid' order by call_time desc limit 1;";
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='02082'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
if ($AGILOG) {$agi_string = "-- VDAC posttime record: |$affected_rows|$FDtsSQLdate|$callerid|"; &agi_output;}
$place=0;
@@ -1769,6 +1857,7 @@ if ( ($start_hold_estimate > 0) && ($moh_delay == '1') )
$stmtA = "UPDATE vicidial_auto_calls set last_update_time='$FDtsSQLdate' where callerid='$callerid' order by call_time desc limit 1;";
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='02083'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
if ($AGILOG) {$agi_string = "-- VDAC posttime record: |$affected_rows|$FDtsSQLdate|$callerid|"; &agi_output;}
$stmtA = "SELECT queue_seconds FROM vicidial_closer_log where campaign_id = '$channel_group' order by call_date desc limit 5;";
@@ -1776,6 +1865,7 @@ if ( ($start_hold_estimate > 0) && ($moh_delay == '1') )
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$dbhP=$dbhA; $mysql_count='02084'; $MEL_aff_rows=$sthArows; &mysql_error_logging;
$r=0;
$agi_string="\n";
while ($sthArows > $r)
@@ -1792,6 +1882,7 @@ if ( ($start_hold_estimate > 0) && ($moh_delay == '1') )
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$dbhP=$dbhA; $mysql_count='02085'; $MEL_aff_rows=$sthArows; &mysql_error_logging;
$s=0; $t=0;
$agi_string="\n";
while ($sthArows > $s)
@@ -1882,6 +1973,7 @@ if ($hold_time_option =~ /PRESS_VMAIL/)
$stmtA = "UPDATE vicidial_auto_calls set last_update_time='$FDtsSQLdate' where callerid='$callerid' order by call_time desc limit 1;";
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='02086'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
if ($AGILOG) {$agi_string = "-- VDAC posttime record: |$affected_rows|$FDtsSQLdate|$callerid|"; &agi_output;}
if ($drop_timer >= 3) {$drop_timer = ($drop_timer + 8);} # add prompt play time to total queue time
@@ -1910,9 +2002,11 @@ if ($hold_time_option =~ /PRESS_VMAIL/)
$stmtB = "INSERT INTO queue_log SET partition='P01',time_id='$now_date_epoch',call_id='$YqueryCID',queue='$channel_group',agent='NONE',verb='EXITWITHKEY',data1='1',data2='$place',serverid='$queuemetrics_log_id';";
$Baffected_rows = $dbhB->do($stmtB);
$dbhP=$dbhB; $stmtA=$stmtB; $mysql_count='02087'; $MEL_aff_rows=$Baffected_rows; &mysql_error_logging;
$stmtB = "INSERT INTO queue_log SET partition='P01',time_id='$now_date_epoch',call_id='$YqueryCID',queue='$channel_group',agent='NONE',verb='CALLSTATUS',data1='QVMAIL',serverid='$queuemetrics_log_id';";
$Baffected_rows = $dbhB->do($stmtB);
$dbhP=$dbhB; $stmtA=$stmtB; $mysql_count='02088'; $MEL_aff_rows=$Baffected_rows; &mysql_error_logging;
$exitwithkey++;
@@ -1945,11 +2039,13 @@ if ($hold_time_option =~ /CALLERID_CALLBACK/)
### insert a record into the vicidial_list table
$stmtA = "INSERT INTO vicidial_list (entry_date,modify_date,status,user,vendor_lead_code,source_id,list_id,called_since_last_reset,phone_code,phone_number,security_phrase,called_count,gmt_offset_now,comments) values('$SQLdate','$tsSQLdate','INBND','$fronter','$inbound_number','VDCL','$hold_time_option_callback_list_id','N','$phone_code','$phone_number','$channel_group','1','$local_gmt','$VLcomments');";
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='02089'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
$cbc=0;
$stmtB = "select LAST_INSERT_ID() LIMIT 1;";
$sthA = $dbhA->prepare($stmtB) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$dbhP=$dbhA; $stmtA=$stmtB; $mysql_count='02103'; $MEL_aff_rows=$sthArows; &mysql_error_logging;
while ($sthArows > $cbc)
{
@aryA = $sthA->fetchrow_array;
@@ -1991,6 +2087,7 @@ if ($wait_in_queue < 1)
$stmtA = "DELETE FROM vicidial_auto_calls where callerid='$callerid' and server_ip='$VARserver_ip' order by call_time desc limit 1;";
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='02090'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
if ($AGILOG) {$agi_string = "-- VDCL vac record deleted: |$affected_rows| $VDADcampaign|"; &agi_output;}
if ($drop_seconds < 1) {$drop_seconds = $drop_timer;}
@@ -1998,10 +2095,12 @@ if ($wait_in_queue < 1)
if (length($HT_status)<1) {$HT_status='HOLDTO';}
$stmtA = "UPDATE vicidial_closer_log set status='$HT_status',end_epoch='$now_date_epoch',length_in_sec='$drop_seconds',queue_seconds='$drop_seconds',term_reason='HOLDTIME' where lead_id = '$insert_lead_id' order by start_epoch desc limit 1;";
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='02091'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
if ($AGILOG) {$agi_string = "-- VDCL vcl update: |$affected_rows|$insert_lead_id|\n|$stmtA|"; &agi_output;}
$stmtA = "UPDATE vicidial_list set status='HOLDTO' where lead_id = '$insert_lead_id';";
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='02092'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
if ($AGILOG) {$agi_string = "-- VDCL vl update: |$affected_rows|$insert_lead_id|\n|$stmtA|"; &agi_output;}
if ( ($enable_queuemetrics_logging > 0) && ($exitwithkey < 1) )
@@ -2018,10 +2117,11 @@ if ($wait_in_queue < 1)
$stmtB = "INSERT INTO queue_log SET partition='P01',time_id='$now_date_epoch',call_id='$YqueryCID',queue='$channel_group',agent='NONE',verb='EXITWITHKEY',data1='2',data2='$place',serverid='$queuemetrics_log_id';";
$Baffected_rows = $dbhB->do($stmtB);
$dbhP=$dbhB; $stmtA=$stmtB; $mysql_count='02093'; $MEL_aff_rows=$Baffected_rows; &mysql_error_logging;
$stmtB = "INSERT INTO queue_log SET partition='P01',time_id='$now_date_epoch',call_id='$YqueryCID',queue='$channel_group',agent='NONE',verb='CALLSTATUS',data1='HOLDTO',serverid='$queuemetrics_log_id';";
$Baffected_rows = $dbhB->do($stmtB);
$dbhP=$dbhB; $stmtA=$stmtB; $mysql_count='02094'; $MEL_aff_rows=$Baffected_rows; &mysql_error_logging;
$dbhB->disconnect();
}
@@ -2077,10 +2177,12 @@ if ($wait_in_queue > 0)
$stmtA = "UPDATE vicidial_auto_calls set stage='LIVE-$drop_timer' where callerid='$callerid';";
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='02095'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
if ($affected_rows < 1)
{
$stmtA = "INSERT INTO vicidial_auto_calls (server_ip,campaign_id,status,lead_id,uniqueid,callerid,channel,phone_code,phone_number,call_time,call_type,stage,queue_priority) values('$VARserver_ip','$channel_group','LIVE','$insert_lead_id','$uniqueid','$callerid','$channel','$phone_code','$phone_number','$SQLdate','IN','LIVE-$drop_timer','$queue_priority')";
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='02096'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
if ($AGILOG) {$agi_string = "$affected_rows|VDAC-reinsert|$stmtA|"; &agi_output;}
}
else
@@ -2125,9 +2227,11 @@ if ($enable_queuemetrics_logging > 0)
$stmtB = "INSERT INTO queue_log SET partition='P01',time_id='$now_date_epoch',call_id='$YqueryCID',queue='$channel_group',agent='NONE',verb='EXITWITHTIMEOUT',data1='$place',serverid='$queuemetrics_log_id';";
$Baffected_rows = $dbhB->do($stmtB);
$dbhP=$dbhB; $stmtA=$stmtB; $mysql_count='02097'; $MEL_aff_rows=$Baffected_rows; &mysql_error_logging;
$stmtB = "INSERT INTO queue_log SET partition='P01',time_id='$now_date_epoch',call_id='$YqueryCID',queue='$channel_group',agent='NONE',verb='CALLSTATUS',data1='DROP',serverid='$queuemetrics_log_id';";
$Baffected_rows = $dbhB->do($stmtB);
$dbhP=$dbhB; $stmtA=$stmtB; $mysql_count='02098'; $MEL_aff_rows=$Baffected_rows; &mysql_error_logging;
$dbhB->disconnect();
}
@@ -2158,14 +2262,17 @@ if ($AGILOG) {$agi_string = "-- VDCL DROP: |$drop_action|$DROPexten|"; &agi
$stmtA = "DELETE FROM vicidial_auto_calls where callerid='$callerid' and server_ip='$VARserver_ip' order by call_time desc limit 1;";
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='02099'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
if ($AGILOG) {$agi_string = "-- VDCL vac record deleted: |$affected_rows| $VDADcampaign|"; &agi_output;}
$stmtA = "UPDATE vicidial_closer_log set status='DROP',end_epoch='$now_date_epoch',length_in_sec='$drop_seconds',queue_seconds='$drop_seconds',term_reason='QUEUETIMEOUT' where lead_id = '$insert_lead_id' order by start_epoch desc limit 1;";
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='02100'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
if ($AGILOG) {$agi_string = "-- VDCL vcl update: |$affected_rows|$insert_lead_id|\n|$stmtA|"; &agi_output;}
$stmtA = "UPDATE vicidial_list set status='XDROP' where lead_id = '$insert_lead_id';";
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='02101'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
if ($AGILOG) {$agi_string = "-- VDCL vl update: |$affected_rows|$insert_lead_id|\n|$stmtA|"; &agi_output;}
### use STDOUT to send call to proper DROP location
@@ -2193,6 +2300,7 @@ if ($AGILOG) {$agi_string = "-- VDCL DROP: |$drop_action|$DROPexten|"; &agi
### insert a NEW record to the vicidial_manager table to be processed
$stmtA = "INSERT INTO vicidial_manager values('','','$SQLdate','NEW','N','$VARserver_ip','','Hangup','$VHqueryCID','Channel: $channel','','','','','','','','','')";
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='02102'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
if ($AGILOG) {$agi_string = "-- VDCL call_hungup timeout: |$VHqueryCID|$VDADconf_exten|$channel|insert to vicidial_manager"; &agi_output;}
}
}
@@ -2383,6 +2491,27 @@ $agi_string='';
}
sub mysql_error_logging
{
$errno='';
$error='';
if ( ($mel > 0) || ($one_mysql_log > 0) )
{
$errno = $dbhP->err();
if ( ($errno > 0) || ($mel > 1) || ($one_mysql_log > 0) )
{
$error = $dbhP->errstr();
### open the log file for writing ###
open(Eout, ">>$ERRLOGfile")
|| die "Can't open $ERRLOGfile: $!\n";
print Eout "$now_date|$script|$mysql_count|$MEL_aff_rows|$errno|$error|$stmtA|$callerid|$insert_lead_id|\n";
close(Eout);
}
}
$one_mysql_log=0;
}
sub trigger_transfer_process
{
# $DS='--';
+82 -1
View File
@@ -57,10 +57,15 @@
# 80909-0603 - Added campaign-specific dnc option for outbound survey
# 81020-0235 - Fixed Drop hangup bug and other small bugs
# 81104-0255 - Changed code to alter callerIDnumber for remote agents to the number of the caller
# 81105-0424 - Added MySQL error logging
#
$script = 'agi-VDAD_ALL_outbound.agi';
$AGILOG = '0';
$mel=1; # Mysql Error Log enabled = 1
$mysql_log_count=53;
$one_mysql_log=0;
$DROP_TIME = 9; ### default number of seconds to wait until you drop a waiting call
$at='@';
@@ -153,6 +158,7 @@ if (!$VARDB_port) {$VARDB_port='3306';}
if (!$AGILOGfile) {$AGILOGfile = "$PATHlogs/agiout.$year-$mon-$mday";}
if (!$PRSLOGfile) {$PRSLOGfile = "$PATHlogs/prsout.$year-$mon-$mday";}
if (!$PRSTESTfile) {$PRSTESTfile = "$PATHlogs/prstest.$year-$mon-$mday";}
if (!$ERRLOGfile) {$ERRLOGfile = "$PATHlogs/MySQLerror.$year-$mon-$mday";}
use DBI;
use Time::HiRes ('gettimeofday','usleep','sleep'); # necessary to have perl sleep command of less than one second
@@ -167,6 +173,7 @@ $stmtA = "SELECT voicemail_dump_exten,ext_context,answer_transfer_agent,local_gm
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$dbhP=$dbhA; $mysql_count='01001'; $MEL_aff_rows=$sthArows; &mysql_error_logging;
$rec_count=0;
while ($sthArows > $rec_count)
{
@@ -297,6 +304,7 @@ $stmtA = "SELECT count(*) FROM vicidial_live_agents where callerid='$callerid';"
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$dbhP=$dbhA; $mysql_count='01002'; $MEL_aff_rows=$sthArows; &mysql_error_logging;
$rec_count=0;
while ($sthArows > $rec_count)
{
@@ -317,6 +325,7 @@ $stmtA = "SELECT count(*) FROM vicidial_auto_calls where callerid='$callerid' an
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$dbhP=$dbhA; $mysql_count='01003'; $MEL_aff_rows=$sthArows; &mysql_error_logging;
$rec_count=0;
while ($sthArows > $rec_count)
{
@@ -337,6 +346,7 @@ exit;
### Grab call parameters from vicidial_auto_calls table
$stmtA = "UPDATE vicidial_auto_calls set uniqueid='$unique_id', channel='$channel',status='LIVE',stage='LIVE-0' where callerid='$callerid' order by call_time desc limit 1;";
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='01004'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
if ($AGILOG) {$agi_string = "-- VDAD : |$affected_rows|update of vac table: $callerid\n|$stmtA|"; &agi_output;}
if ($affected_rows > 0)
{
@@ -344,12 +354,14 @@ if ($affected_rows > 0)
$stmtA = "UPDATE vicidial_list set status='PU' where lead_id='$CIDlead_id' and status NOT IN('CALLBK');";
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='01005'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
if ($AGILOG) {$agi_string = "-- VDAD vicidial_list PU update: |$affected_rows|$uniqueid|"; &agi_output;}
$stmtA = "SELECT campaign_id,phone_number,phone_code,lead_id,call_time,alt_dial FROM vicidial_auto_calls where callerid='$callerid' order by call_time desc limit 1;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$dbhP=$dbhA; $mysql_count='01006'; $MEL_aff_rows=$sthArows; &mysql_error_logging;
$rec_count=0;
while ($sthArows > $rec_count)
{
@@ -369,6 +381,7 @@ if ($affected_rows > 0)
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$dbhP=$dbhA; $mysql_count='01007'; $MEL_aff_rows=$sthArows; &mysql_error_logging;
$rec_count=0;
while ($sthArows > $rec_count)
{
@@ -392,6 +405,7 @@ if ($affected_rows > 0)
$stmtA = "INSERT INTO vicidial_log (uniqueid,lead_id,campaign_id,call_date,start_epoch,status,phone_code,phone_number,user,processed,alt_dial) values('$uniqueid','$CIDlead_id','$VDADcampaign','$SQLdate','$now_date_epoch','$vdlog_status','$VDADphone_code','$VDADphone','VDAD','N','$VDADalt_dial')";
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='01008'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
if ($AGILOG) {$agi_string = "-- VDAD : |$VDADlead_id|$CIDlead_id|insert to vicidial_log: $uniqueid"; &agi_output;}
@@ -401,6 +415,7 @@ if ($affected_rows > 0)
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$dbhP=$dbhA; $mysql_count='01009'; $MEL_aff_rows=$sthArows; &mysql_error_logging;
$rec_count=0;
while ($sthArows > $rec_count)
{
@@ -423,6 +438,7 @@ if ($affected_rows > 0)
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$dbhP=$dbhA; $mysql_count='01010'; $MEL_aff_rows=$sthArows; &mysql_error_logging;
$rec_count=0;
while ($sthArows > $rec_count)
{
@@ -439,6 +455,7 @@ if ($affected_rows > 0)
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$dbhP=$dbhA; $mysql_count='01011'; $MEL_aff_rows=$sthArows; &mysql_error_logging;
$rec_count=0;
while ($sthArows > $rec_count)
{
@@ -458,7 +475,7 @@ if ($affected_rows > 0)
$stmtB = "INSERT INTO queue_log SET partition='P01',time_id='$now_date_epoch',call_id='$callerid',queue='$VDADcampaign',agent='NONE',verb='ENTERQUEUE',data2='$data2',serverid='$queuemetrics_log_id';";
$Baffected_rows = $dbhB->do($stmtB);
$dbhP=$dbhB; $stmtA=$stmtB; $mysql_count='01012'; $MEL_aff_rows=$Baffected_rows; &mysql_error_logging;
$dbhB->disconnect();
}
}
@@ -470,6 +487,7 @@ if ($call_handle_method =~ /REMIND/)
{
$stmtA = "UPDATE vicidial_auto_calls set last_update_time='$FDtsSQLdate',stage='REMIND-0' where callerid='$callerid' order by call_time desc limit 1;";
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='01013'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
if ($AGILOG) {$agi_string = "-- VDAC posttime record: |$affected_rows|$FDtsSQLdate|$callerid|REMIND|"; &agi_output;}
$AGI->stream_file("$survey_first_audio_file");
@@ -487,6 +505,7 @@ if ($call_handle_method =~ /SURVEY/)
$stmtA = "UPDATE vicidial_auto_calls set last_update_time='$FDtsSQLdate',stage='SURVEY-0' where callerid='$callerid' order by call_time desc limit 1;";
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='01014'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
if ($AGILOG) {$agi_string = "-- VDAC posttime record: |$affected_rows|$FDtsSQLdate|$callerid|SURVEY|"; &agi_output;}
### check to see if the SURVEY settings should be pulled from the campaign settings in the database
@@ -496,6 +515,7 @@ if ($call_handle_method =~ /SURVEY/)
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$dbhP=$dbhA; $mysql_count='01015'; $MEL_aff_rows=$sthArows; &mysql_error_logging;
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
@@ -536,6 +556,7 @@ if ($call_handle_method =~ /SURVEY/)
$stmtA = "UPDATE vicidial_list set security_phrase='$opt_description',status='PM' where lead_id = '$CIDlead_id';";
if ($AGILOG) { $agi_string = "|$stmtA|"; &agi_output; }
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='01016'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
if ($AGILOG)
{
$agi_string = "-- VDAD vicidial_list OPT_CODE update: |$affected_rows|$CIDlead_id|$opt_code|";
@@ -552,6 +573,7 @@ if ($call_handle_method =~ /SURVEY/)
$stmtA = "DELETE FROM vicidial_auto_calls where callerid='$callerid' order by call_time desc limit 1;";
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='01017'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
if ($AGILOG)
{
$agi_string = "-- VDAD vac record deleted: |$affected_rows|$VDADcampaign|";
@@ -565,6 +587,7 @@ if ($call_handle_method =~ /SURVEY/)
$stmtA = "UPDATE vicidial_log FORCE INDEX(lead_id) set status='$survey_ni_status', end_epoch='$now_date_epoch', length_in_sec='$drop_seconds', term_reason='CALLER' where lead_id = '$CIDlead_id' and uniqueid LIKE \"$Euniqueid%\";";
if ($AGILOG) { $agi_string = "|$stmtA|"; &agi_output; }
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='01018'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
if ($AGILOG)
{
$agi_string = "-- VDAD vicidial_log update: $survey_ni_status|$affected_rows|$uniqueid|$drop_seconds|";
@@ -574,6 +597,7 @@ if ($call_handle_method =~ /SURVEY/)
$stmtA = "UPDATE vicidial_list set status='$survey_ni_status' where lead_id = '$CIDlead_id';";
if ($AGILOG) { $agi_string = "|$stmtA|"; &agi_output; }
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='01019'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
if ($AGILOG)
{
$agi_string = "-- VDAD vicidial_list update: $survey_ni_status|$affected_rows|$CIDlead_id";
@@ -585,6 +609,7 @@ if ($call_handle_method =~ /SURVEY/)
$stmtA = "INSERT INTO vicidial_dnc set phone_number='$VDADphone';";
if ($AGILOG) { $agi_string = "|$stmtA|"; &agi_output; }
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='01020'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
if ($AGILOG)
{
$agi_string = "-- VDAD vicidial_dnc insert: $affected_rows|$VDADphone";
@@ -596,6 +621,7 @@ if ($call_handle_method =~ /SURVEY/)
$stmtA = "INSERT INTO vicidial_campaign_dnc set phone_number='$VDADphone', campaign_id='$VDADcampaign';";
if ($AGILOG) { $agi_string = "|$stmtA|"; &agi_output; }
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='01021'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
if ($AGILOG)
{
$agi_string = "-- VDAD vicidial_campaign_dnc insert: $affected_rows|$VDADphone|$VDADcampaign";
@@ -626,6 +652,7 @@ if ($call_handle_method =~ /SURVEY/)
$stmtA = "UPDATE vicidial_auto_calls set last_update_time='$FDtsSQLdate' where callerid='$callerid' order by call_time desc limit 1;";
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='01022'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
if ($AGILOG) {$agi_string = "-- VDAC posttime record: |$affected_rows|$FDtsSQLdate|$callerid|"; &agi_output;}
if ( $survey_opt_in_audio_file ne "")
@@ -660,6 +687,7 @@ if ($call_handle_method =~ /SURVEY/)
$stmtA = "UPDATE vicidial_log FORCE INDEX(lead_id) set status='$survey_status', end_epoch='$now_date_epoch', length_in_sec='$drop_seconds', term_reason='CALLER' where lead_id = '$CIDlead_id' and uniqueid LIKE \"$Euniqueid%\";";
if ($AGILOG) { $agi_string = "|$stmtA|"; &agi_output; }
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='01023'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
if ($AGILOG)
{
$agi_string = "-- VDAD vicidial_log update: $survey_status|$affected_rows|$uniqueid|$drop_seconds|";
@@ -669,6 +697,7 @@ if ($call_handle_method =~ /SURVEY/)
$stmtA = "UPDATE vicidial_list set status='$survey_status' where lead_id = '$CIDlead_id';";
if ($AGILOG) { $agi_string = "|$stmtA|"; &agi_output; }
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='01024'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
if ($AGILOG)
{
$agi_string = "-- VDAD vicidial_list update: $survey_status|$affected_rows|$CIDlead_id";
@@ -679,6 +708,7 @@ if ($call_handle_method =~ /SURVEY/)
{
$stmtA = "UPDATE vicidial_auto_calls set status='XFER',stage='XFER-0' where callerid='$callerid' order by call_time desc limit 1;";
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='01025'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
if ($AGILOG) {$agi_string = "-- VDAC XFER status: |$affected_rows|$FDtsSQLdate|$callerid|"; &agi_output;}
if ($AGILOG) {$agi_string = "exiting the VDAD SURVEY app, transferring call to $DROPexten"; &agi_output;}
@@ -694,6 +724,7 @@ if ($call_handle_method =~ /SURVEY/)
{
$stmtA = "DELETE FROM vicidial_auto_calls where callerid='$callerid' order by call_time desc limit 1;";
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='01026'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
if ($AGILOG)
{
$agi_string = "-- VDAD vac record deleted: |$affected_rows|$VDADcampaign|";
@@ -722,6 +753,7 @@ if ($call_handle_method =~ /SURVEY/)
$stmtA = "UPDATE vicidial_log FORCE INDEX(lead_id) set status='$survey_status', end_epoch='$now_date_epoch', length_in_sec='$drop_seconds', term_reason='CALLER' where lead_id = '$CIDlead_id' and uniqueid LIKE \"$Euniqueid%\";";
if ($AGILOG) { $agi_string = "|$stmtA|"; &agi_output; }
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='01027'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
if ($AGILOG)
{
$agi_string = "-- VDAD vicidial_log update: $survey_status|$affected_rows|$uniqueid|$drop_seconds|";
@@ -731,6 +763,7 @@ if ($call_handle_method =~ /SURVEY/)
$stmtA = "UPDATE vicidial_list set status='$survey_status' where lead_id = '$CIDlead_id';";
if ($AGILOG) { $agi_string = "|$stmtA|"; &agi_output; }
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='01028'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
if ($AGILOG)
{
$agi_string = "-- VDAD vicidial_list update: $survey_status|$affected_rows|$CIDlead_id";
@@ -756,6 +789,7 @@ if ($call_handle_method =~ /SURVEY/)
$stmtA = "UPDATE vicidial_log FORCE INDEX(lead_id) set status='$survey_status', end_epoch='$now_date_epoch', length_in_sec='$drop_seconds', term_reason='CALLER' where lead_id = '$CIDlead_id' and uniqueid LIKE \"$Euniqueid%\";";
if ($AGILOG) { $agi_string = "|$stmtA|"; &agi_output; }
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='01029'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
if ($AGILOG)
{
$agi_string = "-- VDAD vicidial_log update: $survey_status|$affected_rows|$uniqueid|$drop_seconds|";
@@ -764,6 +798,7 @@ if ($call_handle_method =~ /SURVEY/)
$stmtA = "DELETE FROM vicidial_auto_calls where callerid='$callerid' order by call_time desc limit 1;";
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='01030'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
if ($AGILOG)
{
$agi_string = "-- VDAD vac record deleted: |$affected_rows|$VDADcampaign|";
@@ -784,6 +819,7 @@ if ($call_handle_method =~ /SURVEY/)
$stmtA = "UPDATE vicidial_log FORCE INDEX(lead_id) set status='PM', end_epoch='$now_date_epoch', length_in_sec='$drop_seconds', term_reason='CALLER' where lead_id = '$CIDlead_id' and uniqueid LIKE \"$Euniqueid%\";";
if ($AGILOG) { $agi_string = "|$stmtA|"; &agi_output; }
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='01031'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
if ($AGILOG)
{
$agi_string = "-- VDAD vicidial_log update: PM|$affected_rows|$uniqueid|$drop_seconds|";
@@ -792,6 +828,7 @@ if ($call_handle_method =~ /SURVEY/)
$stmtA = "DELETE FROM vicidial_auto_calls where callerid='$callerid' order by call_time desc limit 1;";
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='01032'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
if ($AGILOG)
{
$agi_string = "-- VDAD vac record deleted: |$affected_rows|$VDADcampaign|";
@@ -857,6 +894,7 @@ if ($agent_search_method =~ /^SO|^LO/)
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$dbhP=$dbhA; $mysql_count='01033'; $MEL_aff_rows=$sthArows; &mysql_error_logging;
$rec_count=0;
while ($sthArows > $rec_count)
{
@@ -873,6 +911,7 @@ if ($agent_search_method =~ /^SO|^LO/)
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$dbhP=$dbhA; $mysql_count='01034'; $MEL_aff_rows=$sthArows; &mysql_error_logging;
$rec_count=0;
while ($sthArows > $rec_count)
{
@@ -892,6 +931,8 @@ if ($agent_search_method =~ /^SO|^LO/)
{
$stmtA = "UPDATE vicidial_live_agents set status='QUEUE',lead_id='$CIDlead_id',uniqueid='$unique_id', channel='$channel', call_server_ip='$VARserver_ip', callerid='$callerid',comments='AUTO' where status = 'READY' and server_ip='$VARserver_ip' and campaign_id='$VDADcampaign' and last_update_time > '$BDtsSQLdate' $agent_call_order limit 1;";
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='01035'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
if ($AGILOG) {$agi_string = "-- VDAD get agent: |$affected_rows|update of vla table: $VDADcampaign|$VARserver_ip\n|$stmtA|"; &agi_output;}
if ($affected_rows > 0)
{
@@ -904,6 +945,7 @@ if ($agent_search_method =~ /^SO|^LO/)
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$dbhP=$dbhA; $mysql_count='01036'; $MEL_aff_rows=$sthArows; &mysql_error_logging;
$rec_count=0;
while ($sthArows > $rec_count)
{
@@ -930,6 +972,7 @@ if ($agent_search_method =~ /^SO|^LO/)
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$dbhP=$dbhA; $mysql_count='01037'; $MEL_aff_rows=$sthArows; &mysql_error_logging;
$rec_count=0;
while ($sthArows > $rec_count)
{
@@ -962,6 +1005,7 @@ if ($agent_search_method =~ /^SO|^LO/)
$stmtA = "UPDATE vicidial_auto_calls set status='XFER', stage='XFER-$drop_timer' where callerid='$callerid';";
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='01038'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
if ($AGILOG) {$agi_string = "-- VDAD XFER : |$affected_rows|update of vac table: $callerid\n|$stmtA|"; &agi_output;}
$dbhA->disconnect();
@@ -975,6 +1019,7 @@ if ($agent_search_method =~ /^SO|^LO/)
$stmtB = "INSERT INTO queue_log SET partition='P01',time_id='$now_date_epoch',call_id='$callerid',queue='$VDADcampaign',agent='Agent/$VDADuser',verb='CONNECT',data1='$drop_timer',serverid='$queuemetrics_log_id';";
$Baffected_rows = $dbhB->do($stmtB);
$dbhP=$dbhB; $stmtA=$stmtB; $mysql_count='01039'; $MEL_aff_rows=$Baffected_rows; &mysql_error_logging;
$dbhB->disconnect();
}
@@ -1024,6 +1069,7 @@ $stmtA = "SELECT count(*) FROM vicidial_auto_calls where status = 'LIVE' and cam
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$dbhP=$dbhA; $mysql_count='01040'; $MEL_aff_rows=$sthArows; &mysql_error_logging;
$rec_count=0;
while ($sthArows > $rec_count)
{
@@ -1040,6 +1086,7 @@ if ($DBconcurrent_transfers =~ /AUTO/)
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$dbhP=$dbhA; $mysql_count='01041'; $MEL_aff_rows=$sthArows; &mysql_error_logging;
$rec_count=0;
while ($sthArows > $rec_count)
{
@@ -1059,6 +1106,8 @@ if ($rec_countWAITrem < $concurrent_transfers)
{
$stmtA = "UPDATE vicidial_live_agents set status='QUEUE',lead_id='$CIDlead_id',uniqueid='$unique_id', channel='$channel', call_server_ip='$VARserver_ip', callerid='$callerid',comments='AUTO' where status = 'READY' and campaign_id='$VDADcampaign' and last_update_time > '$BDtsSQLdate' $agent_call_order limit 1;";
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='01042'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
if ($AGILOG) {$agi_string = "-- VDAD get agent: |$affected_rows|update of vla table: $VDADcampaign|$VARserver_ip\n|$stmtA|"; &agi_output;}
if ($affected_rows > 0)
{
@@ -1071,6 +1120,7 @@ if ($rec_countWAITrem < $concurrent_transfers)
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$dbhP=$dbhA; $mysql_count='01043'; $MEL_aff_rows=$sthArows; &mysql_error_logging;
$rec_count=0;
while ($sthArows > $rec_count)
{
@@ -1098,6 +1148,7 @@ if ($rec_countWAITrem < $concurrent_transfers)
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$dbhP=$dbhA; $mysql_count='01044'; $MEL_aff_rows=$sthArows; &mysql_error_logging;
$rec_count=0;
while ($sthArows > $rec_count)
{
@@ -1116,6 +1167,7 @@ if ($rec_countWAITrem < $concurrent_transfers)
$stmtA = "UPDATE vicidial_auto_calls set status='XFER', stage='XFER-$drop_timer' where callerid='$callerid';";
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='01045'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
if ($AGILOG) {$agi_string = "-- VDAD XFER REMOTE: |$affected_rows|update of vac table: $callerid\n|$stmtA|"; &agi_output;}
if ($VDADextension =~ /^R\//)
@@ -1144,6 +1196,7 @@ if ($rec_countWAITrem < $concurrent_transfers)
$stmtB = "INSERT INTO queue_log SET partition='P01',time_id='$now_date_epoch',call_id='$callerid',queue='$VDADcampaign',agent='Agent/$VDADuser',verb='CONNECT',data1='$drop_timer',serverid='$queuemetrics_log_id';";
$Baffected_rows = $dbhB->do($stmtB);
$dbhP=$dbhB; $stmtA=$stmtB; $mysql_count='01046'; $MEL_aff_rows=$Baffected_rows; &mysql_error_logging;
$dbhB->disconnect();
}
@@ -1215,6 +1268,7 @@ if ($affected_rows < 1)
{
$stmtA = "INSERT INTO vicidial_auto_calls (server_ip,campaign_id,status,lead_id,uniqueid,callerid,channel,phone_code,phone_number,call_time,call_type,stage) values('$VARserver_ip','$channel_group','CLOSER','$CIDlead_id','$uniqueid','$callerid','$channel','$phone_code','$phone_number','$SQLdate','IN','CLOSER-$drop_timer')";
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='01047'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
if ($AGILOG) {$agi_string = "$affected_rows|VDAC-reinsert|$stmtA|"; &agi_output;}
}
#if ($AGILOG) {$agi_string = "-- VDAD : |$affected_rows|update of vac table: $callerid\n|$stmtA|"; &agi_output;}
@@ -1259,9 +1313,11 @@ if ($enable_queuemetrics_logging > 0)
$stmtB = "INSERT INTO queue_log SET partition='P01',time_id='$now_date_epoch',call_id='$callerid',queue='$VDADcampaign',agent='NONE',verb='EXITWITHTIMEOUT',data1='1',serverid='$queuemetrics_log_id';";
$Baffected_rows = $dbhB->do($stmtB);
$dbhP=$dbhB; $stmtA=$stmtB; $mysql_count='01048'; $MEL_aff_rows=$Baffected_rows; &mysql_error_logging;
$stmtB = "INSERT INTO queue_log SET partition='P01',time_id='$now_date_epoch',call_id='$callerid',queue='$VDADcampaign',agent='NONE',verb='CALLSTATUS',data1='DROP',serverid='$queuemetrics_log_id';";
$Baffected_rows = $dbhB->do($stmtB);
$dbhP=$dbhB; $stmtA=$stmtB; $mysql_count='01049'; $MEL_aff_rows=$Baffected_rows; &mysql_error_logging;
$dbhB->disconnect();
}
@@ -1293,15 +1349,18 @@ if ($drop_action =~ /IN_GROUP/)
$stmtA = "UPDATE vicidial_log FORCE INDEX(lead_id) set status='DROP',end_epoch='$now_date_epoch',length_in_sec='$drop_seconds',term_reason='QUEUETIMEOUT' where lead_id = '$CIDlead_id' and uniqueid LIKE \"$Euniqueid%\";";
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='01050'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
if ($AGILOG) {$agi_string = "-- VDAD vicidial_log update: |$affected_rows|$uniqueid"; &agi_output;}
$stmtA = "UPDATE vicidial_list set status='DROP' where lead_id = '$CIDlead_id';";
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='01051'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
if ($AGILOG) {$agi_string = "-- VDAD vicidial_list update: |$affected_rows|$CIDlead_id"; &agi_output;}
$stmtA = "DELETE FROM vicidial_auto_calls where callerid='$callerid' order by call_time desc limit 1;";
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='01052'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
if ($AGILOG) {$agi_string = "-- VDAD vac record deleted: |$affected_rows|$VDADcampaign|"; &agi_output;}
@@ -1328,6 +1387,7 @@ if ($drop_action =~ /IN_GROUP/)
### insert a NEW record to the vicidial_manager table to be processed
$stmtA = "INSERT INTO vicidial_manager values('','','$SQLdate','NEW','N','$VARserver_ip','','Hangup','$VHqueryCID','Channel: $channel','','','','','','','','','')";
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='01053'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
if ($AGILOG) {$agi_string = "-- VDCL call_hungup timout: |$CIDlead_id|$VHqueryCID|$VDADconf_exten|$channel|insert to vicidial_manager"; &agi_output;}
$AGI->hangup();
@@ -1452,6 +1512,27 @@ $agi_string='';
}
sub mysql_error_logging
{
$errno='';
$error='';
if ( ($mel > 0) || ($one_mysql_log > 0) )
{
$errno = $dbhP->err();
if ( ($errno > 0) || ($mel > 1) || ($one_mysql_log > 0) )
{
$error = $dbhP->errstr();
### open the log file for writing ###
open(Eout, ">>$ERRLOGfile")
|| die "Can't open $ERRLOGfile: $!\n";
print Eout "$now_date|$script|$mysql_count|$MEL_aff_rows|$errno|$error|$stmtA|$callerid|$CIDlead_id|\n";
close(Eout);
}
}
$one_mysql_log=0;
}
sub trigger_transfer_process
{
# $DS='--';
+1 -1
View File
@@ -135,7 +135,7 @@ them:
- If you have chosen a Sangoma T1/E1 or analog card, you will need to
follow their instructions for installation of their driver software
LATEST Sangoma Wanpipe drivers:
ftp://ftp.sangoma.com/linux/current_wanpipe/wanpipe-2.3.4-13.tgz
ftp://ftp.sangoma.com/linux/current_wanpipe/wanpipe-3.2.7.1.tgz
- now your asterisk installation is built and loaded and it's time to
configure it.
+4 -4
View File
@@ -192,13 +192,13 @@ make install
cd /usr/local
wget http://mirror.candidhosting.com/pub/apache/httpd/httpd-2.2.9.tar.gz
gunzip httpd-2.2.9.tar.gz
tar xvf httpd-2.2.9.tar
wget http://mirror.candidhosting.com/pub/apache/httpd/httpd-2.2.10.tar.gz
gunzip httpd-2.2.10.tar.gz
tar xvf httpd-2.2.10.tar
wget http://us2.php.net/distributions/php-5.2.6.tar.gz
gunzip php-5.2.6.tar.gz
tar xvf php-5.2.6.tar
cd httpd-2.2.9
cd httpd-2.2.10
make clean
./configure --prefix=/usr/local/apache2 --enable-ssl --enable-setenvif --enable-so --with-apxs2 --enable-dav --enable-maintainer-mode
make
@@ -6,7 +6,7 @@
[channels]
group=1
language=en
signalling=pri_net
signalling=pri_cpe
usecallerid=yes
callerid=asreceived
callprogress=no
+44 -23
View File
@@ -39,12 +39,14 @@
# 80519-1425 - Added calls-in-queue tally
# 80703-1106 - Added API functionality for Hangup and Dispo
# 81104-0229 - Added mysql error logging capability
# 81104-1409 - Added multi-retry for some vicidial_live_agents table MySQL queries
#
$version = '2.0.4-14';
$build = '81104-0229';
$mysql_error_logging=1;
$mysql_log_count=13;
$version = '2.0.4-15';
$build = '81104-1409';
$mel=1; # Mysql Error Log enabled = 1
$mysql_log_count=14;
$one_mysql_log=0;
require("dbconnect.php");
@@ -81,7 +83,7 @@ header ("Pragma: no-cache"); // HTTP/1.0
##### START SYSTEM_SETTINGS LOOKUP #####
$stmt = "SELECT use_non_latin FROM system_settings;";
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'03001',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03001',$user,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";}
$qm_conf_ct = mysql_num_rows($rslt);
$i=0;
@@ -121,7 +123,7 @@ $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' a
if ($DB) {echo "|$stmt|\n";}
if ($non_latin > 0) {$rslt=mysql_query("SET NAMES 'UTF8'");}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'03002',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03002',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysql_fetch_row($rslt);
$auth=$row[0];
@@ -143,7 +145,7 @@ $auth=$row[0];
$stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'03002',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03002',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysql_fetch_row($rslt);
$SNauth=$row[0];
if($SNauth==0)
@@ -192,7 +194,7 @@ echo "<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>
$stmt="SELECT count(*) from vicidial_live_agents where user='$user' and server_ip='$server_ip';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'03003',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03003',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysql_fetch_row($rslt);
$Acount=$row[0];
@@ -201,7 +203,7 @@ echo "<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>
$stmt="SELECT status from vicidial_live_agents where user='$user' and server_ip='$server_ip';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'03004',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03004',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysql_fetch_row($rslt);
$Astatus=$row[0];
}
@@ -218,7 +220,16 @@ echo "<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>
$stmt="UPDATE vicidial_live_agents set random_id='$random' where user='$user' and server_ip='$server_ip';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'03005',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {$errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03005',$user,$server_ip,$session_name,$one_mysql_log);}
$retry_count=0;
while ( ($errno > 0) and ($retry_count < 5) )
{
$rslt=mysql_query($stmt, $link);
$one_mysql_log=1;
$errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,"9305$retry_count",$user,$server_ip,$session_name,$one_mysql_log);
$one_mysql_log=0;
$retry_count++;
}
if ($campagentstdisp == 'YES')
{
@@ -226,7 +237,7 @@ echo "<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>
$stmt="SELECT status,campaign_id,closer_campaigns from vicidial_live_agents where user='$user' and server_ip='$server_ip';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'03006',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03006',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysql_fetch_row($rslt);
$Alogin=$row[0];
$Acampaign=$row[1];
@@ -238,7 +249,7 @@ echo "<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>
$stmt="SELECT count(*) from vicidial_auto_calls where status IN('LIVE') and ( (campaign_id='$Acampaign') or (campaign_id IN('$AccampSQL')) );";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'03007',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03007',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysql_fetch_row($rslt);
$RingCalls=$row[0];
if ($RingCalls > 0) {$RingCalls = "<font class=\"queue_text_red\">Calls in Queue: $RingCalls</font>";}
@@ -248,7 +259,7 @@ echo "<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>
$stmt="SELECT count(*) from vicidial_auto_calls where status NOT IN('XFER') and ( (campaign_id='$Acampaign') or (campaign_id IN('$AccampSQL')) );";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'03008',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03008',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysql_fetch_row($rslt);
$DiaLCalls=$row[0];
@@ -270,15 +281,23 @@ echo "<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>
$stmt="UPDATE vicidial_live_agents set random_id='$random' where user='$user' and server_ip='$server_ip';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'03009',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {$errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03009',$user,$server_ip,$session_name,$one_mysql_log);}
$retry_count=0;
while ( ($errno > 0) and ($retry_count < 5) )
{
$rslt=mysql_query($stmt, $link);
$one_mysql_log=1;
$errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,"9309$retry_count",$user,$server_ip,$session_name,$one_mysql_log);
$one_mysql_log=0;
$retry_count++;
}
}
### grab the API hangup and API dispo fields in vicidial_live_agents
$stmt="SELECT external_hangup,external_status from vicidial_live_agents where user='$user' and server_ip='$server_ip';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'03010',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03010',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysql_fetch_row($rslt);
$external_hangup = $row[0];
$external_status = $row[1];
@@ -294,7 +313,7 @@ echo "<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>
$stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and extension = '$conf_exten';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'03011',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03011',$user,$server_ip,$session_name,$one_mysql_log);}
if ($rslt) {$sip_list = mysql_num_rows($rslt);}
# echo "$sip_list|";
$loop_count=0;
@@ -308,7 +327,7 @@ echo "<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>
$stmt="SELECT channel FROM live_channels where server_ip = '$server_ip' and extension = '$conf_exten';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'03012',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03012',$user,$server_ip,$session_name,$one_mysql_log);}
if ($rslt) {$channels_list = mysql_num_rows($rslt);}
# echo "$channels_list|";
$loop_count=0;
@@ -351,7 +370,7 @@ echo "<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>
$stmt="UPDATE conferences set extension='$exten' where server_ip = '$server_ip' and conf_exten = '$conf_exten';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'03013',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03013',$user,$server_ip,$session_name,$one_mysql_log);}
}
echo "Conference $conf_exten has been registered to $exten\n";
}
@@ -370,15 +389,15 @@ exit;
##### MySQL Error Logging #####
function mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,$query_id,$user,$server_ip,$session_name)
function mysql_error_logging($NOW_TIME,$link,$mel,$stmt,$query_id,$user,$server_ip,$session_name,$one_mysql_log)
{
$NOW_TIME = date("Y-m-d H:i:s");
# mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'00001',$user,$server_ip,$session_name);
# mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00001',$user,$server_ip,$session_name,$one_mysql_log);
$errno=''; $error='';
if ($mysql_error_logging > 0)
if ( ($mel > 0) or ($one_mysql_log > 0) )
{
$errno = mysql_errno($link);
if ( ($errno > 0) or ($mysql_error_logging > 1) )
if ( ($errno > 0) or ($mel > 1) or ($one_mysql_log > 0) )
{
$error = mysql_error($link);
$efp = fopen ("./vicidial_mysql_errors.txt", "a");
@@ -386,6 +405,8 @@ if ($mysql_error_logging > 0)
fclose($efp);
}
}
$one_mysql_log=0;
return $errno;
}
?>
+91 -87
View File
@@ -82,8 +82,9 @@
$version = '2.0.5-35';
$build = '81104-0203';
$mysql_error_logging=1;
$mel=1; # Mysql Error Log enabled = 1
$mysql_log_count=82;
$one_mysql_log=0;
require("dbconnect.php");
@@ -167,7 +168,7 @@ header ("Pragma: no-cache"); // HTTP/1.0
##### START SYSTEM_SETTINGS LOOKUP #####
$stmt = "SELECT use_non_latin FROM system_settings;";
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'02001',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02001',$user,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";}
$qm_conf_ct = mysql_num_rows($rslt);
$i=0;
@@ -202,7 +203,7 @@ $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' a
if ($DB) {echo "|$stmt|\n";}
if ($non_latin > 0) {$rslt=mysql_query("SET NAMES 'UTF8'");}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'02002',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02002',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysql_fetch_row($rslt);
$auth=$row[0];
@@ -224,7 +225,7 @@ $auth=$row[0];
$stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'02003',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02003',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysql_fetch_row($rslt);
$SNauth=$row[0];
if($SNauth==0)
@@ -274,7 +275,7 @@ if ($ACTION=="SysCIDOriginate")
$stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$queryCID','Channel: $channel','Context: $ext_context','Exten: $exten','Priority: $ext_priority','Callerid: $queryCID','','','','','');";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'02004',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02004',$user,$server_ip,$session_name,$one_mysql_log);}
echo "Originate command sent for Exten $exten Channel $channel on $server_ip\n";
}
}
@@ -302,7 +303,7 @@ if ($ACTION=="OriginateName")
$stmt="SELECT dialplan_number FROM phones where server_ip = '$server_ip' and extension='$extenName';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'02005',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02005',$user,$server_ip,$session_name,$one_mysql_log);}
$name_count = mysql_num_rows($rslt);
if ($name_count>0)
{
@@ -332,7 +333,7 @@ if ($ACTION=="OriginateNameVmail")
$stmt="SELECT voicemail_id FROM phones where server_ip = '$server_ip' and extension='$extenName';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'02006',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02006',$user,$server_ip,$session_name,$one_mysql_log);}
$name_count = mysql_num_rows($rslt);
if ($name_count>0)
{
@@ -373,7 +374,7 @@ if ($ACTION=="Originate")
$stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$queryCID','Channel: $channel','Context: $ext_context','Exten: $exten','Priority: $ext_priority','Callerid: $outCID','','','','','');";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'02007',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02007',$user,$server_ip,$session_name,$one_mysql_log);}
echo "Originate command sent for Exten $exten Channel $channel on $server_ip\n";
}
}
@@ -401,14 +402,14 @@ if ($ACTION=="HangupConfDial")
$stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$hangup_channel_prefix%\";";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'02008',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02008',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysql_fetch_row($rslt);
if ($row > 0)
{
$stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$hangup_channel_prefix%\";";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'02009',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02009',$user,$server_ip,$session_name,$one_mysql_log);}
$rowx=mysql_fetch_row($rslt);
$channel=$rowx[0];
$ACTION="Hangup";
@@ -427,7 +428,7 @@ if ($ACTION=="Hangup")
$stmt="UPDATE vicidial_live_agents SET external_hangup='0' where user='$user';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'02010',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02010',$user,$server_ip,$session_name,$one_mysql_log);}
$row=''; $rowx='';
$channel_live=1;
@@ -461,7 +462,7 @@ $rslt=mysql_query($stmt, $link);
$stmt="SELECT count(*) FROM vicidial_auto_calls where channel='$channel' and callerid='$CalLCID';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'02011',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02011',$user,$server_ip,$session_name,$one_mysql_log);}
$rowx=mysql_fetch_row($rslt);
if ($rowx[0]==0)
{
@@ -470,7 +471,7 @@ $rslt=mysql_query($stmt, $link);
$stmt="SELECT count(*) FROM live_channels where server_ip = '$call_server_ip' and channel='$channel' and extension LIKE \"%$exten\";";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'02012',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02012',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysql_fetch_row($rslt);
if ($row[0]==0)
{
@@ -490,7 +491,7 @@ $rslt=mysql_query($stmt, $link);
{
$stmt="SELECT count(*) FROM vicidial_auto_calls where callerid='$CalLCID';";
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'02013',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02013',$user,$server_ip,$session_name,$one_mysql_log);}
$rowx=mysql_fetch_row($rslt);
if ($format=='debug') {echo "\n<!-- $rowx[0]|$stmt -->";}
if ($rowx[0] > 0)
@@ -499,7 +500,7 @@ $rslt=mysql_query($stmt, $link);
##### START QUEUEMETRICS LOGGING LOOKUP #####
$stmt = "SELECT enable_queuemetrics_logging,queuemetrics_server_ip,queuemetrics_dbname,queuemetrics_login,queuemetrics_pass,queuemetrics_log_id FROM system_settings;";
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'02014',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02014',$user,$server_ip,$session_name,$one_mysql_log);}
if ($format=='debug') {echo "\n<!-- $rowx[0]|$stmt -->";}
$qm_conf_ct = mysql_num_rows($rslt);
$i=0;
@@ -523,7 +524,7 @@ $rslt=mysql_query($stmt, $link);
$stmt="SELECT count(*) from queue_log where call_id='$CalLCID' and verb='CONNECT';";
$rslt=mysql_query($stmt, $linkB);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$linkB,$mysql_error_logging,$stmt,'02015',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'02015',$user,$server_ip,$session_name,$one_mysql_log);}
$VAC_cn_ct = mysql_num_rows($rslt);
if ($VAC_cn_ct > 0)
{
@@ -536,7 +537,7 @@ $rslt=mysql_query($stmt, $link);
### grab call lead information needed for QM logging
$stmt="SELECT auto_call_id,lead_id,phone_number,status,campaign_id,phone_code,alt_dial,stage,callerid,uniqueid from vicidial_auto_calls where callerid='$CalLCID' order by call_time limit 1;";
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'02016',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02016',$user,$server_ip,$session_name,$one_mysql_log);}
$VAC_qm_ct = mysql_num_rows($rslt);
if ($VAC_qm_ct > 0)
{
@@ -559,7 +560,7 @@ $rslt=mysql_query($stmt, $link);
$stmt="SELECT count(*) from queue_log where call_id='$CalLCID' and verb='COMPLETECALLER' and queue='$CLcampaign_id';";
$rslt=mysql_query($stmt, $linkB);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$linkB,$mysql_error_logging,$stmt,'02017',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'02017',$user,$server_ip,$session_name,$one_mysql_log);}
$VAC_cc_ct = mysql_num_rows($rslt);
if ($VAC_cc_ct > 0)
{
@@ -573,7 +574,7 @@ $rslt=mysql_query($stmt, $link);
$time_id=0;
$stmt="SELECT time_id from queue_log where call_id='$CalLCID' and verb='ENTERQUEUE' and queue='$CLcampaign_id';";
$rslt=mysql_query($stmt, $linkB);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$linkB,$mysql_error_logging,$stmt,'02018',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'02018',$user,$server_ip,$session_name,$one_mysql_log);}
$VAC_eq_ct = mysql_num_rows($rslt);
if ($VAC_eq_ct > 0)
{
@@ -587,7 +588,7 @@ $rslt=mysql_query($stmt, $link);
if ($format=='debug') {echo "\n<!-- $caller_complete|$stmt -->";}
$stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='$CalLCID',queue='$CLcampaign_id',agent='Agent/$user',verb='COMPLETEAGENT',data1='$CLstage',data2='$secondS',data3='1',serverid='$queuemetrics_log_id';";
$rslt=mysql_query($stmt, $linkB);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$linkB,$mysql_error_logging,$stmt,'02019',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'02019',$user,$server_ip,$session_name,$one_mysql_log);}
$affected_rows = mysql_affected_rows($linkB);
if ($format=='debug') {echo "\n<!-- $affected_rows|$stmt -->";}
}
@@ -599,7 +600,7 @@ $rslt=mysql_query($stmt, $link);
$stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$call_server_ip','','Hangup','$queryCID','Channel: $channel','','','','','','','','','');";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'02020',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02020',$user,$server_ip,$session_name,$one_mysql_log);}
echo "Hangup command sent for Channel $channel on $call_server_ip\n";
}
}
@@ -634,28 +635,28 @@ if ($ACTION=="RedirectVD")
$stmt = "select count(*) from vicidial_campaigns where campaign_id='$campaign' and campaign_allow_inbound='Y';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'02021',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02021',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysql_fetch_row($rslt);
if ($row[0] > 0)
{
$stmt = "UPDATE vicidial_closer_log set end_epoch='$StarTtime', length_in_sec='$secondS',status='XFER' where lead_id='$lead_id' order by start_epoch desc limit 1;";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'02022',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02022',$user,$server_ip,$session_name,$one_mysql_log);}
}
if ($auto_dial_level < 1)
{
$stmt = "UPDATE vicidial_log set end_epoch='$StarTtime', length_in_sec='$secondS',status='XFER' where uniqueid='$uniqueid';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'02023',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02023',$user,$server_ip,$session_name,$one_mysql_log);}
}
else
{
$stmt = "DELETE from vicidial_auto_calls where uniqueid='$uniqueid';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'02024',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02024',$user,$server_ip,$session_name,$one_mysql_log);}
}
$ACTION="Redirect";
}
@@ -682,7 +683,7 @@ if ($ACTION=="RedirectToPark")
$stmt = "INSERT INTO parked_channels values('$channel','$server_ip','','$extenName','$parkedby','$NOW_TIME');";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'02025',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02025',$user,$server_ip,$session_name,$one_mysql_log);}
$ACTION="Redirect";
}
}
@@ -706,7 +707,7 @@ if ($ACTION=="RedirectFromPark")
$stmt = "DELETE FROM parked_channels where server_ip='$server_ip' and channel='$channel';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'02026',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02026',$user,$server_ip,$session_name,$one_mysql_log);}
$ACTION="Redirect";
}
}
@@ -729,7 +730,7 @@ if ($ACTION=="RedirectName")
$stmt="SELECT dialplan_number FROM phones where server_ip = '$server_ip' and extension='$extenName';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'02027',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02027',$user,$server_ip,$session_name,$one_mysql_log);}
$name_count = mysql_num_rows($rslt);
if ($name_count>0)
{
@@ -759,7 +760,7 @@ if ($ACTION=="RedirectNameVmail")
$stmt="SELECT voicemail_id FROM phones where server_ip = '$server_ip' and extension='$extenName';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'02028',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02028',$user,$server_ip,$session_name,$one_mysql_log);}
$name_count = mysql_num_rows($rslt);
if ($name_count>0)
{
@@ -810,19 +811,19 @@ if ($ACTION=="RedirectXtraCXNeW")
$stmtA="SELECT count(*) FROM vicidial_conferences where server_ip='$server_ip' and ((extension='') or (extension is null)) and conf_exten != '$session_id';";
if ($format=='debug') {echo "\n<!-- $stmtA -->";}
$rslt=mysql_query($stmtA, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmtA,'02029',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmtA,'02029',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysql_fetch_row($rslt);
if ($row[0] > 1)
{
$stmtB="UPDATE vicidial_conferences set extension='$protocol/$extension$NOWnum', leave_3way='0' where server_ip='$server_ip' and ((extension='') or (extension is null)) and conf_exten != '$session_id' limit 1;";
if ($format=='debug') {echo "\n<!-- $stmtB -->";}
$rslt=mysql_query($stmtB, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmtB,'02030',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmtB,'02030',$user,$server_ip,$session_name,$one_mysql_log);}
$stmtC="SELECT conf_exten from vicidial_conferences where server_ip='$server_ip' and extension='$protocol/$extension$NOWnum' and conf_exten != '$session_id';";
if ($format=='debug') {echo "\n<!-- $stmtC -->";}
$rslt=mysql_query($stmtC, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmtC,'02031',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmtC,'02031',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysql_fetch_row($rslt);
$exten = $row[0];
@@ -834,30 +835,30 @@ if ($ACTION=="RedirectXtraCXNeW")
$stmtD="UPDATE vicidial_conferences set extension='$protocol/$extension' where server_ip='$server_ip' and conf_exten='$exten' limit 1;";
if ($format=='debug') {echo "\n<!-- $stmtD -->";}
$rslt=mysql_query($stmtD, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmtD,'02032',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmtD,'02032',$user,$server_ip,$session_name,$one_mysql_log);}
$stmtE="UPDATE vicidial_conferences set leave_3way='1', leave_3way_datetime='$NOW_TIME', extension='3WAY_$user' where server_ip='$server_ip' and conf_exten='$session_id';";
if ($format=='debug') {echo "\n<!-- $stmtE -->";}
$rslt=mysql_query($stmtE, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmtE,'02033',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmtE,'02033',$user,$server_ip,$session_name,$one_mysql_log);}
$queryCID = "CXAR24$NOWnum";
$stmtF="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Redirect','$queryCID','Channel: $agentchannel','Context: $ext_context','Exten: $exten','Priority: 1','CallerID: $queryCID','','','','','');";
if ($format=='debug') {echo "\n<!-- $stmtF -->";}
$rslt=mysql_query($stmtF, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmtF,'02034',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmtF,'02034',$user,$server_ip,$session_name,$one_mysql_log);}
$stmtG="UPDATE vicidial_live_agents set conf_exten='$exten' where server_ip='$server_ip' and user='$user';";
if ($format=='debug') {echo "\n<!-- $stmtG -->";}
$rslt=mysql_query($stmtG, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmtG,'02035',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmtG,'02035',$user,$server_ip,$session_name,$one_mysql_log);}
if ($auto_dial_level < 1)
{
$stmtH = "DELETE from vicidial_auto_calls where lead_id='$lead_id' and callerid LIKE \"M%\";";
if ($format=='debug') {echo "\n<!-- $stmtH -->";}
$rslt=mysql_query($stmtH, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmtH,'02036',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmtH,'02036',$user,$server_ip,$session_name,$one_mysql_log);}
}
// $fp = fopen ("./vicidial_debug_3way.txt", "a");
@@ -882,14 +883,14 @@ if ($ACTION=="RedirectXtraCXNeW")
$stmt="SELECT count(*) FROM live_channels where server_ip = '$call_server_ip' and channel='$channel';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'02037',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02037',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysql_fetch_row($rslt);
if ($row[0]==0)
{
$stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$call_server_ip' and channel='$channel';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'02038',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02038',$user,$server_ip,$session_name,$one_mysql_log);}
$rowx=mysql_fetch_row($rslt);
if ($rowx[0]==0)
{
@@ -901,14 +902,14 @@ if ($ACTION=="RedirectXtraCXNeW")
$stmt="SELECT count(*) FROM live_channels where server_ip = '$server_ip' and channel='$extrachannel';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'02039',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02039',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysql_fetch_row($rslt);
if ($row[0]==0)
{
$stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$server_ip' and channel='$extrachannel';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'02040',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02040',$user,$server_ip,$session_name,$one_mysql_log);}
$rowx=mysql_fetch_row($rslt);
if ($rowx[0]==0)
{
@@ -922,7 +923,7 @@ if ($ACTION=="RedirectXtraCXNeW")
$stmt="SELECT count(*) FROM vicidial_live_agents where lead_id='$lead_id' and user!='$user';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'02041',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02041',$user,$server_ip,$session_name,$one_mysql_log);}
$rowx=mysql_fetch_row($rslt);
if ($rowx[0] < 1)
{
@@ -935,7 +936,7 @@ if ($ACTION=="RedirectXtraCXNeW")
$stmt="SELECT server_ip,conf_exten,user FROM vicidial_live_agents where lead_id='$lead_id' and user!='$user';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'02042',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02042',$user,$server_ip,$session_name,$one_mysql_log);}
$rowx=mysql_fetch_row($rslt);
$dest_server_ip = $rowx[0];
$dest_session_id = $rowx[1];
@@ -956,12 +957,12 @@ if ($ACTION=="RedirectXtraCXNeW")
$stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$call_server_ip','','Redirect','$queryCID','Channel: $channel','Context: $ext_context','Exten: $dest_dialstring','Priority: $ext_priority','CallerID: $queryCID','','','','','');";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'02043',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02043',$user,$server_ip,$session_name,$one_mysql_log);}
$stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Hangup','$queryCID','Channel: $extrachannel','','','','','','','','','');";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'02044',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02044',$user,$server_ip,$session_name,$one_mysql_log);}
echo "RedirectXtraCX command sent for Channel $channel on $call_server_ip and \nHungup $extrachannel on $server_ip\n";
if (ereg("SECOND|FIRST|DEBUG",$filename)) {$DBout .= "$channel on $call_server_ip, Hungup $extrachannel on $server_ip";}
@@ -1037,49 +1038,49 @@ if ($ACTION=="RedirectXtraNeW")
$stmt="SELECT count(*) FROM vicidial_conferences where server_ip='$server_ip' and ((extension='') or (extension is null)) and conf_exten != '$session_id';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'02045',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02045',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysql_fetch_row($rslt);
if ($row[0] > 1)
{
$stmt="UPDATE vicidial_conferences set extension='$protocol/$extension$NOWnum', leave_3way='0' where server_ip='$server_ip' and ((extension='') or (extension is null)) and conf_exten != '$session_id' limit 1;";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'02046',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02046',$user,$server_ip,$session_name,$one_mysql_log);}
$stmt="SELECT conf_exten from vicidial_conferences where server_ip='$server_ip' and extension='$protocol/$extension$NOWnum' and conf_exten != '$session_id';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'02047',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02047',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysql_fetch_row($rslt);
$exten = $row[0];
$stmt="UPDATE vicidial_conferences set extension='$protocol/$extension' where server_ip='$server_ip' and conf_exten='$exten' limit 1;";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'02048',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02048',$user,$server_ip,$session_name,$one_mysql_log);}
$stmt="UPDATE vicidial_conferences set leave_3way='1', leave_3way_datetime='$NOW_TIME', extension='3WAY_$user' where server_ip='$server_ip' and conf_exten='$session_id';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'02049',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02049',$user,$server_ip,$session_name,$one_mysql_log);}
$queryCID = "CXAR23$NOWnum";
$stmtB="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Redirect','$queryCID','Channel: $agentchannel','Context: $ext_context','Exten: $exten','Priority: 1','CallerID: $queryCID','','','','','');";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_query($stmtB, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'02050',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02050',$user,$server_ip,$session_name,$one_mysql_log);}
$stmt="UPDATE vicidial_live_agents set conf_exten='$exten' where server_ip='$server_ip' and user='$user';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'02051',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02051',$user,$server_ip,$session_name,$one_mysql_log);}
if ($auto_dial_level < 1)
{
$stmt = "DELETE from vicidial_auto_calls where lead_id='$lead_id' and callerid LIKE \"M%\";";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'02052',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02052',$user,$server_ip,$session_name,$one_mysql_log);}
}
echo "NeWSessioN|$exten|\n";
@@ -1100,14 +1101,14 @@ if ($ACTION=="RedirectXtraNeW")
$stmt="SELECT count(*) FROM live_channels where server_ip = '$call_server_ip' and channel='$channel';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'02053',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02053',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysql_fetch_row($rslt);
if ( ($row[0]==0) && (!ereg("SECOND",$filename)) )
{
$stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$call_server_ip' and channel='$channel';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'02054',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02054',$user,$server_ip,$session_name,$one_mysql_log);}
$rowx=mysql_fetch_row($rslt);
if ($rowx[0]==0)
{
@@ -1119,14 +1120,14 @@ if ($ACTION=="RedirectXtraNeW")
$stmt="SELECT count(*) FROM live_channels where server_ip = '$server_ip' and channel='$extrachannel';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'02055',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02055',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysql_fetch_row($rslt);
if ( ($row[0]==0) && (!ereg("SECOND",$filename)) )
{
$stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$server_ip' and channel='$extrachannel';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'02056',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02056',$user,$server_ip,$session_name,$one_mysql_log);}
$rowx=mysql_fetch_row($rslt);
if ($rowx[0]==0)
{
@@ -1142,7 +1143,7 @@ if ($ACTION=="RedirectXtraNeW")
$stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Redirect','$queryCID','Channel: $channel','ExtraChannel: $extrachannel','Context: $ext_context','Exten: $exten','Priority: $ext_priority','CallerID: $queryCID','','','','');";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'02057',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02057',$user,$server_ip,$session_name,$one_mysql_log);}
echo "RedirectXtra command sent for Channel $channel and \nExtraChannel $extrachannel\n to $exten on $server_ip\n";
if (ereg("SECOND|FIRST|DEBUG",$filename)) {$DBout .= "$channel and $extrachannel to $exten on $server_ip";}
@@ -1164,12 +1165,12 @@ if ($ACTION=="RedirectXtraNeW")
$stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$call_server_ip','','Redirect','$queryCID','Channel: $channel','Context: $ext_context','Exten: $dest_dialstring','Priority: $ext_priority','CallerID: $queryCID','','','','','');";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'02058',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02058',$user,$server_ip,$session_name,$one_mysql_log);}
$stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Redirect','$queryCID','Channel: $extrachannel','Context: $ext_context','Exten: $exten','Priority: $ext_priority','CallerID: $queryCID','','','','','');";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'02059',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02059',$user,$server_ip,$session_name,$one_mysql_log);}
echo "RedirectXtra command sent for Channel $channel on $call_server_ip and \nExtraChannel $extrachannel\n to $exten on $server_ip\n";
if (ereg("SECOND|FIRST|DEBUG",$filename)) {$DBout .= "$channel/$call_server_ip and $extrachannel/$server_ip to $exten";}
@@ -1506,14 +1507,14 @@ if ($ACTION=="Redirect")
$stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$hangup_channel_prefix%\";";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'02060',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02060',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysql_fetch_row($rslt);
if ($row > 0)
{
$stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$hangup_channel_prefix%\";";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'02061',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02061',$user,$server_ip,$session_name,$one_mysql_log);}
$rowx=mysql_fetch_row($rslt);
$channel=$rowx[0];
$channel = eregi_replace("1$","2",$channel);
@@ -1540,14 +1541,14 @@ if ($ACTION=="Redirect")
$stmt="SELECT count(*) FROM live_channels where server_ip = '$server_ip' and channel='$channel';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'02062',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02062',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysql_fetch_row($rslt);
if ($row[0]==0)
{
$stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$server_ip' and channel='$channel';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'02063',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02063',$user,$server_ip,$session_name,$one_mysql_log);}
$rowx=mysql_fetch_row($rslt);
if ($rowx[0]==0)
{
@@ -1560,7 +1561,7 @@ if ($ACTION=="Redirect")
$stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Redirect','$queryCID','Channel: $channel','Context: $ext_context','Exten: $exten','Priority: $ext_priority','CallerID: $queryCID','','','','','');";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'02064',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02064',$user,$server_ip,$session_name,$one_mysql_log);}
echo "Redirect command sent for Channel $channel on $server_ip\n";
}
@@ -1591,14 +1592,14 @@ if ( ($ACTION=="Monitor") || ($ACTION=="StopMonitor") )
$stmt="SELECT count(*) FROM live_channels where server_ip = '$server_ip' and channel='$channel';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'02065',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02065',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysql_fetch_row($rslt);
if ($row[0]==0)
{
$stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$server_ip' and channel='$channel';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'02066',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02066',$user,$server_ip,$session_name,$one_mysql_log);}
$rowx=mysql_fetch_row($rslt);
if ($rowx[0]==0)
{
@@ -1611,18 +1612,18 @@ if ( ($ACTION=="Monitor") || ($ACTION=="StopMonitor") )
$stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','$ACTION','$queryCID','Channel: $channel','$SQLfile','','','','','','','','');";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'02067',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02067',$user,$server_ip,$session_name,$one_mysql_log);}
if ($ACTION=="Monitor")
{
$stmt = "INSERT INTO recording_log (channel,server_ip,extension,start_time,start_epoch,filename,lead_id,user) values('$channel','$server_ip','$exten','$NOW_TIME','$StarTtime','$filename','$lead_id','$user')";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'02068',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02068',$user,$server_ip,$session_name,$one_mysql_log);}
$stmt="SELECT recording_id FROM recording_log where filename='$filename'";
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'02069',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02069',$user,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$recording_id = $row[0];
@@ -1631,7 +1632,7 @@ if ( ($ACTION=="Monitor") || ($ACTION=="StopMonitor") )
{
$stmt="SELECT recording_id,start_epoch FROM recording_log where filename='$filename'";
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'02070',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02070',$user,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";}
$rec_count = mysql_num_rows($rslt);
if ($rec_count>0)
@@ -1646,7 +1647,7 @@ if ( ($ACTION=="Monitor") || ($ACTION=="StopMonitor") )
$stmt = "UPDATE recording_log set end_time='$NOW_TIME',end_epoch='$StarTtime',length_in_sec=$length_in_sec,length_in_min='$length_in_min' where filename='$filename'";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'02071',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02071',$user,$server_ip,$session_name,$one_mysql_log);}
}
}
@@ -1684,12 +1685,12 @@ if ( ($ACTION=="MonitorConf") || ($ACTION=="StopMonitorConf") )
$stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$filename','Channel: $channel','Context: $ext_context','Exten: $exten','Priority: $ext_priority','Callerid: $filename','','','','','');";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'02072',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02072',$user,$server_ip,$session_name,$one_mysql_log);}
$stmt = "INSERT INTO recording_log (channel,server_ip,extension,start_time,start_epoch,filename,lead_id,user) values('$channel','$server_ip','$exten','$NOW_TIME','$StarTtime','$filename','$lead_id','$user')";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'02073',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02073',$user,$server_ip,$session_name,$one_mysql_log);}
$RLaffected_rows = mysql_affected_rows($link);
if ($RLaffected_rows > 0)
{
@@ -1702,7 +1703,7 @@ if ( ($ACTION=="MonitorConf") || ($ACTION=="StopMonitorConf") )
$VLA_inOUT='NONE';
$stmt="SELECT comments FROM vicidial_live_agents where user='$user' order by last_update_time desc limit 1;";
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'02074',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02074',$user,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";}
$VLA_inOUT_ct = mysql_num_rows($rslt);
if ($VLA_inOUT_ct > 0)
@@ -1723,7 +1724,7 @@ if ( ($ACTION=="MonitorConf") || ($ACTION=="StopMonitorConf") )
$stmt="SELECT uniqueid FROM vicidial_log where uniqueid='$uniqueid' and lead_id='$lead_id';";
}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'02075',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02075',$user,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";}
$VM_mancall_ct = mysql_num_rows($rslt);
if ($VM_mancall_ct > 0)
@@ -1734,7 +1735,7 @@ if ( ($ACTION=="MonitorConf") || ($ACTION=="StopMonitorConf") )
$stmt = "UPDATE recording_log SET vicidial_id='$VDvicidial_id' where recording_id='$recording_id';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'02076',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02076',$user,$server_ip,$session_name,$one_mysql_log);}
}
}
}
@@ -1749,7 +1750,7 @@ if ( ($ACTION=="MonitorConf") || ($ACTION=="StopMonitorConf") )
### find the value to put in the vicidial_id field if this was an inbound call
$stmt="SELECT closecallid from vicidial_closer_log where lead_id='$lead_id' and call_date > \"$four_hours_ago\" order by call_date desc limit 1;";
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'02077',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02077',$user,$server_ip,$session_name,$one_mysql_log);}
$VAC_qm_ct = mysql_num_rows($rslt);
if ($VAC_qm_ct > 0)
{
@@ -1765,7 +1766,7 @@ if ( ($ACTION=="MonitorConf") || ($ACTION=="StopMonitorConf") )
$stmt="SELECT recording_id,start_epoch FROM recording_log where filename='$filename'";
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'02078',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02078',$user,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";}
$rec_count = mysql_num_rows($rslt);
if ($rec_count>0)
@@ -1780,14 +1781,14 @@ if ( ($ACTION=="MonitorConf") || ($ACTION=="StopMonitorConf") )
$stmt = "UPDATE recording_log set end_time='$NOW_TIME',end_epoch='$StarTtime',length_in_sec=$length_in_sec,length_in_min='$length_in_min' $uniqueidSQL where filename='$filename'";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'02079',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02079',$user,$server_ip,$session_name,$one_mysql_log);}
}
# find and hang up all recordings going on in this conference # and extension = '$exten'
$stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$channel%\" and channel LIKE \"%,1\";";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'02080',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02080',$user,$server_ip,$session_name,$one_mysql_log);}
# $rec_count = intval(mysql_num_rows($rslt) / 2);
$rec_count = mysql_num_rows($rslt);
$h=0;
@@ -1803,7 +1804,7 @@ if ( ($ACTION=="MonitorConf") || ($ACTION=="StopMonitorConf") )
$stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Hangup','RH12345$StarTtime$i','Channel: $HUchannel[$i]','','','','','','','','','');";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'02081',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02081',$user,$server_ip,$session_name,$one_mysql_log);}
$i++;
}
@@ -1839,7 +1840,7 @@ if ($ACTION=="VolumeControl")
$stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$queryCID','Channel: $volume_local_channel','Context: $ext_context','Exten: 8300','Priority: 1','Callerid: $queryCID','','','','$channel','$exten');";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'02082',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02082',$user,$server_ip,$session_name,$one_mysql_log);}
echo "Volume command sent for Conference $exten, Stage $stage Channel $channel on $server_ip\n";
}
}
@@ -1864,14 +1865,15 @@ exit;
##### MySQL Error Logging #####
function mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,$query_id,$user,$server_ip,$session_name)
function mysql_error_logging($NOW_TIME,$link,$mel,$stmt,$query_id,$user,$server_ip,$session_name,$one_mysql_log)
{
# mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'00001',$user,$server_ip,$session_name);
$NOW_TIME = date("Y-m-d H:i:s");
# mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00001',$user,$server_ip,$session_name,$one_mysql_log);
$errno=''; $error='';
if ($mysql_error_logging > 0)
if ( ($mel > 0) or ($one_mysql_log > 0) )
{
$errno = mysql_errno($link);
if ( ($errno > 0) or ($mysql_error_logging > 1) )
if ( ($errno > 0) or ($mel > 1) or ($one_mysql_log > 0) )
{
$error = mysql_error($link);
$efp = fopen ("./vicidial_mysql_errors.txt", "a");
@@ -1879,6 +1881,8 @@ if ($mysql_error_logging > 0)
fclose($efp);
}
}
$one_mysql_log=0;
return $errno;
}
?>
File diff suppressed because it is too large Load Diff
+63 -58
View File
@@ -203,12 +203,14 @@
# 81030-0403 - Added option to force Pause Codes on PAUSE
# 81103-1427 - Added 3way call dial prefix
# 81104-0140 - Added mysql error logging capability
# 81104-1618 - Changed MySQL queries logging
#
$version = '2.0.5-182';
$build = '81104-0140';
$mysql_error_logging = 1; # Mysql error log logging for on the web server
$version = '2.0.5-183';
$build = '81104-1618';
$mel=1; # Mysql Error Log enabled = 1
$mysql_log_count=51;
$one_mysql_log=0;
require("dbconnect.php");
@@ -282,7 +284,7 @@ $random = (rand(1000000, 9999999) + 10000000);
##### START SYSTEM_SETTINGS LOOKUP #####
$stmt = "SELECT use_non_latin,vdc_header_date_format,vdc_customer_date_format,vdc_header_phone_format,webroot_writable FROM system_settings;";
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'01001',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01001',$VD_login,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";}
$qm_conf_ct = mysql_num_rows($rslt);
$i=0;
@@ -402,13 +404,13 @@ if ($relogin == 'YES')
$stmt="SELECT user_group from vicidial_users where user='$VD_login' and pass='$VD_pass'";
if ($non_latin > 0) {$rslt=mysql_query("SET NAMES 'UTF8'");}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'01002',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01002',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$row=mysql_fetch_row($rslt);
$VU_user_group=$row[0];
$stmt="SELECT allowed_campaigns from vicidial_user_groups where user_group='$VU_user_group';";
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'01003',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01003',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$row=mysql_fetch_row($rslt);
if ( (!eregi("ALL-CAMPAIGNS",$row[0])) )
{
@@ -421,7 +423,7 @@ if ($relogin == 'YES')
$stmt="SELECT campaign_id,campaign_name from vicidial_campaigns where active='Y' $LOGallowed_campaignsSQL order by campaign_id";
if ($non_latin > 0) {$rslt=mysql_query("SET NAMES 'UTF8'");}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'01004',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01004',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$camps_to_print = mysql_num_rows($rslt);
$o=0;
@@ -586,7 +588,7 @@ if ($user_login_first == 1)
$stmt="SELECT phone_login,phone_pass from vicidial_users where user='$VD_login' and pass='$VD_pass' and user_level > 0;";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'01005',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01005',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$row=mysql_fetch_row($rslt);
$phone_login=$row[0];
$phone_pass=$row[1];
@@ -672,7 +674,7 @@ $VDloginDISPLAY=0;
$stmt="SELECT count(*) from vicidial_users where user='$VD_login' and pass='$VD_pass' and user_level > 0;";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'01006',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01006',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$row=mysql_fetch_row($rslt);
$auth=$row[0];
@@ -683,7 +685,7 @@ $VDloginDISPLAY=0;
##### grab the full name of the agent
$stmt="SELECT full_name,user_level,hotkeys_active,agent_choose_ingroups,scheduled_callbacks,agentonly_callbacks,agentcall_manual,vicidial_recording,vicidial_transfers,closer_default_blended,user_group,vicidial_recording_override,alter_custphone_override from vicidial_users where user='$VD_login' and pass='$VD_pass'";
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'01007',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01007',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$row=mysql_fetch_row($rslt);
$LOGfullname=$row[0];
$user_level=$row[1];
@@ -710,7 +712,7 @@ $VDloginDISPLAY=0;
$stmt="SELECT allowed_campaigns from vicidial_user_groups where user_group='$VU_user_group';";
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'01008',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01008',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$row=mysql_fetch_row($rslt);
$LOGallowed_campaigns =$row[0];
@@ -743,7 +745,7 @@ $VDloginDISPLAY=0;
$stmt="SELECT count(*) FROM vicidial_campaigns where campaign_id='$VD_campaign' and active='Y';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'01009',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01009',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$row=mysql_fetch_row($rslt);
$CAMPactive=$row[0];
if($CAMPactive>0)
@@ -755,7 +757,7 @@ $VDloginDISPLAY=0;
##### grab the statuses that can be used for dispositioning by an agent
$stmt="SELECT status,status_name FROM vicidial_statuses WHERE $selectableSQL status != 'NEW' order by status limit 50;";
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'01010',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01010',$VD_login,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";}
$VD_statuses_ct = mysql_num_rows($rslt);
$i=0;
@@ -772,7 +774,7 @@ $VDloginDISPLAY=0;
##### grab the campaign-specific statuses that can be used for dispositioning by an agent
$stmt="SELECT status,status_name FROM vicidial_campaign_statuses WHERE $selectableSQL status != 'NEW' and campaign_id='$VD_campaign' order by status limit 80;";
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'01011',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01011',$VD_login,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";}
$VD_statuses_camp = mysql_num_rows($rslt);
$j=0;
@@ -793,7 +795,7 @@ $VDloginDISPLAY=0;
##### grab the campaign-specific HotKey statuses that can be used for dispositioning by an agent
$stmt="SELECT hotkey,status,status_name FROM vicidial_campaign_hotkeys WHERE selectable='Y' and status != 'NEW' and campaign_id='$VD_campaign' order by hotkey limit 9;";
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'01012',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01012',$VD_login,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";}
$HK_statuses_camp = mysql_num_rows($rslt);
$w=0;
@@ -824,7 +826,7 @@ $VDloginDISPLAY=0;
##### grab the campaign settings
$stmt="SELECT park_ext,park_file_name,web_form_address,allow_closers,auto_dial_level,dial_timeout,dial_prefix,campaign_cid,campaign_vdad_exten,campaign_rec_exten,campaign_recording,campaign_rec_filename,campaign_script,get_call_launch,am_message_exten,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number,alt_number_dialing,scheduled_callbacks,wrapup_seconds,wrapup_message,closer_campaigns,use_internal_dnc,allcalls_delay,omit_phone_code,agent_pause_codes_active,no_hopper_leads_logins,campaign_allow_inbound,manual_dial_list_id,default_xfer_group,xfer_groups,disable_alter_custphone,display_queue_count,manual_dial_filter,agent_clipboard_copy,use_campaign_dnc,three_way_call_cid,dial_method,three_way_dial_prefix FROM vicidial_campaigns where campaign_id = '$VD_campaign';";
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'01013',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01013',$VD_login,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$park_ext = $row[0];
@@ -903,7 +905,7 @@ $VDloginDISPLAY=0;
##### grab the pause codes for this campaign
$stmt="SELECT pause_code,pause_code_name FROM vicidial_pause_codes WHERE campaign_id='$VD_campaign' order by pause_code limit 50;";
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'01014',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01014',$VD_login,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";}
$VD_pause_codes = mysql_num_rows($rslt);
$j=0;
@@ -929,7 +931,7 @@ $VDloginDISPLAY=0;
$VARingroups='';
$stmt="select group_id from vicidial_inbound_groups where active = 'Y' and group_id IN($closer_campaigns) order by group_id limit 60;";
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'01015',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01015',$VD_login,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";}
$closer_ct = mysql_num_rows($rslt);
$INgrpCT=0;
@@ -953,7 +955,7 @@ $VDloginDISPLAY=0;
$VARxfergroups='';
$stmt="select group_id,group_name from vicidial_inbound_groups where active = 'Y' and group_id IN($xfer_groups) order by group_id limit 60;";
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'01016',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01016',$VD_login,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";}
$xfer_ct = mysql_num_rows($rslt);
$XFgrpCT=0;
@@ -972,7 +974,7 @@ $VDloginDISPLAY=0;
##### grab the number of leads in the hopper for this campaign
$stmt="SELECT count(*) FROM vicidial_hopper where campaign_id = '$VD_campaign' and status='READY';";
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'01017',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01017',$VD_login,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$campaign_leads_to_call = $row[0];
@@ -1038,7 +1040,7 @@ $VDloginDISPLAY=0;
$alias_found=0;
$stmt="select count(*) from phones_alias where alias_id = '$phone_login';";
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'01018',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01018',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$alias_ct = mysql_num_rows($rslt);
if ($alias_ct > 0)
{
@@ -1049,7 +1051,7 @@ if ($alias_found > 0)
{
$stmt="select alias_name,logins_list from phones_alias where alias_id = '$phone_login' limit 1;";
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'01019',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01019',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$alias_ct = mysql_num_rows($rslt);
if ($alias_ct > 0)
{
@@ -1081,7 +1083,7 @@ $authphone=0;
$stmt="SELECT count(*) from phones where $phoneSQL and active = 'Y';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'01020',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01020',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$row=mysql_fetch_row($rslt);
$authphone=$row[0];
if (!$authphone)
@@ -1133,28 +1135,28 @@ else
if ($DB) {echo "|$stmtx|\n";}
if ($non_latin > 0) {$rslt=mysql_query("SET NAMES 'UTF8'");}
$rslt=mysql_query($stmtx, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'01021',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01021',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$rowx=mysql_fetch_row($rslt);
### get number of agents logged in to each server
$stmt="SELECT count(*) from vicidial_live_agents where server_ip = '$rowx[0]';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'01022',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01022',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$row=mysql_fetch_row($rslt);
### find out whether the server is set to active
$stmt="SELECT count(*) from servers where server_ip = '$rowx[0]' and active='Y';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'01023',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01023',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$rowy=mysql_fetch_row($rslt);
### find out whether the server_updater is running
$stmt="SELECT count(*) from server_updater where server_ip = '$rowx[0]' and last_update > '$past_minutes_date';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'01024',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01024',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$rowz=mysql_fetch_row($rslt);
$pb_log .= "$phones_auto[$pb]|$rowx[0]|$row[0]|$rowy[0]|$rowz[0]| ";
@@ -1176,7 +1178,7 @@ else
$stmt="SELECT * from phones where login='$phone_login' and pass='$phone_pass' and active = 'Y';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'01025',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01025',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$row=mysql_fetch_row($rslt);
$extension=$row[0];
$dialplan_number=$row[1];
@@ -1248,7 +1250,7 @@ else
$stmt="UPDATE phones SET computer_ip='$ip' where login='$phone_login' and pass='$phone_pass' and active = 'Y';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'01026',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01026',$VD_login,$server_ip,$session_name,$one_mysql_log);}
}
}
if ($PhoneSComPIP == '2')
@@ -1256,7 +1258,7 @@ else
$stmt="UPDATE phones SET computer_ip='$ip' where login='$phone_login' and pass='$phone_pass' and active = 'Y';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'01027',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01027',$VD_login,$server_ip,$session_name,$one_mysql_log);}
}
if ($clientDST)
{
@@ -1277,7 +1279,7 @@ else
$stmt="SELECT asterisk_version from servers where server_ip='$server_ip';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'01028',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01028',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$row=mysql_fetch_row($rslt);
$asterisk_version=$row[0];
@@ -1331,12 +1333,12 @@ else
$stmt="DELETE from web_client_sessions where start_time < '$past_month_date' and extension='$extension' and server_ip = '$server_ip' and program = 'vicidial';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'01029',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01029',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$stmt="INSERT INTO web_client_sessions values('$extension','$server_ip','vicidial','$NOW_TIME','$session_name');";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'01030',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01030',$VD_login,$server_ip,$session_name,$one_mysql_log);}
if ( ($campaign_allow_inbound == 'Y') || ($campaign_leads_to_call > 0) || (ereg('Y',$no_hopper_leads_logins)) )
{
@@ -1344,12 +1346,12 @@ else
$stmt = "INSERT INTO vicidial_user_log (user,event,campaign_id,event_date,event_epoch,user_group) values('$VD_login','LOGIN','$VD_campaign','$NOW_TIME','$StarTtimE','$VU_user_group')";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'01031',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01031',$VD_login,$server_ip,$session_name,$one_mysql_log);}
##### check to see if the user has a conf extension already, this happens if they previously exited uncleanly
$stmt="SELECT conf_exten FROM vicidial_conferences where extension='$SIP_user' and server_ip = '$server_ip' LIMIT 1;";
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'01032',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01032',$VD_login,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";}
$prev_login_ct = mysql_num_rows($rslt);
$i=0;
@@ -1367,19 +1369,19 @@ else
$stmt="SELECT count(*) FROM vicidial_conferences where server_ip='$server_ip' and ((extension='') or (extension is null));";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'01033',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01033',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$row=mysql_fetch_row($rslt);
if ($row[0] > 0)
{
$stmt="UPDATE vicidial_conferences set extension='$SIP_user', leave_3way='0' where server_ip='$server_ip' and ((extension='') or (extension is null)) limit 1;";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'01034',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01034',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$stmt="SELECT conf_exten from vicidial_conferences where server_ip='$server_ip' and ( (extension='$SIP_user') or (extension='$user') );";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'01035',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01035',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$row=mysql_fetch_row($rslt);
$session_id = $row[0];
}
@@ -1390,28 +1392,28 @@ else
$stmt="UPDATE vicidial_list set status='ERI', user='' where status IN('QUEUE','INCALL') and user ='$VD_login';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'01036',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01036',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$affected_rows = mysql_affected_rows($link);
print "<!-- old QUEUE and INCALL reverted list: |$affected_rows| -->\n";
$stmt="DELETE from vicidial_hopper where status IN('QUEUE','INCALL','DONE') and user ='$VD_login';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'01037',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01037',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$affected_rows = mysql_affected_rows($link);
print "<!-- old QUEUE and INCALL reverted hopper: |$affected_rows| -->\n";
$stmt="DELETE from vicidial_live_agents where user ='$VD_login';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'01038',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01038',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$affected_rows = mysql_affected_rows($link);
print "<!-- old vicidial_live_agents records cleared: |$affected_rows| -->\n";
$stmt="DELETE from vicidial_live_inbound_agents where user ='$VD_login';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'01039',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01039',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$affected_rows = mysql_affected_rows($link);
print "<!-- old vicidial_live_inbound_agents records cleared: |$affected_rows| -->\n";
@@ -1425,7 +1427,7 @@ else
##### START SYSTEM_SETTINGS LOOKUP #####
$stmt = "SELECT enable_queuemetrics_logging,queuemetrics_server_ip,queuemetrics_dbname,queuemetrics_login,queuemetrics_pass,queuemetrics_log_id,vicidial_agent_disable,allow_sipsak_messages FROM system_settings;";
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'01040',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01040',$VD_login,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";}
$qm_conf_ct = mysql_num_rows($rslt);
$i=0;
@@ -1457,7 +1459,7 @@ else
$stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$SIqueryCID','Channel: $SIP_user_DiaL','Context: $ext_context','Exten: $session_id','Priority: 1','Callerid: $SIqueryCID','','','','','');";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'01041',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01041',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$affected_rows = mysql_affected_rows($link);
print "<!-- call placed to session_id: $session_id from phone: $SIP_user $SIP_user_DiaL -->\n";
@@ -1468,7 +1470,7 @@ else
##### grab the campaign_weight and number of calls today on that campaign for the agent
$stmt="SELECT campaign_weight,calls_today FROM vicidial_campaign_agents where user='$VD_login' and campaign_id = '$VD_campaign';";
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'01042',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01042',$VD_login,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";}
$vca_ct = mysql_num_rows($rslt);
if ($vca_ct > 0)
@@ -1485,7 +1487,7 @@ else
$stmt="INSERT INTO vicidial_campaign_agents (user,campaign_id,campaign_rank,campaign_weight,calls_today) values('$VD_login','$VD_campaign','0','0','$calls_today');";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'01043',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01043',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$affected_rows = mysql_affected_rows($link);
print "<!-- new vicidial_campaign_agents record inserted: |$affected_rows| -->\n";
}
@@ -1493,7 +1495,7 @@ else
$stmt="INSERT INTO vicidial_live_agents (user,server_ip,conf_exten,extension,status,lead_id,campaign_id,uniqueid,callerid,channel,random_id,last_call_time,last_update_time,last_call_finish,closer_campaigns,user_level,campaign_weight,calls_today) values('$VD_login','$server_ip','$session_id','$SIP_user','PAUSED','','$VD_campaign','','','','$random','$NOW_TIME','$tsNOW_TIME','$NOW_TIME','$closer_chooser_string','$user_level','$campaign_weight','$calls_today');";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'01044',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01044',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$affected_rows = mysql_affected_rows($link);
print "<!-- new vicidial_live_agents record inserted: |$affected_rows| -->\n";
@@ -1505,14 +1507,14 @@ else
$stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtimE',call_id='NONE',queue='NONE',agent='Agent/$VD_login',verb='AGENTLOGIN',data1='$VD_login@agents',serverid='$queuemetrics_log_id';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_query($stmt, $linkB);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$linkB,$mysql_error_logging,$stmt,'01045',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'01045',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$affected_rows = mysql_affected_rows($linkB);
print "<!-- queue_log AGENTLOGIN entry added: $VD_login|$affected_rows -->\n";
$stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtimE',call_id='NONE',queue='NONE',agent='Agent/$VD_login',verb='PAUSEALL',serverid='$queuemetrics_log_id';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_query($stmt, $linkB);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$linkB,$mysql_error_logging,$stmt,'01046',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'01046',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$affected_rows = mysql_affected_rows($linkB);
print "<!-- queue_log PAUSE entry added: $VD_login|$affected_rows -->\n";
@@ -1533,7 +1535,7 @@ else
$stmt="INSERT INTO vicidial_live_agents (user,server_ip,conf_exten,extension,status,lead_id,campaign_id,uniqueid,callerid,channel,random_id,last_call_time,last_update_time,last_call_finish,user_level) values('$VD_login','$server_ip','$session_id','$SIP_user','PAUSED','','$VD_campaign','','','','$random','$NOW_TIME','$tsNOW_TIME','$NOW_TIME','$user_level');";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'01047',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01047',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$affected_rows = mysql_affected_rows($link);
print "<!-- new vicidial_live_agents record inserted: |$affected_rows| -->\n";
@@ -1545,14 +1547,14 @@ else
$stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtimE',call_id='NONE',queue='$VD_campaign',agent='Agent/$VD_login',verb='AGENTLOGIN',data1='$VD_login@agents',serverid='$queuemetrics_log_id';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_query($stmt, $linkB);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$linkB,$mysql_error_logging,$stmt,'01048',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'01048',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$affected_rows = mysql_affected_rows($linkB);
print "<!-- queue_log AGENTLOGIN entry added: $VD_login|$affected_rows -->\n";
$stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtimE',call_id='NONE',queue='NONE',agent='Agent/$VD_login',verb='PAUSEALL',serverid='$queuemetrics_log_id';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_query($stmt, $linkB);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$linkB,$mysql_error_logging,$stmt,'01049',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'01049',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$affected_rows = mysql_affected_rows($linkB);
print "<!-- queue_log PAUSE entry added: $VD_login|$affected_rows -->\n";
@@ -1627,7 +1629,7 @@ else
$stmt="INSERT INTO vicidial_agent_log (user,server_ip,event_time,campaign_id,pause_epoch,pause_sec,wait_epoch,user_group,sub_status) values('$VD_login','$server_ip','$NOW_TIME','$VD_campaign','$StarTtimE','0','$StarTtimE','$VU_user_group','LOGIN');";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'01050',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01050',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$affected_rows = mysql_affected_rows($link);
$agent_log_id = mysql_insert_id($link);
print "<!-- vicidial_agent_log record inserted: |$affected_rows|$agent_log_id| -->\n";
@@ -1647,7 +1649,7 @@ else
##### grab the datails of all active scripts in the system
$stmt="SELECT script_id,script_name,script_text FROM vicidial_scripts WHERE active='Y' order by script_id limit 100;";
$rslt=mysql_query($stmt, $link);
if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'01051',$VD_login,$server_ip,$session_name);}
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01051',$VD_login,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";}
$MM_scripts = mysql_num_rows($rslt);
$e=0;
@@ -7827,14 +7829,15 @@ exit;
##### MySQL Error Logging #####
function mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,$query_id,$user,$server_ip,$session_name)
function mysql_error_logging($NOW_TIME,$link,$mel,$stmt,$query_id,$user,$server_ip,$session_name,$one_mysql_log)
{
# mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'00001',$user,$server_ip,$session_name);
$NOW_TIME = date("Y-m-d H:i:s");
# mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00001',$user,$server_ip,$session_name,$one_mysql_log);
$errno=''; $error='';
if ($mysql_error_logging > 0)
if ( ($mel > 0) or ($one_mysql_log > 0) )
{
$errno = mysql_errno($link);
if ( ($errno > 0) or ($mysql_error_logging > 1) )
if ( ($errno > 0) or ($mel > 1) or ($one_mysql_log > 0) )
{
$error = mysql_error($link);
$efp = fopen ("./vicidial_mysql_errors.txt", "a");
@@ -7842,6 +7845,8 @@ if ($mysql_error_logging > 0)
fclose($efp);
}
}
$one_mysql_log=0;
return $errno;
}
?>