diff --git a/agc_2-X/trunk/UPGRADE b/agc_2-X/trunk/UPGRADE index 3d71171c..d9ac8bb8 100644 --- a/agc_2-X/trunk/UPGRADE +++ b/agc_2-X/trunk/UPGRADE @@ -248,6 +248,10 @@ OTHER CHANGES: make install (then stop and restart asterisk) +42. Added admin report logging to all reports on the system, and added the + "Admin Report Log Viewer" linked from the "Admin Utilities" page which + allows you to see the reports that have been run on the system. + diff --git a/agc_2-X/trunk/docs/REQUIRED_APPS_INSTALL.txt b/agc_2-X/trunk/docs/REQUIRED_APPS_INSTALL.txt index 9b6a5596..1b98f2ba 100644 --- a/agc_2-X/trunk/docs/REQUIRED_APPS_INSTALL.txt +++ b/agc_2-X/trunk/docs/REQUIRED_APPS_INSTALL.txt @@ -86,6 +86,8 @@ install Mail::POP3Client install Mail::IMAPClient install Mail::Message install IO::Socket::SSL +install MIME::Base64 +install MIME::QuotedPrint quit diff --git a/agc_2-X/trunk/docs/SCRATCH_INSTALL.txt b/agc_2-X/trunk/docs/SCRATCH_INSTALL.txt index ffa82310..93081e42 100644 --- a/agc_2-X/trunk/docs/SCRATCH_INSTALL.txt +++ b/agc_2-X/trunk/docs/SCRATCH_INSTALL.txt @@ -460,6 +460,8 @@ following modules first: (say YES if asked to install prerequisites) - install Mail::IMAPClient - install Mail::Message - install IO::Socket::SSL + - install MIME::Base64 + - install MIME::QuotedPrint - then quit cpan, you are done 5. Go to http://asterisk.gnuinter.net/ and download the asterisk-perl module (backup link: http://download.vicidial.com/packages/asterisk-perl-0.08.tar.gz) diff --git a/agc_2-X/trunk/extras/MySQL_AST_CREATE_tables.sql b/agc_2-X/trunk/extras/MySQL_AST_CREATE_tables.sql index 6de3fac6..dabf258d 100644 --- a/agc_2-X/trunk/extras/MySQL_AST_CREATE_tables.sql +++ b/agc_2-X/trunk/extras/MySQL_AST_CREATE_tables.sql @@ -2867,6 +2867,22 @@ KEY vicidial_email_log_lead_id_key (lead_id), KEY vicidial_email_log_email_row_id_key (email_row_id) ); +CREATE TABLE vicidial_report_log ( +report_log_id INT(9) UNSIGNED AUTO_INCREMENT PRIMARY KEY NOT NULL, +event_date DATETIME NOT NULL, +user VARCHAR(20) NOT NULL, +ip_address VARCHAR(15) NOT NULL, +report_name VARCHAR(50) NOT NULL, +browser TEXT, +referer TEXT, +notes TEXT, +url TEXT, +run_time VARCHAR(20) default '0', +index (user), +index (report_name) +); + + ALTER TABLE vicidial_email_list MODIFY message text character set utf8; ALTER TABLE vicidial_email_log MODIFY message text character set utf8; @@ -3105,4 +3121,4 @@ UPDATE vicidial_configuration set value='1766' where name='qc_database_version'; UPDATE system_settings set vdc_agent_api_active='1'; -UPDATE system_settings SET db_schema_version='1343',db_schema_update_date=NOW(); +UPDATE system_settings SET db_schema_version='1344',db_schema_update_date=NOW(); diff --git a/agc_2-X/trunk/extras/upgrade_2.6.sql b/agc_2-X/trunk/extras/upgrade_2.6.sql index 80f21e88..346c7ef8 100644 --- a/agc_2-X/trunk/extras/upgrade_2.6.sql +++ b/agc_2-X/trunk/extras/upgrade_2.6.sql @@ -335,3 +335,20 @@ ALTER TABLE vicidial_carrier_log ADD caller_code VARCHAR(30) default ''; ALTER TABLE vicidial_carrier_log_archive ADD caller_code VARCHAR(30) default ''; UPDATE system_settings SET db_schema_version='1343',db_schema_update_date=NOW() where db_schema_version < 1343; + +CREATE TABLE vicidial_report_log ( +report_log_id INT(9) UNSIGNED AUTO_INCREMENT PRIMARY KEY NOT NULL, +event_date DATETIME NOT NULL, +user VARCHAR(20) NOT NULL, +ip_address VARCHAR(15) NOT NULL, +report_name VARCHAR(50) NOT NULL, +browser TEXT, +referer TEXT, +notes TEXT, +url TEXT, +run_time VARCHAR(20) default '0', +index (user), +index (report_name) +); + +UPDATE system_settings SET db_schema_version='1344',db_schema_update_date=NOW() where db_schema_version < 1344; diff --git a/agc_2-X/trunk/translations/raw_translation_files/TO_BE_TRANSLATED_2.6.txt b/agc_2-X/trunk/translations/raw_translation_files/TO_BE_TRANSLATED_2.6.txt index b3a2f543..c678d264 100644 --- a/agc_2-X/trunk/translations/raw_translation_files/TO_BE_TRANSLATED_2.6.txt +++ b/agc_2-X/trunk/translations/raw_translation_files/TO_BE_TRANSLATED_2.6.txt @@ -184,6 +184,11 @@ Level 8 Disable Add|| This setting if enabled will prevent any level 8 user from adding or copying any record in the system, no matter what their user settings are. Excluded from these restrictions are the ability to add DNC and Filter Phone Groups numbers and the Add a New Lead page. Default is 0 for disabled|| You do not have permission to add records on this system|| These options allows you to limit the viewable callbacks in the agent callback alert section on the agent screen, to only LIVE callbacks. LIVE callbacks are user-only scheduled callbacks that have hit their trigger date and time. ACTIVE call backs are user-only callbacks that are active in the system but have not yet triggered. You can view both ACTIVE and LIVE callbacks by selecting ALL_ACTIVE. Default is ALL_ACTIVE|| +VICIDIAL ADMIN REPORT LOG|| +VICIDIAL USER ADMIN REPORT LOG|| +VICIDIAL DETAIL ADMIN REPORT LOG|| +ADMIN REPORT LOG|| +Admin Report Log Viewer|| ############################################################ CLIENT 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 c1b8173a..31ee1851 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 @@ -1,7 +1,7 @@ LICENSE: AGPLv2 +# Copyright (C) 2013 Matt Florell LICENSE: AGPLv2 # # CHANGES # @@ -20,8 +20,11 @@ # 110703-1756 - Added download option # 111103-2300 - Added user_group restrictions for selecting in-groups # 120224-0910 - Added HTML display option with bar graphs +# 130414-0104 - Added report logging # +$startMS = microtime(); + require("dbconnect.php"); $PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; @@ -69,15 +72,6 @@ if ($qm_conf_ct > 0) ##### END SETTINGS LOOKUP ##### ########################################### -if ( (strlen($slave_db_server)>5) and (preg_match("/$report_name/",$reports_use_slave_db)) ) - { - mysql_close($link); - $use_slave_server=1; - $db_source = 'S'; - require("dbconnect.php"); - $MAIN.="\n"; - } - $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level >= 7 and view_reports='1' and active='Y';"; if ($DB) {$MAIN.="|$stmt|\n";} if ($non_latin > 0) {$rslt=mysql_query("SET NAMES 'UTF8'");} @@ -99,6 +93,35 @@ if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) 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"; + +$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); +##### 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); + $use_slave_server=1; + $db_source = 'S'; + require("dbconnect.php"); + $MAIN.="\n"; + } + $stmt="SELECT user_group from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6 and view_reports='1' and active='Y';"; if ($DB) {$MAIN.="|$stmt|\n";} $rslt=mysql_query($stmt, $link); @@ -1280,10 +1303,8 @@ if ($file_download > 0) flush(); echo "$CSV_text"; - - exit; } - else +else { echo "$HEADER"; @@ -1293,6 +1314,26 @@ if ($file_download > 0) } } +if ($db_source == 'S') + { + mysql_close($link); + $use_slave_server=0; + $db_source = 'M'; + require("dbconnect.php"); + } + +$endMS = microtime(); +$startMSary = explode(" ",$startMS); +$endMSary = explode(" ",$endMS); +$runS = ($endMSary[0] - $startMSary[0]); +$runM = ($endMSary[1] - $startMSary[1]); +$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); + +exit; ?> diff --git a/agc_2-X/trunk/www/vicidial/AST_CLOSERstats.php b/agc_2-X/trunk/www/vicidial/AST_CLOSERstats.php index 4db468b4..5d3748f7 100644 --- a/agc_2-X/trunk/www/vicidial/AST_CLOSERstats.php +++ b/agc_2-X/trunk/www/vicidial/AST_CLOSERstats.php @@ -3,8 +3,7 @@ # # Copyright (C) 2013 Matt Florell LICENSE: AGPLv2 # -# CHANGES -# +# CHANGES: # 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 @@ -37,8 +36,11 @@ # 120224-0910 - Added HTML display option with bar graphs # 120730-0724 - Small fix for HTML output # 130124-1719 - Added email report support +# 130414-1429 - Added report logging # +$startMS = microtime(); + require("dbconnect.php"); require("functions.php"); @@ -96,15 +98,6 @@ if ($qm_conf_ct > 0) ##### END SETTINGS LOOKUP ##### ########################################### -if ( (strlen($slave_db_server)>5) and (preg_match("/$report_name/",$reports_use_slave_db)) ) - { - mysql_close($link); - $use_slave_server=1; - $db_source = 'S'; - require("dbconnect.php"); - $MAIN.="\n"; - } - $stmt = "SELECT local_gmt FROM servers where active='Y' limit 1;"; $rslt=mysql_query($stmt, $link); @@ -242,6 +235,37 @@ else } if (strlen($group_SQL)<3) {$group_SQL="''";} +##### 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"; + +$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); +##### 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); + $use_slave_server=1; + $db_source = 'S'; + require("dbconnect.php"); + $MAIN.="\n"; + } $stmt="select vsc_id,vsc_name from vicidial_status_categories;"; $rslt=mysql_query($stmt, $link); @@ -2554,7 +2578,6 @@ if ($file_download>0) { echo "$CSV_text"; - exit; } else { echo $HEADER; echo $JS_text; @@ -2564,6 +2587,27 @@ if ($file_download>0) { } +if ($db_source == 'S') + { + mysql_close($link); + $use_slave_server=0; + $db_source = 'M'; + require("dbconnect.php"); + } + +$endMS = microtime(); +$startMSary = explode(" ",$startMS); +$endMSary = explode(" ",$endMS); +$runS = ($endMSary[0] - $startMSary[0]); +$runM = ($endMSary[1] - $startMSary[1]); +$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); + +exit; + diff --git a/agc_2-X/trunk/www/vicidial/AST_CLOSERsummary_hourly.php b/agc_2-X/trunk/www/vicidial/AST_CLOSERsummary_hourly.php index bc23c425..80419335 100644 --- a/agc_2-X/trunk/www/vicidial/AST_CLOSERsummary_hourly.php +++ b/agc_2-X/trunk/www/vicidial/AST_CLOSERsummary_hourly.php @@ -1,7 +1,7 @@ LICENSE: AGPLv2 +# Copyright (C) 2013 Matt Florell LICENSE: AGPLv2 # # CHANGES # @@ -15,8 +15,11 @@ # 110703-1806 - Added download option # 111103-2315 - Added user_group restrictions for selecting in-groups # 120224-0910 - Added HTML display option with bar graphs +# 130414-0107 - Added report logging # +$startMS = microtime(); + require("dbconnect.php"); require("functions.php"); @@ -82,15 +85,6 @@ if ($qm_conf_ct > 0) ##### END SETTINGS LOOKUP ##### ########################################### -if ( (strlen($slave_db_server)>5) and (preg_match("/$report_name/",$reports_use_slave_db)) ) - { - mysql_close($link); - $use_slave_server=1; - $db_source = 'S'; - require("dbconnect.php"); - $MAIN.="\n"; - } - $stmt = "SELECT local_gmt FROM servers where active='Y' limit 1;"; $rslt=mysql_query($stmt, $link); if ($DB) {$MAIN.="$stmt\n";} @@ -124,6 +118,35 @@ if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) 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"; + +$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, $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); +##### 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); + $use_slave_server=1; + $db_source = 'S'; + require("dbconnect.php"); + $MAIN.="\n"; + } + $stmt="SELECT user_group from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6 and view_reports='1' and active='Y';"; if ($DB) {$MAIN.="|$stmt|\n";} $rslt=mysql_query($stmt, $link); @@ -938,6 +961,25 @@ else $ASCII_text.="INBOUND $query_date to $end_date,   $rawTOTtalk_min minutes at \$$inbound_rate = \$$inbound_cost\n"; + if ($db_source == 'S') + { + mysql_close($link); + $use_slave_server=0; + $db_source = 'M'; + require("dbconnect.php"); + } + + $endMS = microtime(); + $startMSary = explode(" ",$startMS); + $endMSary = explode(" ",$endMS); + $runS = ($endMSary[0] - $startMSary[0]); + $runM = ($endMSary[1] - $startMSary[1]); + $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); + exit; } @@ -961,10 +1003,8 @@ if ($file_download > 0) flush(); echo "$CSV_text"; - - exit; } - else +else { if ($report_display_type=="HTML") @@ -998,5 +1038,24 @@ if ($file_download > 0) } +if ($db_source == 'S') + { + mysql_close($link); + $use_slave_server=0; + $db_source = 'M'; + require("dbconnect.php"); + } + +$endMS = microtime(); +$startMSary = explode(" ",$startMS); +$endMSary = explode(" ",$endMS); +$runS = ($endMSary[0] - $startMSary[0]); +$runM = ($endMSary[1] - $startMSary[1]); +$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); + ?> diff --git a/agc_2-X/trunk/www/vicidial/AST_DIDstats.php b/agc_2-X/trunk/www/vicidial/AST_DIDstats.php index b3c41a12..de26a509 100644 --- a/agc_2-X/trunk/www/vicidial/AST_DIDstats.php +++ b/agc_2-X/trunk/www/vicidial/AST_DIDstats.php @@ -1,7 +1,7 @@ LICENSE: AGPLv2 +# Copyright (C) 2013 Matt Florell LICENSE: AGPLv2 # # CHANGES # @@ -15,8 +15,11 @@ # 110703-1809 - Added download option # 111104-1133 - Added user_group restrictions for selecting in-groups # 120224-0910 - Added HTML display option with bar graphs +# 130414-0113 - Added report logging # +$startMS = microtime(); + require("dbconnect.php"); require("functions.php"); @@ -67,15 +70,6 @@ if ($qm_conf_ct > 0) ##### END SETTINGS LOOKUP ##### ########################################### -if ( (strlen($slave_db_server)>5) and (preg_match("/$report_name/",$reports_use_slave_db)) ) - { - mysql_close($link); - $use_slave_server=1; - $db_source = 'S'; - require("dbconnect.php"); - $MAIN.="\n"; - } - $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level >= 7 and view_reports='1' and active='Y';"; if ($DB) {$MAIN.="|$stmt|\n";} if ($non_latin > 0) {$rslt=mysql_query("SET NAMES 'UTF8'");} @@ -189,6 +183,36 @@ else if (strlen($group_SQL)<3) {$group_SQL="''";} +##### 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"; + +$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, $file_download, $report_display_type|', url='".$LOGfull_url."?DB=".$DB."&file_download=".$file_download."&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); +##### 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); + $use_slave_server=1; + $db_source = 'S'; + require("dbconnect.php"); + $MAIN.="\n"; + } $HEADER.="\n"; $HEADER.="\n"; @@ -1070,6 +1094,25 @@ else echo "$CSV_text"; + if ($db_source == 'S') + { + mysql_close($link); + $use_slave_server=0; + $db_source = 'M'; + require("dbconnect.php"); + } + + $endMS = microtime(); + $startMSary = explode(" ",$startMS); + $endMSary = explode(" ",$endMS); + $runS = ($endMSary[0] - $startMSary[0]); + $runM = ($endMSary[1] - $startMSary[1]); + $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); + exit; } else { echo $HEADER; @@ -1079,5 +1122,25 @@ else echo $MAIN; } +if ($db_source == 'S') + { + mysql_close($link); + $use_slave_server=0; + $db_source = 'M'; + require("dbconnect.php"); + } + +$endMS = microtime(); +$startMSary = explode(" ",$startMS); +$endMSary = explode(" ",$endMS); +$runS = ($endMSary[0] - $startMSary[0]); +$runM = ($endMSary[1] - $startMSary[1]); +$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); + + ?> diff --git a/agc_2-X/trunk/www/vicidial/AST_GROUP_ALIASstats.php b/agc_2-X/trunk/www/vicidial/AST_GROUP_ALIASstats.php index 28b7b2d1..ff8a0d59 100644 --- a/agc_2-X/trunk/www/vicidial/AST_GROUP_ALIASstats.php +++ b/agc_2-X/trunk/www/vicidial/AST_GROUP_ALIASstats.php @@ -1,7 +1,7 @@ LICENSE: AGPLv2 +# Copyright (C) 2013 Matt Florell LICENSE: AGPLv2 # # If you are going to run this report I would recommend adding the following in MySQL: # CREATE INDEX extension on call_log (extension); @@ -9,8 +9,13 @@ # CHANGES # # 90914-1003 - First build +# 130414-0214 - Added report logging # +$startMS = microtime(); + +$report_name='Group Alias Report'; + require("dbconnect.php"); require("functions.php"); @@ -54,7 +59,6 @@ $rslt=mysql_query($stmt, $link); $row=mysql_fetch_row($rslt); $auth=$row[0]; - if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) { Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); @@ -63,6 +67,26 @@ if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) 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"; + +$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 |$query_date, $end_date|', url='$LOGfull_url';"; +if ($DB) {echo "|$stmt|\n";} +$rslt=mysql_query($stmt, $link); +$report_log_id = mysql_insert_id($link); +##### END log visit to the vicidial_report_log table ##### + $NOW_DATE = date("Y-m-d"); $NOW_TIME = date("Y-m-d H:i:s"); $STARTtime = date("U"); @@ -234,6 +258,25 @@ $ENDtime = date("U"); $RUNtime = ($ENDtime - $STARTtime); echo "

