From c62422ce7502846fff9e909a64b28499d21432ca Mon Sep 17 00:00:00 2001 From: mattf Date: Thu, 22 Sep 2022 14:36:46 +0000 Subject: [PATCH] Fix for user group permissions in Uer Logins Report Fix for loading internal chat while agent screen is still loading git-svn-id: svn://192.168.202.10@3643 3d104415-ff17-0410-8863-d5cf3c621b8a --- .../agc/agc_agent_manager_chat_interface.php | 11 +++++-- agc_2-X/trunk/www/agc/functions.php | 8 ++--- agc_2-X/trunk/www/agc/vicidial.php | 12 ++++--- .../trunk/www/vicidial/user_logins_report.php | 33 +++++++++++++++---- 4 files changed, 47 insertions(+), 17 deletions(-) diff --git a/agc_2-X/trunk/www/agc/agc_agent_manager_chat_interface.php b/agc_2-X/trunk/www/agc/agc_agent_manager_chat_interface.php index 429ac622..e7067eba 100644 --- a/agc_2-X/trunk/www/agc/agc_agent_manager_chat_interface.php +++ b/agc_2-X/trunk/www/agc/agc_agent_manager_chat_interface.php @@ -19,10 +19,11 @@ # 210616-2056 - Added optional CORS support, see options.php for details # 220220-0855 - Added allow_web_debug system setting # 220518-2210 - Small fix for encrypted auth +# 220922-1027 - Added BLANK action for first agent screen page load # -$admin_version = '2.14-12'; -$build = '220220-0855'; +$admin_version = '2.14-13'; +$build = '220922-1027'; $php_script = 'agc_agent_manager_chat_interface.php'; $sh="managerchats"; @@ -94,6 +95,12 @@ if (file_exists('options.php')) require_once('options.php'); } +if ($action == 'BLANK') + { + header ("Content-type: text/html; charset=utf-8"); + exit; + } + $auth=0; $auth_message = user_authorization($user,$pass,'',0,1,0,0,'chat'); if ($auth_message == 'GOOD') diff --git a/agc_2-X/trunk/www/agc/functions.php b/agc_2-X/trunk/www/agc/functions.php index 9def29de..156c6395 100644 --- a/agc_2-X/trunk/www/agc/functions.php +++ b/agc_2-X/trunk/www/agc/functions.php @@ -139,7 +139,7 @@ function user_authorization($user,$pass,$user_option,$user_update,$bcrypt,$retur if ($failed_login_count < $LOCK_trigger_attempts) { - $stmt="UPDATE vicidial_users set failed_login_count=(failed_login_count+1),failed_login_attempts_today=(failed_login_attempts_today+1),failed_login_count_today=(failed_login_count_today+1),failed_last_ip_today='$ip',failed_last_type_today='cBAD' where user='$user';"; + $stmt="UPDATE vicidial_users set failed_login_count=(failed_login_count+1),failed_login_attempts_today=(failed_login_attempts_today+1),failed_login_count_today=(failed_login_count_today+1),failed_last_ip_today='$ip',failed_last_type_today='01cBAD' where user='$user';"; $rslt=mysql_to_mysqli($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'05011',$user,$server_ip,$session_name,$one_mysql_log);} } @@ -147,14 +147,14 @@ function user_authorization($user,$pass,$user_option,$user_update,$bcrypt,$retur { if ($LOCK_over > $last_login_date) { - $stmt="UPDATE vicidial_users set last_login_date=NOW(),failed_login_count=1,failed_last_ip_today='$ip',failed_login_attempts_today=(failed_login_attempts_today+1),failed_login_count_today=(failed_login_count_today+1),failed_last_type_today='cBAD' where user='$user';"; + $stmt="UPDATE vicidial_users set last_login_date=NOW(),failed_login_count=1,failed_last_ip_today='$ip',failed_login_attempts_today=(failed_login_attempts_today+1),failed_login_count_today=(failed_login_count_today+1),failed_last_type_today='02cBAD' where user='$user';"; $rslt=mysql_to_mysqli($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'05012',$user,$server_ip,$session_name,$one_mysql_log);} } else { $auth_key='LOCK'; - $stmt="UPDATE vicidial_users set failed_login_attempts_today=(failed_login_attempts_today+1),failed_last_type_today='cLOCK' where user='$user';"; + $stmt="UPDATE vicidial_users set failed_login_attempts_today=(failed_login_attempts_today+1),failed_last_type_today='03cLOCK' where user='$user';"; $rslt=mysql_to_mysqli($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'05027',$user,$server_ip,$session_name,$one_mysql_log);} } @@ -330,7 +330,7 @@ function user_authorization($user,$pass,$user_option,$user_update,$bcrypt,$retur } else { - $stmt="UPDATE vicidial_users set failed_login_attempts_today=(failed_login_attempts_today+1),failed_last_type_today='c$auth_key' where user='$user';"; + $stmt="UPDATE vicidial_users set failed_login_attempts_today=(failed_login_attempts_today+1),failed_last_type_today='04c$auth_key' where user='$user';"; $rslt=mysql_to_mysqli($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'05028',$user,$server_ip,$session_name,$one_mysql_log);} } diff --git a/agc_2-X/trunk/www/agc/vicidial.php b/agc_2-X/trunk/www/agc/vicidial.php index ad71d449..256566d8 100644 --- a/agc_2-X/trunk/www/agc/vicidial.php +++ b/agc_2-X/trunk/www/agc/vicidial.php @@ -700,10 +700,11 @@ # 220901-1330 - Fix for issues with manager validation where manager has a long password # 220908-0819 - Small change for user_group_script override # 220916-0906 - Added INSERT_before_body_close options.php setting, Issue #1375 +# 220922-1032 - Fix for loading internal chat while agent screen is still loading # -$version = '2.14-668c'; -$build = '220916-0906'; +$version = '2.14-669c'; +$build = '220922-1032'; $php_script = 'vicidial.php'; $mel=1; # Mysql Error Log enabled = 1 $mysql_log_count=98; @@ -20920,7 +20921,10 @@ function phone_number_format(formatphone) { divref.visibility = 'hidden'; if (divvar == 'InternalChatPanel') // Clear the manager chat panel to prevent incoming messages from immediately being marked as read { - document.getElementById('InternalChatIFrame').src='./agc_agent_manager_chat_interface.php?user='+user+'&pass='+pass; + if (check_n > 3) + { + document.getElementById('InternalChatIFrame').src='./agc_agent_manager_chat_interface.php?user='+user+'&pass='+pass; + } } } } @@ -22290,7 +22294,7 @@ if ($agent_display_dialable_leads > 0) if ($webphone_location == 'bar') {echo "
\n";} ?> -
+
diff --git a/agc_2-X/trunk/www/vicidial/user_logins_report.php b/agc_2-X/trunk/www/vicidial/user_logins_report.php index 1a6d8ef7..9dc13c75 100644 --- a/agc_2-X/trunk/www/vicidial/user_logins_report.php +++ b/agc_2-X/trunk/www/vicidial/user_logins_report.php @@ -4,7 +4,8 @@ # Copyright (C) 2022 Matt Florell LICENSE: AGPLv2 # # CHANGES -# 110514-1231 - First build +# 220921-2203 - First build +# 220922-1031 - Fix for user group permissions # $startMS = microtime(); @@ -173,6 +174,24 @@ if ( (!preg_match('/\-ALL/i', $LOGallowed_campaigns)) ) } $regexLOGallowed_campaigns = " $LOGallowed_campaigns "; +$admin_viewable_groupsALL=0; +$LOGadmin_viewable_groupsSQL=''; +$whereLOGadmin_viewable_groupsSQL=''; +$valLOGadmin_viewable_groupsSQL=''; +$vmLOGadmin_viewable_groupsSQL=''; +if ( (!preg_match('/\-\-ALL\-\-/i',$LOGadmin_viewable_groups)) and (strlen($LOGadmin_viewable_groups) > 3) ) + { + $rawLOGadmin_viewable_groupsSQL = preg_replace("/ -/",'',$LOGadmin_viewable_groups); + $rawLOGadmin_viewable_groupsSQL = preg_replace("/ /","','",$rawLOGadmin_viewable_groupsSQL); + $LOGadmin_viewable_groupsSQL = "and user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')"; + $whereLOGadmin_viewable_groupsSQL = "where user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')"; + $valLOGadmin_viewable_groupsSQL = "and val.user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')"; + $vmLOGadmin_viewable_groupsSQL = "and vm.user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')"; + } +else + {$admin_viewable_groupsALL=1;} +$regexLOGadmin_viewable_groups = " $LOGadmin_viewable_groups "; + if ( (!preg_match("/$report_name/",$LOGallowed_reports)) and (!preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) { Header("WWW-Authenticate: Basic realm=\"CONTACT-CENTER-ADMIN\""); @@ -237,7 +256,7 @@ if ( (strlen($slave_db_server)>5) and (preg_match("/$report_name/",$reports_use_ $MAIN.="\n"; } -$stmt="select user,full_name from vicidial_users order by user;"; +$stmt="select user,full_name from vicidial_users $whereLOGadmin_viewable_groupsSQL order by user;"; $rslt=mysql_to_mysqli($stmt, $link); if ($DB) {echo "$stmt\n";} $campaigns_to_print = mysqli_num_rows($rslt); @@ -269,7 +288,7 @@ $NWE = "')\" WIDTH=20 HEIGHT=20 BORDER=0 ALT=\"HELP\" ALIGN=TOP>"; echo "\n"; echo "\n"; echo "\n"; -echo ""._QXZ("Campaign Debug")."\n"; +echo ""._QXZ("$report_name")."\n"; echo ""; $short_header=1; @@ -312,16 +331,16 @@ if (!$user) else { $multi_user=0; - $stmt="select user,login_day,last_login_date,last_ip,failed_login_attempts_today,failed_login_count_today,failed_last_ip_today,failed_last_type_today from vicidial_user_logins_daily where user='" . mysqli_real_escape_string($link, $user) . "' order by login_day desc limit 1000;"; + $stmt="select vuld.user,vuld.login_day,vuld.last_login_date,vuld.last_ip,vuld.failed_login_attempts_today,vuld.failed_login_count_today,vuld.failed_last_ip_today,vuld.failed_last_type_today from vicidial_user_logins_daily vuld, vicidial_users vm where vuld.user='" . mysqli_real_escape_string($link, $user) . "' and vm.user=vuld.user $vmLOGadmin_viewable_groupsSQL order by login_day desc limit 1000;"; if ($user == '--MOST-RECENT-ACTIVE-ARCHIVE--') { $multi_user=1; - $stmt="select user,login_day,last_login_date,last_ip,failed_login_attempts_today,failed_login_count_today,failed_last_ip_today,failed_last_type_today from vicidial_user_logins_daily order by login_day desc, last_login_date desc limit 1000;"; + $stmt="select vuld.user,vuld.login_day,vuld.last_login_date,vuld.last_ip,vuld.failed_login_attempts_today,vuld.failed_login_count_today,vuld.failed_last_ip_today,vuld.failed_last_type_today from vicidial_user_logins_daily vuld, vicidial_users vm where vm.user=vuld.user $vmLOGadmin_viewable_groupsSQL order by login_day desc, last_login_date desc limit 1000;"; } if ($user == '--MOST-RECENT-ACTIVE-TODAY--') { $multi_user=1; - $stmt="select user,'TODAY',last_login_date,last_ip,failed_login_attempts_today,failed_login_count_today,failed_last_ip_today,failed_last_type_today from vicidial_users where last_login_date >= \"$last_midnight\" order by last_login_date desc limit 1000;"; + $stmt="select user,'TODAY',last_login_date,last_ip,failed_login_attempts_today,failed_login_count_today,failed_last_ip_today,failed_last_type_today from vicidial_users where last_login_date >= \"$last_midnight\" $LOGadmin_viewable_groupsSQL order by last_login_date desc limit 1000;"; } $rslt=mysql_to_mysqli($stmt, $link); if ($DB) {echo "$stmt\n";} @@ -350,7 +369,7 @@ else } if ($multi_user < 1) { - $stmt="select user,'TODAY',last_login_date,last_ip,failed_login_attempts_today,failed_login_count_today,failed_last_ip_today,failed_last_type_today from vicidial_users where user='" . mysqli_real_escape_string($link, $user) . "' and last_login_date >= \"$last_midnight\" order by last_login_date desc limit 1000;"; + $stmt="select user,'TODAY',last_login_date,last_ip,failed_login_attempts_today,failed_login_count_today,failed_last_ip_today,failed_last_type_today from vicidial_users where user='" . mysqli_real_escape_string($link, $user) . "' and last_login_date >= \"$last_midnight\" $LOGadmin_viewable_groupsSQL order by last_login_date desc limit 1000;"; $rslt=mysql_to_mysqli($stmt, $link); if ($DB) {echo "$stmt\n";} $shortages_to_print = mysqli_num_rows($rslt);