diff --git a/agc_2-X/trunk/UPGRADE b/agc_2-X/trunk/UPGRADE index d004ed12..1bc53bbc 100644 --- a/agc_2-X/trunk/UPGRADE +++ b/agc_2-X/trunk/UPGRADE @@ -121,7 +121,7 @@ OTHER CHANGES: AGI call_log line of the dialplan and before the Dial line: exten => _91NXXNXXXXXX,n,SipAddHeader(X-campaignid: ${CAMPCUST}) -14. Changed the agent code to use PHP mysqli functions. This does not require +14. Changed all PHP code to use PHP mysqli functions. This does not require any action or changes to enable since it is a change to the code. We are working on converting the administrative PHP scripts as well. These require MySQL 5.0 minimum to be used, but for several years that diff --git a/agc_2-X/trunk/bin/ADMIN_update_archive_url.pl b/agc_2-X/trunk/bin/ADMIN_update_archive_url.pl index 3451bf0a..c9d97b0b 100644 --- a/agc_2-X/trunk/bin/ADMIN_update_archive_url.pl +++ b/agc_2-X/trunk/bin/ADMIN_update_archive_url.pl @@ -1,151 +1,154 @@ -#!/usr/bin/perl - -# ADMIN_update_archive_url.pl - updates the url for the archive server -# in the recording_log table -# -# Copyright (C) 2009 Matt Florell LICENSE: AGPLv2 -# -# CHANGELOG -# 90609-1609 - mikec - created the script - -use DBI; - -# function to print out the help for this script -sub print_help { - print "$0 - updates the url in the recording_log\n"; - print "command-line options:\n"; - print " [--debug] = shows the sql as it is being executed.\n"; - print " [--test] = activates debuging and does not actually\n"; - print " execute the updates.\n"; - print " [--old-server-url] = the old url used to access the recordings.\n"; - print " This is a required argument.\n"; - print " [--new-server-url] = the new url used to access the recordings.\n"; - print " This is a required argument.\n\n"; - - exit; -} - -# default path to astguiclient configuration file: -$PATHconf = '/etc/astguiclient.conf'; - -# read in the conf file -open(CONFIG, "$PATHconf") || die "can't open $PATHconf: $!\n"; -@config = ; -close(CONFIG); -$i=0; -foreach(@config) { - $line = $config[$i]; - $line =~ s/ |>|\n|\r|\t|\#.*|;.*//gi; - if ($line =~ /^VARserver_ip/) - {$VARserver_ip = $line; $VARserver_ip =~ s/.*=//gi;} - if ($line =~ /^VARDB_server/) - {$VARDB_server = $line; $VARDB_server =~ s/.*=//gi;} - if ($line =~ /^VARDB_database/) - {$VARDB_database = $line; $VARDB_database =~ s/.*=//gi;} - if ($line =~ /^VARDB_user/) - {$VARDB_user = $line; $VARDB_user =~ s/.*=//gi;} - if ($line =~ /^VARDB_pass/) - {$VARDB_pass = $line; $VARDB_pass =~ s/.*=//gi;} - if ($line =~ /^VARDB_port/) - {$VARDB_port = $line; $VARDB_port =~ s/.*=//gi;} - $i++; -} - -# initialize the variables -$old_url = ""; -$new_url = ""; -$DB = 0; -$TEST = 0; - -# begin parsing run-time options -if ( length($ARGV[0]) > 1 ) { - $i=0; - while ($#ARGV >= $i) { - $args = "$args $ARGV[$i]"; - $i++; - } - - if ($args =~ /--help/i) { - &print_help; - } else { - # activate debugging - if ($args =~ /--debug/i) { - $DB=1; - } - - # activate test mode - if ($args =~ /--test/i) { - $DB=1; - $TEST=1; - } - - # get the old server url - if ($args =~ /--old-server-url=/i) { - @CLIoldurlARY = split(/--old-server-url=/,$args); - @CLIoldurlARX = split(/ /,$CLIoldurlARY[1]); - $old_url = $CLIoldurlARX[0]; - } - - # get the new server url - if ($args =~ /--new-server-url=/i) { - @CLInewurlARY = split(/--new-server-url=/,$args); - @CLInewurlARX = split(/ /,$CLInewurlARY[1]); - $new_url = $CLInewurlARX[0]; - } - } -} else { - # we didnt get any arguments - &print_help; -} - -# make sure they set something -if (( $new_url eq "") || ( $old_url eq "")) { - &print_help; -} - -# connect to the db -$dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass") - or die "Couldn't connect to database: " . DBI->errstr; - -# get all the recordings with the old_url -$stmtA = "SELECT recording_id, location from recording_log where location LIKE '$old_url%';"; -if ( $DB ) { - print $stmtA . "\n"; -} -$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; -$sthA->execute or die "executing: $stmtA ", $dbhA->errstr; -$sthArows=$sthA->rows; -$rec_count=0; - -# cycle through them -while ($sthArows > $rec_count) { - @aryA = $sthA->fetchrow_array; - - # get the parameters from the DB - $rec_id = "$aryA[0]"; - $location = "$aryA[1]"; - - # change the url - $new_loc = $location; - $new_loc =~ s/$old_url/$new_url/gi; - - # UPDATE THE recording_log RECORD - $stmtB = "UPDATE recording_log SET location='$new_loc' where recording_id='$rec_id';"; - if ( $DB ) { - print $stmtB . "\n"; - } - - # execute the update if we are not in test mode - if ( $TEST == 0 ) { - $sthB = $dbhA->prepare($stmtB) or die "preparing: ",$dbhB->errstr; - $sthB->execute or die "executing: $stmtB ", $dbhB->errstr; - $sthB->finish(); - } - $rec_count++; -} - -print "Updated $rec_count records in the recording_log table\n"; - -$sthA->finish(); - +#!/usr/bin/perl + +# ADMIN_update_archive_url.pl - updates the url for the archive server +# in the recording_log table +# +# Copyright (C) 2013 Matt Florell LICENSE: AGPLv2 +# +# CHANGELOG +# 90609-1609 - mikec - created the script +# 130902-1132 - Fix for issue #697 +# + +use DBI; + +# function to print out the help for this script +sub print_help + { + print "$0 - updates the url in the recording_log\n"; + print "command-line options:\n"; + print " [--debug] = shows the sql as it is being executed.\n"; + print " [--test] = activates debuging and does not actually\n"; + print " execute the updates.\n"; + print " [--old-server-url] = the old url used to access the recordings.\n"; + print " This is a required argument.\n"; + print " [--new-server-url] = the new url used to access the recordings.\n"; + print " This is a required argument.\n\n"; + + exit; + } + +# default path to astguiclient configuration file: +$PATHconf = '/etc/astguiclient.conf'; + +# read in the conf file +open(CONFIG, "$PATHconf") || die "can't open $PATHconf: $!\n"; +@config = ; +close(CONFIG); +$i=0; +foreach(@config) { + $line = $config[$i]; + $line =~ s/ |>|\n|\r|\t|\#.*|;.*//gi; + if ($line =~ /^VARserver_ip/) + {$VARserver_ip = $line; $VARserver_ip =~ s/.*=//gi;} + if ($line =~ /^VARDB_server/) + {$VARDB_server = $line; $VARDB_server =~ s/.*=//gi;} + if ($line =~ /^VARDB_database/) + {$VARDB_database = $line; $VARDB_database =~ s/.*=//gi;} + if ($line =~ /^VARDB_user/) + {$VARDB_user = $line; $VARDB_user =~ s/.*=//gi;} + if ($line =~ /^VARDB_pass/) + {$VARDB_pass = $line; $VARDB_pass =~ s/.*=//gi;} + if ($line =~ /^VARDB_port/) + {$VARDB_port = $line; $VARDB_port =~ s/.*=//gi;} + $i++; +} + +# initialize the variables +$old_url = ""; +$new_url = ""; +$DB = 0; +$TEST = 0; + +# begin parsing run-time options +if ( length($ARGV[0]) > 1 ) { + $i=0; + while ($#ARGV >= $i) { + $args = "$args $ARGV[$i]"; + $i++; + } + + if ($args =~ /--help/i) { + &print_help; + } else { + # activate debugging + if ($args =~ /--debug/i) { + $DB=1; + } + + # activate test mode + if ($args =~ /--test/i) { + $DB=1; + $TEST=1; + } + + # get the old server url + if ($args =~ /--old-server-url=/i) { + @CLIoldurlARY = split(/--old-server-url=/,$args); + @CLIoldurlARX = split(/ /,$CLIoldurlARY[1]); + $old_url = $CLIoldurlARX[0]; + } + + # get the new server url + if ($args =~ /--new-server-url=/i) { + @CLInewurlARY = split(/--new-server-url=/,$args); + @CLInewurlARX = split(/ /,$CLInewurlARY[1]); + $new_url = $CLInewurlARX[0]; + } + } +} else { + # we didnt get any arguments + &print_help; +} + +# make sure they set something +if (( $new_url eq "") || ( $old_url eq "")) { + &print_help; +} + +# connect to the db +$dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass") + or die "Couldn't connect to database: " . DBI->errstr; + +# get all the recordings with the old_url +$stmtA = "SELECT recording_id, location from recording_log where location LIKE '$old_url%';"; +if ( $DB ) { + print $stmtA . "\n"; +} +$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; +$sthA->execute or die "executing: $stmtA ", $dbhA->errstr; +$sthArows=$sthA->rows; +$rec_count=0; + +# cycle through them +while ($sthArows > $rec_count) { + @aryA = $sthA->fetchrow_array; + + # get the parameters from the DB + $rec_id = "$aryA[0]"; + $location = "$aryA[1]"; + + # change the url + $new_loc = $location; + $new_loc =~ s/$old_url/$new_url/gi; + + # UPDATE THE recording_log RECORD + $stmtB = "UPDATE recording_log SET location='$new_loc' where recording_id='$rec_id';"; + if ( $DB ) { + print $stmtB . "\n"; + } + + # execute the update if we are not in test mode + if ( $TEST == 0 ) { + $sthB = $dbhA->prepare($stmtB) or die "preparing: ",$dbhB->errstr; + $sthB->execute or die "executing: $stmtB ", $dbhB->errstr; + $sthB->finish(); + } + $rec_count++; +} + +print "Updated $rec_count records in the recording_log table\n"; + +$sthA->finish(); + $dbhA->disconnect(); \ No newline at end of file diff --git a/agc_2-X/trunk/www/vicidial/AST_CLOSER_service_level.php b/agc_2-X/trunk/www/vicidial/AST_CLOSER_service_level.php index 3d1b9daf..544d1786 100644 --- a/agc_2-X/trunk/www/vicidial/AST_CLOSER_service_level.php +++ b/agc_2-X/trunk/www/vicidial/AST_CLOSER_service_level.php @@ -23,11 +23,12 @@ # 130414-0104 - Added report logging # 130610-1024 - Finalized changing of all ereg instances to preg # 130621-0806 - Added filtering of input to prevent SQL injection attacks and new user auth +# 130902-0737 - Changed to mysqli PHP functions # $startMS = microtime(); -require("dbconnect.php"); +require("dbconnect_mysqli.php"); require("functions.php"); $PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; @@ -58,12 +59,12 @@ $db_source = 'M'; ############################################# ##### START SYSTEM_SETTINGS LOOKUP ##### $stmt = "SELECT use_non_latin,outbound_autodial_active,slave_db_server,reports_use_slave_db FROM system_settings;"; -$rslt=mysql_query($stmt, $link); +$rslt=mysql_to_mysqli($stmt, $link); if ($DB) {$MAIN.="$stmt\n";} -$qm_conf_ct = mysql_num_rows($rslt); +$qm_conf_ct = mysqli_num_rows($rslt); if ($qm_conf_ct > 0) { - $row=mysql_fetch_row($rslt); + $row=mysqli_fetch_row($rslt); $non_latin = $row[0]; $outbound_autodial_active = $row[1]; $slave_db_server = $row[2]; @@ -94,14 +95,14 @@ if ($auth > 0) { $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and user_level > 7 and view_reports > 0;"; if ($DB) {echo "|$stmt|\n";} - $rslt=mysql_query($stmt, $link); - $row=mysql_fetch_row($rslt); + $rslt=mysql_to_mysqli($stmt, $link); + $row=mysqli_fetch_row($rslt); $admin_auth=$row[0]; $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and user_level > 6 and view_reports > 0;"; if ($DB) {echo "|$stmt|\n";} - $rslt=mysql_query($stmt, $link); - $row=mysql_fetch_row($rslt); + $rslt=mysql_to_mysqli($stmt, $link); + $row=mysqli_fetch_row($rslt); $reports_auth=$row[0]; if ($reports_auth < 1) @@ -149,29 +150,29 @@ $LOGfull_url = "$HTTPprotocol$LOGserver_name$LOGserver_port$LOGrequest_uri"; $stmt="INSERT INTO vicidial_report_log set event_date=NOW(), user='$PHP_AUTH_USER', ip_address='$LOGip', report_name='$report_name', browser='$LOGbrowser', referer='$LOGhttp_referer', notes='$LOGserver_name:$LOGserver_port $LOGscript_name |$group, $query_date, $end_date, $shift, $file_download, $report_display_type|', url='$LOGfull_url';"; if ($DB) {echo "|$stmt|\n";} -$rslt=mysql_query($stmt, $link); -$report_log_id = mysql_insert_id($link); +$rslt=mysql_to_mysqli($stmt, $link); +$report_log_id = mysqli_insert_id($link); ##### END log visit to the vicidial_report_log table ##### if ( (strlen($slave_db_server)>5) and (preg_match("/$report_name/",$reports_use_slave_db)) ) { - mysql_close($link); + mysqli_close($link); $use_slave_server=1; $db_source = 'S'; - require("dbconnect.php"); + require("dbconnect_mysqli.php"); $MAIN.="\n"; } $stmt="SELECT user_group from vicidial_users where user='$PHP_AUTH_USER';"; if ($DB) {$MAIN.="|$stmt|\n";} -$rslt=mysql_query($stmt, $link); -$row=mysql_fetch_row($rslt); +$rslt=mysql_to_mysqli($stmt, $link); +$row=mysqli_fetch_row($rslt); $LOGuser_group = $row[0]; $stmt="SELECT allowed_campaigns,allowed_reports,admin_viewable_groups,admin_viewable_call_times from vicidial_user_groups where user_group='$LOGuser_group';"; if ($DB) {$MAIN.="|$stmt|\n";} -$rslt=mysql_query($stmt, $link); -$row=mysql_fetch_row($rslt); +$rslt=mysql_to_mysqli($stmt, $link); +$row=mysqli_fetch_row($rslt); $LOGallowed_campaigns = $row[0]; $LOGallowed_reports = $row[1]; $LOGadmin_viewable_groups = $row[2]; @@ -213,14 +214,14 @@ if (!isset($query_date)) {$query_date = $NOW_DATE;} if (!isset($end_date)) {$end_date = $NOW_DATE;} $stmt="select group_id,group_name from vicidial_inbound_groups $whereLOGadmin_viewable_groupsSQL order by group_id;"; -$rslt=mysql_query($stmt, $link); +$rslt=mysql_to_mysqli($stmt, $link); if ($DB) {$MAIN.="$stmt\n";} -$groups_to_print = mysql_num_rows($rslt); +$groups_to_print = mysqli_num_rows($rslt); $i=0; $groups_string='|'; while ($i < $groups_to_print) { - $row=mysql_fetch_row($rslt); + $row=mysqli_fetch_row($rslt); $groups[$i] = $row[0]; $group_names[$i] = $row[1]; $groups_string .= "$groups[$i]|"; @@ -518,14 +519,14 @@ $TOTintervals = $j; ### GRAB ALL RECORDS WITHIN RANGE FROM THE DATABASE ### -$stmt="select queue_seconds,UNIX_TIMESTAMP(call_date),length_in_sec,status from vicidial_closer_log where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and campaign_id='" . mysql_real_escape_string($group) . "';"; -$rslt=mysql_query($stmt, $link); +$stmt="select queue_seconds,UNIX_TIMESTAMP(call_date),length_in_sec,status from vicidial_closer_log where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and campaign_id='" . mysqli_real_escape_string($link, $group) . "';"; +$rslt=mysql_to_mysqli($stmt, $link); if ($DB) {$MAIN.="$stmt\n";} -$records_to_grab = mysql_num_rows($rslt); +$records_to_grab = mysqli_num_rows($rslt); $i=0; while ($i < $records_to_grab) { - $row=mysql_fetch_row($rslt); + $row=mysqli_fetch_row($rslt); $qs[$i] = $row[0]; $dt[$i] = 0; $ut[$i] = ($row[1] - $SQepochDAY); @@ -1356,10 +1357,10 @@ else if ($db_source == 'S') { - mysql_close($link); + mysqli_close($link); $use_slave_server=0; $db_source = 'M'; - require("dbconnect.php"); + require("dbconnect_mysqli.php"); } $endMS = microtime(); @@ -1371,7 +1372,7 @@ $TOTALrun = ($runS + $runM); $stmt="UPDATE vicidial_report_log set run_time='$TOTALrun' where report_log_id='$report_log_id';"; if ($DB) {echo "|$stmt|\n";} -$rslt=mysql_query($stmt, $link); +$rslt=mysql_to_mysqli($stmt, $link); exit; diff --git a/agc_2-X/trunk/www/vicidial/AST_CLOSERstats.php b/agc_2-X/trunk/www/vicidial/AST_CLOSERstats.php index 85a32a81..e58f7339 100644 --- a/agc_2-X/trunk/www/vicidial/AST_CLOSERstats.php +++ b/agc_2-X/trunk/www/vicidial/AST_CLOSERstats.php @@ -7,7 +7,7 @@ # 60619-1714 - Added variable filtering to eliminate SQL injection attack threat # - Added required user/pass to gain access to this page # 60905-1326 - Added queue time stats -# 71008-1436 - Added shift to be defined in dbconnect.php +# 71008-1436 - Added shift to be defined in dbconnect_mysqli.php # 71025-0021 - Added status breakdown # 71218-1155 - Added end_date for multi-day reports # 80430-1920 - Added Customer hangup cause stats @@ -40,11 +40,12 @@ # 130610-1023 - Finalized changing of all ereg instances to preg # 130621-0805 - Added filtering of input to prevent SQL injection attacks and new user auth # 130704-0936 - Fixed issue #675 +# 130901-0816 - Changed to mysqli PHP functions # $startMS = microtime(); -require("dbconnect.php"); +require("dbconnect_mysqli.php"); require("functions.php"); $PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; @@ -84,12 +85,12 @@ $db_source = 'M'; ############################################# ##### START SYSTEM_SETTINGS LOOKUP ##### $stmt = "SELECT use_non_latin,outbound_autodial_active,slave_db_server,reports_use_slave_db FROM system_settings;"; -$rslt=mysql_query($stmt, $link); +$rslt=mysql_to_mysqli($stmt, $link); if ($DB) {$MAIN.="$stmt\n";} -$qm_conf_ct = mysql_num_rows($rslt); +$qm_conf_ct = mysqli_num_rows($rslt); if ($qm_conf_ct > 0) { - $row=mysql_fetch_row($rslt); + $row=mysqli_fetch_row($rslt); $non_latin = $row[0]; $outbound_autodial_active = $row[1]; $slave_db_server = $row[2]; @@ -100,13 +101,13 @@ if ($qm_conf_ct > 0) $stmt = "SELECT local_gmt FROM servers where active='Y' limit 1;"; -$rslt=mysql_query($stmt, $link); +$rslt=mysql_to_mysqli($stmt, $link); if ($DB) {$MAIN.="$stmt\n";} -$gmt_conf_ct = mysql_num_rows($rslt); +$gmt_conf_ct = mysqli_num_rows($rslt); $dst = date("I"); if ($gmt_conf_ct > 0) { - $row=mysql_fetch_row($rslt); + $row=mysqli_fetch_row($rslt); $local_gmt = $row[0]; $epoch_offset = (($local_gmt + $dst) * 3600); } @@ -133,14 +134,14 @@ if ($auth > 0) { $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and user_level > 7 and view_reports > 0;"; if ($DB) {echo "|$stmt|\n";} - $rslt=mysql_query($stmt, $link); - $row=mysql_fetch_row($rslt); + $rslt=mysql_to_mysqli($stmt, $link); + $row=mysqli_fetch_row($rslt); $admin_auth=$row[0]; $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and user_level > 6 and view_reports > 0;"; if ($DB) {echo "|$stmt|\n";} - $rslt=mysql_query($stmt, $link); - $row=mysql_fetch_row($rslt); + $rslt=mysql_to_mysqli($stmt, $link); + $row=mysqli_fetch_row($rslt); $reports_auth=$row[0]; if ($reports_auth < 1) @@ -174,14 +175,14 @@ else $stmt="SELECT user_group from vicidial_users where user='$PHP_AUTH_USER';"; if ($DB) {$MAIN.="|$stmt|\n";} -$rslt=mysql_query($stmt, $link); -$row=mysql_fetch_row($rslt); +$rslt=mysql_to_mysqli($stmt, $link); +$row=mysqli_fetch_row($rslt); $LOGuser_group = $row[0]; $stmt="SELECT allowed_campaigns,allowed_reports,admin_viewable_groups,admin_viewable_call_times from vicidial_user_groups where user_group='$LOGuser_group';"; if ($DB) {$MAIN.="|$stmt|\n";} -$rslt=mysql_query($stmt, $link); -$row=mysql_fetch_row($rslt); +$rslt=mysql_to_mysqli($stmt, $link); +$row=mysqli_fetch_row($rslt); $LOGallowed_campaigns = $row[0]; $LOGallowed_reports = $row[1]; $LOGadmin_viewable_groups = $row[2]; @@ -232,9 +233,9 @@ if ($EMAIL=='Y') $stmt="select email_account_id,email_account_name,email_account_id from vicidial_email_accounts $whereLOGadmin_viewable_groupsSQL order by email_account_id;"; $stmt="select group_id,group_name,8 from vicidial_inbound_groups where group_handling='EMAIL' $LOGadmin_viewable_groupsSQL order by group_id;"; } -$rslt=mysql_query($stmt, $link); +$rslt=mysql_to_mysqli($stmt, $link); if ($DB) {$MAIN.="$stmt\n";} -$groups_to_print = mysql_num_rows($rslt); +$groups_to_print = mysqli_num_rows($rslt); $i=0; $LISTgroups[$i]='---NONE---'; $i++; @@ -242,7 +243,7 @@ $groups_to_print++; $groups_string='|'; while ($i < $groups_to_print) { - $row=mysql_fetch_row($rslt); + $row=mysqli_fetch_row($rslt); $LISTgroups[$i] = $row[0]; $LISTgroup_names[$i] = $row[1]; $LISTgroup_ids[$i] = $row[2]; @@ -293,28 +294,28 @@ $AMP='&'; $QM='?'; $stmt="INSERT INTO vicidial_report_log set event_date=NOW(), user='$PHP_AUTH_USER', ip_address='$LOGip', report_name='$report_name', browser='$LOGbrowser', referer='$LOGhttp_referer', notes='$LOGserver_name:$LOGserver_port $LOGscript_name |$group[0], $query_date, $end_date, $shift, $DID, $EMAIL, $file_download, $report_display_type|', url='".$LOGfull_url."?DB=".$DB."&DID=".$DID."&EMAIL=".$EMAIL."&query_date=".$query_date."&end_date=".$end_date."&shift=".$shift."&report_display_type=".$report_display_type."$groupQS';"; if ($DB) {echo "|$stmt|\n";} -$rslt=mysql_query($stmt, $link); -$report_log_id = mysql_insert_id($link); +$rslt=mysql_to_mysqli($stmt, $link); +$report_log_id = mysqli_insert_id($link); ##### END log visit to the vicidial_report_log table ##### if ( (strlen($slave_db_server)>5) and (preg_match("/$report_name/",$reports_use_slave_db)) ) { - mysql_close($link); + mysqli_close($link); $use_slave_server=1; $db_source = 'S'; - require("dbconnect.php"); + require("dbconnect_mysqli.php"); $MAIN.="\n"; } $stmt="select vsc_id,vsc_name from vicidial_status_categories;"; -$rslt=mysql_query($stmt, $link); +$rslt=mysql_to_mysqli($stmt, $link); if ($DB) {$MAIN.="$stmt\n";} -$statcats_to_print = mysql_num_rows($rslt); +$statcats_to_print = mysqli_num_rows($rslt); $i=0; while ($i < $statcats_to_print) { - $row=mysql_fetch_row($rslt); + $row=mysqli_fetch_row($rslt); $vsc_id[$i] = $row[0]; $vsc_name[$i] = $row[1]; $vsc_count[$i] = 0; @@ -498,13 +499,13 @@ else if ($DID=='Y') { $stmt="select did_id from vicidial_inbound_dids where did_pattern IN($group_SQL) $LOGadmin_viewable_groupsSQL;"; - $rslt=mysql_query($stmt, $link); + $rslt=mysql_to_mysqli($stmt, $link); if ($DB) {$MAIN.="$stmt\n";} - $dids_to_print = mysql_num_rows($rslt); + $dids_to_print = mysqli_num_rows($rslt); $i=0; while ($i < $dids_to_print) { - $row=mysql_fetch_row($rslt); + $row=mysqli_fetch_row($rslt); $did_id[$i] = $row[0]; $did_SQL .= "'$row[0]',"; $i++; @@ -513,13 +514,13 @@ if ($DID=='Y') if (strlen($did_SQL)<3) {$did_SQL="''";} $stmt="select uniqueid from vicidial_did_log where did_id IN($did_SQL);"; - $rslt=mysql_query($stmt, $link); + $rslt=mysql_to_mysqli($stmt, $link); if ($DB) {$MAIN.="$stmt\n";} - $unids_to_print = mysql_num_rows($rslt); + $unids_to_print = mysqli_num_rows($rslt); $i=0; while ($i < $unids_to_print) { - $row=mysql_fetch_row($rslt); + $row=mysqli_fetch_row($rslt); $unid_SQL .= "'$row[0]',"; $i++; } @@ -566,23 +567,23 @@ if ($group_ct > 1) $did_id[$i]='0'; $DIDunid_SQL=''; $stmt="select did_id from vicidial_inbound_dids where did_pattern='$group[$i]';"; - $rslt=mysql_query($stmt, $link); + $rslt=mysql_to_mysqli($stmt, $link); if ($DB) {$ASCII_text.="$stmt\n";} - $Sdids_to_print = mysql_num_rows($rslt); + $Sdids_to_print = mysqli_num_rows($rslt); if ($Sdids_to_print > 0) { - $row=mysql_fetch_row($rslt); + $row=mysqli_fetch_row($rslt); $did_id[$i] = $row[0]; } $stmt="select uniqueid from vicidial_did_log where did_id='$did_id[$i]';"; - $rslt=mysql_query($stmt, $link); + $rslt=mysql_to_mysqli($stmt, $link); if ($DB) {$ASCII_text.="$stmt\n";} - $DIDunids_to_print = mysql_num_rows($rslt); + $DIDunids_to_print = mysqli_num_rows($rslt); $k=0; while ($k < $DIDunids_to_print) { - $row=mysql_fetch_row($rslt); + $row=mysqli_fetch_row($rslt); $DIDunid_SQL .= "'$row[0]',"; $k++; } @@ -594,27 +595,27 @@ if ($group_ct > 1) { $stmt="select count(*),sum(length_in_sec) from vicidial_closer_log where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and uniqueid IN($DIDunid_SQL);"; } - $rslt=mysql_query($stmt, $link); + $rslt=mysql_to_mysqli($stmt, $link); if ($DB) {$ASCII_text.="$stmt\n";} - $row=mysql_fetch_row($rslt); + $row=mysqli_fetch_row($rslt); $stmt="select count(*) from live_inbound_log where start_time >= '$query_date_BEGIN' and start_time <= '$query_date_END' and comment_a='$group[$i]' and comment_b='START';"; if ($DID=='Y') { $stmt="select count(*) from live_inbound_log where start_time >= '$query_date_BEGIN' and start_time <= '$query_date_END' and uniqueid IN($DIDunid_SQL);"; } - $rslt=mysql_query($stmt, $link); + $rslt=mysql_to_mysqli($stmt, $link); if ($DB) {$ASCII_text.="$stmt\n";} - $rowx=mysql_fetch_row($rslt); + $rowx=mysqli_fetch_row($rslt); $stmt="select count(*),sum(length_in_sec) from vicidial_closer_log where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and campaign_id='$group[$i]' and status IN('DROP','XDROP') and (length_in_sec <= 49999 or length_in_sec is null);"; if ($DID=='Y') { $stmt="select count(*),sum(length_in_sec) from vicidial_closer_log where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and status IN('DROP','XDROP') and (length_in_sec <= 49999 or length_in_sec is null) and uniqueid IN($DIDunid_SQL);"; } - $rslt=mysql_query($stmt, $link); + $rslt=mysql_to_mysqli($stmt, $link); if ($DB) {$ASCII_text.="$stmt\n";} - $rowy=mysql_fetch_row($rslt); + $rowy=mysqli_fetch_row($rslt); if ($row[0]>$max_value) {$max_value=$row[0];} $groupDISPLAY = sprintf("%20s", $group[$i]); @@ -698,27 +699,27 @@ if ($DID=='Y') { $stmt="select count(*),sum(length_in_sec) from vicidial_closer_log where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and uniqueid IN($unid_SQL);"; } -$rslt=mysql_query($stmt, $link); +$rslt=mysql_to_mysqli($stmt, $link); if ($DB) {$MAIN.="$stmt\n";} -$row=mysql_fetch_row($rslt); +$row=mysqli_fetch_row($rslt); $stmt="select count(*),sum(queue_seconds) from vicidial_closer_log where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and campaign_id IN($group_SQL) and status NOT IN('DROP','XDROP','HXFER','QVMAIL','HOLDTO','LIVE','QUEUE','TIMEOT','AFTHRS','NANQUE','INBND','MAXCAL');"; if ($DID=='Y') { $stmt="select count(*),sum(queue_seconds) from vicidial_closer_log where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and status NOT IN('DROP','XDROP','HXFER','QVMAIL','HOLDTO','LIVE','QUEUE','TIMEOT','AFTHRS','NANQUE','INBND','MAXCAL') and uniqueid IN($unid_SQL);"; } -$rslt=mysql_query($stmt, $link); +$rslt=mysql_to_mysqli($stmt, $link); if ($DB) {$MAIN.="$stmt\n";} -$rowy=mysql_fetch_row($rslt); +$rowy=mysqli_fetch_row($rslt); $stmt="select count(*) from live_inbound_log where start_time >= '$query_date_BEGIN' and start_time <= '$query_date_END' and comment_a IN($group_SQL) and comment_b='START';"; if ($DID=='Y') { $stmt="select count(*) from live_inbound_log where start_time >= '$query_date_BEGIN' and start_time <= '$query_date_END' and uniqueid IN($unid_SQL);"; } -$rslt=mysql_query($stmt, $link); +$rslt=mysql_to_mysqli($stmt, $link); if ($DB) {$MAIN.="$stmt\n";} -$rowx=mysql_fetch_row($rslt); +$rowx=mysqli_fetch_row($rslt); $TOTALcalls = sprintf("%10s", $row[0]); $IVRcalls = sprintf("%10s", $rowx[0]); @@ -787,9 +788,9 @@ if ($DID=='Y') { $stmt="select count(*),sum(length_in_sec) from vicidial_closer_log where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and status IN('DROP','XDROP') and (length_in_sec <= 49999 or length_in_sec is null) and uniqueid IN($unid_SQL);"; } -$rslt=mysql_query($stmt, $link); +$rslt=mysql_to_mysqli($stmt, $link); if ($DB) {$MAIN.="$stmt\n";} -$row=mysql_fetch_row($rslt); +$row=mysqli_fetch_row($rslt); $DROPcalls = sprintf("%10s", $row[0]); if ( ($DROPcalls < 1) or ($TOTALcalls < 1) ) @@ -840,22 +841,22 @@ if (strlen($group_SQL)>3) if ($DID!='Y') { $stmt = "SELECT answer_sec_pct_rt_stat_one,answer_sec_pct_rt_stat_two from vicidial_inbound_groups where group_id IN($group_SQL) order by answer_sec_pct_rt_stat_one desc limit 1;"; - $rslt=mysql_query($stmt, $link); + $rslt=mysql_to_mysqli($stmt, $link); if ($DB) {$MAIN.="$stmt\n";} - $row=mysql_fetch_row($rslt); + $row=mysqli_fetch_row($rslt); $Sanswer_sec_pct_rt_stat_one = $row[0]; $Sanswer_sec_pct_rt_stat_two = $row[1]; $stmt = "SELECT count(*) from vicidial_closer_log where campaign_id IN($group_SQL) and call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and queue_seconds <= $Sanswer_sec_pct_rt_stat_one and status NOT IN('DROP','XDROP','HXFER','QVMAIL','HOLDTO','LIVE','QUEUE','TIMEOT','AFTHRS','NANQUE','INBND','MAXCAL');"; - $rslt=mysql_query($stmt, $link); + $rslt=mysql_to_mysqli($stmt, $link); if ($DB) {$MAIN.="$stmt\n";} - $row=mysql_fetch_row($rslt); + $row=mysqli_fetch_row($rslt); $answer_sec_pct_rt_stat_one = $row[0]; $stmt = "SELECT count(*) from vicidial_closer_log where campaign_id IN($group_SQL) and call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and queue_seconds <= $Sanswer_sec_pct_rt_stat_two and status NOT IN('DROP','XDROP','HXFER','QVMAIL','HOLDTO','LIVE','QUEUE','TIMEOT','AFTHRS','NANQUE','INBND','MAXCAL');"; - $rslt=mysql_query($stmt, $link); + $rslt=mysql_to_mysqli($stmt, $link); if ($DB) {$MAIN.="$stmt\n";} - $row=mysql_fetch_row($rslt); + $row=mysqli_fetch_row($rslt); $answer_sec_pct_rt_stat_two = $row[0]; if ( ($ANSWEREDcalls > 0) and ($answer_sec_pct_rt_stat_one > 0) and ($answer_sec_pct_rt_stat_two > 0) ) @@ -905,13 +906,13 @@ if ($DID!='Y') # GET LIST OF ALL STATUSES and create SQL from human_answered statuses $q=0; $stmt = "SELECT status,status_name,human_answered,category from vicidial_statuses;"; -$rslt=mysql_query($stmt, $link); +$rslt=mysql_to_mysqli($stmt, $link); if ($DB) {$MAIN.="$stmt\n";} -$statuses_to_print = mysql_num_rows($rslt); +$statuses_to_print = mysqli_num_rows($rslt); $p=0; while ($p < $statuses_to_print) { - $row=mysql_fetch_row($rslt); + $row=mysqli_fetch_row($rslt); $status[$q] = $row[0]; $status_name[$q] = $row[1]; $human_answered[$q] = $row[2]; @@ -922,13 +923,13 @@ while ($p < $statuses_to_print) $p++; } $stmt = "SELECT status,status_name,human_answered,category from vicidial_campaign_statuses;"; -$rslt=mysql_query($stmt, $link); +$rslt=mysql_to_mysqli($stmt, $link); if ($DB) {$MAIN.="$stmt\n";} -$statuses_to_print = mysql_num_rows($rslt); +$statuses_to_print = mysqli_num_rows($rslt); $p=0; while ($p < $statuses_to_print) { - $row=mysql_fetch_row($rslt); + $row=mysqli_fetch_row($rslt); $status[$q] = $row[0]; $status_name[$q] = $row[1]; $human_answered[$q] = $row[2]; @@ -951,9 +952,9 @@ if ($DID=='Y') { $stmt="select count(*),sum(queue_seconds) from vicidial_closer_log where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and (queue_seconds > 0) and uniqueid IN($unid_SQL);"; } -$rslt=mysql_query($stmt, $link); +$rslt=mysql_to_mysqli($stmt, $link); if ($DB) {$MAIN.="$stmt\n";} -$row=mysql_fetch_row($rslt); +$row=mysqli_fetch_row($rslt); $QUEUEcalls = sprintf("%10s", $row[0]); if ( ($QUEUEcalls < 1) or ($TOTALcalls < 1) ) @@ -1031,15 +1032,15 @@ if ($DID=='Y') { $stmt="select count(*),queue_seconds from vicidial_closer_log where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and uniqueid IN($unid_SQL) group by queue_seconds;"; } -$rslt=mysql_query($stmt, $link); +$rslt=mysql_to_mysqli($stmt, $link); if ($DB) {$ASCII_text.="$stmt\n";} -$reasons_to_print = mysql_num_rows($rslt); +$reasons_to_print = mysqli_num_rows($rslt); $i=0; $hd_5=0; $hd10=0; $hd15=0; $hd20=0; $hd25=0; $hd30=0; $hd35=0; $hd40=0; $hd45=0; $hd50=0; $hd55=0; $hd60=0; $hd90=0; $hd99=0; while ($i < $reasons_to_print) { - $row=mysql_fetch_row($rslt); + $row=mysqli_fetch_row($rslt); $TOTALcalls = ($TOTALcalls + $row[0]); @@ -1096,16 +1097,16 @@ if ($report_display_type=="HTML") { $mc_stmt="select count(*) as ct from vicidial_closer_log where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and uniqueid IN($unid_SQL) group by queue_seconds order by ct desc limit 1;"; } if ($DB) {$GRAPH_text.=$stmt."\n";} - $ms_rslt=mysql_query($ms_stmt, $link); - $ms_row=mysql_fetch_row($ms_rslt); + $ms_rslt=mysql_to_mysqli($ms_stmt, $link); + $ms_row=mysqli_fetch_row($ms_rslt); $max_seconds=$ms_row[0]; if ($max_seconds>90) {$max_seconds=91;} for ($i=0; $i<=$max_seconds; $i++) { $sec_ary[$i]=0; } - $mc_rslt=mysql_query($mc_stmt, $link); - $mc_row=mysql_fetch_row($mc_rslt); + $mc_rslt=mysql_to_mysqli($mc_stmt, $link); + $mc_row=mysqli_fetch_row($mc_rslt); $max_calls=$ms_row[0]; if ($max_calls<=10) { while ($maxcalls%5!=0) { @@ -1124,13 +1125,13 @@ if ($report_display_type=="HTML") { $maxcalls++; } } - $rslt=mysql_query($stmt, $link); + $rslt=mysql_to_mysqli($stmt, $link); $GRAPH_text="
\n"; $GRAPH_text.="