\nRun Time: $RUNtime seconds\n"; +if ($db_source == 'S') + { + mysql_close($link); + $use_slave_server=0; + $db_source = 'M'; + require("dbconnect.php"); + } + +$endMS = microtime(); +$startMSary = explode(" ",$startMS); +$endMSary = explode(" ",$endMS); +$runS = ($endMSary[0] - $startMSary[0]); +$runM = ($endMSary[1] - $startMSary[1]); +$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); + } ?> diff --git a/agc_2-X/trunk/www/vicidial/AST_IVRfilter.php b/agc_2-X/trunk/www/vicidial/AST_IVRfilter.php index af0adedf..8ade418c 100644 --- a/agc_2-X/trunk/www/vicidial/AST_IVRfilter.php +++ b/agc_2-X/trunk/www/vicidial/AST_IVRfilter.php @@ -1,7 +1,7 @@ LICENSE: AGPLv2 +# Copyright (C) 2013 Matt Florell LICENSE: AGPLv2 # # CHANGES # @@ -9,8 +9,13 @@ # 90310-2054 - Admin header # 90508-0644 - Changed to PHP long tags # 120113-2022 - Added new columns for sent to queue and agent +# 130414-0257 - Added report logging # +$startMS = microtime(); + +$report_name='IVR Filter Report'; + require("dbconnect.php"); $PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; @@ -88,6 +93,26 @@ if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) 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"; + +$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 |$campaign[0], $query_date, $end_date|', url='$LOGfull_url';"; +if ($DB) {echo "|$stmt|\n";} +$rslt=mysql_query($stmt, $link); +$report_log_id = mysql_insert_id($link); +##### END log visit to the vicidial_report_log table ##### + $NOW_DATE = date("Y-m-d"); $NOW_TIME = date("Y-m-d H:i:s"); $STARTtime = date("U"); @@ -494,8 +519,6 @@ if ($file_download == 0 || !$file_download) { flush(); echo "$CSV_text"; - - exit; # $CSV_report=fopen("AST_pause_code_breakdown.csv", "w"); # fwrite($CSV_report, $CSV_header); @@ -503,4 +526,26 @@ if ($file_download == 0 || !$file_download) { # fwrite($CSV_report, $CSV_total); } + +if ($db_source == 'S') + { + mysql_close($link); + $use_slave_server=0; + $db_source = 'M'; + require("dbconnect.php"); + } + +$endMS = microtime(); +$startMSary = explode(" ",$startMS); +$endMSary = explode(" ",$endMS); +$runS = ($endMSary[0] - $startMSary[0]); +$runM = ($endMSary[1] - $startMSary[1]); +$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); + +exit; + ?> \ No newline at end of file diff --git a/agc_2-X/trunk/www/vicidial/AST_IVRstats.php b/agc_2-X/trunk/www/vicidial/AST_IVRstats.php index 9f5ad460..536c64ca 100644 --- a/agc_2-X/trunk/www/vicidial/AST_IVRstats.php +++ b/agc_2-X/trunk/www/vicidial/AST_IVRstats.php @@ -1,7 +1,7 @@ LICENSE: AGPLv2 +# Copyright (C) 2013 Matt Florell LICENSE: AGPLv2 # # CHANGES # 81026-2026 - First build @@ -20,8 +20,11 @@ # 110703-1850 - Added download option # 111103-2315 - Added user_group restrictions for selecting in-groups # 120224-0910 - Added HTML display option with bar graphs +# 130114-0115 - Added report logging # +$startMS = microtime(); + require("dbconnect.php"); $PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; @@ -79,15 +82,6 @@ if ($qm_conf_ct > 0) ##### END SETTINGS LOOKUP ##### ########################################### -if ( (strlen($slave_db_server)>5) and (preg_match("/$report_name/",$reports_use_slave_db)) ) - { - mysql_close($link); - $use_slave_server=1; - $db_source = 'S'; - require("dbconnect.php"); - $MAIN.="\n"; - } - $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level >= 7 and view_reports='1' and active='Y';"; if ($DB) {$MAIN.="|$stmt|\n";} if ($non_latin > 0) {$rslt=mysql_query("SET NAMES 'UTF8'");} @@ -109,6 +103,35 @@ if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) 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"; + +$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, $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); +##### 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); + $use_slave_server=1; + $db_source = 'S'; + require("dbconnect.php"); + $MAIN.="\n"; + } + $stmt="SELECT user_group from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6 and view_reports='1' and active='Y';"; if ($DB) {$MAIN.="|$stmt|\n";} $rslt=mysql_query($stmt, $link); @@ -1001,6 +1024,25 @@ else echo "$CSV_text"; + if ($db_source == 'S') + { + mysql_close($link); + $use_slave_server=0; + $db_source = 'M'; + require("dbconnect.php"); + } + + $endMS = microtime(); + $startMSary = explode(" ",$startMS); + $endMSary = explode(" ",$endMS); + $runS = ($endMSary[0] - $startMSary[0]); + $runM = ($endMSary[1] - $startMSary[1]); + $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); + exit; } else { $JS_onload.="}\n"; @@ -1013,6 +1055,25 @@ else echo $MAIN; } +if ($db_source == 'S') + { + mysql_close($link); + $use_slave_server=0; + $db_source = 'M'; + require("dbconnect.php"); + } + +$endMS = microtime(); +$startMSary = explode(" ",$startMS); +$endMSary = explode(" ",$endMS); +$runS = ($endMSary[0] - $startMSary[0]); +$runM = ($endMSary[1] - $startMSary[1]); +$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); + ?> diff --git a/agc_2-X/trunk/www/vicidial/AST_LISTS_campaign_stats.php b/agc_2-X/trunk/www/vicidial/AST_LISTS_campaign_stats.php index 23cd522d..3288e58d 100644 --- a/agc_2-X/trunk/www/vicidial/AST_LISTS_campaign_stats.php +++ b/agc_2-X/trunk/www/vicidial/AST_LISTS_campaign_stats.php @@ -12,8 +12,11 @@ # 120224-0910 - Added HTML display option with bar graphs # 120524-1754 - Fixed status categories issue # 130221-1928 - small change to remove nested SQL query +# 130414-0127 - Added report logging # +$startMS = microtime(); + header ("Content-type: text/html; charset=utf-8"); require("dbconnect.php"); @@ -60,15 +63,6 @@ if ($qm_conf_ct > 0) ##### END SETTINGS LOOKUP ##### ########################################### -if ( (strlen($slave_db_server)>5) and (preg_match("/$report_name/",$reports_use_slave_db)) ) - { - mysql_close($link); - $use_slave_server=1; - $db_source = 'S'; - require("dbconnect.php"); - $MAIN.="\n"; - } - $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level >= 7 and view_reports='1' and active='Y';"; if ($DB) {$MAIN.="|$stmt|\n";} if ($non_latin > 0) {$rslt=mysql_query("SET NAMES 'UTF8'");} @@ -90,6 +84,35 @@ if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) 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"; + +$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, $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); +##### 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); + $use_slave_server=1; + $db_source = 'S'; + require("dbconnect.php"); + $MAIN.="\n"; + } + $stmt="SELECT user_group from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6 and view_reports='1' and active='Y';"; if ($DB) {$MAIN.="|$stmt|\n";} $rslt=mysql_query($stmt, $link); @@ -982,7 +1005,6 @@ else echo "$CSV_text"; - exit; } else { $JS_onload.="}\n"; $JS_text.=$JS_onload; @@ -995,5 +1017,25 @@ else } +if ($db_source == 'S') + { + mysql_close($link); + $use_slave_server=0; + $db_source = 'M'; + require("dbconnect.php"); + } + +$endMS = microtime(); +$startMSary = explode(" ",$startMS); +$endMSary = explode(" ",$endMS); +$runS = ($endMSary[0] - $startMSary[0]); +$runM = ($endMSary[1] - $startMSary[1]); +$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); + +exit; ?> diff --git a/agc_2-X/trunk/www/vicidial/AST_LIST_UPDATEstats.php b/agc_2-X/trunk/www/vicidial/AST_LIST_UPDATEstats.php index a0424e20..5e3411df 100644 --- a/agc_2-X/trunk/www/vicidial/AST_LIST_UPDATEstats.php +++ b/agc_2-X/trunk/www/vicidial/AST_LIST_UPDATEstats.php @@ -1,7 +1,7 @@ LICENSE: AGPLv2 +# Copyright (C) 2013 Matt Florell LICENSE: AGPLv2 # # CHANGES # @@ -10,8 +10,11 @@ # 100712-1324 - Added system setting slave server option # 100802-2347 - Added User Group Allowed Reports option validation # 100914-1326 - Added lookup for user_level 7 users to set to reports only which will remove other admin links +# 130414-0201 - Added report logging # +$startMS = microtime(); + require("dbconnect.php"); require("functions.php"); @@ -54,15 +57,6 @@ if ($qm_conf_ct > 0) ##### END SETTINGS LOOKUP ##### ########################################### -if ( (strlen($slave_db_server)>5) and (preg_match("/$report_name/",$reports_use_slave_db)) ) - { - mysql_close($link); - $use_slave_server=1; - $db_source = 'S'; - require("dbconnect.php"); - echo "\n"; - } - $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level >= 7 and view_reports='1' and active='Y';"; if ($DB) {echo "|$stmt|\n";} if ($non_latin > 0) {$rslt=mysql_query("SET NAMES 'UTF8'");} @@ -84,6 +78,35 @@ if ( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) 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"; + +$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 |$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); +##### 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); + $use_slave_server=1; + $db_source = 'S'; + require("dbconnect.php"); + echo "\n"; + } + $stmt="SELECT user_group from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6 and view_reports='1' and active='Y';"; if ($DB) {echo "|$stmt|\n";} $rslt=mysql_query($stmt, $link); @@ -233,6 +256,24 @@ $RUNtime = ($ENDtime - $STARTtime); echo "
\nRun Time: $RUNtime seconds|$db_source\n"; } +if ($db_source == 'S') + { + mysql_close($link); + $use_slave_server=0; + $db_source = 'M'; + require("dbconnect.php"); + } + +$endMS = microtime(); +$startMSary = explode(" ",$startMS); +$endMSary = explode(" ",$endMS); +$runS = ($endMSary[0] - $startMSary[0]); +$runM = ($endMSary[1] - $startMSary[1]); +$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); ?> diff --git a/agc_2-X/trunk/www/vicidial/AST_OUTBOUNDsummary_interval.php b/agc_2-X/trunk/www/vicidial/AST_OUTBOUNDsummary_interval.php index 90fb0409..48c66262 100644 --- a/agc_2-X/trunk/www/vicidial/AST_OUTBOUNDsummary_interval.php +++ b/agc_2-X/trunk/www/vicidial/AST_OUTBOUNDsummary_interval.php @@ -1,7 +1,7 @@ LICENSE: AGPLv2 +# Copyright (C) 2013 Matt Florell LICENSE: AGPLv2 # # CHANGES # @@ -15,8 +15,11 @@ # 110703-1825 - Added download option # 111104-1205 - Added user_group and calltime restrictions # 120224-0910 - Added HTML display option with bar graphs +# 130414-0119 - Added report logging # +$startMS = microtime(); + require("dbconnect.php"); require("functions.php"); @@ -82,15 +85,6 @@ if ($qm_conf_ct > 0) ##### END SETTINGS LOOKUP ##### ########################################### -if ( (strlen($slave_db_server)>5) and (preg_match("/$report_name/",$reports_use_slave_db)) ) - { - mysql_close($link); - $use_slave_server=1; - $db_source = 'S'; - require("dbconnect.php"); - $MAIN.="\n"; - } - $stmt = "SELECT local_gmt FROM servers where active='Y' limit 1;"; $rslt=mysql_query($stmt, $link); if ($DB) {$MAIN.="$stmt\n";} @@ -132,6 +126,35 @@ if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) 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"; + +$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, $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); +##### 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); + $use_slave_server=1; + $db_source = 'S'; + require("dbconnect.php"); + $MAIN.="\n"; + } + $LOGallowed_campaignsSQL=''; $whereLOGallowed_campaignsSQL=''; $stmt="SELECT allowed_campaigns,allowed_reports,admin_viewable_call_times from vicidial_user_groups where user_group='$user_group';"; @@ -1452,6 +1475,25 @@ else $ASCII_text.="INBOUND $query_date to $end_date,   $rawTOTtalk_min minutes at \$$inbound_rate = \$$inbound_cost\n"; + if ($db_source == 'S') + { + mysql_close($link); + $use_slave_server=0; + $db_source = 'M'; + require("dbconnect.php"); + } + + $endMS = microtime(); + $startMSary = explode(" ",$startMS); + $endMSary = explode(" ",$endMS); + $runS = ($endMSary[0] - $startMSary[0]); + $runM = ($endMSary[1] - $startMSary[1]); + $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); + exit; } @@ -1521,6 +1563,25 @@ else echo "$CSV_text"; + if ($db_source == 'S') + { + mysql_close($link); + $use_slave_server=0; + $db_source = 'M'; + require("dbconnect.php"); + } + + $endMS = microtime(); + $startMSary = explode(" ",$startMS); + $endMSary = explode(" ",$endMS); + $runS = ($endMSary[0] - $startMSary[0]); + $runM = ($endMSary[1] - $startMSary[1]); + $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); + exit; } else { $JS_onload.="}\n"; @@ -1555,6 +1616,24 @@ else } +if ($db_source == 'S') + { + mysql_close($link); + $use_slave_server=0; + $db_source = 'M'; + require("dbconnect.php"); + } + +$endMS = microtime(); +$startMSary = explode(" ",$startMS); +$endMSary = explode(" ",$endMS); +$runS = ($endMSary[0] - $startMSary[0]); +$runM = ($endMSary[1] - $startMSary[1]); +$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); ?> diff --git a/agc_2-X/trunk/www/vicidial/AST_VDADstats.php b/agc_2-X/trunk/www/vicidial/AST_VDADstats.php index 9e7d9c64..12cac4c2 100644 --- a/agc_2-X/trunk/www/vicidial/AST_VDADstats.php +++ b/agc_2-X/trunk/www/vicidial/AST_VDADstats.php @@ -1,7 +1,7 @@ LICENSE: AGPLv2 +# Copyright (C) 2013 Matt Florell LICENSE: AGPLv2 # # CHANGES # 60619-1718 - Added variable filtering to eliminate SQL injection attack threat @@ -32,8 +32,11 @@ # 100914-1326 - Added lookup for user_level 7 users to set to reports only which will remove other admin links # 101207-1634 - Changed limits on seconds to 65000 from 36000 in vicidial_agent_log # 120224-0910 - Added HTML display option with bar graphs +# 130414-0117 - Added report logging # +$startMS = microtime(); + header ("Content-type: text/html; charset=utf-8"); require("dbconnect.php"); @@ -103,15 +106,6 @@ if ($qm_conf_ct > 0) ##### END SETTINGS LOOKUP ##### ########################################### -if ( (strlen($slave_db_server)>5) and (preg_match("/$report_name/",$reports_use_slave_db)) ) - { - mysql_close($link); - $use_slave_server=1; - $db_source = 'S'; - require("dbconnect.php"); - echo "\n"; - } - ##### SERVER CARRIER LOGGING LOOKUP ##### $stmt = "SELECT count(*) FROM servers where carrier_logging_active='Y' and max_vicidial_trunks > 0;"; $rslt=mysql_query($stmt, $link); @@ -144,6 +138,35 @@ if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) 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"; + +$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, $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); +##### 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); + $use_slave_server=1; + $db_source = 'S'; + require("dbconnect.php"); + echo "\n"; + } + $stmt="SELECT user_group from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6 and view_reports='1' and active='Y';"; if ($DB) {echo "|$stmt|\n";} $rslt=mysql_query($stmt, $link); @@ -1557,6 +1580,25 @@ else echo "OUTBOUND $query_date to $end_date,   $rawTOTtalk_min minutes at \$$outbound_rate = \$$outbound_cost\n"; + if ($db_source == 'S') + { + mysql_close($link); + $use_slave_server=0; + $db_source = 'M'; + require("dbconnect.php"); + } + + $endMS = microtime(); + $startMSary = explode(" ",$startMS); + $endMSary = explode(" ",$endMS); + $runS = ($endMSary[0] - $startMSary[0]); + $runM = ($endMSary[1] - $startMSary[1]); + $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); + exit; } @@ -1792,6 +1834,25 @@ else $JS_text.="\n"; echo $JS_text; +if ($db_source == 'S') + { + mysql_close($link); + $use_slave_server=0; + $db_source = 'M'; + require("dbconnect.php"); + } + +$endMS = microtime(); +$startMSary = explode(" ",$startMS); +$endMSary = explode(" ",$endMS); +$runS = ($endMSary[0] - $startMSary[0]); +$runM = ($endMSary[1] - $startMSary[1]); +$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); + ?> diff --git a/agc_2-X/trunk/www/vicidial/AST_VICIDIAL_hopperlist.php b/agc_2-X/trunk/www/vicidial/AST_VICIDIAL_hopperlist.php index b9e76cdd..f47aeb69 100644 --- a/agc_2-X/trunk/www/vicidial/AST_VICIDIAL_hopperlist.php +++ b/agc_2-X/trunk/www/vicidial/AST_VICIDIAL_hopperlist.php @@ -1,7 +1,7 @@ LICENSE: AGPLv2 +# Copyright (C) 2013 Matt Florell LICENSE: AGPLv2 # # CHANGES # @@ -16,8 +16,13 @@ # 111103-1207 - Added admin_hide_phone_data and admin_hide_lead_data options # 120210-1218 - Added vendor_lead_code to output # 120221-0059 - Added User Group restriction settings +# 130414-0159 - Added report logging # +$startMS = microtime(); + +$report_name='Hopper List Report'; + require("dbconnect.php"); $PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; @@ -49,6 +54,26 @@ if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) 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"; + +$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); +##### END log visit to the vicidial_report_log table ##### + $stmt="SELECT full_name,user_group,admin_hide_lead_data,admin_hide_phone_data from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; $rslt=mysql_query($stmt, $link); $row=mysql_fetch_row($rslt); @@ -226,6 +251,24 @@ else } +if ($db_source == 'S') + { + mysql_close($link); + $use_slave_server=0; + $db_source = 'M'; + require("dbconnect.php"); + } + +$endMS = microtime(); +$startMSary = explode(" ",$startMS); +$endMSary = explode(" ",$endMS); +$runS = ($endMSary[0] - $startMSary[0]); +$runM = ($endMSary[1] - $startMSary[1]); +$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); ?> diff --git a/agc_2-X/trunk/www/vicidial/AST_VICIDIAL_ingrouplist.php b/agc_2-X/trunk/www/vicidial/AST_VICIDIAL_ingrouplist.php index 8ba9630d..435bf338 100644 --- a/agc_2-X/trunk/www/vicidial/AST_VICIDIAL_ingrouplist.php +++ b/agc_2-X/trunk/www/vicidial/AST_VICIDIAL_ingrouplist.php @@ -3,12 +3,17 @@ # # shows the agents logged into vicidial and set to take calls from in-group # -# Copyright (C) 2010 Matt Florell LICENSE: AGPLv2 +# Copyright (C) 2013 Matt Florell LICENSE: AGPLv2 # # CHANGES # 100320-2102 - First Build +# 130414-0222 - Added report logging # +$startMS = microtime(); + +$report_name='In-Group User List'; + require("dbconnect.php"); $PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; @@ -40,6 +45,26 @@ if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) 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"; + +$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|', url='$LOGfull_url';"; +if ($DB) {echo "|$stmt|\n";} +$rslt=mysql_query($stmt, $link); +$report_log_id = mysql_insert_id($link); +##### END log visit to the vicidial_report_log table ##### + $NOW_DATE = date("Y-m-d"); $NOW_TIME = date("Y-m-d H:i:s"); $STARTtime = date("U"); @@ -205,6 +230,25 @@ else } +if ($db_source == 'S') + { + mysql_close($link); + $use_slave_server=0; + $db_source = 'M'; + require("dbconnect.php"); + } + +$endMS = microtime(); +$startMSary = explode(" ",$startMS); +$endMSary = explode(" ",$endMS); +$runS = ($endMSary[0] - $startMSary[0]); +$runM = ($endMSary[1] - $startMSary[1]); +$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); + ?> diff --git a/agc_2-X/trunk/www/vicidial/AST_agent_days_detail.php b/agc_2-X/trunk/www/vicidial/AST_agent_days_detail.php index 333027ce..b9022b6f 100644 --- a/agc_2-X/trunk/www/vicidial/AST_agent_days_detail.php +++ b/agc_2-X/trunk/www/vicidial/AST_agent_days_detail.php @@ -1,7 +1,7 @@ LICENSE: AGPLv2 +# Copyright (C) 2013 Matt Florell LICENSE: AGPLv2 # # CHANGES # @@ -16,8 +16,10 @@ # 100914-1326 - Added lookup for user_level 7 users to set to reports only which will remove other admin links # 111104-1302 - Added user_group restrictions for selecting in-groups # 120224-0910 - Added HTML display option with bar graphs +# 130414-0143 - Added report logging # +$startMS = microtime(); require("dbconnect.php"); @@ -71,15 +73,6 @@ if ($qm_conf_ct > 0) ##### END SETTINGS LOOKUP ##### ########################################### -if ( (strlen($slave_db_server)>5) and (preg_match("/$report_name/",$reports_use_slave_db)) ) - { - mysql_close($link); - $use_slave_server=1; - $db_source = 'S'; - require("dbconnect.php"); - echo "\n"; - } - $PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); $PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); @@ -104,6 +97,35 @@ if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) 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"; + +$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, $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); +##### 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); + $use_slave_server=1; + $db_source = 'S'; + require("dbconnect.php"); + echo "\n"; + } + $stmt="SELECT user_group from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6 and view_reports='1' and active='Y';"; if ($DB) {echo "|$stmt|\n";} $rslt=mysql_query($stmt, $link); @@ -718,6 +740,25 @@ if ($file_download > 0) echo "$file_output"; + if ($db_source == 'S') + { + mysql_close($link); + $use_slave_server=0; + $db_source = 'M'; + require("dbconnect.php"); + } + + $endMS = microtime(); + $startMSary = explode(" ",$startMS); + $endMSary = explode(" ",$endMS); + $runS = ($endMSary[0] - $startMSary[0]); + $runM = ($endMSary[1] - $startMSary[1]); + $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); + exit; } @@ -846,6 +887,27 @@ if ($report_display_type=="TEXT" || !$report_display_type) echo "\n"; } + +if ($db_source == 'S') + { + mysql_close($link); + $use_slave_server=0; + $db_source = 'M'; + require("dbconnect.php"); + } + +$endMS = microtime(); +$startMSary = explode(" ",$startMS); +$endMSary = explode(" ",$endMS); +$runS = ($endMSary[0] - $startMSary[0]); +$runM = ($endMSary[1] - $startMSary[1]); +$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); + + ?> diff --git a/agc_2-X/trunk/www/vicidial/AST_agent_performance_detail.php b/agc_2-X/trunk/www/vicidial/AST_agent_performance_detail.php index c432be4e..fb6ac8c4 100644 --- a/agc_2-X/trunk/www/vicidial/AST_agent_performance_detail.php +++ b/agc_2-X/trunk/www/vicidial/AST_agent_performance_detail.php @@ -1,7 +1,7 @@ LICENSE: AGPLv2 +# Copyright (C) 2013 Matt Florell LICENSE: AGPLv2 # # CHANGES # @@ -31,8 +31,11 @@ # 111104-1249 - Added user_group restrictions for selecting in-groups # 120224-0910 - Added HTML display option with bar graphs # 121130-0952 - Fix for user group permissions issue #588 +# 130414-0140 - Added report logging # +$startMS = microtime(); + require("dbconnect.php"); require("functions.php"); @@ -87,15 +90,6 @@ if ($qm_conf_ct > 0) ##### END SETTINGS LOOKUP ##### ########################################### -if ( (strlen($slave_db_server)>5) and (preg_match("/$report_name/",$reports_use_slave_db)) ) - { - mysql_close($link); - $use_slave_server=1; - $db_source = 'S'; - require("dbconnect.php"); - $HTML_text.="\n"; - } - $PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); $PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); @@ -120,6 +114,35 @@ if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) 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"; + +$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, $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); +##### 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); + $use_slave_server=1; + $db_source = 'S'; + require("dbconnect.php"); + $HTML_text.="\n"; + } + $stmt="SELECT user_group from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6 and view_reports='1' and active='Y';"; if ($DB) {$HTML_text.="|$stmt|\n";} $rslt=mysql_query($stmt, $link); @@ -960,6 +983,25 @@ if ($file_download == 1) echo "$CSV_header$CSV_lines$CSV_total"; + if ($db_source == 'S') + { + mysql_close($link); + $use_slave_server=0; + $db_source = 'M'; + require("dbconnect.php"); + } + + $endMS = microtime(); + $startMSary = explode(" ",$startMS); + $endMSary = explode(" ",$endMS); + $runS = ($endMSary[0] - $startMSary[0]); + $runM = ($endMSary[1] - $startMSary[1]); + $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); + exit; } @@ -974,11 +1016,6 @@ $ASCII_text.="\n\n"; - - - - - $sub_statuses='-'; $sub_statusesTXT=''; $sub_statusesHEAD=''; @@ -1330,6 +1367,25 @@ if ($file_download == 2) echo "$CSV_header$CSV_lines$CSV_total"; + if ($db_source == 'S') + { + mysql_close($link); + $use_slave_server=0; + $db_source = 'M'; + require("dbconnect.php"); + } + + $endMS = microtime(); + $startMSary = explode(" ",$startMS); + $endMSary = explode(" ",$endMS); + $runS = ($endMSary[0] - $startMSary[0]); + $runM = ($endMSary[1] - $startMSary[1]); + $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); + exit; } $CSV_report=fopen("AST_pause_code_breakdown.csv", "w"); @@ -1360,5 +1416,25 @@ if ($file_download == 0 || !$file_download) { } +if ($db_source == 'S') + { + mysql_close($link); + $use_slave_server=0; + $db_source = 'M'; + require("dbconnect.php"); + } + +$endMS = microtime(); +$startMSary = explode(" ",$startMS); +$endMSary = explode(" ",$endMS); +$runS = ($endMSary[0] - $startMSary[0]); +$runM = ($endMSary[1] - $startMSary[1]); +$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); + +exit; ?> diff --git a/agc_2-X/trunk/www/vicidial/AST_agent_status_detail.php b/agc_2-X/trunk/www/vicidial/AST_agent_status_detail.php index ad6ffeba..aab6aa31 100644 --- a/agc_2-X/trunk/www/vicidial/AST_agent_status_detail.php +++ b/agc_2-X/trunk/www/vicidial/AST_agent_status_detail.php @@ -1,7 +1,7 @@ LICENSE: AGPLv2 +# Copyright (C) 2013 Matt Florell LICENSE: AGPLv2 # # CHANGES # @@ -18,8 +18,10 @@ # 111104-1248 - Added user_group restrictions for selecting in-groups # 120224-0910 - Added HTML display option with bar graphs # 121130-0958 - Fix for user group permissions issue #588 +# 130414-0139 - Added report logging # +$startMS = microtime(); require("dbconnect.php"); @@ -73,15 +75,6 @@ if ($qm_conf_ct > 0) ##### END SETTINGS LOOKUP ##### ########################################### -if ( (strlen($slave_db_server)>5) and (preg_match("/$report_name/",$reports_use_slave_db)) ) - { - mysql_close($link); - $use_slave_server=1; - $db_source = 'S'; - require("dbconnect.php"); -# echo "\n"; - } - $PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); $PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); @@ -106,6 +99,35 @@ if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) 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"; + +$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, $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); +##### 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); + $use_slave_server=1; + $db_source = 'S'; + require("dbconnect.php"); +# echo "\n"; + } + $stmt="SELECT user_group from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6 and view_reports='1' and active='Y';"; if ($DB) {echo "|$stmt|\n";} $rslt=mysql_query($stmt, $link); @@ -791,6 +813,25 @@ if ($file_download > 0) echo "$file_output"; + if ($db_source == 'S') + { + mysql_close($link); + $use_slave_server=0; + $db_source = 'M'; + require("dbconnect.php"); + } + + $endMS = microtime(); + $startMSary = explode(" ",$startMS); + $endMSary = explode(" ",$endMS); + $runS = ($endMSary[0] - $startMSary[0]); + $runM = ($endMSary[1] - $startMSary[1]); + $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); + exit; } @@ -933,6 +974,26 @@ if (!$report_display_type || $report_display_type=="TEXT") echo "\n"; } + +if ($db_source == 'S') + { + mysql_close($link); + $use_slave_server=0; + $db_source = 'M'; + require("dbconnect.php"); + } + +$endMS = microtime(); +$startMSary = explode(" ",$startMS); +$endMSary = explode(" ",$endMS); +$runS = ($endMSary[0] - $startMSary[0]); +$runM = ($endMSary[1] - $startMSary[1]); +$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); + ?> \ No newline at end of file diff --git a/agc_2-X/trunk/www/vicidial/AST_agent_time_detail.php b/agc_2-X/trunk/www/vicidial/AST_agent_time_detail.php index dd08f96c..4b635912 100644 --- a/agc_2-X/trunk/www/vicidial/AST_agent_time_detail.php +++ b/agc_2-X/trunk/www/vicidial/AST_agent_time_detail.php @@ -4,7 +4,7 @@ # Pulls time stats per agent selectable by campaign or user group # should be most accurate agent stats of all of the reports # -# Copyright (C) 2012 Matt Florell LICENSE: AGPLv2 +# Copyright (C) 2013 Matt Florell LICENSE: AGPLv2 # # CHANGES # 90522-0723 - First build @@ -24,8 +24,11 @@ # 111104-1248 - Added user_group restrictions for selecting in-groups # 120224-0910 - Added HTML display option with bar graphs # 121130-0957 - Fix for user group permissions issue #588 +# 130414-0137 - Added report logging # +$startMS = microtime(); + require("dbconnect.php"); require("functions.php"); @@ -95,15 +98,6 @@ if ($qm_conf_ct > 0) ##### END SETTINGS LOOKUP ##### ########################################### -if ( (strlen($slave_db_server)>5) and (preg_match("/$report_name/",$reports_use_slave_db)) ) - { - mysql_close($link); - $use_slave_server=1; - $db_source = 'S'; - require("dbconnect.php"); -# echo "\n"; - } - $PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); $PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); @@ -128,6 +122,35 @@ if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) 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"; + +$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, $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); +##### 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); + $use_slave_server=1; + $db_source = 'S'; + require("dbconnect.php"); +# echo "\n"; + } + $stmt="SELECT user_group from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6 and view_reports='1' and active='Y';"; if ($DB) {echo "|$stmt|\n";} $rslt=mysql_query($stmt, $link); @@ -1126,6 +1149,25 @@ if ($file_download > 0) echo "$file_output"; + if ($db_source == 'S') + { + mysql_close($link); + $use_slave_server=0; + $db_source = 'M'; + require("dbconnect.php"); + } + + $endMS = microtime(); + $startMSary = explode(" ",$startMS); + $endMSary = explode(" ",$endMS); + $runS = ($endMSary[0] - $startMSary[0]); + $runM = ($endMSary[1] - $startMSary[1]); + $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); + exit; } @@ -1282,6 +1324,25 @@ while ($m < $k) echo "\n"; ##### END horizontal yellow transparent bar graph overlay on top of agent stats +if ($db_source == 'S') + { + mysql_close($link); + $use_slave_server=0; + $db_source = 'M'; + require("dbconnect.php"); + } + +$endMS = microtime(); +$startMSary = explode(" ",$startMS); +$endMSary = explode(" ",$endMS); +$runS = ($endMSary[0] - $startMSary[0]); +$runM = ($endMSary[1] - $startMSary[1]); +$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); + ?> diff --git a/agc_2-X/trunk/www/vicidial/AST_agent_time_sheet.php b/agc_2-X/trunk/www/vicidial/AST_agent_time_sheet.php index 6ae2274e..d4255dd0 100644 --- a/agc_2-X/trunk/www/vicidial/AST_agent_time_sheet.php +++ b/agc_2-X/trunk/www/vicidial/AST_agent_time_sheet.php @@ -1,7 +1,7 @@ LICENSE: AGPLv2 +# Copyright (C) 2013 Matt Florell LICENSE: AGPLv2 # # CHANGES # @@ -16,8 +16,11 @@ # 100914-1326 - Added lookup for user_level 7 users to set to reports only which will remove other admin links # 110703-1848 - Added download option # 111104-1308 - Added user_group restrictions for selecting in-groups +# 130414-0148 - Added report logging # +$startMS = microtime(); + require("dbconnect.php"); require("functions.php"); @@ -42,14 +45,6 @@ if ($qm_conf_ct > 0) ##### END SETTINGS LOOKUP ##### ########################################### -if ( (strlen($slave_db_server)>5) and (preg_match("/$report_name/",$reports_use_slave_db)) ) - { - mysql_close($link); - $use_slave_server=1; - $db_source = 'S'; - require("dbconnect.php"); - $MAIN.="\n"; - } $PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; $PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; @@ -93,6 +88,35 @@ if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) 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"; + +$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 |$user, $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); +##### 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); + $use_slave_server=1; + $db_source = 'S'; + require("dbconnect.php"); + $MAIN.="\n"; + } + $stmt="SELECT user_group from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6 and view_reports='1' and active='Y';"; if ($DB) {$MAIN.="|$stmt|\n";} $rslt=mysql_query($stmt, $link); @@ -416,16 +440,33 @@ $MAIN.="\n"; echo "$CSV_text"; - exit; } else { header ("Content-type: text/html; charset=utf-8"); echo $HEADER; require("admin_header.php"); echo $MAIN; - exit; } +if ($db_source == 'S') + { + mysql_close($link); + $use_slave_server=0; + $db_source = 'M'; + require("dbconnect.php"); + } +$endMS = microtime(); +$startMSary = explode(" ",$startMS); +$endMSary = explode(" ",$endMS); +$runS = ($endMSary[0] - $startMSary[0]); +$runM = ($endMSary[1] - $startMSary[1]); +$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); + +exit; ?> diff --git a/agc_2-X/trunk/www/vicidial/AST_agent_time_sheet_archive.php b/agc_2-X/trunk/www/vicidial/AST_agent_time_sheet_archive.php index 81861817..29df8969 100644 --- a/agc_2-X/trunk/www/vicidial/AST_agent_time_sheet_archive.php +++ b/agc_2-X/trunk/www/vicidial/AST_agent_time_sheet_archive.php @@ -1,15 +1,20 @@ LICENSE: AGPLv2 +# Copyright (C) 2013 Matt Florell LICENSE: AGPLv2 # # CHANGES # # 60619-1721 - Added variable filtering to eliminate SQL injection attack threat # - Added required user/pass to gain access to this page # 90508-0644 - Changed to PHP long tags +# 130414-0156 - Added report logging # +$startMS = microtime(); + +$report_name='Agent Timesheet Archive'; + require("dbconnect.php"); $PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; @@ -43,6 +48,26 @@ $PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); 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"; + +$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, $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); +##### END log visit to the vicidial_report_log table ##### + $NOW_DATE = date("Y-m-d"); $NOW_TIME = date("Y-m-d H:i:s"); $STARTtime = date("U"); @@ -278,6 +303,26 @@ $login_time = ($end - $start); echo "-----------------------------------------\n"; echo "TOTAL LOGGED-IN TIME: $pfLOGIN_TIME_HMS\n"; + +if ($db_source == 'S') + { + mysql_close($link); + $use_slave_server=0; + $db_source = 'M'; + require("dbconnect.php"); + } + +$endMS = microtime(); +$startMSary = explode(" ",$startMS); +$endMSary = explode(" ",$endMS); +$runS = ($endMSary[0] - $startMSary[0]); +$runM = ($endMSary[1] - $startMSary[1]); +$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); + } diff --git a/agc_2-X/trunk/www/vicidial/AST_agent_timeclock_detail.php b/agc_2-X/trunk/www/vicidial/AST_agent_timeclock_detail.php index 896e81ec..70cdaa45 100644 --- a/agc_2-X/trunk/www/vicidial/AST_agent_timeclock_detail.php +++ b/agc_2-X/trunk/www/vicidial/AST_agent_timeclock_detail.php @@ -3,7 +3,7 @@ # # Pulls all timeclock records for an agent # -# Copyright (C) 2012 Matt Florell LICENSE: AGPLv2 +# Copyright (C) 2013 Matt Florell LICENSE: AGPLv2 # # CHANGES # 90602-2244 - First build @@ -13,8 +13,10 @@ # 100914-1326 - Added lookup for user_level 7 users to set to reports only which will remove other admin links # 111104-1315 - Added user_group restrictions for selecting in-groups # 120224-0910 - Added HTML display option with bar graphs +# 130414-0154 - Added report logging # +$startMS = microtime(); require("dbconnect.php"); require("functions.php"); @@ -67,15 +69,6 @@ if ($qm_conf_ct > 0) ##### END SETTINGS LOOKUP ##### ########################################### -if ( (strlen($slave_db_server)>5) and (preg_match("/$report_name/",$reports_use_slave_db)) ) - { - mysql_close($link); - $use_slave_server=1; - $db_source = 'S'; - require("dbconnect.php"); -# echo "\n"; - } - $PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); $PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); @@ -100,6 +93,35 @@ if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) 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"; + +$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 |$user_group[0], $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); +##### 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); + $use_slave_server=1; + $db_source = 'S'; + require("dbconnect.php"); +# echo "\n"; + } + $stmt="SELECT user_group from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6 and view_reports='1' and active='Y';"; if ($DB) {echo "|$stmt|\n";} $rslt=mysql_query($stmt, $link); @@ -682,6 +704,25 @@ if ($file_download > 0) echo "$file_output"; + if ($db_source == 'S') + { + mysql_close($link); + $use_slave_server=0; + $db_source = 'M'; + require("dbconnect.php"); + } + + $endMS = microtime(); + $startMSary = explode(" ",$startMS); + $endMSary = explode(" ",$endMS); + $runS = ($endMSary[0] - $startMSary[0]); + $runM = ($endMSary[1] - $startMSary[1]); + $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); + exit; } @@ -816,6 +857,25 @@ $ENDtime = date("U"); $RUNtime = ($ENDtime - $STARTtime); echo "$RUNtime|$db_source\n"; +if ($db_source == 'S') + { + mysql_close($link); + $use_slave_server=0; + $db_source = 'M'; + require("dbconnect.php"); + } + +$endMS = microtime(); +$startMSary = explode(" ",$startMS); +$endMSary = explode(" ",$endMS); +$runS = ($endMSary[0] - $startMSary[0]); +$runM = ($endMSary[1] - $startMSary[1]); +$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); + ?> diff --git a/agc_2-X/trunk/www/vicidial/AST_campaign_status_list_report.php b/agc_2-X/trunk/www/vicidial/AST_campaign_status_list_report.php index a08bad06..86a2f5da 100644 --- a/agc_2-X/trunk/www/vicidial/AST_campaign_status_list_report.php +++ b/agc_2-X/trunk/www/vicidial/AST_campaign_status_list_report.php @@ -4,14 +4,17 @@ # This report is designed to show the breakdown by list_id of the calls and # their statuses for all lists within a campaign for a set time period # -# Copyright (C) 2012 Joe Johnson, Matt Florell LICENSE: AGPLv2 +# Copyright (C) 2013 Joe Johnson, Matt Florell LICENSE: AGPLv2 # # CHANGES # # 110815-2138 - First build # 120224-0910 - Added HTML display option with bar graphs +# 130414-0129 - Added report logging # +$startMS = microtime(); + require("dbconnect.php"); require("functions.php"); @@ -64,15 +67,6 @@ if ($qm_conf_ct > 0) ##### END SETTINGS LOOKUP ##### ########################################### -###################################### -if ( (strlen($slave_db_server)>5) and (preg_match("/$report_name/",$reports_use_slave_db)) ) - { - mysql_close($link); - $use_slave_server=1; - $db_source = 'S'; - require("dbconnect.php"); - $HTML_text.="\n"; - } $PHP_AUTH_USER = preg_replace("/[^0-9a-zA-Z]/","",$PHP_AUTH_USER); $PHP_AUTH_PW = preg_replace("/[^0-9a-zA-Z]/","",$PHP_AUTH_PW); @@ -97,6 +91,36 @@ if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\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"; + +$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, $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); +##### 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); + $use_slave_server=1; + $db_source = 'S'; + require("dbconnect.php"); + $HTML_text.="\n"; + } + $stmt="SELECT user_group from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6 and view_reports='1' and active='Y';"; if ($DB) {$HTML_text.="|$stmt|\n";} $rslt=mysql_query($stmt, $link); @@ -456,8 +480,6 @@ if ($file_download>0) flush(); echo "$CSV_text"; - - exit; } else { @@ -468,4 +490,26 @@ else echo $HTML_text; flush(); } + +if ($db_source == 'S') + { + mysql_close($link); + $use_slave_server=0; + $db_source = 'M'; + require("dbconnect.php"); + } + +$endMS = microtime(); +$startMSary = explode(" ",$startMS); +$endMSary = explode(" ",$endMS); +$runS = ($endMSary[0] - $startMSary[0]); +$runM = ($endMSary[1] - $startMSary[1]); +$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); + +exit; + ?> diff --git a/agc_2-X/trunk/www/vicidial/AST_carrier_log_report.php b/agc_2-X/trunk/www/vicidial/AST_carrier_log_report.php index 8d180e31..e7060353 100644 --- a/agc_2-X/trunk/www/vicidial/AST_carrier_log_report.php +++ b/agc_2-X/trunk/www/vicidial/AST_carrier_log_report.php @@ -1,26 +1,30 @@ LICENSE: AGPLv2 +# Copyright (C) 2013 Joe Johnson, Matt Florell LICENSE: AGPLv2 # # CHANGES # 120210-2202 - First build +# 130413-2213 - Added SIP codes summary and fields, and report logging # +$startMS = microtime(); require("dbconnect.php"); +$report_name='Carrier 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"];} +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"];} +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["server_ip"])) {$server_ip=$_GET["server_ip"];} - elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} 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"];} @@ -54,14 +58,7 @@ if ($qm_conf_ct > 0) ##### END SETTINGS LOOKUP ##### ########################################### -if ( (strlen($slave_db_server)>5) and (preg_match("/$report_name/",$reports_use_slave_db)) ) - { - mysql_close($link); - $use_slave_server=1; - $db_source = 'S'; - require("dbconnect.php"); - $MAIN.="\n"; - } +$NOW_DATE = date("Y-m-d"); $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level >= 7 and view_reports='1' and active='Y';"; if ($DB) {$MAIN.="|$stmt|\n";} @@ -84,10 +81,39 @@ if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) 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"; + +$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';"; +if ($DB) {echo "|$stmt|\n";} +$rslt=mysql_query($stmt, $link); +$report_log_id = mysql_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); + $use_slave_server=1; + $db_source = 'S'; + require("dbconnect.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";} -$NOW_DATE = date("Y-m-d"); if (!isset($query_date)) {$query_date = $NOW_DATE;} $server_ip_string='|'; @@ -223,7 +249,29 @@ if ($SUBMIT && $server_ip_ct>0) { } $MAIN.="+--------------+-------------+---------+\n"; $MAIN.="| TOTAL | ".sprintf("%-8s", $total_count)."|\n"; - $MAIN.="+--------------+-------------+---------+\n\n\n"; + $MAIN.="+--------------+-------------+---------+\n\n"; + + $stmt="select sip_hangup_cause,sip_hangup_reason,count(*) as ct From vicidial_carrier_log where call_date>='$query_date $query_date_D' and call_date<='$query_date $query_date_T' $server_ip_SQL group by sip_hangup_cause,sip_hangup_reason order by sip_hangup_cause,sip_hangup_reason"; + $rslt=mysql_query($stmt, $link); + $MAIN.="
\n";
+		if ($DB) {$MAIN.=$stmt."\n";}
+		if (mysql_num_rows($rslt)>0) {
+			$MAIN.="--- SIP ERROR REASON BREAKDOWN FOR $query_date, $query_date_D TO $query_date_T $server_rpt_string\n";
+			$MAIN.="+----------+--------------------------------+---------+\n";
+			$MAIN.="| SIP CODE | SIP HANGUP REASON              |  COUNT  |\n";
+			$MAIN.="+----------+--------------------------------+---------+\n";
+			$total_count=0;
+			while ($row=mysql_fetch_array($rslt)) {
+				$MAIN.="| ".sprintf("%8s", $row["sip_hangup_cause"])." ";
+				$MAIN.="| ".sprintf("%-31s", $row["sip_hangup_reason"]);
+				$MAIN.="| ".sprintf("%-8s", $row["ct"]);
+				$MAIN.="|\n";
+				$total_count+=$row["ct"];
+			}
+			$MAIN.="+----------+--------------------------------+---------+\n";
+			$MAIN.="|                                     TOTAL | ".sprintf("%-8s", $total_count)."|\n";
+			$MAIN.="+-------------------------------------------+---------+\n\n\n";
+		}
 
 		$rpt_stmt="select vicidial_carrier_log.*, vicidial_log.phone_number from vicidial_carrier_log left join vicidial_log on vicidial_log.uniqueid=vicidial_carrier_log.uniqueid where vicidial_carrier_log.call_date>='$query_date $query_date_D' and vicidial_carrier_log.call_date<='$query_date $query_date_T' $server_ip_SQL order by vicidial_carrier_log.call_date asc";
 		$rpt_rslt=mysql_query($rpt_stmt, $link);
