diff --git a/bin/ADMIN_www_languages.pl b/bin/ADMIN_www_languages.pl index cd899a30..ca09898a 100644 --- a/bin/ADMIN_www_languages.pl +++ b/bin/ADMIN_www_languages.pl @@ -63,7 +63,7 @@ if (length($ARGV[0])>1) if ($args =~ /--help/i) { - print "QXZanalyzer.pl - analyze php scripts for QXZ functions and contents\n"; + print "ADMIN_www_languages.pl - analyze php scripts for QXZ functions and contents\n"; print "\n"; print "options:\n"; print " [--help] = this help screen\n"; diff --git a/docs/OUTBOUND_OPTIMIZATIONS.txt b/docs/OUTBOUND_OPTIMIZATIONS.txt index b84cec62..e8a10479 100644 --- a/docs/OUTBOUND_OPTIMIZATIONS.txt +++ b/docs/OUTBOUND_OPTIMIZATIONS.txt @@ -102,6 +102,17 @@ The new script we will be testing changes on will be named "agi-VDAD_ALL_outboun To be added to dialplan +; BETA VICIDIAL_auto_dialer transfer script Load Balanced Survey: +exten => 8376,1,Playback(sip-silence) +exten => 8376,n,AGI(agi://127.0.0.1:4577/call_log) +exten => 8376,n,Set(LRct=1) +exten => 8376,n,While($[${LRct} < 100]) +exten => 8376,n,AGI(agi-VDAD_ALL_outboundBETA.agi,SURVEYCAMP-----LB) +exten => 8376,n,Set(LRct=$[${LRct} + 1]) +exten => 8376,n,EndWhile() +exten => 8376,n,AGI(agi-VDAD_ALL_outboundBETA.agi,SURVEYCAMP-----LB) +exten => 8376,n,Hangup() + ; BETA VICIDIAL_auto_dialer transfer script Load Balanced: exten => 8377,1,Playback(sip-silence) exten => 8377,n,AGI(agi://127.0.0.1:4577/call_log) diff --git a/www/vicidial/AST_vdad_debug_log_report.php b/www/vicidial/AST_vdad_debug_log_report.php new file mode 100644 index 00000000..dab68b50 --- /dev/null +++ b/www/vicidial/AST_vdad_debug_log_report.php @@ -0,0 +1,733 @@ + LICENSE: AGPLv2 +# +# CHANGES +# 161124-0737 - First build +# + +$startMS = microtime(); + +require("dbconnect_mysqli.php"); +require("functions.php"); + +$report_name='VDAD Debug Log Report'; + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];} + elseif (isset($_POST["query_date"])) {$query_date=$_POST["query_date"];} +if (isset($_GET["query_date_D"])) {$query_date_D=$_GET["query_date_D"];} + elseif (isset($_POST["query_date_D"])) {$query_date_D=$_POST["query_date_D"];} +if (isset($_GET["query_date_T"])) {$query_date_T=$_GET["query_date_T"];} + elseif (isset($_POST["query_date_T"])) {$query_date_T=$_POST["query_date_T"];} +if (isset($_GET["stage"])) {$stage=$_GET["stage"];} + elseif (isset($_POST["stage"])) {$stage=$_POST["stage"];} +if (isset($_GET["file_download"])) {$file_download=$_GET["file_download"];} + elseif (isset($_POST["file_download"])) {$file_download=$_POST["file_download"];} +if (isset($_GET["lower_limit"])) {$lower_limit=$_GET["lower_limit"];} + elseif (isset($_POST["lower_limit"])) {$lower_limit=$_POST["lower_limit"];} +if (isset($_GET["upper_limit"])) {$upper_limit=$_GET["upper_limit"];} + elseif (isset($_POST["upper_limit"])) {$upper_limit=$_POST["upper_limit"];} +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["DBX"])) {$DBX=$_GET["DBX"];} + elseif (isset($_POST["DBX"])) {$DBX=$_POST["DBX"];} +if (isset($_GET["archive"])) {$archive=$_GET["archive"];} + elseif (isset($_POST["archive"])) {$archive=$_POST["archive"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + +############################################# +##### START SYSTEM_SETTINGS LOOKUP ##### +$stmt = "SELECT use_non_latin,outbound_autodial_active,slave_db_server,reports_use_slave_db,enable_languages,language_method FROM system_settings;"; +$rslt=mysql_to_mysqli($stmt, $link); +if ($DB) {$MAIN.="$stmt\n";} +$qm_conf_ct = mysqli_num_rows($rslt); +if ($qm_conf_ct > 0) + { + $row=mysqli_fetch_row($rslt); + $non_latin = $row[0]; + $outbound_autodial_active = $row[1]; + $slave_db_server = $row[2]; + $reports_use_slave_db = $row[3]; + $SSenable_languages = $row[4]; + $SSlanguage_method = $row[5]; + } +##### END SETTINGS LOOKUP ##### +########################################### + +$NOW_DATE = date("Y-m-d"); + +if ($non_latin < 1) + { + $PHP_AUTH_USER = preg_replace('/[^-_0-9a-zA-Z]/', '', $PHP_AUTH_USER); + $PHP_AUTH_PW = preg_replace('/[^-_0-9a-zA-Z]/', '', $PHP_AUTH_PW); + $stage = preg_replace('/[^-_0-9a-zA-Z]/', '', $stage); + } +else + { + $PHP_AUTH_PW = preg_replace("/'|\"|\\\\|;/","",$PHP_AUTH_PW); + $PHP_AUTH_USER = preg_replace("/'|\"|\\\\|;/","",$PHP_AUTH_USER); + $stage = preg_replace("/'|\"|\\\\|;/","",$stage); + } + +$stmt="SELECT selected_language from vicidial_users where user='$PHP_AUTH_USER';"; +if ($DB) {echo "|$stmt|\n";} +$rslt=mysql_to_mysqli($stmt, $link); +$sl_ct = mysqli_num_rows($rslt); +if ($sl_ct > 0) + { + $row=mysqli_fetch_row($rslt); + $VUselected_language = $row[0]; + } + +$auth=0; +$reports_auth=0; +$admin_auth=0; +$auth_message = user_authorization($PHP_AUTH_USER,$PHP_AUTH_PW,'REPORTS',1); +if ($auth_message == 'GOOD') + {$auth=1;} + +if ($auth > 0) + { + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and user_level > 7 and view_reports='1';"; + if ($DB) {echo "|$stmt|\n";} + $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='1';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_to_mysqli($stmt, $link); + $row=mysqli_fetch_row($rslt); + $reports_auth=$row[0]; + + if ($reports_auth < 1) + { + $VDdisplayMESSAGE = _QXZ("You are not allowed to view reports"); + Header ("Content-type: text/html; charset=utf-8"); + echo "$VDdisplayMESSAGE: |$PHP_AUTH_USER|$auth_message|\n"; + exit; + } + if ( ($reports_auth > 0) and ($admin_auth < 1) ) + { + $ADD=999999; + $reports_only_user=1; + } + } +else + { + $VDdisplayMESSAGE = _QXZ("Login incorrect, please try again"); + if ($auth_message == 'LOCK') + { + $VDdisplayMESSAGE = _QXZ("Too many login attempts, try again in 15 minutes"); + Header ("Content-type: text/html; charset=utf-8"); + echo "$VDdisplayMESSAGE: |$PHP_AUTH_USER|$auth_message|\n"; + exit; + } + Header("WWW-Authenticate: Basic realm=\"CONTACT-CENTER-ADMIN\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "$VDdisplayMESSAGE: |$PHP_AUTH_USER|$PHP_AUTH_PW|$auth_message|\n"; + exit; + } + +##### BEGIN log visit to the vicidial_report_log table ##### +$LOGip = getenv("REMOTE_ADDR"); +$LOGbrowser = getenv("HTTP_USER_AGENT"); +$LOGscript_name = getenv("SCRIPT_NAME"); +$LOGserver_name = getenv("SERVER_NAME"); +$LOGserver_port = getenv("SERVER_PORT"); +$LOGrequest_uri = getenv("REQUEST_URI"); +$LOGhttp_referer = getenv("HTTP_REFERER"); +if (preg_match("/443/i",$LOGserver_port)) {$HTTPprotocol = 'https://';} + else {$HTTPprotocol = 'http://';} +if (($LOGserver_port == '80') or ($LOGserver_port == '443') ) {$LOGserver_port='';} +else {$LOGserver_port = ":$LOGserver_port";} +$LOGfull_url = "$HTTPprotocol$LOGserver_name$LOGserver_port$LOGrequest_uri"; + +$LOGhostname = php_uname('n'); +if (strlen($LOGhostname)<1) {$LOGhostname='X';} +if (strlen($LOGserver_name)<1) {$LOGserver_name='X';} + +$stmt="SELECT webserver_id FROM vicidial_webservers where webserver='$LOGserver_name' and hostname='$LOGhostname' LIMIT 1;"; +$rslt=mysql_to_mysqli($stmt, $link); +if ($DB) {echo "$stmt\n";} +$webserver_id_ct = mysqli_num_rows($rslt); +if ($webserver_id_ct > 0) + { + $row=mysqli_fetch_row($rslt); + $webserver_id = $row[0]; + } +else + { + ##### insert webserver entry + $stmt="INSERT INTO vicidial_webservers (webserver,hostname) values('$LOGserver_name','$LOGhostname');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_to_mysqli($stmt, $link); + $affected_rows = mysqli_affected_rows($link); + $webserver_id = mysqli_insert_id($link); + } + +$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', url='$LOGfull_url', webserver='$webserver_id';"; +if ($DB) {echo "|$stmt|\n";} +$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)) ) + { + mysqli_close($link); + $use_slave_server=1; + $db_source = 'S'; + require("dbconnect_mysqli.php"); + $MAIN.="\n"; + } + + +if (strlen($query_date_D) < 6) {$query_date_D = "00:00:00";} +if (strlen($query_date_T) < 6) {$query_date_T = "23:59:59";} +if (!isset($query_date)) {$query_date = $NOW_DATE;} +if (strlen($stage) < 2) {$stage = 'SUMMARY';} +$vicidial_vdad_log = 'vicidial_vdad_log'; +if ($archive > 0) {$vicidial_vdad_log = 'vicidial_vdad_log_archive';} + +/* +$server_ip_string='|'; +$server_ip_ct = count($server_ip); +$i=0; +while($i < $server_ip_ct) + { + $server_ip_string .= "$server_ip[$i]|"; + $i++; + } + +$server_stmt="select server_ip,server_description from servers where active_asterisk_server='Y' order by server_ip asc;"; +$server_rslt=mysql_to_mysqli($server_stmt, $link); +$servers_to_print=mysqli_num_rows($server_rslt); +$i=0; +while ($i < $servers_to_print) + { + $row=mysqli_fetch_row($server_rslt); + $LISTserverIPs[$i] = $row[0]; + $LISTserver_names[$i] = $row[1]; + if (preg_match('/\-ALL/',$server_ip_string) ) + { + $server_ip[$i] = $LISTserverIPs[$i]; + } + $i++; + } + +$i=0; +$server_ips_string='|'; +$server_ip_ct = count($server_ip); +while($i < $server_ip_ct) + { + if ( (strlen($server_ip[$i]) > 0) and (preg_match("/\|$server_ip[$i]\|/",$server_ip_string)) ) + { + $server_ips_string .= "$server_ip[$i]|"; + $server_ip_SQL .= "'$server_ip[$i]',"; + $server_ipQS .= "&server_ip[]=$server_ip[$i]"; + } + $i++; + } + +if ( (preg_match('/\-\-ALL\-\-/',$server_ip_string) ) or ($server_ip_ct < 1) ) + { + $server_ip_SQL = ""; + $server_rpt_string="- "._QXZ("ALL servers")." "; + if (preg_match('/\-\-ALL\-\-/',$server_ip_string)) {$server_ipQS="&server_ip[]=--ALL--";} + } +else + { + $server_ip_SQL = preg_replace('/,$/i', '',$server_ip_SQL); + $server_ip_SQL = "and server_ip IN($server_ip_SQL)"; + $server_rpt_string="- server(s) ".preg_replace('/\|/', ", ", substr($server_ip_string, 1, -1)); + } +if (strlen($server_ip_SQL)<3) {$server_ip_SQL="";} +*/ + +$HEADER.="\n"; +$HEADER.="
\n"; +$HEADER.="\n"; +$HEADER.="\n"; +$HEADER.="\n"; +$HEADER.="\n"; +$HEADER.="\n"; +$HEADER.="\n"; +$HEADER.="\n"; +$HEADER.="\n"; +$HEADER.="";
+$MAIN.="\n";
+ }
+ ##### END SUMMARY SECTION #####
+
+
+ ##### BEGIN CALL SECTION #####
+ if ($stage == 'CALL')
+ {
+ $MAIN.="\n";
+ $stmt = "SELECT caller_code,server_ip,count(*) FROM $vicidial_vdad_log where db_time >= '$query_date $query_date_D' and db_time <= '$query_date $query_date_T' group by caller_code,server_ip order by caller_code;";
+ $rslt=mysql_to_mysqli($stmt, $link);
+ if ($DB) {$MAIN.="$stmt\n";}
+ $cc_ct = mysqli_num_rows($rslt);
+ $i=0;
+ while ($cc_ct > $i)
+ {
+ $row=mysqli_fetch_row($rslt);
+ $Acaller_code[$i] = $row[0];
+ $Aserver_ip[$i] = $row[1];
+ $Acc_count[$i] = $row[2];
+ $i++;
+ }
+ if ($cc_ct < 1)
+ {
+ $MAIN.="*** "._QXZ("NO RECORDS FOUND")." ***\n";
+ }
+
+ $i=0;
+ while ($cc_ct > $i)
+ {
+ if ($DB > 0)
+ {$MAIN.= "$i $Acaller_code[$i] $Aserver_ip[$i] $Acc_count[$i]\n";}
+ $i++;
+ }
+
+ $MAIN.="\n";
+
+ $MAIN.=" |