Fix for rare issue with Automated Reports

git-svn-id: svn://192.168.202.10@3819 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
mattf
2024-04-02 02:38:44 +00:00
parent 58bc293076
commit 97a3ccab17
12 changed files with 2199 additions and 11 deletions
+24 -2
View File
@@ -4,7 +4,7 @@
#
# functions for administrative scripts and reports
#
# Copyright (C) 2023 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
# Copyright (C) 2024 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
#
# CHANGES:
@@ -41,6 +41,7 @@
# 210615-0952 - Default security fix, CVE-2021-28854
# 220921-1209 - Added more failed login logging in user_authorization function
# 231119-1445 - Added user_authorization for HCI page users
# 240401-1459 - Added check for vicidial_pending_ar entries in user_authorization
#
##### BEGIN validate user login credentials, check for failed lock out #####
@@ -51,7 +52,7 @@ function user_authorization($user,$pass,$user_option,$user_update,$api_call)
#############################################
##### START SYSTEM_SETTINGS LOOKUP #####
$stmt = "SELECT use_non_latin,webroot_writable,pass_hash_enabled,pass_key,pass_cost,allow_ip_lists,system_ip_blacklist,two_factor_auth_hours,two_factor_container FROM system_settings;";
$stmt = "SELECT use_non_latin,webroot_writable,pass_hash_enabled,pass_key,pass_cost,allow_ip_lists,system_ip_blacklist,two_factor_auth_hours,two_factor_container,enable_auto_reports FROM system_settings;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($DB) {echo "$stmt\n";}
$qm_conf_ct = mysqli_num_rows($rslt);
@@ -67,6 +68,7 @@ function user_authorization($user,$pass,$user_option,$user_update,$api_call)
$SSsystem_ip_blacklist = $row[6];
$SStwo_factor_auth_hours = $row[7];
$SStwo_factor_container = $row[8];
$SSenable_auto_reports = $row[9];
}
##### END SETTINGS LOOKUP #####
###########################################
@@ -260,6 +262,26 @@ function user_authorization($user,$pass,$user_option,$user_update,$api_call)
if ($VALID_2FA < 1)
{
$auth_key='2FA';
if ( ($user_option == 'REPORTS') and ($SSenable_auto_reports > 0) )
{
# If this is a REPORT, check for a triggered automated report, and if so, allow it to proceed
$stmt="SELECT count(*) from vicidial_pending_ar where user='$user' and status='TRIGGERED' and start_datetime > date_add(now(), interval 5 minute);";
$rslt=mysql_to_mysqli($stmt, $link);
if ($DB) {echo "$stmt\n";}
$auth_check_to_print = mysqli_num_rows($rslt);
if ($auth_check_to_print > 0)
{
$row=mysqli_fetch_row($rslt);
if ($row[0] > 0);
{
$stmt="UPDATE vicidial_pending_ar SET status='AUTHORIZED',notes='$NOW_TIME $ip' WHERE user='$user' and status='TRIGGERED' and start_datetime > date_add(now(), interval 5 minute) order by start_datetime limit 1;";
$rslt=mysql_to_mysqli($stmt, $link);
$auth_key='GOOD';
}
}
}
}
}
}