@@ -233,10 +281,10 @@ if ($SUBMIT && $server_ip_ct>0) {
 		if ($lower_limit+999>=mysql_num_rows($rpt_rslt)) {$upper_limit=($lower_limit+mysql_num_rows($rpt_rslt)%1000)-1;} else {$upper_limit=$lower_limit+999;}
 		
 		$MAIN.="--- CARRIER LOG RECORDS FOR $query_date, $query_date_D TO $query_date_T $server_rpt_string, RECORDS #$lower_limit-$upper_limit               [DOWNLOAD]\n";
-		$carrier_rpt.="+----------------------+---------------------+-----------------+-----------+--------------+-------------+------------------------------------------+-----------+---------------+--------------+\n";
-		$carrier_rpt.="| UNIQUE ID            | CALL DATE           | SERVER IP       | LEAD ID   | HANGUP CAUSE | DIAL STATUS | CHANNEL                                  | DIAL TIME | ANSWERED TIME | PHONE NUMBER |\n";
-		$carrier_rpt.="+----------------------+---------------------+-----------------+-----------+--------------+-------------+------------------------------------------+-----------+---------------+--------------+\n";
-		$CSV_text="\"UNIQUE ID\",\"CALL DATE\",\"SERVER IP\",\"LEAD ID\",\"HANGUP CAUSE\",\"DIAL STATUS\",\"CHANNEL\",\"DIAL TIME\",\"ANSWERED TIME\",\"PHONE NUMBER\"\n";
+		$carrier_rpt.="+----------------------+---------------------+-----------------+-----------+--------------+-------------+------------------------------------------+-----------+---------------+----------+--------------------------------+--------------+\n";
+		$carrier_rpt.="| UNIQUE ID            | CALL DATE           | SERVER IP       | LEAD ID   | HANGUP CAUSE | DIAL STATUS | CHANNEL                                  | DIAL TIME | ANSWERED TIME | SIP CODE | SIP HANGUP REASON              | PHONE NUMBER |\n";
+		$carrier_rpt.="+----------------------+---------------------+-----------------+-----------+--------------+-------------+------------------------------------------+-----------+---------------+----------+--------------------------------+--------------+\n";
+		$CSV_text="\"UNIQUE ID\",\"CALL DATE\",\"SERVER IP\",\"LEAD ID\",\"HANGUP CAUSE\",\"DIAL STATUS\",\"CHANNEL\",\"DIAL TIME\",\"ANSWERED TIME\",\"SIP CODE\",\"SIP HANGUP REASON\",\"PHONE NUMBER\"\n";
 
 		for ($i=1; $i<=mysql_num_rows($rpt_rslt); $i++) {
 			$row=mysql_fetch_array($rpt_rslt);
@@ -255,7 +303,7 @@ if ($SUBMIT && $server_ip_ct>0) {
 				$phone_number=$row["phone_number"];
 			}
 
-			$CSV_text.="\"$row[uniqueid]\",\"$row[call_date]\",\"$row[server_ip]\",\"$row[lead_id]\",\"$row[hangup_cause]\",\"$row[dialstatus]\",\"$row[channel]\",\"$row[dial_time]\",\"$row[answered_time]\",\"$phone_number\"\n";
+			$CSV_text.="\"$row[uniqueid]\",\"$row[call_date]\",\"$row[server_ip]\",\"$row[lead_id]\",\"$row[hangup_cause]\",\"$row[dialstatus]\",\"$row[channel]\",\"$row[dial_time]\",\"$row[answered_time]\",\"$row[sip_hangup_cause]\",\"$row[sip_hangup_reason]\",\"$phone_number\"\n";
 			if ($i>=$lower_limit && $i<=$upper_limit) {
 				if (strlen($row["channel"])>37) {$row["channel"]=substr($row["channel"],0,37)."...";}
 				$carrier_rpt.="| ".sprintf("%-21s", $row["uniqueid"]); 
@@ -267,10 +315,12 @@ if ($SUBMIT && $server_ip_ct>0) {
 				$carrier_rpt.="| ".sprintf("%-41s", $row["channel"]); 
 				$carrier_rpt.="| ".sprintf("%-10s", $row["dial_time"]); 
 				$carrier_rpt.="| ".sprintf("%-14s", $row["answered_time"]); 
+				$carrier_rpt.="| ".sprintf("%8s", $row["sip_hangup_cause"])." "; 
+				$carrier_rpt.="| ".sprintf("%-31s", $row["sip_hangup_reason"]); 
 				$carrier_rpt.="| ".sprintf("%-13s", $phone_number)."|\n"; 
 			}
 		}
-		$carrier_rpt.="+----------------------+---------------------+-----------------+-----------+--------------+-------------+------------------------------------------+-----------+---------------+--------------+\n";
+		$carrier_rpt.="+----------------------+---------------------+-----------------+-----------+--------------+-------------+------------------------------------------+-----------+---------------+----------+--------------------------------+--------------+\n";
 
 		$carrier_rpt_hf="";
 		$ll=$lower_limit-1000;
@@ -315,11 +365,31 @@ if ($SUBMIT && $server_ip_ct>0) {
 
 		echo "$CSV_text";
 
-		exit;
 	} else {
 		echo $HEADER;
 		require("admin_header.php");
 		echo $MAIN;
 	}
 
+if ($db_source == 'S')
+	{
+	mysql_close($link);
+	$use_slave_server=0;
+	$db_source = 'M';
+	require("dbconnect.php");
+	}
+
+$endMS = microtime();
+$startMSary = explode(" ",$startMS);
+$endMSary = explode(" ",$endMS);
+$runS = ($endMSary[0] - $startMSary[0]);
+$runM = ($endMSary[1] - $startMSary[1]);
+$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);
+
+exit;
+
 ?>
diff --git a/agc_2-X/trunk/www/vicidial/AST_dialer_inventory_report.php b/agc_2-X/trunk/www/vicidial/AST_dialer_inventory_report.php
index 2cd29fde..eae4a9d9 100644
--- a/agc_2-X/trunk/www/vicidial/AST_dialer_inventory_report.php
+++ b/agc_2-X/trunk/www/vicidial/AST_dialer_inventory_report.php
@@ -1,7 +1,7 @@
     LICENSE: AGPLv2
+# Copyright (C) 2013  Joe Johnson     LICENSE: AGPLv2
 #                     Matt Florell 
 #
 # NOTES:
@@ -14,8 +14,11 @@
 # 111106-1327 - Reformatting, other minor changes
 # 111230-1145 - Debugging additions and more minor changes
 # 120221-2237 - Added totals, list options, other small changes
+# 130414-0131 - Added report logging
 #
 
+$startMS = microtime();
+
 error_reporting(0);
 
 require("dbconnect.php");
@@ -77,15 +80,6 @@ if ($qm_conf_ct > 0)
 ##### END SETTINGS LOOKUP #####
 ###########################################
 
-if ( (strlen($slave_db_server)>5) and (preg_match("/$report_name/",$reports_use_slave_db)) )
-	{
-	mysql_close($link);
-	$use_slave_server=1;
-	$db_source = 'S';
-	require("dbconnect.php");
-	#$HTML_header.="\n";
-	}
-
 $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6 and view_reports='1' and active='Y';";
 if ($DB) {$HTML_header.="|$stmt|\n";}
 if ($non_latin > 0) { $rslt=mysql_query("SET NAMES 'UTF8'");}
@@ -107,6 +101,34 @@ if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
     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";
+
+$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, $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);
+##### 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);
+	$use_slave_server=1;
+	$db_source = 'S';
+	require("dbconnect.php");
+	#$HTML_header.="\n";
+	}
 
 $stmt="SELECT user_group from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6 and view_reports='1' and active='Y';";
 if ($DB) {$HTML_header.="|$stmt|\n";}
