diff --git a/agi/agi-VDAD_ALL_inbound.agi b/agi/agi-VDAD_ALL_inbound.agi index b6fbf3d4..4c22b761 100644 --- a/agi/agi-VDAD_ALL_inbound.agi +++ b/agi/agi-VDAD_ALL_inbound.agi @@ -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='--'; diff --git a/agi/agi-VDAD_ALL_outbound.agi b/agi/agi-VDAD_ALL_outbound.agi index 6adc0e70..db4edb17 100644 --- a/agi/agi-VDAD_ALL_outbound.agi +++ b/agi/agi-VDAD_ALL_outbound.agi @@ -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='--'; diff --git a/docs/BASE_INSTALL.txt b/docs/BASE_INSTALL.txt index 429ad2b1..cf2038c8 100644 --- a/docs/BASE_INSTALL.txt +++ b/docs/BASE_INSTALL.txt @@ -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. diff --git a/docs/REQUIRED_APPS_INSTALL.txt b/docs/REQUIRED_APPS_INSTALL.txt index 95459b53..668eadab 100644 --- a/docs/REQUIRED_APPS_INSTALL.txt +++ b/docs/REQUIRED_APPS_INSTALL.txt @@ -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 diff --git a/docs/conf_examples/zapata.conf.t100p.sample b/docs/conf_examples/zapata.conf.t100p.sample index 1117086e..caa219a9 100644 --- a/docs/conf_examples/zapata.conf.t100p.sample +++ b/docs/conf_examples/zapata.conf.t100p.sample @@ -6,7 +6,7 @@ [channels] group=1 language=en -signalling=pri_net +signalling=pri_cpe usecallerid=yes callerid=asreceived callprogress=no diff --git a/www/agc/conf_exten_check.php b/www/agc/conf_exten_check.php index 651528af..30372102 100644 --- a/www/agc/conf_exten_check.php +++ b/www/agc/conf_exten_check.php @@ -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 " $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 " $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 " $stmt="UPDATE vicidial_live_agents set random_id='$random' where user='$user' and server_ip='$server_ip';"; if ($format=='debug') {echo "\n";} $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 " $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 " $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 = "Calls in Queue: $RingCalls";} @@ -248,7 +259,7 @@ echo " $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 " $stmt="UPDATE vicidial_live_agents set random_id='$random' where user='$user' and server_ip='$server_ip';"; if ($format=='debug') {echo "\n";} $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 " $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and extension = '$conf_exten';"; if ($format=='debug') {echo "\n";} $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 " $stmt="SELECT channel FROM live_channels where server_ip = '$server_ip' and extension = '$conf_exten';"; if ($format=='debug') {echo "\n";} $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 " $stmt="UPDATE conferences set extension='$exten' where server_ip = '$server_ip' and conf_exten = '$conf_exten';"; if ($format=='debug') {echo "\n";} $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; } ?> diff --git a/www/agc/manager_send.php b/www/agc/manager_send.php index 74cb31a8..8f4ce315 100644 --- a/www/agc/manager_send.php +++ b/www/agc/manager_send.php @@ -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";} $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";} $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";} $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";} $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";} $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";} $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";} $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";} $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";} $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";} 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";} $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";} $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";} } @@ -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";} $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";} $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";} $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";} $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";} $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";} $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";} $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";} $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";} $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";} $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";} $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";} $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";} $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";} $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";} $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";} $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";} $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";} $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";} $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";} $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";} $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";} $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";} $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";} $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";} $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";} $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";} $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";} $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";} $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";} $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";} $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";} $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";} $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";} $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";} $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";} $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";} $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";} $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";} $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";} $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";} $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";} $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";} $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";} $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";} $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";} $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";} $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";} $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";} $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";} $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";} $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";} $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";} $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";} $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";} $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; } ?> diff --git a/www/agc/vdc_db_query.php b/www/agc/vdc_db_query.php index 2d66eb40..b7553c8e 100644 --- a/www/agc/vdc_db_query.php +++ b/www/agc/vdc_db_query.php @@ -168,12 +168,14 @@ # 81011-1404 - Fixed bugs in leave3way when transferring a manual dial call # 81020-1459 - Fixed bugs in queue_log logging # 81104-0134 - Added mysql error logging capability +# 81104-1617 - Added multi-retry for some vicidial_live_agents table MySQL queries # -$version = '2.0.5-86'; -$build = '81104-0134'; -$mysql_error_logging=1; +$version = '2.0.5-87'; +$build = '81104-1617'; +$mel=1; # Mysql Error Log enabled = 1 $mysql_log_count=180; +$one_mysql_log=0; require("dbconnect.php"); @@ -342,7 +344,7 @@ $agents='@agents'; ##### 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,'00001',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00001',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} $qm_conf_ct = mysql_num_rows($rslt); $i=0; @@ -380,7 +382,7 @@ else 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,'00002',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00002',$user,$server_ip,$session_name,$one_mysql_log);} $row=mysql_fetch_row($rslt); $auth=$row[0]; @@ -401,7 +403,7 @@ else $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,'00003',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00003',$user,$server_ip,$session_name,$one_mysql_log);} $row=mysql_fetch_row($rslt); $SNauth=$row[0]; if($SNauth==0) @@ -451,7 +453,7 @@ if ($ACTION == 'LogiNCamPaigns') $stmt="SELECT user_group from vicidial_users where user='$user' and pass='$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,'00004',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00004',$user,$server_ip,$session_name,$one_mysql_log);} $row=mysql_fetch_row($rslt); $VU_user_group=$row[0]; @@ -459,7 +461,7 @@ if ($ACTION == 'LogiNCamPaigns') $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,'00005',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00005',$user,$server_ip,$session_name,$one_mysql_log);} $row=mysql_fetch_row($rslt); if ( (!eregi("ALL-CAMPAIGNS",$row[0])) ) { @@ -470,7 +472,7 @@ if ($ACTION == 'LogiNCamPaigns') $stmt="SELECT campaign_id,campaign_name from vicidial_campaigns where active='Y' $LOGallowed_campaignsSQL order by campaign_id"; $rslt=mysql_query($stmt, $link); - if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'00006',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00006',$user,$server_ip,$session_name,$one_mysql_log);} $camps_to_print = mysql_num_rows($rslt); $o=0; @@ -507,7 +509,7 @@ if ($ACTION == 'regCLOSER') { $stmt="SELECT closer_campaigns FROM vicidial_users where user='$user' LIMIT 1;"; $rslt=mysql_query($stmt, $link); - if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'00007',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00007',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} $row=mysql_fetch_row($rslt); $closer_choice =$row[0]; @@ -515,30 +517,30 @@ if ($ACTION == 'regCLOSER') $stmt="UPDATE vicidial_live_agents set closer_campaigns='$closer_choice' where user='$user' and server_ip='$server_ip';"; if ($format=='debug') {echo "\n";} $rslt=mysql_query($stmt, $link); - if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'00008',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00008',$user,$server_ip,$session_name,$one_mysql_log);} } else { $stmt="UPDATE vicidial_live_agents set closer_campaigns='$closer_choice' where user='$user' and server_ip='$server_ip';"; if ($format=='debug') {echo "\n";} $rslt=mysql_query($stmt, $link); - if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'00009',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00009',$user,$server_ip,$session_name,$one_mysql_log);} $stmt="UPDATE vicidial_users set closer_campaigns='$closer_choice' where user='$user';"; if ($format=='debug') {echo "\n";} $rslt=mysql_query($stmt, $link); - if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'00010',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00010',$user,$server_ip,$session_name,$one_mysql_log);} } $stmt="INSERT INTO vicidial_user_closer_log set user='$user',campaign_id='$campaign',event_date='$NOW_TIME',blended='$closer_blended',closer_campaigns='$closer_choice';"; if ($format=='debug') {echo "\n";} $rslt=mysql_query($stmt, $link); - if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'00011',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00011',$user,$server_ip,$session_name,$one_mysql_log);} $stmt="DELETE FROM vicidial_live_inbound_agents where user='$user';"; if ($format=='debug') {echo "\n";} $rslt=mysql_query($stmt, $link); - if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'00012',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00012',$user,$server_ip,$session_name,$one_mysql_log);} $in_groups_pre = preg_replace('/-$/','',$closer_choice); $in_groups = explode(" ",$in_groups_pre); @@ -550,7 +552,7 @@ if ($ACTION == 'regCLOSER') { $stmt="SELECT group_weight,calls_today FROM vicidial_inbound_group_agents where user='$user' and group_id='$in_groups[$k]';"; $rslt=mysql_query($stmt, $link); - if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'00013',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00013',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} $viga_ct = mysql_num_rows($rslt); if ($viga_ct > 0) @@ -567,7 +569,7 @@ if ($ACTION == 'regCLOSER') $stmt="INSERT INTO vicidial_live_inbound_agents set user='$user',group_id='$in_groups[$k]',group_weight='$group_weight',calls_today='$calls_today',last_call_time='$NOW_TIME',last_call_finish='$NOW_TIME';"; if ($format=='debug') {echo "\n";} $rslt=mysql_query($stmt, $link); - if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'00014',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00014',$user,$server_ip,$session_name,$one_mysql_log);} } $k++; } @@ -600,7 +602,7 @@ if ($ACTION == 'manDiaLnextCaLL') ##### grab number of calls today in this campaign and increment $stmt="SELECT calls_today FROM vicidial_live_agents WHERE user='$user' and campaign_id='$campaign';"; $rslt=mysql_query($stmt, $link); - if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'00015',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00015',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} $vla_cc_ct = mysql_num_rows($rslt); if ($vla_cc_ct > 0) @@ -621,7 +623,7 @@ if ($ACTION == 'manDiaLnextCaLL') $stmt = "UPDATE vicidial_callbacks set status='INACTIVE' where callback_id='$callback_id';"; 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,'00016',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00016',$user,$server_ip,$session_name,$one_mysql_log);} } else { @@ -631,7 +633,7 @@ if ($ACTION == 'manDiaLnextCaLL') { $stmt="SELECT count(*) FROM vicidial_dnc where phone_number='$phone_number';"; $rslt=mysql_query($stmt, $link); - if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'00017',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00017',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} $row=mysql_fetch_row($rslt); @@ -642,7 +644,7 @@ if ($ACTION == 'manDiaLnextCaLL') } $stmt="SELECT count(*) FROM vicidial_campaign_dnc where phone_number='$phone_number' and campaign_id='$campaign';"; $rslt=mysql_query($stmt, $link); - if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'00018',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00018',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} $row=mysql_fetch_row($rslt); @@ -656,7 +658,7 @@ if ($ACTION == 'manDiaLnextCaLL') { $stmt="SELECT list_id,active from vicidial_lists where campaign_id='$campaign'"; $rslt=mysql_query($stmt, $link); - if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'00019',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00019',$user,$server_ip,$session_name,$one_mysql_log);} $lists_to_parse = mysql_num_rows($rslt); $camp_lists=''; $o=0; @@ -671,7 +673,7 @@ if ($ACTION == 'manDiaLnextCaLL') $stmt="SELECT count(*) FROM vicidial_list where phone_number='$phone_number' and list_id IN($camp_lists);"; $rslt=mysql_query($stmt, $link); - if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'00020',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00020',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} $row=mysql_fetch_row($rslt); @@ -685,7 +687,7 @@ if ($ACTION == 'manDiaLnextCaLL') { $stmt="SELECT lead_id FROM vicidial_list where phone_number='$phone_number' order by modify_date desc LIMIT 1;"; $rslt=mysql_query($stmt, $link); - if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'00021',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00021',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} $man_leadID_ct = mysql_num_rows($rslt); if ($man_leadID_ct > 0) @@ -701,7 +703,7 @@ if ($ACTION == 'manDiaLnextCaLL') $stmt = "INSERT INTO vicidial_list SET phone_code='$phone_code',phone_number='$phone_number',list_id='$list_id',status='QUEUE',user='$user',called_since_last_reset='Y',entry_date='$ENTRYdate',last_local_call_time='$NOW_TIME';"; 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,'00022',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00022',$user,$server_ip,$session_name,$one_mysql_log);} $affected_rows = mysql_affected_rows($link); $lead_id = mysql_insert_id($link); $CBleadIDset=1; @@ -713,7 +715,7 @@ if ($ACTION == 'manDiaLnextCaLL') $stmt = "INSERT INTO vicidial_list SET phone_code='$phone_code',phone_number='$phone_number',list_id='$list_id',status='QUEUE',user='$user',called_since_last_reset='Y',entry_date='$ENTRYdate',last_local_call_time='$NOW_TIME';"; 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,'00023',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00023',$user,$server_ip,$session_name,$one_mysql_log);} $affected_rows = mysql_affected_rows($link); $lead_id = mysql_insert_id($link); $CBleadIDset=1; @@ -725,7 +727,7 @@ if ($ACTION == 'manDiaLnextCaLL') $stmt = "UPDATE vicidial_hopper set status='QUEUE', user='$user' where campaign_id='$campaign' and status='READY' order by priority desc,hopper_id LIMIT 1"; 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,'00024',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00024',$user,$server_ip,$session_name,$one_mysql_log);} $affected_rows = mysql_affected_rows($link); } } @@ -737,7 +739,7 @@ if ($ACTION == 'manDiaLnextCaLL') ##### grab the lead_id of the reserved user in vicidial_hopper $stmt="SELECT lead_id FROM vicidial_hopper where campaign_id='$campaign' and status='QUEUE' and user='$user' LIMIT 1;"; $rslt=mysql_query($stmt, $link); - if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'00025',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00025',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} $hopper_leadID_ct = mysql_num_rows($rslt); if ($hopper_leadID_ct > 0) @@ -750,7 +752,7 @@ if ($ACTION == 'manDiaLnextCaLL') ##### grab the data from vicidial_list for the lead_id $stmt="SELECT * FROM vicidial_list where lead_id='$lead_id' LIMIT 1;"; $rslt=mysql_query($stmt, $link); - if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'00026',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00026',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} $list_lead_ct = mysql_num_rows($rslt); if ($list_lead_ct > 0) @@ -792,7 +794,7 @@ if ($ACTION == 'manDiaLnextCaLL') ##### check if system is set to generate logfile for transfers $stmt="SELECT enable_agc_xfer_log FROM system_settings;"; $rslt=mysql_query($stmt, $link); - if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'00027',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00027',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} $enable_agc_xfer_log_ct = mysql_num_rows($rslt); if ($enable_agc_xfer_log_ct > 0) @@ -825,7 +827,7 @@ if ($ACTION == 'manDiaLnextCaLL') { $stmt="SELECT entry_time,callback_time,user,comments FROM vicidial_callbacks where lead_id='$lead_id' order by callback_id desc LIMIT 1;"; $rslt=mysql_query($stmt, $link); - if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'00028',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00028',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} $cb_record_ct = mysql_num_rows($rslt); if ($cb_record_ct > 0) @@ -840,7 +842,7 @@ if ($ACTION == 'manDiaLnextCaLL') $stmt = "SELECT local_gmt FROM servers where active='Y' limit 1;"; $rslt=mysql_query($stmt, $link); - if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'00029',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00029',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} $server_ct = mysql_num_rows($rslt); if ($server_ct > 0) @@ -863,7 +865,7 @@ if ($ACTION == 'manDiaLnextCaLL') $stmt = "UPDATE vicidial_list set status='INCALL', called_since_last_reset='$called_since_last_reset', called_count='$called_count',user='$user',last_local_call_time='$LLCT_DATE' where lead_id='$lead_id';"; 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,'00030',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00030',$user,$server_ip,$session_name,$one_mysql_log);} if (!$CBleadIDset) { @@ -871,13 +873,13 @@ if ($ACTION == 'manDiaLnextCaLL') $stmt = "DELETE FROM vicidial_hopper where lead_id='$lead_id';"; 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,'00031',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00031',$user,$server_ip,$session_name,$one_mysql_log);} } $stmt="UPDATE vicidial_agent_log set lead_id='$lead_id',comments='MANUAL' where agent_log_id='$agent_log_id';"; if ($format=='debug') {echo "\n";} $rslt=mysql_query($stmt, $link); - if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'00032',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00032',$user,$server_ip,$session_name,$one_mysql_log);} ### if preview dialing, do not send the call if ( (strlen($preview)<1) || ($preview == 'NO') ) @@ -914,30 +916,30 @@ if ($ACTION == 'manDiaLnextCaLL') $stmt = "INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$MqueryCID','Exten: $Ndialstring','Context: $ext_context','Channel: $local_DEF$conf_exten$local_AMP$ext_context$Local_persist','Priority: 1','Callerid: $CIDstring','Timeout: $Local_dial_timeout','','','','');"; 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,'00033',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00033',$user,$server_ip,$session_name,$one_mysql_log);} $stmt = "INSERT INTO vicidial_auto_calls (server_ip,campaign_id,status,lead_id,callerid,phone_code,phone_number,call_time,call_type) values('$server_ip','$campaign','XFER','$lead_id','$MqueryCID','$phone_code','$phone_number','$NOW_TIME','OUT')"; 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,'00034',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00034',$user,$server_ip,$session_name,$one_mysql_log);} ### update the agent status to INCALL in vicidial_live_agents $stmt = "UPDATE vicidial_live_agents set status='INCALL',last_call_time='$NOW_TIME',callerid='$MqueryCID',lead_id='$lead_id',comments='MANUAL',calls_today='$calls_today',external_hangup=0,external_status='' 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,'00035',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00035',$user,$server_ip,$session_name,$one_mysql_log);} ### update calls_today count in vicidial_campaign_agents $stmt = "UPDATE vicidial_campaign_agents set calls_today='$calls_today' where user='$user' and campaign_id='$campaign';"; 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,'00036',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00036',$user,$server_ip,$session_name,$one_mysql_log);} ############################################# ##### 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,'00037',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00037',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} $qm_conf_ct = mysql_num_rows($rslt); $i=0; @@ -963,21 +965,21 @@ if ($ACTION == 'manDiaLnextCaLL') $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='NONE',queue='NONE',agent='Agent/$user',verb='UNPAUSEALL',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,'00038',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00038',$user,$server_ip,$session_name,$one_mysql_log);} $affected_rows = mysql_affected_rows($linkB); # ENTERQUEUE $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='$MqueryCID',queue='$campaign',agent='NONE',verb='ENTERQUEUE',data2='$phone_number',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,'00039',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00039',$user,$server_ip,$session_name,$one_mysql_log);} $affected_rows = mysql_affected_rows($linkB); # CONNECT $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='$MqueryCID',queue='$campaign',agent='Agent/$user',verb='CONNECT',data1='0',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,'00040',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00040',$user,$server_ip,$session_name,$one_mysql_log);} $affected_rows = mysql_affected_rows($linkB); mysql_close($linkB); @@ -1056,7 +1058,7 @@ if ($ACTION == 'alt_phone_change') $stmt = "UPDATE vicidial_list_alt_phones set active='$stage' where lead_id='$lead_id' and phone_number='$phone_number' and alt_phone_count='$called_count';"; 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,'00041',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00041',$user,$server_ip,$session_name,$one_mysql_log);} echo "ALT PHONE NUMBER STATUS CHANGED\n"; } @@ -1086,7 +1088,7 @@ if ($ACTION == 'manDiaLskip') $stmt = "UPDATE vicidial_list set status='$stage', called_count='$called_count',user='$user' where lead_id='$lead_id';"; 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,'00042',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00042',$user,$server_ip,$session_name,$one_mysql_log);} echo "LEAD REVERTED\n"; @@ -1115,7 +1117,7 @@ if ($ACTION == 'manDiaLonly') ##### grab number of calls today in this campaign and increment $stmt="SELECT calls_today FROM vicidial_live_agents WHERE user='$user' and campaign_id='$campaign';"; $rslt=mysql_query($stmt, $link); - if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'00043',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00043',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} $vla_cc_ct = mysql_num_rows($rslt); if ($vla_cc_ct > 0) @@ -1158,23 +1160,32 @@ if ($ACTION == 'manDiaLonly') $stmt = "INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$MqueryCID','Exten: $Ndialstring','Context: $ext_context','Channel: $local_DEF$conf_exten$local_AMP$ext_context$Local_persist','Priority: 1','Callerid: $CIDstring','Timeout: $Local_dial_timeout','','','','');"; 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,'00044',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00044',$user,$server_ip,$session_name,$one_mysql_log);} $stmt = "INSERT INTO vicidial_auto_calls (server_ip,campaign_id,status,lead_id,callerid,phone_code,phone_number,call_time,call_type) values('$server_ip','$campaign','XFER','$lead_id','$MqueryCID','$phone_code','$phone_number','$NOW_TIME','OUT')"; 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,'00045',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00045',$user,$server_ip,$session_name,$one_mysql_log);} ### update the agent status to INCALL in vicidial_live_agents $stmt = "UPDATE vicidial_live_agents set status='INCALL',last_call_time='$NOW_TIME',callerid='$MqueryCID',lead_id='$lead_id',comments='MANUAL',calls_today='$calls_today',external_hangup=0,external_status='' 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,'00046',$user,$server_ip,$session_name);} + if ($mel > 0) {$errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00046',$user,$server_ip,$session_name,$one_mysql_log);} + $retry_count=0; + while ( ($errno > 0) and ($retry_count < 9) ) + { + $rslt=mysql_query($stmt, $link); + $one_mysql_log=1; + $errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,"9046$retry_count",$user,$server_ip,$session_name,$one_mysql_log); + $one_mysql_log=0; + $retry_count++; + } $stmt = "UPDATE vicidial_campaign_agents set calls_today='$calls_today' where user='$user' and campaign_id='$campaign';"; 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,'00047',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00047',$user,$server_ip,$session_name,$one_mysql_log);} echo "$MqueryCID\n"; @@ -1182,7 +1193,7 @@ if ($ACTION == 'manDiaLonly') ##### 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,'00048',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00048',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} $qm_conf_ct = mysql_num_rows($rslt); $i=0; @@ -1208,21 +1219,21 @@ if ($ACTION == 'manDiaLonly') $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='NONE',queue='NONE',agent='Agent/$user',verb='UNPAUSEALL',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,'00049',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00049',$user,$server_ip,$session_name,$one_mysql_log);} $affected_rows = mysql_affected_rows($linkB); # ENTERQUEUE $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='$MqueryCID',queue='$campaign',agent='NONE',verb='ENTERQUEUE',data2='$phone_number',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,'00050',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00050',$user,$server_ip,$session_name,$one_mysql_log);} $affected_rows = mysql_affected_rows($linkB); # CONNECT $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='$MqueryCID',queue='$campaign',agent='Agent/$user',verb='CONNECT',data1='0',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,'00051',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00051',$user,$server_ip,$session_name,$one_mysql_log);} $affected_rows = mysql_affected_rows($linkB); mysql_close($linkB); @@ -1251,7 +1262,7 @@ else ##### look for the channel in the UPDATED vicidial_manager record of the call initiation $stmt="SELECT uniqueid,channel FROM vicidial_manager where callerid='$MDnextCID' and server_ip='$server_ip' and status='UPDATED' LIMIT 1;"; $rslt=mysql_query($stmt, $link); - if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'00052',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00052',$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) @@ -1265,7 +1276,7 @@ else $stmt = "select wait_epoch,wait_sec from vicidial_agent_log where agent_log_id='$agent_log_id';"; 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,'00053',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00053',$user,$server_ip,$session_name,$one_mysql_log);} $VDpr_ct = mysql_num_rows($rslt); if ($VDpr_ct > 0) { @@ -1275,12 +1286,12 @@ else $stmt="UPDATE vicidial_agent_log set wait_sec='$wait_sec',wait_epoch='$StarTtime',talk_epoch='$StarTtime',lead_id='$lead_id' where agent_log_id='$agent_log_id';"; if ($format=='debug') {echo "\n";} $rslt=mysql_query($stmt, $link); - if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'00054',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00054',$user,$server_ip,$session_name,$one_mysql_log);} $stmt="UPDATE vicidial_auto_calls set uniqueid='$uniqueid',channel='$channel' where callerid='$MDnextCID';"; if ($format=='debug') {echo "\n";} $rslt=mysql_query($stmt, $link); - if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'00055',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00055',$user,$server_ip,$session_name,$one_mysql_log);} } else { @@ -1315,7 +1326,7 @@ if ($stage == "start") $user_group=''; $stmt="SELECT user_group FROM vicidial_users where user='$user' LIMIT 1;"; $rslt=mysql_query($stmt, $link); - if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'00056',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00056',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} $ug_record_ct = mysql_num_rows($rslt); if ($ug_record_ct > 0) @@ -1327,7 +1338,7 @@ if ($stage == "start") $stmt="INSERT INTO vicidial_log (uniqueid,lead_id,list_id,campaign_id,call_date,start_epoch,status,phone_code,phone_number,user,comments,processed,user_group,alt_dial) values('$uniqueid','$lead_id','$list_id','$campaign','$NOW_TIME','$StarTtime','INCALL','$phone_code','$phone_number','$user','MANUAL','N','$user_group','$alt_dial');"; 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,'00057',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00057',$user,$server_ip,$session_name,$one_mysql_log);} $affected_rows = mysql_affected_rows($link); if ($affected_rows > 0) @@ -1343,7 +1354,7 @@ if ($stage == "start") $stmt = "UPDATE vicidial_auto_calls SET uniqueid='$uniqueid' where lead_id='$lead_id';"; 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,'00058',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00058',$user,$server_ip,$session_name,$one_mysql_log);} # ##### insert log into call_log for manual VICIDiaL call # $stmt = "INSERT INTO call_log (uniqueid,channel,server_ip,extension,number_dialed,caller_code,start_time,start_epoch) values('$uniqueid','$channel','$server_ip','$exten','$phone_code$phone_number','MD $user $lead_id','$NOW_TIME','$StarTtime')"; @@ -1368,7 +1379,7 @@ if ($stage == "end") $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,'00059',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00059',$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) @@ -1410,7 +1421,7 @@ if ($stage == "end") $VDIDselect = "VDL_UIDLID $uniqueid $lead_id"; } $rslt=mysql_query($stmt, $link); - if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'00060',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00060',$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) @@ -1436,7 +1447,7 @@ if ($stage == "end") ##### start epoch in the vicidial_log table, couldn't find one in vicidial_closer_log $stmt="SELECT start_epoch,term_reason,campaign_id FROM vicidial_log where uniqueid='$uniqueid' and lead_id='$lead_id' 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,'00061',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00061',$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) @@ -1464,7 +1475,7 @@ if ($stage == "end") $stmt = "UPDATE vicidial_closer_log set end_epoch='$StarTtime', length_in_sec='$length_in_sec' where lead_id='$lead_id' and user='$user' and call_date > \"$four_hours_ago\" order by call_date desc limit 1;"; 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,'00062',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00062',$user,$server_ip,$session_name,$one_mysql_log);} $affected_rows = mysql_affected_rows($link); if ($affected_rows > 0) { @@ -1482,7 +1493,7 @@ if ($stage == "end") ##### 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,'00063',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00063',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} $qm_conf_ct = mysql_num_rows($rslt); $i=0; @@ -1510,7 +1521,7 @@ if ($stage == "end") ### check to see if campaign has alt_dial enabled $stmt="SELECT auto_alt_dial FROM vicidial_campaigns where campaign_id='$campaign';"; $rslt=mysql_query($stmt, $link); - if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'00064',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00064',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} $VAC_mancall_ct = mysql_num_rows($rslt); if ($VAC_mancall_ct > 0) @@ -1529,7 +1540,7 @@ if ($stage == "end") $alt_dial_skip=0; $stmt="SELECT alt_phone,gmt_offset_now,state FROM vicidial_list where lead_id='$lead_id';"; $rslt=mysql_query($stmt, $link); - if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'00065',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00065',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} $VAC_mancall_ct = mysql_num_rows($rslt); if ($VAC_mancall_ct > 0) @@ -1547,7 +1558,7 @@ if ($stage == "end") { $stmtA="SELECT count(*) FROM vicidial_dnc where phone_number='$alt_phone';"; $rslt=mysql_query($stmt, $link); - if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmtA,'00066',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmtA,'00066',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} $VLAP_dnc_ct = mysql_num_rows($rslt); if ($VLAP_dnc_ct > 0) @@ -1561,7 +1572,7 @@ if ($stage == "end") { $stmtA="SELECT count(*) FROM vicidial_campaign_dnc where phone_number='$alt_phone' and campaign_id='$campaign';"; $rslt=mysql_query($stmt, $link); - if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmtA,'00067',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmtA,'00067',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} $VLAP_cdnc_ct = mysql_num_rows($rslt); if ($VLAP_cdnc_ct > 0) @@ -1576,7 +1587,7 @@ if ($stage == "end") $stmt = "INSERT INTO vicidial_hopper SET lead_id='$lead_id',campaign_id='$campaign',status='HOLD',list_id='$list_id',gmt_offset_now='$gmt_offset_now',state='$state',alt_dial='ALT',user='',priority='25';"; 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,'00068',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00068',$user,$server_ip,$session_name,$one_mysql_log);} } else {$alt_dial_skip=1;} @@ -1592,7 +1603,7 @@ if ($stage == "end") $addr3_dial_skip=0; $stmt="SELECT address3,gmt_offset_now,state FROM vicidial_list where lead_id='$lead_id';"; $rslt=mysql_query($stmt, $link); - if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'00069',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00069',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} $VAC_mancall_ct = mysql_num_rows($rslt); if ($VAC_mancall_ct > 0) @@ -1610,7 +1621,7 @@ if ($stage == "end") { $stmtA="SELECT count(*) FROM vicidial_dnc where phone_number='$address3';"; $rslt=mysql_query($stmt, $link); - if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmtA,'00070',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmtA,'00070',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} $VLAP_dnc_ct = mysql_num_rows($rslt); if ($VLAP_dnc_ct > 0) @@ -1624,7 +1635,7 @@ if ($stage == "end") { $stmtA="SELECT count(*) FROM vicidial_campaign_dnc where phone_number='$address3' and campaign_id='$campaign';"; $rslt=mysql_query($stmt, $link); - if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmtA,'00071',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmtA,'00071',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} $VLAP_cdnc_ct = mysql_num_rows($rslt); if ($VLAP_cdnc_ct > 0) @@ -1639,7 +1650,7 @@ if ($stage == "end") $stmt = "INSERT INTO vicidial_hopper SET lead_id='$lead_id',campaign_id='$campaign',status='HOLD',list_id='$list_id',gmt_offset_now='$gmt_offset_now',state='$state',alt_dial='ADDR3',user='',priority='20';"; 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,'00072',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00072',$user,$server_ip,$session_name,$one_mysql_log);} } else {$addr3_dial_skip=1;} @@ -1665,7 +1676,7 @@ if ($stage == "end") $stmt="SELECT gmt_offset_now,state,list_id FROM vicidial_list where lead_id='$lead_id';"; $rslt=mysql_query($stmt, $link); - if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'00073',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00073',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} $VL_deailts_ct = mysql_num_rows($rslt); if ($VL_deailts_ct > 0) @@ -1678,7 +1689,7 @@ if ($stage == "end") $alt_dial_phones_count=0; $stmt="SELECT count(*) FROM vicidial_list_alt_phones where lead_id='$lead_id';"; $rslt=mysql_query($stmt, $link); - if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'00074',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00074',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} $VLAP_ct = mysql_num_rows($rslt); if ($VLAP_ct > 0) @@ -1691,7 +1702,7 @@ if ($stage == "end") $Xlast++; $stmt="SELECT alt_phone_id,phone_number,active FROM vicidial_list_alt_phones where lead_id='$lead_id' and alt_phone_count='$Xlast';"; $rslt=mysql_query($stmt, $link); - if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'00075',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00075',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} $VLAP_detail_ct = mysql_num_rows($rslt); if ($VLAP_detail_ct > 0) @@ -1710,7 +1721,7 @@ if ($stage == "end") { $stmtA="SELECT count(*) FROM vicidial_dnc where phone_number='$VD_altdial_phone';"; $rslt=mysql_query($stmt, $link); - if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmtA,'00076',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmtA,'00076',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} $VLAP_dnc_ct = mysql_num_rows($rslt); if ($VLAP_dnc_ct > 0) @@ -1724,7 +1735,7 @@ if ($stage == "end") { $stmtA="SELECT count(*) FROM vicidial_campaign_dnc where phone_number='$VD_altdial_phone' and campaign_id='$campaign';"; $rslt=mysql_query($stmt, $link); - if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmtA,'00077',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmtA,'00077',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} $VLAP_cdnc_ct = mysql_num_rows($rslt); if ($VLAP_cdnc_ct > 0) @@ -1740,7 +1751,7 @@ if ($stage == "end") $stmt = "INSERT INTO vicidial_hopper SET lead_id='$lead_id',campaign_id='$campaign',status='HOLD',list_id='$EA_list_id',gmt_offset_now='$EA_gmt_offset_now',state='$EA_state',alt_dial='X$Xlast',user='',priority='15';"; 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,'00078',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00078',$user,$server_ip,$session_name,$one_mysql_log);} $Xlast=9999999999; } } @@ -1753,7 +1764,7 @@ if ($stage == "end") ### 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 lead_id='$lead_id' 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,'00079',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00079',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} $VAC_qm_ct = mysql_num_rows($rslt); if ($VAC_qm_ct > 0) @@ -1776,7 +1787,7 @@ if ($stage == "end") $stmt="SELECT count(*) from queue_log where call_id='$MDnextCID' and verb='COMPLETECALLER' and queue='$VDcampaign_id';"; $rslt=mysql_query($stmt, $linkB); - if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$linkB,$mysql_error_logging,$stmt,'00080',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00080',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} $VAC_cc_ct = mysql_num_rows($rslt); if ($VAC_cc_ct > 0) @@ -1800,12 +1811,22 @@ if ($stage == "end") $stmt = "DELETE from vicidial_auto_calls where lead_id='$lead_id' and campaign_id='$VDcampaign_id' and uniqueid='$uniqueid';"; 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,'00081',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00081',$user,$server_ip,$session_name,$one_mysql_log);} $stmt = "UPDATE vicidial_live_agents set status='PAUSED',uniqueid=0,callerid='',channel='',call_server_ip='',last_call_finish='$NOW_TIME',comments='' 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,'00082',$user,$server_ip,$session_name);} + if ($mel > 0) {$errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00082',$user,$server_ip,$session_name,$one_mysql_log);} + $retry_count=0; + while ( ($errno > 0) and ($retry_count < 9) ) + { + $rslt=mysql_query($stmt, $link); + $one_mysql_log=1; + $errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,"9082$retry_count",$user,$server_ip,$session_name,$one_mysql_log); + $one_mysql_log=0; + $retry_count++; + } + $affected_rows = mysql_affected_rows($link); if ($affected_rows > 0) { @@ -1814,7 +1835,7 @@ if ($stage == "end") $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='NONE',queue='NONE',agent='Agent/$user',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,'00083',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00083',$user,$server_ip,$session_name,$one_mysql_log);} $affected_rows = mysql_affected_rows($linkB); } } @@ -1826,7 +1847,7 @@ if ($stage == "end") ### check to see if lead should be alt_dialed $stmt="SELECT auto_call_id,lead_id,phone_number,status,campaign_id,phone_code,alt_dial,stage,callerid,uniqueid from vicidial_auto_calls where lead_id='$lead_id' order by call_time desc limit 1;"; $rslt=mysql_query($stmt, $link); - if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'00084',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00084',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} $VAC_qm_ct = mysql_num_rows($rslt); if ($VAC_qm_ct > 0) @@ -1850,7 +1871,7 @@ if ($stage == "end") $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='$MDnextCID',queue='$VDcampaign_id',agent='Agent/$user',verb='COMPLETEAGENT',data1='$CLstage',data2='$length_in_sec',data3='1',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,'00085',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00085',$user,$server_ip,$session_name,$one_mysql_log);} $affected_rows = mysql_affected_rows($linkB); } @@ -1858,12 +1879,22 @@ if ($stage == "end") $stmt = "DELETE from vicidial_auto_calls where lead_id='$lead_id' and campaign_id='$VDcampaign_id' and callerid LIKE \"M%\";"; 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,'00086',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00086',$user,$server_ip,$session_name,$one_mysql_log);} $stmt = "UPDATE vicidial_live_agents set status='PAUSED',uniqueid=0,callerid='',channel='',call_server_ip='',last_call_finish='$NOW_TIME',comments='' 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,'00087',$user,$server_ip,$session_name);} + if ($mel > 0) {$errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00087',$user,$server_ip,$session_name,$one_mysql_log);} + $retry_count=0; + while ( ($errno > 0) and ($retry_count < 9) ) + { + $rslt=mysql_query($stmt, $link); + $one_mysql_log=1; + $errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,"9087$retry_count",$user,$server_ip,$session_name,$one_mysql_log); + $one_mysql_log=0; + $retry_count++; + } + $affected_rows = mysql_affected_rows($link); if ($affected_rows > 0) { @@ -1872,7 +1903,7 @@ if ($stage == "end") $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='NONE',queue='NONE',agent='Agent/$user',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,'00088',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00088',$user,$server_ip,$session_name,$one_mysql_log);} $affected_rows = mysql_affected_rows($linkB); } } @@ -1887,7 +1918,7 @@ if ($stage == "end") ### check to see if lead should be alt_dialed $stmt="SELECT term_reason,uniqueid from vicidial_log where uniqueid='$uniqueid' and lead_id='$lead_id' 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,'00089',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00089',$user,$server_ip,$session_name,$one_mysql_log);} $VAC_qm_ct = mysql_num_rows($rslt); if ($VAC_qm_ct > 0) { @@ -1910,7 +1941,7 @@ if ($stage == "end") $stmt="UPDATE vicidial_log set $SQLterm end_epoch='$StarTtime', length_in_sec='$length_in_sec' where uniqueid='$uniqueid' and lead_id='$lead_id' and user='$user' order by call_date desc limit 1;"; 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,'00090',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00090',$user,$server_ip,$session_name,$one_mysql_log);} $affected_rows = mysql_affected_rows($link); if ($affected_rows > 0) @@ -1932,7 +1963,7 @@ if ($stage == "end") ### check to see if lead should be alt_dialed $stmt="SELECT term_reason,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,'00091',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00091',$user,$server_ip,$session_name,$one_mysql_log);} $VAC_qm_ct = mysql_num_rows($rslt); if ($VAC_qm_ct > 0) { @@ -1952,18 +1983,21 @@ if ($stage == "end") } } - ##### update the duration and end time in the vicidial_log table - $stmt="UPDATE vicidial_closer_log set $SQLterm where lead_id='$lead_id' and call_date > \"$four_hours_ago\" order by call_date desc limit 1;"; - 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,'00092',$user,$server_ip,$session_name);} - $affected_rows = mysql_affected_rows($link); + if (strlen($SQLterm) > 0) + { + ##### update the duration and end time in the vicidial_log table + $stmt="UPDATE vicidial_closer_log set $SQLterm where lead_id='$lead_id' and call_date > \"$four_hours_ago\" order by call_date desc limit 1;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00092',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($link); + } if ( (strlen($QL_term) > 0) and ($leaving_threeway > 0) ) { $stmt="SELECT count(*) from queue_log where call_id='$MDnextCID' and verb='COMPLETEAGENT' and queue='$VDcampaign_id';"; $rslt=mysql_query($stmt, $linkB); - if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$linkB,$mysql_error_logging,$stmt,'00093',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00093',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} $VAC_cc_ct = mysql_num_rows($rslt); if ($VAC_cc_ct > 0) @@ -1976,7 +2010,7 @@ if ($stage == "end") $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='$MDnextCID',queue='$VDcampaign_id',agent='Agent/$user',verb='COMPLETEAGENT',data1='$CLstage',data2='$length_in_sec',data3='1',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,'00094',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00094',$user,$server_ip,$session_name,$one_mysql_log);} $affected_rows = mysql_affected_rows($linkB); } } @@ -1998,7 +2032,7 @@ if ($stage == "end") $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and extension = '$conf_exten' order by channel desc;"; if ($format=='debug') {echo "\n";} $rslt=mysql_query($stmt, $link); - if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'00095',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00095',$user,$server_ip,$session_name,$one_mysql_log);} if ($rslt) {$rec_list = mysql_num_rows($rslt);} while ($rec_list>$loop_count) { @@ -2036,7 +2070,7 @@ if ($stage == "end") $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Hangup','CH12346$StarTtime$loop_count','Channel: $hangup_channels[$loop_count]','','','','','','','','','');"; if ($format=='debug') {echo "\n";} $rslt=mysql_query($stmt, $link); - if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'00096',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00096',$user,$server_ip,$session_name,$one_mysql_log);} } $loop_count++; } @@ -2048,7 +2082,7 @@ if ($stage == "end") $stmt="SELECT cmd_line_f FROM vicidial_manager where server_ip='$server_ip' and action='Originate' and cmd_line_b = 'Channel: $local_DEF$conf_silent_prefix$conf_exten$local_AMP$ext_context' order by entry_date desc limit $total_rec;"; if ($format=='debug') {echo "\n";} $rslt=mysql_query($stmt, $link); - if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'00097',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00097',$user,$server_ip,$session_name,$one_mysql_log);} if ($rslt) {$recFN_list = mysql_num_rows($rslt);} while ($recFN_list>$loop_count) { @@ -2067,7 +2101,7 @@ if ($stage == "end") $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Hangup','RH12345$StarTtime$loop_count','Channel: $rec_channels[$loop_count]','','','','','','','','','');"; if ($format=='debug') {echo "\n";} $rslt=mysql_query($stmt, $link); - if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'00098',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00098',$user,$server_ip,$session_name,$one_mysql_log);} echo "REC_STOP|$rec_channels[$loop_count]|$filename[$loop_count]|"; if (strlen($filename)>2) @@ -2075,7 +2109,7 @@ if ($stage == "end") $stmt="SELECT recording_id,start_epoch,vicidial_id,lead_id FROM recording_log where filename='$filename[$loop_count]'"; if ($format=='debug') {echo "\n";} $rslt=mysql_query($stmt, $link); - if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'00099',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00099',$user,$server_ip,$session_name,$one_mysql_log);} if ($rslt) {$fn_count = mysql_num_rows($rslt);} if ($fn_count) { @@ -2108,7 +2142,7 @@ if ($stage == "end") $stmt="UPDATE recording_log set end_time='$NOW_TIME',end_epoch='$StarTtime',length_in_sec=$length_in_sec,length_in_min='$length_in_min' $vidSQL $lidSQL where filename='$filename[$loop_count]' and end_epoch is NULL;"; if ($format=='debug') {echo "\n";} $rslt=mysql_query($stmt, $link); - if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'00100',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00100',$user,$server_ip,$session_name,$one_mysql_log);} echo "$recording_id|$length_in_min|"; @@ -2131,7 +2165,7 @@ if ($stage == "end") $stmt = "select talk_epoch,talk_sec from vicidial_agent_log where agent_log_id='$agent_log_id';"; 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,'00101',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00101',$user,$server_ip,$session_name,$one_mysql_log);} $VDpr_ct = mysql_num_rows($rslt); if ($VDpr_ct > 0) { @@ -2141,7 +2175,7 @@ if ($stage == "end") $stmt="UPDATE vicidial_agent_log set talk_sec='$talk_sec',talk_epoch='$StarTtime',dispo_epoch='$StarTtime' where agent_log_id='$agent_log_id';"; if ($format=='debug') {echo "\n";} $rslt=mysql_query($stmt, $link); - if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'00102',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00102',$user,$server_ip,$session_name,$one_mysql_log);} } } @@ -2170,7 +2204,7 @@ if ($ACTION == 'VDADREcheckINCOMING') $stmt = "SELECT lead_id,uniqueid,callerid,channel,call_server_ip FROM vicidial_live_agents where server_ip = '$server_ip' and user='$user' and campaign_id='$campaign' and lead_id='$lead_id';"; 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,'00103',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00103',$user,$server_ip,$session_name,$one_mysql_log);} $queue_leadID_ct = mysql_num_rows($rslt); if ($queue_leadID_ct > 0) @@ -2220,7 +2254,7 @@ if ($ACTION == 'VDADcheckINCOMING') $stmt = "SELECT lead_id,uniqueid,callerid,channel,call_server_ip,comments FROM vicidial_live_agents where server_ip = '$server_ip' and user='$user' and campaign_id='$campaign' and status='QUEUE';"; 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,'00104',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00104',$user,$server_ip,$session_name,$one_mysql_log);} $queue_leadID_ct = mysql_num_rows($rslt); if ($queue_leadID_ct > 0) @@ -2239,7 +2273,7 @@ if ($ACTION == 'VDADcheckINCOMING') ##### grab number of calls today in this campaign and increment $stmt="SELECT calls_today FROM vicidial_live_agents WHERE user='$user' and campaign_id='$campaign';"; $rslt=mysql_query($stmt, $link); - if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'00105',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00105',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} $vla_cc_ct = mysql_num_rows($rslt); if ($vla_cc_ct > 0) @@ -2255,17 +2289,26 @@ if ($ACTION == 'VDADcheckINCOMING') $stmt = "UPDATE vicidial_live_agents set status='INCALL',last_call_time='$NOW_TIME',calls_today='$calls_today',external_hangup=0,external_status='' 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,'00106',$user,$server_ip,$session_name);} + if ($mel > 0) {$errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00106',$user,$server_ip,$session_name,$one_mysql_log);} + $retry_count=0; + while ( ($errno > 0) and ($retry_count < 9) ) + { + $rslt=mysql_query($stmt, $link); + $one_mysql_log=1; + $errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,"9106$retry_count",$user,$server_ip,$session_name,$one_mysql_log); + $one_mysql_log=0; + $retry_count++; + } $stmt = "UPDATE vicidial_campaign_agents set calls_today='$calls_today' where user='$user' and campaign_id='$campaign';"; 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,'00107',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00107',$user,$server_ip,$session_name,$one_mysql_log);} ##### grab the data from vicidial_list for the lead_id $stmt="SELECT * FROM vicidial_list where lead_id='$lead_id' LIMIT 1;"; $rslt=mysql_query($stmt, $link); - if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'00108',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00108',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} $list_lead_ct = mysql_num_rows($rslt); if ($list_lead_ct > 0) @@ -2310,7 +2353,7 @@ if ($ACTION == 'VDADcheckINCOMING') { $stmt="SELECT entry_time,callback_time,user,comments FROM vicidial_callbacks where lead_id='$lead_id' order by callback_id desc LIMIT 1;"; $rslt=mysql_query($stmt, $link); - if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'00109',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00109',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} $cb_record_ct = mysql_num_rows($rslt); if ($cb_record_ct > 0) @@ -2327,13 +2370,13 @@ if ($ACTION == 'VDADcheckINCOMING') $stmt = "UPDATE vicidial_list set status='INCALL', user='$user' where lead_id='$lead_id';"; 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,'00110',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00110',$user,$server_ip,$session_name,$one_mysql_log);} ### update the log status to INCALL $user_group=''; $stmt="SELECT user_group FROM vicidial_users where user='$user' LIMIT 1;"; $rslt=mysql_query($stmt, $link); - if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'00111',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00111',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} $ug_record_ct = mysql_num_rows($rslt); if ($ug_record_ct > 0) @@ -2346,7 +2389,7 @@ if ($ACTION == 'VDADcheckINCOMING') $stmt = "select campaign_id,phone_number,alt_dial,call_type from vicidial_auto_calls where callerid = '$callerid' order by call_time desc limit 1;"; 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,'00112',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00112',$user,$server_ip,$session_name,$one_mysql_log);} $VDAC_cid_ct = mysql_num_rows($rslt); if ($VDAC_cid_ct > 0) { @@ -2371,12 +2414,12 @@ if ($ACTION == 'VDADcheckINCOMING') $stmt = "UPDATE vicidial_log set user='$user', comments='AUTO', list_id='$list_id', status='INCALL', user_group='$user_group' where lead_id='$lead_id' and uniqueid='$uniqueid';"; 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,'00113',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00113',$user,$server_ip,$session_name,$one_mysql_log);} $stmt = "select campaign_script,get_call_launch,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number from vicidial_campaigns where campaign_id='$campaign';"; 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,'00114',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00114',$user,$server_ip,$session_name,$one_mysql_log);} $VDIG_cid_ct = mysql_num_rows($rslt); if ($VDIG_cid_ct > 0) { @@ -2393,7 +2436,7 @@ if ($ACTION == 'VDADcheckINCOMING') $stmt = "select phone_number,alt_dial from vicidial_auto_calls where callerid = '$callerid' order by call_time desc limit 1;"; 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,'00115',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00115',$user,$server_ip,$session_name,$one_mysql_log);} $VDAC_cid_ct = mysql_num_rows($rslt); if ($VDAC_cid_ct > 0) { @@ -2415,7 +2458,7 @@ if ($ACTION == 'VDADcheckINCOMING') 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,'00116',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00116',$user,$server_ip,$session_name,$one_mysql_log);} $VLAP_ct = mysql_num_rows($rslt); if ($VLAP_ct > 0) { @@ -2434,12 +2477,12 @@ if ($ACTION == 'VDADcheckINCOMING') $stmt = "UPDATE vicidial_closer_log set user='$user', comments='AUTO', list_id='$list_id', status='INCALL', user_group='$user_group' where lead_id='$lead_id' order by closecallid desc limit 1;"; 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,'00117',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00117',$user,$server_ip,$session_name,$one_mysql_log);} $stmt = "select count(*) from vicidial_log where lead_id='$lead_id' and uniqueid='$uniqueid';"; 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,'00118',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00118',$user,$server_ip,$session_name,$one_mysql_log);} $VDL_cid_ct = mysql_num_rows($rslt); if ($VDL_cid_ct > 0) { @@ -2450,7 +2493,7 @@ if ($ACTION == 'VDADcheckINCOMING') $stmt = "select group_name,group_color,web_form_address,fronter_display,ingroup_script,get_call_launch,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number,default_xfer_group,ingroup_recording_override,ingroup_rec_filename from vicidial_inbound_groups where group_id='$VDADchannel_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,'00119',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00119',$user,$server_ip,$session_name,$one_mysql_log);} $VDIG_cid_ct = mysql_num_rows($rslt); if ($VDIG_cid_ct > 0) { @@ -2473,7 +2516,7 @@ if ($ACTION == 'VDADcheckINCOMING') $stmt = "UPDATE vicidial_live_agents set comments='INBOUND' 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,'00120',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00120',$user,$server_ip,$session_name,$one_mysql_log);} $Ctype = 'I'; } @@ -2482,7 +2525,7 @@ if ($ACTION == 'VDADcheckINCOMING') $stmt = "select campaign_script,get_call_launch,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number from vicidial_campaigns where campaign_id='$VDADchannel_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,'00121',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00121',$user,$server_ip,$session_name,$one_mysql_log);} $VDIG_cid_ct = mysql_num_rows($rslt); if ($VDIG_cid_ct > 0) { @@ -2503,7 +2546,7 @@ if ($ACTION == 'VDADcheckINCOMING') $stmt = "SELECT full_name from vicidial_users where user='$tsr';"; 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,'00122',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00122',$user,$server_ip,$session_name,$one_mysql_log);} $VDU_cid_ct = mysql_num_rows($rslt); if ($VDU_cid_ct > 0) { @@ -2567,7 +2610,7 @@ if ($ACTION == 'VDADcheckINCOMING') $stmt = "select wait_epoch,wait_sec from vicidial_agent_log where agent_log_id='$agent_log_id';"; 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,'00123',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00123',$user,$server_ip,$session_name,$one_mysql_log);} $VDpr_ct = mysql_num_rows($rslt); if ($VDpr_ct > 0) { @@ -2577,7 +2620,7 @@ if ($ACTION == 'VDADcheckINCOMING') $stmt="UPDATE vicidial_agent_log set wait_sec='$wait_sec',talk_epoch='$StarTtime',lead_id='$lead_id' where agent_log_id='$agent_log_id';"; if ($format=='debug') {echo "\n";} $rslt=mysql_query($stmt, $link); - if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'00124',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00124',$user,$server_ip,$session_name,$one_mysql_log);} ### If CALLBK, change vicidial_callback record to INACTIVE if (eregi("CALLBK|CBHOLD", $dispo)) @@ -2585,13 +2628,13 @@ if ($ACTION == 'VDADcheckINCOMING') $stmt="UPDATE vicidial_callbacks set status='INACTIVE' where lead_id='$lead_id' and status NOT IN('INACTIVE','DEAD','ARCHIVE');"; if ($format=='debug') {echo "\n";} $rslt=mysql_query($stmt, $link); - if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'00125',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00125',$user,$server_ip,$session_name,$one_mysql_log);} } ##### check if system is set to generate logfile for transfers $stmt="SELECT enable_agc_xfer_log FROM system_settings;"; $rslt=mysql_query($stmt, $link); - if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'00126',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00126',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} $enable_agc_xfer_log_ct = mysql_num_rows($rslt); if ($enable_agc_xfer_log_ct > 0) @@ -2639,7 +2682,7 @@ else $user_group=''; $stmt="SELECT user_group FROM vicidial_users where user='$user' LIMIT 1;"; $rslt=mysql_query($stmt, $link); - if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'00127',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00127',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} $ug_record_ct = mysql_num_rows($rslt); if ($ug_record_ct > 0) @@ -2651,7 +2694,7 @@ else $stmt="INSERT INTO vicidial_user_log (user,event,campaign_id,event_date,event_epoch,user_group) values('$user','LOGOUT','$campaign','$NOW_TIME','$StarTtime','$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,'00128',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00128',$user,$server_ip,$session_name,$one_mysql_log);} $vul_insert = mysql_affected_rows($link); if ($no_delete_sessions < 1) @@ -2660,7 +2703,7 @@ else $stmt="UPDATE vicidial_conferences set extension='' where server_ip='$server_ip' and conf_exten='$conf_exten';"; 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,'00129',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00129',$user,$server_ip,$session_name,$one_mysql_log);} $vc_remove = mysql_affected_rows($link); } @@ -2668,28 +2711,37 @@ else $stmt="DELETE from vicidial_live_agents where server_ip='$server_ip' and user ='$user';"; 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,'00130',$user,$server_ip,$session_name);} + if ($mel > 0) {$errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00130',$user,$server_ip,$session_name,$one_mysql_log);} + $retry_count=0; + while ( ($errno > 0) and ($retry_count < 9) ) + { + $rslt=mysql_query($stmt, $link); + $one_mysql_log=1; + $errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,"9130$retry_count",$user,$server_ip,$session_name,$one_mysql_log); + $one_mysql_log=0; + $retry_count++; + } $vla_delete = mysql_affected_rows($link); ##### Delete the vicidial_live_inbound_agents records for this session $stmt="DELETE from vicidial_live_inbound_agents where user ='$user';"; 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,'00131',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00131',$user,$server_ip,$session_name,$one_mysql_log);} $vlia_delete = mysql_affected_rows($link); ##### Delete the web_client_sessions $stmt="DELETE from web_client_sessions where server_ip='$server_ip' and session_name ='$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,'00132',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00132',$user,$server_ip,$session_name,$one_mysql_log);} $wcs_delete = mysql_affected_rows($link); ##### Hangup the client phone $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$protocol/$extension%\" order by channel desc;"; if ($format=='debug') {echo "\n";} $rslt=mysql_query($stmt, $link); - if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'00133',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00133',$user,$server_ip,$session_name,$one_mysql_log);} if ($rslt) { $row=mysql_fetch_row($rslt); @@ -2698,7 +2750,7 @@ else $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Hangup','ULGH3459$StarTtime','Channel: $agent_channel','','','','','','','','','');"; if ($format=='debug') {echo "\n";} $rslt=mysql_query($stmt, $link); - if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'00134',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00134',$user,$server_ip,$session_name,$one_mysql_log);} } if ($LogouTKicKAlL > 0) @@ -2711,14 +2763,14 @@ else $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$queryCID','Channel: $kick_local_channel','Context: $ext_context','Exten: 8300','Priority: 1','Callerid: $queryCID','','','','$channel','$exten');"; if ($format=='debug') {echo "\n";} $rslt=mysql_query($stmt, $link); - if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'00135',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00135',$user,$server_ip,$session_name,$one_mysql_log);} } $pause_sec=0; $stmt = "select pause_epoch,pause_sec,wait_epoch,talk_epoch,dispo_epoch from vicidial_agent_log where agent_log_id='$agent_log_id';"; 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,'00136',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00136',$user,$server_ip,$session_name,$one_mysql_log);} $VDpr_ct = mysql_num_rows($rslt); if ( ($VDpr_ct > 0) and (strlen($row[3]<5)) and (strlen($row[4]<5)) ) { @@ -2728,7 +2780,7 @@ else $stmt="UPDATE vicidial_agent_log set pause_sec='$pause_sec',wait_epoch='$StarTtime' where agent_log_id='$agent_log_id';"; if ($format=='debug') {echo "\n";} $rslt=mysql_query($stmt, $link); - if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'00137',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00137',$user,$server_ip,$session_name,$one_mysql_log);} } if ($vla_delete > 0) @@ -2737,7 +2789,7 @@ else ##### START QUEUEMETRICS LOGGING LOOKUP ##### $stmt = "SELECT enable_queuemetrics_logging,queuemetrics_server_ip,queuemetrics_dbname,queuemetrics_login,queuemetrics_pass,queuemetrics_log_id,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,'00138',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00138',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} $qm_conf_ct = mysql_num_rows($rslt); $i=0; @@ -2774,7 +2826,7 @@ else $stmt = "SELECT time_id FROM queue_log where agent='Agent/$user' and verb='AGENTLOGIN' order by time_id desc limit 1;"; $rslt=mysql_query($stmt, $linkB); - if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$linkB,$mysql_error_logging,$stmt,'00139',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00139',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} echo "$stmt\n"; $li_conf_ct = mysql_num_rows($rslt); @@ -2792,7 +2844,7 @@ else $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='NONE',queue='NONE',agent='Agent/$user',verb='AGENTLOGOFF',data1='$user$agents',data2='$time_logged_in',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,'00140',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00140',$user,$server_ip,$session_name,$one_mysql_log);} $affected_rows = mysql_affected_rows($linkB); mysql_close($linkB); @@ -2823,31 +2875,40 @@ if ($ACTION == 'updateDISPO') $stmt = "UPDATE vicidial_live_agents set lead_id='',external_hangup=0,external_status='' 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,'00141',$user,$server_ip,$session_name);} + if ($mel > 0) {$errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00141',$user,$server_ip,$session_name,$one_mysql_log);} + $retry_count=0; + while ( ($errno > 0) and ($retry_count < 9) ) + { + $rslt=mysql_query($stmt, $link); + $one_mysql_log=1; + $errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,"9141$retry_count",$user,$server_ip,$session_name,$one_mysql_log); + $one_mysql_log=0; + $retry_count++; + } $stmt="UPDATE vicidial_list set status='$dispo_choice', user='$user' where lead_id='$lead_id';"; if ($format=='debug') {echo "\n";} $rslt=mysql_query($stmt, $link); - if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'00142',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00142',$user,$server_ip,$session_name,$one_mysql_log);} $stmt = "select count(*) from vicidial_inbound_groups where group_id='$stage';"; if ($format=='debug') {echo "\n";} $rslt=mysql_query($stmt, $link); - if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'00143',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00143',$user,$server_ip,$session_name,$one_mysql_log);} $row=mysql_fetch_row($rslt); if ($row[0] > 0) { $stmt = "UPDATE vicidial_closer_log set status='$dispo_choice' where lead_id='$lead_id' and user='$user' order by closecallid desc limit 1;"; 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,'00144',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00144',$user,$server_ip,$session_name,$one_mysql_log);} } else { $stmt="UPDATE vicidial_log set status='$dispo_choice' where lead_id='$lead_id' and user='$user' order by uniqueid desc limit 1;"; if ($format=='debug') {echo "\n";} $rslt=mysql_query($stmt, $link); - if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'00145',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00145',$user,$server_ip,$session_name,$one_mysql_log);} } if ( ($use_internal_dnc=='Y') and ($dispo_choice=='DNC') ) @@ -2855,11 +2916,11 @@ if ($ACTION == 'updateDISPO') $stmt = "select phone_number from vicidial_list where lead_id='$lead_id';"; 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,'00146',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00146',$user,$server_ip,$session_name,$one_mysql_log);} $row=mysql_fetch_row($rslt); $stmt="INSERT INTO vicidial_dnc (phone_number) values('$row[0]');"; $rslt=mysql_query($stmt, $link); - if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'00147',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00147',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} } if ( ($use_campaign_dnc=='Y') and ($dispo_choice=='DNC') ) @@ -2867,11 +2928,11 @@ if ($ACTION == 'updateDISPO') $stmt = "select phone_number from vicidial_list where lead_id='$lead_id';"; 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,'00148',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00148',$user,$server_ip,$session_name,$one_mysql_log);} $row=mysql_fetch_row($rslt); $stmt="INSERT INTO vicidial_campaign_dnc (phone_number,campaign_id) values('$row[0]','$campaign');"; $rslt=mysql_query($stmt, $link); - if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'00149',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00149',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} } } @@ -2881,7 +2942,7 @@ if ($ACTION == 'updateDISPO') $stmt = "select dispo_epoch,dispo_sec from vicidial_agent_log where agent_log_id='$agent_log_id';"; 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,'00150',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00150',$user,$server_ip,$session_name,$one_mysql_log);} $VDpr_ct = mysql_num_rows($rslt); if ($VDpr_ct > 0) { @@ -2891,12 +2952,12 @@ if ($ACTION == 'updateDISPO') $stmt="UPDATE vicidial_agent_log set dispo_sec='$dispo_sec',dispo_epoch='$StarTtime',status='$dispo_choice' where agent_log_id='$agent_log_id';"; if ($format=='debug') {echo "\n";} $rslt=mysql_query($stmt, $link); - if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'00151',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00151',$user,$server_ip,$session_name,$one_mysql_log);} $user_group=''; $stmt="SELECT user_group FROM vicidial_users where user='$user' LIMIT 1;"; $rslt=mysql_query($stmt, $link); - if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'00152',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00152',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} $ug_record_ct = mysql_num_rows($rslt); if ($ug_record_ct > 0) @@ -2908,22 +2969,23 @@ if ($ACTION == 'updateDISPO') $stmt="INSERT INTO vicidial_agent_log (user,server_ip,event_time,campaign_id,pause_epoch,pause_sec,wait_epoch,user_group) values('$user','$server_ip','$NOW_TIME','$campaign','$StarTtime','0','$StarTtime','$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,'00153',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00153',$user,$server_ip,$session_name,$one_mysql_log);} $affected_rows = mysql_affected_rows($link); $agent_log_id = mysql_insert_id($link); ### CALLBACK ENTRY if ( ($dispo_choice == 'CBHOLD') and (strlen($CallBackDatETimE)>10) ) { + $comments = eregi_replace("'",'',$comments); $stmt="INSERT INTO vicidial_callbacks (lead_id,list_id,campaign_id,status,entry_time,callback_time,user,recipient,comments,user_group) values('$lead_id','$list_id','$campaign','ACTIVE','$NOW_TIME','$CallBackDatETimE','$user','$recipient','$comments','$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,'00154',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00154',$user,$server_ip,$session_name,$one_mysql_log);} } $stmt="SELECT auto_alt_dial_statuses from vicidial_campaigns where campaign_id='$campaign';"; $rslt=mysql_query($stmt, $link); - if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'00155',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00155',$user,$server_ip,$session_name,$one_mysql_log);} $row=mysql_fetch_row($rslt); if ( ($auto_dial_level > 0) and (ereg(" $dispo_choice ",$row[0])) ) @@ -2931,7 +2993,7 @@ if ($ACTION == 'updateDISPO') $stmt = "select count(*) from vicidial_hopper where lead_id='$lead_id' and status='HOLD';"; 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,'00156',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00156',$user,$server_ip,$session_name,$one_mysql_log);} $row=mysql_fetch_row($rslt); if ($row[0] > 0) @@ -2939,7 +3001,7 @@ if ($ACTION == 'updateDISPO') $stmt="UPDATE vicidial_hopper set status='READY' where lead_id='$lead_id' and status='HOLD' limit 1;"; if ($format=='debug') {echo "\n";} $rslt=mysql_query($stmt, $link); - if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'00157',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00157',$user,$server_ip,$session_name,$one_mysql_log);} } } else @@ -2947,14 +3009,14 @@ if ($ACTION == 'updateDISPO') $stmt="DELETE from vicidial_hopper where lead_id='$lead_id' and status='HOLD';"; if ($format=='debug') {echo "\n";} $rslt=mysql_query($stmt, $link); - if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'00158',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00158',$user,$server_ip,$session_name,$one_mysql_log);} } ############################################# ##### 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,'00159',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00159',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} $qm_conf_ct = mysql_num_rows($rslt); $i=0; @@ -2982,7 +3044,7 @@ if ($ACTION == 'updateDISPO') $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='$MDnextCID',queue='$stage',agent='Agent/$user',verb='CALLSTATUS',data1='$dispo_choice',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,'00160',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00160',$user,$server_ip,$session_name,$one_mysql_log);} $affected_rows = mysql_affected_rows($linkB); mysql_close($linkB); @@ -3011,7 +3073,7 @@ if ($ACTION == 'updateLEAD') $stmt = "SELECT disable_alter_custdata,disable_alter_custphone FROM vicidial_campaigns where campaign_id='$campaign'"; $rslt=mysql_query($stmt, $link); - if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'00161',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00161',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} $dac_conf_ct = mysql_num_rows($rslt); $i=0; @@ -3035,7 +3097,7 @@ if ($ACTION == 'updateLEAD') } $stmt = "SELECT alter_custdata_override,alter_custphone_override FROM vicidial_users where user='$user'"; $rslt=mysql_query($stmt, $link); - if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'00162',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00162',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} $aco_conf_ct = mysql_num_rows($rslt); $i=0; @@ -3072,14 +3134,23 @@ if ($ACTION == 'updateLEAD') $stmt="UPDATE vicidial_list set vendor_lead_code='" . mysql_real_escape_string($vendor_lead_code) . "', title='" . mysql_real_escape_string($title) . "', first_name='" . mysql_real_escape_string($first_name) . "', middle_initial='" . mysql_real_escape_string($middle_initial) . "', last_name='" . mysql_real_escape_string($last_name) . "', address1='" . mysql_real_escape_string($address1) . "', address2='" . mysql_real_escape_string($address2) . "', address3='" . mysql_real_escape_string($address3) . "', city='" . mysql_real_escape_string($city) . "', state='" . mysql_real_escape_string($state) . "', province='" . mysql_real_escape_string($province) . "', postal_code='" . mysql_real_escape_string($postal_code) . "', country_code='" . mysql_real_escape_string($country_code) . "', gender='" . mysql_real_escape_string($gender) . "', date_of_birth='" . mysql_real_escape_string($date_of_birth) . "', alt_phone='" . mysql_real_escape_string($alt_phone) . "', email='" . mysql_real_escape_string($email) . "', security_phrase='" . mysql_real_escape_string($security_phrase) . "', comments='" . mysql_real_escape_string($comments) . "' $phoneSQL where lead_id='$lead_id';"; if ($format=='debug') {echo "\n";} $rslt=mysql_query($stmt, $link); - if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'00163',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00163',$user,$server_ip,$session_name,$one_mysql_log);} } $random = (rand(1000000, 9999999) + 10000000); $stmt="UPDATE vicidial_live_agents set random_id='$random' where user='$user' and server_ip='$server_ip';"; if ($format=='debug') {echo "\n";} $rslt=mysql_query($stmt, $link); - if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'00164',$user,$server_ip,$session_name);} + if ($mel > 0) {$errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00164',$user,$server_ip,$session_name,$one_mysql_log);} + $retry_count=0; + while ( ($errno > 0) and ($retry_count < 9) ) + { + $rslt=mysql_query($stmt, $link); + $one_mysql_log=1; + $errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,"9164$retry_count",$user,$server_ip,$session_name,$one_mysql_log); + $one_mysql_log=0; + $retry_count++; + } } echo "Lead $lead_id information has$DO_NOT_UPDATE_text been updated\n"; @@ -3105,12 +3176,30 @@ if ( ($ACTION == 'VDADpause') || ($ACTION == 'VDADready') ) $stmt="UPDATE vicidial_live_agents set uniqueid=0,callerid='',channel='', random_id='$random',comments='' where user='$user' and server_ip='$server_ip';"; if ($format=='debug') {echo "\n";} $rslt=mysql_query($stmt, $link); - if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'00165',$user,$server_ip,$session_name);} + if ($mel > 0) {$errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00165',$user,$server_ip,$session_name,$one_mysql_log);} + $retry_count=0; + while ( ($errno > 0) and ($retry_count < 9) ) + { + $rslt=mysql_query($stmt, $link); + $one_mysql_log=1; + $errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,"9165$retry_count",$user,$server_ip,$session_name,$one_mysql_log); + $one_mysql_log=0; + $retry_count++; + } $stmt="UPDATE vicidial_live_agents set status='$stage' where user='$user' and server_ip='$server_ip';"; if ($format=='debug') {echo "\n";} $rslt=mysql_query($stmt, $link); - if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'00166',$user,$server_ip,$session_name);} + if ($mel > 0) {$errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00166',$user,$server_ip,$session_name,$one_mysql_log);} + $retry_count=0; + while ( ($errno > 0) and ($retry_count < 9) ) + { + $rslt=mysql_query($stmt, $link); + $one_mysql_log=1; + $errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,"9166$retry_count",$user,$server_ip,$session_name,$one_mysql_log); + $one_mysql_log=0; + $retry_count++; + } $affected_rows = mysql_affected_rows($link); if ($affected_rows > 0) { @@ -3118,7 +3207,7 @@ if ( ($ACTION == 'VDADpause') || ($ACTION == 'VDADready') ) ##### 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,'00167',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00167',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} $qm_conf_ct = mysql_num_rows($rslt); $i=0; @@ -3145,7 +3234,7 @@ if ( ($ACTION == 'VDADpause') || ($ACTION == 'VDADready') ) $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='NONE',queue='NONE',agent='Agent/$user',verb='$QMstatus',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,'00168',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00168',$user,$server_ip,$session_name,$one_mysql_log);} $affected_rows = mysql_affected_rows($linkB); mysql_close($linkB); @@ -3160,7 +3249,7 @@ if ( ($ACTION == 'VDADpause') || ($ACTION == 'VDADready') ) $stmt = "select pause_epoch,pause_sec,wait_epoch,wait_sec,dispo_epoch from vicidial_agent_log where agent_log_id='$agent_log_id';"; 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,'00169',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00169',$user,$server_ip,$session_name,$one_mysql_log);} $VDpr_ct = mysql_num_rows($rslt); if ($VDpr_ct > 0) { @@ -3181,14 +3270,14 @@ if ( ($ACTION == 'VDADpause') || ($ACTION == 'VDADready') ) $stmt="UPDATE vicidial_agent_log set pause_sec='$pause_sec',wait_epoch='$StarTtime' where agent_log_id='$agent_log_id';"; if ($format=='debug') {echo "\n";} $rslt=mysql_query($stmt, $link); - if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'00170',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00170',$user,$server_ip,$session_name,$one_mysql_log);} } if ($ACTION == 'VDADpause') { $stmt="UPDATE vicidial_agent_log set pause_epoch='$StarTtime',wait_sec='$wait_sec' where agent_log_id='$agent_log_id';"; if ($format=='debug') {echo "\n";} $rslt=mysql_query($stmt, $link); - if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'00171',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00171',$user,$server_ip,$session_name,$one_mysql_log);} } } } @@ -3213,7 +3302,7 @@ if ($ACTION == 'UpdatEFavoritEs') $stmt = "select count(*) from phone_favorites where extension='$exten' 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,'00172',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00172',$user,$server_ip,$session_name,$one_mysql_log);} $row=mysql_fetch_row($rslt); if ($row[0] > 0) @@ -3221,14 +3310,14 @@ if ($ACTION == 'UpdatEFavoritEs') $stmt="UPDATE phone_favorites set extensions_list=\"$favorites_list\" where extension='$exten' and server_ip='$server_ip';"; if ($format=='debug') {echo "\n";} $rslt=mysql_query($stmt, $link); - if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'00173',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00173',$user,$server_ip,$session_name,$one_mysql_log);} } else { $stmt="INSERT INTO phone_favorites values('$exten','$server_ip',\"$favorites_list\");"; if ($format=='debug') {echo "\n";} $rslt=mysql_query($stmt, $link); - if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'00174',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00174',$user,$server_ip,$session_name,$one_mysql_log);} } } echo "Favorites list has been updated to $favorites_list for $exten\n"; @@ -3251,7 +3340,7 @@ if ($ACTION == 'PauseCodeSubmit') $stmt="UPDATE vicidial_agent_log set sub_status=\"$status\" where agent_log_id='$agent_log_id';"; if ($format=='debug') {echo "\n";} $rslt=mysql_query($stmt, $link); - if ($mysql_error_logging > 0) {mysql_error_logging($NOW_TIME,$link,$mysql_error_logging,$stmt,'00175',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00175',$user,$server_ip,$session_name,$one_mysql_log);} $affected_rows = mysql_affected_rows($link); if ($affected_rows > 0) { @@ -3259,7 +3348,7 @@ if ($ACTION == 'PauseCodeSubmit') ##### START QUEUEMETRICS LOGGING LOOKUP ##### $stmt = "SELECT enable_queuemetrics_logging,queuemetrics_server_ip,queuemetrics_dbname,queuemetrics_login,queuemetrics_pass,queuemetrics_log_id,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,'00176',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00176',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} $qm_conf_ct = mysql_num_rows($rslt); $i=0; @@ -3290,7 +3379,7 @@ if ($ACTION == 'PauseCodeSubmit') $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='NONE',queue='$campaign',agent='Agent/$user',verb='PAUSEREASON',serverid='$queuemetrics_log_id',data1='$status';"; 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,'00177',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00177',$user,$server_ip,$session_name,$one_mysql_log);} $affected_rows = mysql_affected_rows($linkB); mysql_close($linkB); @@ -3309,7 +3398,7 @@ if ($ACTION == 'CalLBacKLisT') $stmt = "select callback_id,lead_id,campaign_id,status,entry_time,callback_time,comments from vicidial_callbacks where recipient='USERONLY' and user='$user' and campaign_id='$campaign' and status NOT IN('INACTIVE','DEAD') order by callback_time;"; 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,'00178',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00178',$user,$server_ip,$session_name,$one_mysql_log);} if ($rslt) {$callbacks_count = mysql_num_rows($rslt);} echo "$callbacks_count\n"; $loop_count=0; @@ -3331,7 +3420,7 @@ $loop_count=0; $stmt = "select first_name,last_name,phone_number from vicidial_list where lead_id='$lead_id[$loop_count]';"; 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,'00179',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00179',$user,$server_ip,$session_name,$one_mysql_log);} $row=mysql_fetch_row($rslt); echo "$row[0] ~$row[1] ~$row[2] ~$callback_id[$loop_count] ~$lead_id[$loop_count] ~$campaign_id[$loop_count] ~$status[$loop_count] ~$entry_time[$loop_count] ~$callback_time[$loop_count] ~$comments[$loop_count]\n"; @@ -3349,7 +3438,7 @@ if ($ACTION == 'CalLBacKCounT') $stmt = "select count(*) from vicidial_callbacks where recipient='USERONLY' and user='$user' and campaign_id='$campaign' and status NOT IN('INACTIVE','DEAD');"; 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,'00180',$user,$server_ip,$session_name);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00180',$user,$server_ip,$session_name,$one_mysql_log);} $row=mysql_fetch_row($rslt); $cbcount=$row[0]; @@ -3374,14 +3463,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"); @@ -3389,5 +3479,8 @@ if ($mysql_error_logging > 0) fclose($efp); } } +$one_mysql_log=0; +return $errno; } + ?> diff --git a/www/agc/vicidial.php b/www/agc/vicidial.php index 74696964..a0172fd2 100644 --- a/www/agc/vicidial.php +++ b/www/agc/vicidial.php @@ -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";} $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";} $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 "\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 "\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 "\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 "\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 "\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 "\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 "\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 "\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 "\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 "\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 "\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 "\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 "\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; } ?>