@@ -882,8 +904,6 @@ if ($file_download>0)
 	flush();
 
 	echo "$CSV_text";
-
-	exit;
 	} 
 else 
 	{
@@ -894,6 +914,27 @@ else
 	echo $HTML_text;
 	}
 
+if ($db_source == 'S')
+	{
+	mysql_close($link);
+	$use_slave_server=0;
+	$db_source = 'M';
+	require("dbconnect.php");
+	}
+
+$endMS = microtime();
+$startMSary = explode(" ",$startMS);
+$endMSary = explode(" ",$endMS);
+$runS = ($endMSary[0] - $startMSary[0]);
+$runM = ($endMSary[1] - $startMSary[1]);
+$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);
+
+exit;
+
 ?>
 
 
diff --git a/agc_2-X/trunk/www/vicidial/AST_email_log_report.php b/agc_2-X/trunk/www/vicidial/AST_email_log_report.php
index 24015eec..4aeddac3 100644
--- a/agc_2-X/trunk/www/vicidial/AST_email_log_report.php
+++ b/agc_2-X/trunk/www/vicidial/AST_email_log_report.php
@@ -7,10 +7,13 @@
 # 
 # CHANGELOG:
 # 130221-2117 - First build
+# 130414-0132 - Added report logging
 #
 
-$version = '2.6-1';
-$build = '130221-2117';
+$startMS = microtime();
+
+$version = '2.6-2';
+$build = '130414-0132';
 
 header ("Content-type: text/html; charset=utf-8");
 
@@ -73,15 +76,6 @@ if ($qm_conf_ct > 0)
 ##### END SETTINGS LOOKUP #####
 ###########################################
 
-if ( (strlen($slave_db_server)>5) and (preg_match("/$report_name/",$reports_use_slave_db)) )
-	{
-	mysql_close($link);
-	$use_slave_server=1;
-	$db_source = 'S';
-	require("dbconnect.php");
-	echo "\n";
-	}
-
 $stmt = "SELECT local_gmt FROM servers where active='Y' limit 1;";
 $rslt=mysql_query($stmt, $link);
 if ($DB) {$MAIN.="$stmt\n";}
@@ -115,6 +109,35 @@ if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
     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";
+
+$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, $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);
+##### 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);
+	$use_slave_server=1;
+	$db_source = 'S';
+	require("dbconnect.php");
+	echo "\n";
+	}
+
 $stmt="SELECT user_group from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6 and view_reports='1' and active='Y';";
 if ($DB) {$MAIN.="|$stmt|\n";}
 $rslt=mysql_query($stmt, $link);
@@ -502,7 +525,6 @@ if ($file_download>0) {
 
 	echo "$CSV_text1";
 
-	exit;
 } else {
 	echo $HEADER;
 	echo $JS_text;
@@ -512,5 +534,26 @@ if ($file_download>0) {
 
 }
 
+if ($db_source == 'S')
+	{
+	mysql_close($link);
+	$use_slave_server=0;
+	$db_source = 'M';
+	require("dbconnect.php");
+	}
+
+$endMS = microtime();
+$startMSary = explode(" ",$startMS);
+$endMSary = explode(" ",$endMS);
+$runS = ($endMSary[0] - $startMSary[0]);
+$runM = ($endMSary[1] - $startMSary[1]);
+$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);
+
+exit;
+
 
 ?>
diff --git a/agc_2-X/trunk/www/vicidial/AST_hangup_cause_report.php b/agc_2-X/trunk/www/vicidial/AST_hangup_cause_report.php
index 6f5d1104..e3e7b315 100644
--- a/agc_2-X/trunk/www/vicidial/AST_hangup_cause_report.php
+++ b/agc_2-X/trunk/www/vicidial/AST_hangup_cause_report.php
@@ -1,12 +1,16 @@
     LICENSE: AGPLv2
+# Copyright (C) 2013  Joe Johnson, Matt Florell     LICENSE: AGPLv2
 #
 # CHANGES
 # 120331-2301 - First build
+# 130413-2348 - Added report logging
 #
 
+$startMS = microtime();
+
+$report_name='Hangup Cause Report';
 
 require("dbconnect.php");
 
@@ -56,15 +60,6 @@ if ($qm_conf_ct > 0)
 ##### END SETTINGS LOOKUP #####
 ###########################################
 
-if ( (strlen($slave_db_server)>5) and (preg_match("/$report_name/",$reports_use_slave_db)) )
-	{
-	mysql_close($link);
-	$use_slave_server=1;
-	$db_source = 'S';
-	require("dbconnect.php");
-	$MAIN.="\n";
-	}
-
 $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level >= 7 and view_reports='1' and active='Y';";
 if ($DB) {$MAIN.="|$stmt|\n";}
 if ($non_latin > 0) {$rslt=mysql_query("SET NAMES 'UTF8'");}
@@ -87,6 +82,35 @@ if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
 	}
 
 
+##### 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";
+
+$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';";
+if ($DB) {echo "|$stmt|\n";}
+$rslt=mysql_query($stmt, $link);
+$report_log_id = mysql_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);
+	$use_slave_server=1;
+	$db_source = 'S';
+	require("dbconnect.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";}
 $NOW_DATE = date("Y-m-d");
@@ -101,7 +125,7 @@ while($i < $server_ip_ct)
 	$i++;
 	}
 
-$server_stmt="select distinct s.server_ip, s.server_description from servers s, vicidial_carrier_log vcl where s.server_ip=vcl.server_ip order by server_ip asc";
+$server_stmt="SELECT distinct s.server_ip, s.server_description from servers s, vicidial_carrier_log vcl where s.server_ip=vcl.server_ip order by server_ip asc";
 $server_rslt=mysql_query($server_stmt, $link);
 $servers_to_print=mysql_num_rows($server_rslt);
 $i=0;
@@ -161,7 +185,7 @@ while($i < $hangup_cause_ct)
 	$i++;
 	}
 
-$hangupcause_stmt="select distinct hangup_cause, dialstatus from vicidial_carrier_log order by dialstatus, hangup_cause asc";
+$hangupcause_stmt="SELECT distinct hangup_cause, dialstatus from vicidial_carrier_log order by dialstatus, hangup_cause asc";
 $hangupcause_rslt=mysql_query($hangupcause_stmt, $link);
 $causes_to_print=mysql_num_rows($hangupcause_rslt);
 $i=0;
@@ -292,7 +316,7 @@ $MAIN.="\n";
 $MAIN.="

\n"; $MAIN.="\n"; if ($SUBMIT && $server_ip_ct>0) { - $stmt="select hangup_cause, dialstatus, count(*) as ct From vicidial_carrier_log where call_date>='$query_date $query_date_D' and call_date<='$query_date $query_date_T' $server_ip_SQL $hangup_cause_SQL group by hangup_cause, dialstatus order by hangup_cause, dialstatus"; + $stmt="SELECT hangup_cause, dialstatus, count(*) as ct From vicidial_carrier_log where call_date>='$query_date $query_date_D' and call_date<='$query_date $query_date_T' $server_ip_SQL $hangup_cause_SQL group by hangup_cause, dialstatus order by hangup_cause, dialstatus"; $rslt=mysql_query($stmt, $link); $MAIN.="
\n";
 	if ($DB) {$MAIN.=$stmt."\n";}
@@ -313,7 +337,7 @@ if ($SUBMIT && $server_ip_ct>0) {
 		$MAIN.="|                      TOTAL | ".sprintf("%-8s", $total_count)."|\n";
 		$MAIN.="+--------------+-------------+---------+\n\n\n";
 
-		$rpt_stmt="select vicidial_carrier_log.*, vicidial_log.phone_number from vicidial_carrier_log left join vicidial_log on vicidial_log.uniqueid=vicidial_carrier_log.uniqueid where vicidial_carrier_log.call_date>='$query_date $query_date_D' and vicidial_carrier_log.call_date<='$query_date $query_date_T' $server_ip_SQL $hangup_cause_SQL order by vicidial_carrier_log.call_date asc";
+		$rpt_stmt="SELECT vicidial_carrier_log.*, vicidial_log.phone_number from vicidial_carrier_log left join vicidial_log on vicidial_log.uniqueid=vicidial_carrier_log.uniqueid where vicidial_carrier_log.call_date>='$query_date $query_date_D' and vicidial_carrier_log.call_date<='$query_date $query_date_T' $server_ip_SQL $hangup_cause_SQL order by vicidial_carrier_log.call_date asc";
 		$rpt_rslt=mysql_query($rpt_stmt, $link);
 		if ($DB) {$MAIN.=$rpt_stmt."\n";}
 
@@ -331,7 +355,7 @@ if ($SUBMIT && $server_ip_ct>0) {
 			$phone_number=""; $phone_note="";
 
 			if (strlen($row["phone_number"])==0) {
-				$stmt2="select phone_number, alt_phone, address3 from vicidial_list where lead_id='$row[lead_id]'";
+				$stmt2="SELECT phone_number, alt_phone, address3 from vicidial_list where lead_id='$row[lead_id]'";
 				$rslt2=mysql_query($stmt2, $link);
 				$channel=$row["channel"];
 				while ($row2=mysql_fetch_array($rslt2)) {
@@ -403,11 +427,31 @@ if ($SUBMIT && $server_ip_ct>0) {
 
 		echo "$CSV_text";
 
-		exit;
 	} else {
 		echo $HEADER;
 		require("admin_header.php");
 		echo $MAIN;
 	}
 
+if ($db_source == 'S')
+	{
+	mysql_close($link);
+	$use_slave_server=0;
+	$db_source = 'M';
+	require("dbconnect.php");
+	}
+
+$endMS = microtime();
+$startMSary = explode(" ",$startMS);
+$endMSary = explode(" ",$endMS);
+$runS = ($endMSary[0] - $startMSary[0]);
+$runM = ($endMSary[1] - $startMSary[1]);
+$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);
+
+exit;
+
 ?>
diff --git a/agc_2-X/trunk/www/vicidial/AST_inbound_daily_report.php b/agc_2-X/trunk/www/vicidial/AST_inbound_daily_report.php
index e80a6027..d4193521 100644
--- a/agc_2-X/trunk/www/vicidial/AST_inbound_daily_report.php
+++ b/agc_2-X/trunk/www/vicidial/AST_inbound_daily_report.php
@@ -13,8 +13,11 @@
 # 120819-0118 - Formatting changes
 # 121115-0621 - Changed to multi-select for in-group selection
 # 130322-2008 - Added Unique Agents column
+# 130414-0110 - Added report logging
 #
 
+$startMS = microtime();
+
 require("dbconnect.php");
 
 if (file_exists('options.php'))
@@ -77,15 +80,6 @@ if ($qm_conf_ct > 0)
 ##### END SETTINGS LOOKUP #####
 ###########################################
 
-if ( (strlen($slave_db_server)>5) and (preg_match("/$report_name/",$reports_use_slave_db)) )
-	{
-	mysql_close($link);
-	$use_slave_server=1;
-	$db_source = 'S';
-	require("dbconnect.php");
-	$MAIN.="\n";
-	}
-
 $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level >= 7 and view_reports='1' and active='Y';";
 if ($DB) {$MAIN.="|$stmt|\n";}
 if ($non_latin > 0) {$rslt=mysql_query("SET NAMES 'UTF8'");}
@@ -107,6 +101,35 @@ if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
     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";
+
+$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, $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);
+##### 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);
+	$use_slave_server=1;
+	$db_source = 'S';
+	require("dbconnect.php");
+	$MAIN.="\n";
+	}
+
 $stmt="SELECT user_group from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6 and view_reports='1' and active='Y';";
 if ($DB) {$MAIN.="|$stmt|\n";}
 $rslt=mysql_query($stmt, $link);
@@ -2205,18 +2228,42 @@ else
 		flush();
 
 		echo "$CSV_text";
-
-		exit;
 		}
 	else 
 		{
-
 		echo "$HEADER";
 		require("admin_header.php");
 		echo "$MAIN";
 		}
 	}
 
+if ($db_source == 'S')
+	{
+	mysql_close($link);
+	$use_slave_server=0;
+	$db_source = 'M';
+	require("dbconnect.php");
+	if ($file_download < 1) 
+		{echo "\n";}
+	}
+
+$endMS = microtime();
+$startMSary = explode(" ",$startMS);
+$endMSary = explode(" ",$endMS);
+$runS = ($endMSary[0] - $startMSary[0]);
+$runM = ($endMSary[1] - $startMSary[1]);
+$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);
+
+exit;
+
+
+
+
+
 function HourDifference($time_BEGIN, $time_END) {
 	global $hpd;
 	$TB_array =	explode(':',$time_BEGIN);
diff --git a/agc_2-X/trunk/www/vicidial/AST_server_performance.php b/agc_2-X/trunk/www/vicidial/AST_server_performance.php
index fc3adacd..cc5be1f3 100644
--- a/agc_2-X/trunk/www/vicidial/AST_server_performance.php
+++ b/agc_2-X/trunk/www/vicidial/AST_server_performance.php
@@ -1,7 +1,7 @@
     LICENSE: AGPLv2
+# Copyright (C) 2013  Matt Florell     LICENSE: AGPLv2
 #
 # CHANGES
 #
@@ -16,8 +16,11 @@
 # 100712-1324 - Added system setting slave server option
 # 100802-2347 - Added User Group Allowed Reports option validation
 # 100914-1326 - Added lookup for user_level 7 users to set to reports only which will remove other admin links
+# 130414-0157 - Added report logging
 #
 
+$startMS = microtime();
+
 require("dbconnect.php");
 
 $PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
@@ -59,15 +62,6 @@ if ($qm_conf_ct > 0)
 ##### END SETTINGS LOOKUP #####
 ###########################################
 
-if ( (strlen($slave_db_server)>5) and (preg_match("/$report_name/",$reports_use_slave_db)) )
-	{
-	mysql_close($link);
-	$use_slave_server=1;
-	$db_source = 'S';
-	require("dbconnect.php");
-	echo "\n";
-	}
-
 $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6 and view_reports='1' and active='Y';";
 if ($DB) {echo "|$stmt|\n";}
 $rslt=mysql_query($stmt, $link);
@@ -88,6 +82,35 @@ if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
     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";
+
+$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);
+##### 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);
+	$use_slave_server=1;
+	$db_source = 'S';
+	require("dbconnect.php");
+	echo "\n";
+	}
+
 $stmt="SELECT user_group from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6 and view_reports='1' and active='Y';";
 if ($DB) {echo "|$stmt|\n";}
 $rslt=mysql_query($stmt, $link);
@@ -397,6 +420,24 @@ echo "";
 
 }
 
+if ($db_source == 'S')
+	{
+	mysql_close($link);
+	$use_slave_server=0;
+	$db_source = 'M';
+	require("dbconnect.php");
+	}
+
+$endMS = microtime();
+$startMSary = explode(" ",$startMS);
+$endMSary = explode(" ",$endMS);
+$runS = ($endMSary[0] - $startMSary[0]);
+$runM = ($endMSary[1] - $startMSary[1]);
+$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);
 
 
 ?>
diff --git a/agc_2-X/trunk/www/vicidial/AST_team_performance_detail.php b/agc_2-X/trunk/www/vicidial/AST_team_performance_detail.php
index c1c8b66a..fdebcd7e 100644
--- a/agc_2-X/trunk/www/vicidial/AST_team_performance_detail.php
+++ b/agc_2-X/trunk/www/vicidial/AST_team_performance_detail.php
@@ -6,7 +6,7 @@
 # QC statuses of QCFAIL, QCCANC and sales are defined by the Sale=Y status
 # flags being set on those statuses.
 #
-# Copyright (C) 2012  Joe Johnson, Matt Florell     LICENSE: AGPLv2
+# Copyright (C) 2013  Joe Johnson, Matt Florell     LICENSE: AGPLv2
 #
 # CHANGES
 #
@@ -15,8 +15,11 @@
 # 111104-1259 - Added user_group restrictions for selecting in-groups
 # 120224-1424 - Added new colums and PRECAL to System Time
 # 120307-1926 - Added additional statuses option and HTML display option
+# 130414-0142 - Added report logging
 #
 
+$startMS = microtime();
+
 require("dbconnect.php");
 require("functions.php");
 
@@ -70,15 +73,6 @@ if ($qm_conf_ct > 0)
 ##### END SETTINGS LOOKUP #####
 ###########################################
 
-######################################
-if ( (strlen($slave_db_server)>5) and (preg_match("/$report_name/",$reports_use_slave_db)) )
-	{
-	mysql_close($link);
-	$use_slave_server=1;
-	$db_source = 'S';
-	require("dbconnect.php");
-	$HTML_text.="\n";
-	}
 
 $PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
 $PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
@@ -104,6 +98,35 @@ if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
     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";
+
+$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, $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);
+##### 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);
+	$use_slave_server=1;
+	$db_source = 'S';
+	require("dbconnect.php");
+	$HTML_text.="\n";
+	}
+
 $stmt="SELECT user_group from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6 and view_reports='1' and active='Y';";
 if ($DB) {$HTML_text.="|$stmt|\n";}
 $rslt=mysql_query($stmt, $link);
@@ -1301,8 +1324,6 @@ if ($file_download>0)
 	flush();
 
 	echo "$CSV_text";
-
-	exit;
 	}
 else
 	{
@@ -1327,4 +1348,26 @@ else
 	echo $HTML_text;
 	flush();
 	}
+
+if ($db_source == 'S')
+	{
+	mysql_close($link);
+	$use_slave_server=0;
+	$db_source = 'M';
+	require("dbconnect.php");
+	}
+
+$endMS = microtime();
+$startMSary = explode(" ",$startMS);
+$endMSary = explode(" ",$endMS);
+$runS = ($endMSary[0] - $startMSary[0]);
+$runM = ($endMSary[1] - $startMSary[1]);
+$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);
+
+exit;
+
 ?>
diff --git a/agc_2-X/trunk/www/vicidial/AST_usergroup_login_report.php b/agc_2-X/trunk/www/vicidial/AST_usergroup_login_report.php
index 5933b52c..58d3ed36 100644
--- a/agc_2-X/trunk/www/vicidial/AST_usergroup_login_report.php
+++ b/agc_2-X/trunk/www/vicidial/AST_usergroup_login_report.php
@@ -4,13 +4,16 @@
 # This User-Group based report runs some very intensive SQL queries, so it is
 # not recommended to run this on long time periods. 
 #
-# Copyright (C) 2012  Joe Johnson, Matt Florell     LICENSE: AGPLv2
+# Copyright (C) 2013  Joe Johnson, Matt Florell     LICENSE: AGPLv2
 #
 # CHANGES
 #
 # 120526-0803 - First build
+# 130414-0145 - Added report logging
 #
 
+$startMS = microtime();
+
 require("dbconnect.php");
 require("functions.php");
 
@@ -51,16 +54,6 @@ if ($qm_conf_ct > 0)
 ##### END SETTINGS LOOKUP #####
 ###########################################
 
-######################################
-if ( (strlen($slave_db_server)>5) and (preg_match("/$report_name/",$reports_use_slave_db)) )
-	{
-	mysql_close($link);
-	$use_slave_server=1;
-	$db_source = 'S';
-	require("dbconnect.php");
-	$HTML_text.="\n";
-	}
-
 $PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
 $PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
 
@@ -85,6 +78,35 @@ if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
     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";
+
+$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, $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);
+##### 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);
+	$use_slave_server=1;
+	$db_source = 'S';
+	require("dbconnect.php");
+	$HTML_text.="\n";
+	}
+
 $stmt="SELECT user_group from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6 and view_reports='1' and active='Y';";
 if ($DB) {$HTML_text.="|$stmt|\n";}
 $rslt=mysql_query($stmt, $link);
@@ -270,8 +292,6 @@ if ($file_download>0)
 	flush();
 
 	echo "$CSV_text";
-
-	exit;
 	}
 else
 	{
@@ -296,4 +316,26 @@ else
 	echo $HTML_text;
 	flush();
 	}
+
+if ($db_source == 'S')
+	{
+	mysql_close($link);
+	$use_slave_server=0;
+	$db_source = 'M';
+	require("dbconnect.php");
+	}
+
+$endMS = microtime();
+$startMSary = explode(" ",$startMS);
+$endMSary = explode(" ",$endMS);
+$runS = ($endMSary[0] - $startMSary[0]);
+$runM = ($endMSary[1] - $startMSary[1]);
+$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);
+
+exit;
+
 ?>
diff --git a/agc_2-X/trunk/www/vicidial/admin.php b/agc_2-X/trunk/www/vicidial/admin.php
index 426c878e..0d935267 100644
--- a/agc_2-X/trunk/www/vicidial/admin.php
+++ b/agc_2-X/trunk/www/vicidial/admin.php
@@ -4,6 +4,8 @@
 # Copyright (C) 2013  Matt Florell     LICENSE: AGPLv2
 # 
 
+$startMS = microtime();
+
 require("dbconnect.php");
 require("functions.php");
 
@@ -107,7 +109,7 @@ $PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
 $PHP_SELF=$_SERVER['PHP_SELF'];
 $QUERY_STRING = getenv("QUERY_STRING");
 
-$Vreports = 'NONE, Real-Time Main Report, Real-Time Campaign Summary , Inbound Report, Inbound Service Level Report, Inbound Summary Hourly Report, Inbound Daily Report, Inbound DID Report, Inbound IVR Report, Outbound Calling Report, Outbound Summary Interval Report, Outbound IVR Report, Fronter - Closer Report, Lists Campaign Statuses Report, Campaign Status List Report, Export Calls Report, Export Leads Report , Agent Time Detail, Agent Status Detail, Agent Performance Detail, Team Performance Detail, Single Agent Daily, User Group Login Report, User Timeclock Report, User Group Timeclock Status Report, User Timeclock Detail Report , Server Performance Report, Administration Change Log, List Update Stats, User Stats, User Time Sheet, Download List, Dialer Inventory Report, Maximum System Stats, Maximum Stats Detail, Search Leads Logs, Email Log Report';
+$Vreports = 'NONE, Real-Time Main Report, Real-Time Campaign Summary , Inbound Report, Inbound Service Level Report, Inbound Summary Hourly Report, Inbound Daily Report, Inbound DID Report, Inbound IVR Report, Outbound Calling Report, Outbound Summary Interval Report, Outbound IVR Report, Fronter - Closer Report, Lists Campaign Statuses Report, Campaign Status List Report, Export Calls Report, Export Leads Report , Agent Time Detail, Agent Status Detail, Agent Performance Detail, Team Performance Detail, Single Agent Daily, User Group Login Report, User Timeclock Report, User Group Timeclock Status Report, User Timeclock Detail Report , Server Performance Report, Administration Change Log, List Update Stats, User Stats, User Time Sheet, Download List, Dialer Inventory Report, Maximum System Stats, Maximum Stats Detail, Search Leads Logs, Email Log Report, Carrier Log Report, Campaign Debug, Hangup Cause Report';
 
 $UGreports = 'ALL REPORTS, NONE, Real-Time Main Report, Real-Time Campaign Summary , Inbound Report, Inbound Service Level Report, Inbound Summary Hourly Report, Inbound Daily Report, Inbound DID Report, Inbound Email Report, Inbound IVR Report, Outbound Calling Report, Outbound Summary Interval Report, Outbound IVR Report, Fronter - Closer Report, Lists Campaign Statuses Report, Campaign Status List Report, Export Calls Report , Export Leads Report , Agent Time Detail, Agent Status Detail, Agent Performance Detail, Team Performance Detail, Single Agent Daily, User Group Login Report, User Timeclock Report, User Group Timeclock Status Report, User Timeclock Detail Report , Server Performance Report, Administration Change Log, List Update Stats, User Stats, User Time Sheet, Download List, Dialer Inventory Report, Custom Reports Links, CallCard Search, Maximum System Stats, Maximum Stats Detail, Search Leads Logs, Email Log Report';
 
@@ -3235,12 +3237,13 @@ else
 # 130130-1207 - Added new CPD AMD options for In-Groups and CallMenus
 # 130221-1736 - Added Level 8 Disable Add option to system settings and new Email Log Report link, DID exten made non-editable
 # 130402-2322 - Added user_group script variable
+# 130414-1924 - Added report logging and display
 #
 
 # make sure you have added a user to the vicidial_users MySQL table with at least user_level 8 to access this page the first time
 
-$admin_version = '2.6-396a';
-$build = '130402-2322';
+$admin_version = '2.6-397a';
+$build = '130414-1924';
 
 $STARTtime = date("U");
 $SQLdate = date("Y-m-d H:i:s");
@@ -3835,6 +3838,9 @@ if ($ADD==700000000000000)	{$hh='reports';	echo "VICIDIAL ADMIN CHANGE LOG";}
 if ($ADD==710000000000000)	{$hh='reports';	echo "VICIDIAL USER ADMIN CHANGE LOG";}
 if ($ADD==720000000000000)	{$hh='reports';	echo "VICIDIAL SECTION ADMIN CHANGE LOG";}
 if ($ADD==730000000000000)	{$hh='reports';	echo "VICIDIAL DETAIL ADMIN CHANGE LOG";}
+if ($ADD==800000000000000)	{$hh='reports';	echo "VICIDIAL ADMIN REPORT LOG";}
+if ($ADD==810000000000000)	{$hh='reports';	echo "VICIDIAL USER ADMIN REPORT LOG";}
+if ($ADD==830000000000000)	{$hh='reports';	echo "VICIDIAL DETAIL ADMIN REPORT LOG";}
 if ($ADD==0)			{$hh='users';		echo "Users List";}
 if ($ADD==8)			{$hh='users';		echo "CallBacks Within Agent";}
 if ($ADD==81)			{$hh='campaigns';	$sh='list';	echo "CallBacks Within Campaign";}
@@ -3887,6 +3893,33 @@ if ($ADD==999993)		{$hh='reports';		echo "SUMMARY STATS";}
 if ($ADD==999992)		{$hh='reports';		echo "SYSTEM SUMMARY STATS";}
 if ($ADD==999991)		{$hh='reports';		echo "SERVERS VERSIONS";}
 
+if ( ($ADD==999993) or ($ADD==999992) or ($ADD==730000000000000) or ($ADD==830000000000000) )
+	{
+	if ($ADD==999993)		{$report_name = "SUMMARY STATS";}
+	if ($ADD==999992)		{$report_name = "SYSTEM SUMMARY STATS";}
+	if ($ADD==730000000000000)	{$report_name = "DETAIL ADMIN CHANGE LOG";}
+	if ($ADD==830000000000000)	{$report_name = "DETAIL ADMIN REPORT LOG";}
+
+	##### 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";
+
+	$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, $stage, $report_display_type|', url='$LOGfull_url';";
+	if ($DB) {echo "|$stmt|\n";}
+	$rslt=mysql_query($stmt, $link);
+	$report_log_id = mysql_insert_id($link);
+	##### END log visit to the vicidial_report_log table #####
+	}
 
 if ( ($ADD>9) and ($ADD < 99998) )
 	{
@@ -32537,7 +32570,7 @@ if ($ADD==311111111111111)
 
 		echo "Slave Database Server: $NWB#settings-slave_db_server$NWE\n";
 
-		echo "Reports to use Slave DB: \n";
 
 		$Vreports_ARY = explode(',',$Vreports);
 		$Vreports_ct = count($Vreports_ARY);
@@ -32555,7 +32588,7 @@ if ($ADD==311111111111111)
 
 		if ($SSallow_custom_dialplan > 0)
 			{
-			echo "Custom Dialplan Entry: $NWB#settings-custom_dialplan_entry$NWE \n";
+			echo "Custom Dialplan Entry: $NWB#settings-custom_dialplan_entry$NWE \n";
 
 			echo "Reload Dialplan On Servers: $NWB#settings-reload_dialplan_on_servers$NWE\n";
 			}
@@ -34751,22 +34784,22 @@ if ($ADD==700000000000000)
 	echo "
\n"; echo ""; - if ($stage > 9999) + if ($stage > 4999) { - $next_limit = ($stage + 10000); - $limitSQL = "10000 offset $stage"; + $next_limit = ($stage + 5000); + $limitSQL = "5000 offset $stage"; } else { - $next_limit = "10000"; - $limitSQL = "10000"; + $next_limit = "5000"; + $limitSQL = "5000"; } $stmt="SELECT admin_log_id,event_date,user,ip_address,event_section,event_type,record_id,event_code,user_group from vicidial_admin_log $whereLOGadmin_viewable_groupsSQL order by event_date desc limit $limitSQL;"; $rslt=mysql_query($stmt, $link); $logs_to_print = mysql_num_rows($rslt); - echo "
ADMIN CHANGE LOG: (Last 10000 records)\n"; + echo "
ADMIN CHANGE LOG: (Last 5000 records)\n"; echo "
\n"; echo ""; echo ""; @@ -34848,7 +34881,7 @@ if ($ADD==710000000000000) $user_name = $row[0]; } - $stmt="SELECT admin_log_id,event_date,user,ip_address,event_section,event_type,record_id,event_code,user_group from vicidial_admin_log where user='$stage' $LOGadmin_viewable_groupsSQL order by event_date desc limit 10000;"; + $stmt="SELECT admin_log_id,event_date,user,ip_address,event_section,event_type,record_id,event_code,user_group from vicidial_admin_log where user='$stage' $LOGadmin_viewable_groupsSQL order by event_date desc limit 5000;"; $rslt=mysql_query($stmt, $link); $logs_to_print = mysql_num_rows($rslt); @@ -34934,7 +34967,7 @@ if ($ADD==720000000000000) if (preg_match("/DIDS/",$category)) {$sectionSQL = "event_section IN('DIDS','DID_RA-EXTEN')";} - $stmt="SELECT admin_log_id,event_date,user,ip_address,event_section,event_type,record_id,event_code,user_group from vicidial_admin_log where $sectionSQL and record_id='$stage' $LOGadmin_viewable_groupsSQL order by event_date desc limit 10000;"; + $stmt="SELECT admin_log_id,event_date,user,ip_address,event_section,event_type,record_id,event_code,user_group from vicidial_admin_log where $sectionSQL and record_id='$stage' $LOGadmin_viewable_groupsSQL order by event_date desc limit 5000;"; $rslt=mysql_query($stmt, $link); $logs_to_print = mysql_num_rows($rslt); @@ -35083,6 +35116,214 @@ if ($ADD==730000000000000) } +###################### +# ADD=800000000000000 view all activity in the admin report log +###################### + +if ($ADD==800000000000000) + { + echo "
ID
\n"; + echo ""; + + if ($stage > 4999) + { + $next_limit = ($stage + 5000); + $limitSQL = "5000 offset $stage"; + } + else + { + $next_limit = "5000"; + $limitSQL = "5000"; + } + + $stmt="SELECT report_log_id,event_date,user,ip_address,report_name,browser,referer,notes,url,run_time from vicidial_report_log order by event_date desc limit $limitSQL;"; + $rslt=mysql_query($stmt, $link); + $logs_to_print = mysql_num_rows($rslt); + + + echo "
ADMIN REPORT LOG: (Last 5000 records)\n"; + echo "
\n"; + echo ""; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + $logs_printed = ''; + $o=0; + while ($logs_to_print > $o) + { + $row=mysql_fetch_row($rslt); + + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + $run_color='color=blue'; + if ($row[9] > 5) {$run_color='color=black';} + if ($row[9] > 10) {$run_color='color=purple';} + if ($row[9] > 30) {$run_color='color=red';} + + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + $logs_printed .= "'$row[0]',"; + $o++; + } + echo "
IDDATE TIMEUSERIPREPORTRUN TIMEGOTO
$row[0] $row[1] $row[2] $row[3] $row[4] $row[9] GOTO


\n"; + echo "NEXT\n"; + echo "
\n"; + } + + +###################### +# ADD=810000000000000 view all activity in the report log made by one user +###################### + +if ($ADD==810000000000000) + { + echo "
\n"; + echo ""; + + $stmt="SELECT full_name from vicidial_users where user='$stage' $LOGadmin_viewable_groupsSQL;"; + $rslt=mysql_query($stmt, $link); + $names_to_print = mysql_num_rows($rslt); + if ($names_to_print > 0) + { + $row=mysql_fetch_row($rslt); + $user_name = $row[0]; + } + + $stmt="SELECT report_log_id,event_date,user,ip_address,report_name,browser,referer,notes,url,run_time from vicidial_report_log where user='$stage' order by event_date desc limit 5000;"; + $rslt=mysql_query($stmt, $link); + $logs_to_print = mysql_num_rows($rslt); + + echo "
ADMIN REPORT LOG: Changes made by $stage - $user_name\n"; + echo "
\n"; + echo ""; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + $logs_printed = ''; + $o=0; + while ($logs_to_print > $o) + { + $row=mysql_fetch_row($rslt); + + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + $run_color='color=blue'; + if ($row[9] > 5) {$run_color='color=black';} + if ($row[9] > 10) {$run_color='color=purple';} + if ($row[9] > 30) {$run_color='color=red';} + + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + $logs_printed .= "'$row[0]',"; + $o++; + } + echo "
IDDATE TIMEUSERIPREPORTRUN TIMEGOTO
$row[0] $row[1] $row[2] $row[3] $row[4] $row[9] GOTO


\n"; + echo "\n"; + echo "
\n"; + } + + +###################### +# ADD=830000000000000 detail view of one report log entry +###################### + +if ($ADD==830000000000000) + { + if ($LOGuser_level >= 9) + { + echo "
\n"; + echo ""; + + $stmt="SELECT report_log_id,event_date,vrl.user,ip_address,report_name,browser,referer,notes,url,full_name,val.user_group,run_time from vicidial_report_log vrl, vicidial_users val where report_log_id='$stage' and val.user=vrl.user $valLOGadmin_viewable_groupsSQL;"; + if ($DB > 0) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $logs_to_print = mysql_num_rows($rslt); + + if ($logs_to_print > 0) + { + $row=mysql_fetch_row($rslt); + + $run_color='color=blue'; + if ($row[11] > 5) {$run_color='color=black';} + if ($row[11] > 10) {$run_color='color=purple';} + if ($row[11] > 30) {$run_color='color=red';} + + echo "
ADMIN REPORT LOG: Record Detail - $stage

\n"; + echo "
\n"; + echo ""; + echo ""; + echo ""; + echo "\n"; + echo ""; + echo ""; + echo "\n"; + echo ""; + echo ""; + echo "\n"; + echo ""; + echo ""; + echo "\n"; + echo ""; + echo ""; + echo "\n"; + echo ""; + echo ""; + echo "\n"; + echo ""; + echo ""; + echo "\n"; + echo ""; + echo ""; + echo "\n"; + echo ""; + echo ""; + echo "\n"; + echo ""; + echo ""; + echo "\n"; + echo "
ID: $row[0]
DATE TIME: $row[1]
RUN TIME: $row[11] seconds
USER: $row[2] - $row[9]
IP: $row[3]
REPORT: $row[4]
BROWSER: $row[5]
NOTES: $row[7]
REFERER:

$row[6]

URL:

$row[8]



\n"; + echo "\n"; + echo "
\n"; + } + } + else + { + echo "You do not have permission to view this page\n"; + exit; + } + } + + ###################### # ADD=999999 display reports section ###################### @@ -35680,6 +35921,7 @@ if ($ADD==999994) echo "
  • Servers Versions\n"; echo "
  • Carrier Log Report\n"; echo "
  • Hangup Cause Report\n"; + echo "
  • Admin Report Log Viewer\n"; echo "
  • Bulk Phone Insert Page\n"; echo "
  • Basic Lead Management Tools\n"; echo "
  • Callbacks Transferral Page\n"; @@ -35891,6 +36133,21 @@ if ($ADD==999992) } ##### END max system stats report ##### +##### If report run, update the time in the vicidial_report_log table ##### +if ( ($ADD==999993) or ($ADD==999992) or ($ADD==730000000000000) or ($ADD==830000000000000) ) + { + $endMS = microtime(); + $startMSary = explode(" ",$startMS); + $endMSary = explode(" ",$endMS); + $runS = ($endMSary[0] - $startMSary[0]); + $runM = ($endMSary[1] - $startMSary[1]); + $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); + } + ###################### # ADD=999991 display server version info diff --git a/agc_2-X/trunk/www/vicidial/call_report_export.php b/agc_2-X/trunk/www/vicidial/call_report_export.php index 6c2ee790..d9c79755 100644 --- a/agc_2-X/trunk/www/vicidial/call_report_export.php +++ b/agc_2-X/trunk/www/vicidial/call_report_export.php @@ -5,7 +5,7 @@ # and/or vicidial_closer_log information by status, list_id and date range. # downloads to a flat text file that is tab delimited # -# Copyright (C) 2011 Matt Florell LICENSE: AGPLv2 +# Copyright (C) 2013 Matt Florell LICENSE: AGPLv2 # # CHANGES # @@ -33,8 +33,11 @@ # 110911-1445 - Added did fields to the EXTENDED format # 111010-1930 - Added ALTERNATE_1 format # 111104-1240 - Added user_group restrictions for selecting in-groups +# 130414-0122 - Added report logging # +$startMS = microtime(); + require("dbconnect.php"); $PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; @@ -79,6 +82,7 @@ if (strlen($shift)<2) {$shift='ALL';} $report_name = 'Export Calls Report'; $db_source = 'M'; +$file_exported=0; ############################################# ##### START SYSTEM_SETTINGS LOOKUP ##### @@ -98,15 +102,6 @@ if ($qm_conf_ct > 0) ##### END SETTINGS LOOKUP ##### ########################################### -if ( (strlen($slave_db_server)>5) and (preg_match("/$report_name/",$reports_use_slave_db)) ) - { - mysql_close($link); - $use_slave_server=1; - $db_source = 'S'; - require("dbconnect.php"); -# echo "\n"; - } - $PHP_AUTH_USER = ereg_replace("[^-_0-9a-zA-Z]","",$PHP_AUTH_USER); $PHP_AUTH_PW = ereg_replace("[^-_0-9a-zA-Z]","",$PHP_AUTH_PW); @@ -131,6 +126,35 @@ if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) 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"; + +$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 |$campaign[0], $query_date, $end_date|', url='$LOGfull_url';"; +if ($DB) {echo "|$stmt|\n";} +$rslt=mysql_query($stmt, $link); +$report_log_id = mysql_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); + $use_slave_server=1; + $db_source = 'S'; + require("dbconnect.php"); +# echo "\n"; + } + $stmt="SELECT user_group from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6 and view_reports='1' and active='Y';"; if ($DB) {echo "|$stmt|\n";} $rslt=mysql_query($stmt, $link); @@ -434,14 +458,6 @@ if ($run_export > 0) if ( ($outbound_to_print > 0) or ($inbound_to_print > 0) ) { - ### LOG INSERTION Admin Log Table ### - $SQL_log = "$stmt|$stmtA|"; - $SQL_log = ereg_replace(';','',$SQL_log); - $SQL_log = addslashes($SQL_log); - $stmt="INSERT INTO vicidial_admin_log set event_date='$NOW_TIME', user='$PHP_AUTH_USER', ip_address='$ip', event_section='LEADS', event_type='EXPORT', record_id='', event_code='ADMIN EXPORT CALLS REPORT', event_sql=\"$SQL_log\", event_notes='';"; - if ($DB) {echo "|$stmt|\n";} - $rslt=mysql_query($stmt, $link); - $TXTfilename = "EXPORT_CALL_REPORT_$FILE_TIME.txt"; // We'll be outputting a TXT file @@ -768,6 +784,7 @@ if ($run_export > 0) } $i++; } + $file_exported++; } else { @@ -1067,6 +1084,37 @@ else echo "\n\n"; } + +if ($db_source == 'S') + { + mysql_close($link); + $use_slave_server=0; + $db_source = 'M'; + require("dbconnect.php"); + } + +$endMS = microtime(); +$startMSary = explode(" ",$startMS); +$endMSary = explode(" ",$endMS); +$runS = ($endMSary[0] - $startMSary[0]); +$runM = ($endMSary[1] - $startMSary[1]); +$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); + +if ($file_exported > 0) + { + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|$stmtA|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$NOW_TIME', user='$PHP_AUTH_USER', ip_address='$ip', event_section='LEADS', event_type='EXPORT', record_id='', event_code='ADMIN EXPORT CALLS REPORT', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + exit; ?> \ No newline at end of file diff --git a/agc_2-X/trunk/www/vicidial/callbacks_bulk_change.php b/agc_2-X/trunk/www/vicidial/callbacks_bulk_change.php index 67f056a0..f1c8a083 100644 --- a/agc_2-X/trunk/www/vicidial/callbacks_bulk_change.php +++ b/agc_2-X/trunk/www/vicidial/callbacks_bulk_change.php @@ -1,10 +1,11 @@ LICENSE: AGPLv2 +# Copyright (C) 2013 Matt Florell LICENSE: AGPLv2 # # CHANGES # 120819-0119 - First build +# 130414-0021 - Added admin logging # header ("Content-type: text/html; charset=utf-8"); @@ -146,9 +147,17 @@ while ($i < $groups_to_print) } if ($SUBMIT && $old_user && $new_user && $confirm_transfer) { - $upd_stmt="update vicidial_callbacks set user='$new_user' where recipient='USERONLY' and status!='INACTIVE' and user='$old_user' $LOGadmin_viewable_groupsSQL"; + $upd_stmt="UPDATE vicidial_callbacks set user='$new_user' where recipient='USERONLY' and status!='INACTIVE' and user='$old_user' $LOGadmin_viewable_groupsSQL"; $upd_rslt=mysql_query($upd_stmt, $link); if ($DB) {echo "$upd_stmt\n";} + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$upd_stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date=NOW(), user='$PHP_AUTH_USER', ip_address='$ip', event_section='USERS', event_type='MODIFY', record_id='$new_user', event_code='ADMIN CALLBACK BULK CHANGE', event_sql=\"$SQL_log\", event_notes='Old user: $old_user';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); } ?> diff --git a/agc_2-X/trunk/www/vicidial/campaign_debug.php b/agc_2-X/trunk/www/vicidial/campaign_debug.php index dddedaba..f2a2ff22 100644 --- a/agc_2-X/trunk/www/vicidial/campaign_debug.php +++ b/agc_2-X/trunk/www/vicidial/campaign_debug.php @@ -1,12 +1,17 @@ LICENSE: AGPLv2 +# Copyright (C) 2013 Matt Florell LICENSE: AGPLv2 # # CHANGES # 110514-1231 - First build +# 130413-2342 - Added report logging # +$startMS = microtime(); + +$report_name='Campaign Debug'; + require("dbconnect.php"); $PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; @@ -38,6 +43,35 @@ if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) 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"; + +$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';"; +if ($DB) {echo "|$stmt|\n";} +$rslt=mysql_query($stmt, $link); +$report_log_id = mysql_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); + $use_slave_server=1; + $db_source = 'S'; + require("dbconnect.php"); + $MAIN.="\n"; + } + $NOW_DATE = date("Y-m-d"); $NOW_TIME = date("Y-m-d H:i:s"); $STARTtime = date("U"); @@ -181,6 +215,24 @@ else } +if ($db_source == 'S') + { + mysql_close($link); + $use_slave_server=0; + $db_source = 'M'; + require("dbconnect.php"); + } + +$endMS = microtime(); +$startMSary = explode(" ",$startMS); +$endMSary = explode(" ",$endMS); +$runS = ($endMSary[0] - $startMSary[0]); +$runM = ($endMSary[1] - $startMSary[1]); +$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); ?> diff --git a/agc_2-X/trunk/www/vicidial/fcstats.php b/agc_2-X/trunk/www/vicidial/fcstats.php index aa173a56..13a1d6c8 100644 --- a/agc_2-X/trunk/www/vicidial/fcstats.php +++ b/agc_2-X/trunk/www/vicidial/fcstats.php @@ -1,7 +1,7 @@ LICENSE: AGPLv2 +# Copyright (C) 2013 Matt Florell LICENSE: AGPLv2 # # CHANGES # @@ -21,8 +21,11 @@ # 111104-1213 - Added user_group restrictions for selecting in-groups # 120224-0910 - Added HTML display option with bar graphs # 120705-2007 - Changed SALES to use sales status flag +# 130414-0126 - Added report logging # +$startMS = microtime(); + require("dbconnect.php"); $PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; @@ -73,15 +76,6 @@ if ($qm_conf_ct > 0) ##### END SETTINGS LOOKUP ##### ########################################### -if ( (strlen($slave_db_server)>5) and (preg_match("/$report_name/",$reports_use_slave_db)) ) - { - mysql_close($link); - $use_slave_server=1; - $db_source = 'S'; - require("dbconnect.php"); - echo "\n"; - } - $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6 and view_reports='1' and active='Y';"; if ($DB) {$HTML_text.="|$stmt|\n";} $rslt=mysql_query($stmt, $link); @@ -102,6 +96,35 @@ if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) 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"; + +$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); +##### 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); + $use_slave_server=1; + $db_source = 'S'; + require("dbconnect.php"); + echo "\n"; + } + $stmt="SELECT user_group from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6 and view_reports='1' and active='Y';"; if ($DB) {$HTML_text.="|$stmt|\n";} $rslt=mysql_query($stmt, $link); @@ -907,10 +930,8 @@ if ($file_download > 0) flush(); echo "$CSV_text"; - - exit; } - else +else { $JS_onload.="}\n"; $JS_text.=$JS_onload; @@ -930,10 +951,28 @@ if ($file_download > 0) +if ($db_source == 'S') + { + mysql_close($link); + $use_slave_server=0; + $db_source = 'M'; + require("dbconnect.php"); + } + +$endMS = microtime(); +$startMSary = explode(" ",$startMS); +$endMSary = explode(" ",$endMS); +$runS = ($endMSary[0] - $startMSary[0]); +$runM = ($endMSary[1] - $startMSary[1]); +$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); + +exit; + } - - - ?> diff --git a/agc_2-X/trunk/www/vicidial/group_hourly_stats.php b/agc_2-X/trunk/www/vicidial/group_hourly_stats.php index 28d4b8ca..3c5e6f44 100644 --- a/agc_2-X/trunk/www/vicidial/group_hourly_stats.php +++ b/agc_2-X/trunk/www/vicidial/group_hourly_stats.php @@ -1,7 +1,7 @@ LICENSE: AGPLv2 +# Copyright (C) 2013 Matt Florell LICENSE: AGPLv2 # # CHANGES # @@ -11,8 +11,13 @@ # 90508-0644 - Changed to PHP long tags # 120221-0159 - Added User Group restrictions # 120223-2135 - Removed logging of good login passwords if webroot writable is enabled +# 130414-0224 - Added report logging # +$startMS = microtime(); + +$report_name='User Group Hourly Stats'; + require("dbconnect.php"); $PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; @@ -66,6 +71,26 @@ if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) 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"; + +$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, $status|', url='$LOGfull_url';"; +if ($DB) {echo "|$stmt|\n";} +$rslt=mysql_query($stmt, $link); +$report_log_id = mysql_insert_id($link); +##### END log visit to the vicidial_report_log table ##### + $STARTtime = date("U"); $TODAY = date("Y-m-d"); $date_with_hour_default = date("Y-m-d H"); @@ -269,7 +294,7 @@ echo "
  • \n"; echo "

    \n"; -echo "
    Please enter the group you want to get hourly stats for:
    \n"; +echo "
    Please enter the group you want to get hourly stats for: \n"; echo "\n"; echo "group:
    \n"; echo "\n"; + +if ($db_source == 'S') + { + mysql_close($link); + $use_slave_server=0; + $db_source = 'M'; + require("dbconnect.php"); + } + +$endMS = microtime(); +$startMSary = explode(" ",$startMS); +$endMSary = explode(" ",$endMS); +$runS = ($endMSary[0] - $startMSary[0]); +$runM = ($endMSary[1] - $startMSary[1]); +$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); + + } diff --git a/agc_2-X/trunk/www/vicidial/timeclock_report.php b/agc_2-X/trunk/www/vicidial/timeclock_report.php index 9888389a..198e28a9 100644 --- a/agc_2-X/trunk/www/vicidial/timeclock_report.php +++ b/agc_2-X/trunk/www/vicidial/timeclock_report.php @@ -1,7 +1,7 @@ LICENSE: AGPLv2 +# Copyright (C) 2013 Matt Florell LICENSE: AGPLv2 # # CHANGES # @@ -18,8 +18,11 @@ # 110703-1830 - Added download option # 111104-1314 - Added user_group restrictions for selecting in-groups # 120224-0910 - Added HTML display option with bar graphs +# 130414-0150 - Added report logging # +$startMS = microtime(); + require("dbconnect.php"); ##### Pull values from posted form variables ##### @@ -73,15 +76,6 @@ if ($qm_conf_ct > 0) ##### END SETTINGS LOOKUP ##### ########################################### -if ( (strlen($slave_db_server)>5) and (preg_match("/$report_name/",$reports_use_slave_db)) ) - { - mysql_close($link); - $use_slave_server=1; - $db_source = 'S'; - require("dbconnect.php"); - $MAIN.="\n"; - } - $PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); $PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); @@ -106,6 +100,35 @@ if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) 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"; + +$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 |$user_group[0], $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); +##### 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); + $use_slave_server=1; + $db_source = 'S'; + require("dbconnect.php"); + $MAIN.="\n"; + } + $stmt="SELECT user_group from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6 and view_reports='1' and active='Y';"; if ($DB) {$MAIN.="|$stmt|\n";} $rslt=mysql_query($stmt, $link); @@ -530,13 +553,31 @@ $MAIN.="\n"; echo "$CSV_text"; - exit; } else { echo $HEADER; require("admin_header.php"); echo $MAIN; - exit; } +if ($db_source == 'S') + { + mysql_close($link); + $use_slave_server=0; + $db_source = 'M'; + require("dbconnect.php"); + } + +$endMS = microtime(); +$startMSary = explode(" ",$startMS); +$endMSary = explode(" ",$endMS); +$runS = ($endMSary[0] - $startMSary[0]); +$runM = ($endMSary[1] - $startMSary[1]); +$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); + +exit; ?> diff --git a/agc_2-X/trunk/www/vicidial/timeclock_status.php b/agc_2-X/trunk/www/vicidial/timeclock_status.php index 2cc13695..899489c9 100644 --- a/agc_2-X/trunk/www/vicidial/timeclock_status.php +++ b/agc_2-X/trunk/www/vicidial/timeclock_status.php @@ -1,7 +1,7 @@ LICENSE: AGPLv2 +# Copyright (C) 2013 Matt Florell LICENSE: AGPLv2 # # CHANGES # @@ -15,10 +15,13 @@ # 100914-1326 - Added lookup for user_level 7 users to set to reports only which will remove other admin links # 110703-1833 - Added download option # 111104-1315 - Added user_group restrictions for selecting in-groups +# 130414-0152 - Added report logging # #header ("Content-type: text/html; charset=utf-8"); +$startMS = microtime(); + require("dbconnect.php"); $PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; @@ -64,15 +67,6 @@ if ($qm_conf_ct > 0) ##### END SETTINGS LOOKUP ##### ########################################### -if ( (strlen($slave_db_server)>5) and (preg_match("/$report_name/",$reports_use_slave_db)) ) - { - mysql_close($link); - $use_slave_server=1; - $db_source = 'S'; - require("dbconnect.php"); - $MAIN.="\n"; - } - $PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); $PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); @@ -113,6 +107,35 @@ if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) 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"; + +$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 |$user_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); +##### 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); + $use_slave_server=1; + $db_source = 'S'; + require("dbconnect.php"); + $MAIN.="\n"; + } + $stmt="SELECT user_group from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6 and view_reports='1' and active='Y';"; if ($DB) {$MAIN.="|$stmt|\n";} $rslt=mysql_query($stmt, $link); @@ -233,6 +256,26 @@ if (strlen($user_group) < 1) echo "$HEADER"; require("admin_header.php"); echo "$MAIN"; + + if ($db_source == 'S') + { + mysql_close($link); + $use_slave_server=0; + $db_source = 'M'; + require("dbconnect.php"); + } + + $endMS = microtime(); + $startMSary = explode(" ",$startMS); + $endMSary = explode(" ",$endMS); + $runS = ($endMSary[0] - $startMSary[0]); + $runM = ($endMSary[1] - $startMSary[1]); + $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); + exit; } @@ -467,10 +510,8 @@ if ($file_download > 0) flush(); echo "$CSV_text"; - - exit; } - else +else { header ("Content-type: text/html; charset=utf-8"); echo "$HEADER"; @@ -478,6 +519,24 @@ if ($file_download > 0) echo "$MAIN"; } +if ($db_source == 'S') + { + mysql_close($link); + $use_slave_server=0; + $db_source = 'M'; + require("dbconnect.php"); + } + +$endMS = microtime(); +$startMSary = explode(" ",$startMS); +$endMSary = explode(" ",$endMS); +$runS = ($endMSary[0] - $startMSary[0]); +$runM = ($endMSary[1] - $startMSary[1]); +$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); exit; @@ -598,7 +657,25 @@ $MAIN.="
    \n"; $MAIN.="\n"; $MAIN.="\n"; - +if ($db_source == 'S') + { + mysql_close($link); + $use_slave_server=0; + $db_source = 'M'; + require("dbconnect.php"); + } + +$endMS = microtime(); +$startMSary = explode(" ",$startMS); +$endMSary = explode(" ",$endMS); +$runS = ($endMSary[0] - $startMSary[0]); +$runM = ($endMSary[1] - $startMSary[1]); +$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); + exit; diff --git a/agc_2-X/trunk/www/vicidial/user_stats.php b/agc_2-X/trunk/www/vicidial/user_stats.php index bb68bb7b..b673ecc3 100644 --- a/agc_2-X/trunk/www/vicidial/user_stats.php +++ b/agc_2-X/trunk/www/vicidial/user_stats.php @@ -36,8 +36,10 @@ # 120223-2135 - Removed logging of good login passwords if webroot writable is enabled # 121222-2152 - Added email log display # 130124-1740 - Added option to display first and last name of lead +# 130414-0146 - Added report logging # +$startMS = microtime(); require("dbconnect.php"); require("functions.php"); @@ -72,15 +74,6 @@ if ($qm_conf_ct > 0) ##### END SETTINGS LOOKUP ##### ########################################### -if ( (strlen($slave_db_server)>5) and (preg_match("/$report_name/",$reports_use_slave_db)) ) - { - mysql_close($link); - $use_slave_server=1; - $db_source = 'S'; - require("dbconnect.php"); - $MAIN.="\n"; - } - $PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; $PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; $PHP_SELF=$_SERVER['PHP_SELF']; @@ -139,6 +132,35 @@ if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) 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"; + +$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 |$user, $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); +##### 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); + $use_slave_server=1; + $db_source = 'S'; + require("dbconnect.php"); + $MAIN.="\n"; + } + $stmt="SELECT full_name,user_group,admin_hide_lead_data,admin_hide_phone_data from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; $rslt=mysql_query($stmt, $link); $row=mysql_fetch_row($rslt); @@ -1292,8 +1314,6 @@ if ($file_download>0) flush(); echo "$CSV_text"; - - exit; } else { @@ -1301,9 +1321,29 @@ else echo $HEADER; require("admin_header.php"); echo $MAIN; - exit; } +if ($db_source == 'S') + { + mysql_close($link); + $use_slave_server=0; + $db_source = 'M'; + require("dbconnect.php"); + } + +$endMS = microtime(); +$startMSary = explode(" ",$startMS); +$endMSary = explode(" ",$endMS); +$runS = ($endMSary[0] - $startMSary[0]); +$runM = ($endMSary[1] - $startMSary[1]); +$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); + +exit; + diff --git a/agc_2-X/trunk/www/vicidial/user_status.php b/agc_2-X/trunk/www/vicidial/user_status.php index ab3eb70b..c1648b5d 100644 --- a/agc_2-X/trunk/www/vicidial/user_status.php +++ b/agc_2-X/trunk/www/vicidial/user_status.php @@ -1,7 +1,7 @@ LICENSE: AGPLv2 +# Copyright (C) 2013 Matt Florell LICENSE: AGPLv2 # # CHANGES # @@ -20,10 +20,15 @@ # 110224-2350 - Small QM logout fix # 110420-0344 - Added DEAD/PARK agent statuses # 120223-2135 - Removed logging of good login passwords if webroot writable is enabled +# 130414-0252 - Added report logging # +$startMS = microtime(); + header ("Content-type: text/html; charset=utf-8"); +$report_name='User Status'; + require("dbconnect.php"); $PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; @@ -95,6 +100,26 @@ if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) } else { + ##### 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"; + + $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 |$user, $stage, $group|', url='$LOGfull_url';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $report_log_id = mysql_insert_id($link); + ##### END log visit to the vicidial_report_log table ##### + if($auth>0) { $stmt="SELECT full_name,change_agent_campaign,modify_timeclock_log from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; @@ -486,7 +511,26 @@ if ($stage == "log_agent_out") { echo "Agent $user is not logged in
    \n"; } - + + if ($db_source == 'S') + { + mysql_close($link); + $use_slave_server=0; + $db_source = 'M'; + require("dbconnect.php"); + } + + $endMS = microtime(); + $startMSary = explode(" ",$startMS); + $endMSary = explode(" ",$endMS); + $runS = ($endMSary[0] - $startMSary[0]); + $runM = ($endMSary[1] - $startMSary[1]); + $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); + exit; } @@ -652,6 +696,25 @@ if ( ( ($stage == "tc_log_user_OUT") or ($stage == "tc_log_user_IN") ) and ($mod echo "$VDdisplayMESSAGE\n"; + if ($db_source == 'S') + { + mysql_close($link); + $use_slave_server=0; + $db_source = 'M'; + require("dbconnect.php"); + } + + $endMS = microtime(); + $startMSary = explode(" ",$startMS); + $endMSary = explode(" ",$endMS); + $runS = ($endMSary[0] - $startMSary[0]); + $runM = ($endMSary[1] - $startMSary[1]); + $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); + exit; } @@ -768,6 +831,26 @@ echo "|$stage|$group|"; LICENSE: AGPLv2 +# Copyright (C) 2013 Matt Florell LICENSE: AGPLv2 # # # CHANGES @@ -13,8 +13,13 @@ # 70115-1246 - Added ability to define an exten to play # 90508-0644 - Changed to PHP long tags # 120223-2124 - Removed logging of good login passwords if webroot writable is enabled +# 130414-0045 - Added report logging # +$startMS = microtime(); + +$report_name='Voice Lab'; + require("dbconnect.php"); $PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; @@ -52,24 +57,24 @@ $local_DEF = 'Local/'; $local_AMP = '@'; $ext_context = 'demo'; - $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7;"; - $rslt=mysql_query($stmt, $link); - $row=mysql_fetch_row($rslt); - $auth=$row[0]; +$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7;"; +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$auth=$row[0]; $fp = fopen ("./project_auth_entries.txt", "a"); $date = date("r"); $ip = getenv("REMOTE_ADDR"); $browser = getenv("HTTP_USER_AGENT"); - if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) +if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) { Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); Header("HTTP/1.0 401 Unauthorized"); echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; exit; } - else +else { if($auth>0) { @@ -94,6 +99,26 @@ $browser = getenv("HTTP_USER_AGENT"); $full_name = $row[0]; } +##### 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"; + +$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';"; +if ($DB) {echo "|$stmt|\n";} +$rslt=mysql_query($stmt, $link); +$report_log_id = mysql_insert_id($link); +##### END log visit to the vicidial_report_log table ##### + ##### get server listing for dynamic pulldown $stmt="SELECT server_ip,server_description from servers order by server_ip"; @@ -307,6 +332,25 @@ if ($KILL_VOICE_LAB > 1) } +if ($db_source == 'S') + { + mysql_close($link); + $use_slave_server=0; + $db_source = 'M'; + require("dbconnect.php"); + } + +$endMS = microtime(); +$startMSary = explode(" ",$startMS); +$endMSary = explode(" ",$endMS); +$runS = ($endMSary[0] - $startMSary[0]); +$runM = ($endMSary[1] - $startMSary[1]); +$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); + ?> \ No newline at end of file