diff --git a/functions.php b/functions.php
index 190c1f65..9434776c 100644
--- a/functions.php
+++ b/functions.php
@@ -215,7 +215,7 @@ function formatPhoneNumber($phoneNumber)
return $phoneNumber;
}
-
+
$phoneNumber = $phoneNumber ? preg_replace('/[^0-9]/', '', $phoneNumber) : "";
if (strlen($phoneNumber) > 10) {
@@ -733,12 +733,14 @@ function sanitizeInput($input)
{
global $mysqli;
- // Detect encoding
- $encoding = mb_detect_encoding($input, ['UTF-8', 'ISO-8859-1', 'Windows-1252', 'ISO-8859-15'], true);
+ if (!empty($input)) {
+ // Detect encoding
+ $encoding = mb_detect_encoding($input, ['UTF-8', 'ISO-8859-1', 'Windows-1252', 'ISO-8859-15'], true);
- // If not UTF-8, convert to UTF8 (primarily Windows-1252 is problematic)
- if ($encoding !== 'UTF-8') {
- $input = mb_convert_encoding($input, 'UTF-8', $encoding);
+ // If not UTF-8, convert to UTF8 (primarily Windows-1252 is problematic)
+ if ($encoding !== 'UTF-8') {
+ $input = mb_convert_encoding($input, 'UTF-8', $encoding);
+ }
}
// Remove HTML and PHP tags
@@ -1115,7 +1117,7 @@ function fetchUpdates() {
$updates->latest_version = $latest_version;
$updates->update_message = $update_message;
-
+
return $updates;
}
@@ -1301,3 +1303,11 @@ function enforceUserPermission($module, $check_access_level = 1) {
exit(WORDING_ROLECHECK_FAILED . "
Tell your admin: $map[$check_access_level] access to $module is not permitted for your role.");
}
}
+
+function enforceAdminPermission() {
+ global $session_is_admin;
+ if (!isset($session_is_admin) || !$session_is_admin) {
+ exit(WORDING_ROLECHECK_FAILED . "
Tell your admin: Your role does not have admin access.");
+ }
+ return true;
+}
diff --git a/inc_all_admin.php b/inc_all_admin.php
index 500af82b..0d2e1f61 100644
--- a/inc_all_admin.php
+++ b/inc_all_admin.php
@@ -7,9 +7,9 @@ require_once "functions.php";
require_once "check_login.php";
validateAdminRole();
-//if (!isset($session_is_admin) || !$session_is_admin) {
-// exit(WORDING_ROLECHECK_FAILED . "
Tell your admin: Your role does not have admin access.");
-//}
+
+// TODO: Change this to enforceAdminPermission();
+// We can't do this until everyone has the new database fields added in 1.4.9 on Sept 14th 2024
require_once "header.php";
diff --git a/invoice_add_modal.php b/invoice_add_modal.php
index 70cdf469..ba8f6dec 100644
--- a/invoice_add_modal.php
+++ b/invoice_add_modal.php
@@ -73,7 +73,7 @@
?>
diff --git a/invoice_edit_modal.php b/invoice_edit_modal.php
index ddf6a39a..29cb268c 100644
--- a/invoice_edit_modal.php
+++ b/invoice_edit_modal.php
@@ -56,7 +56,7 @@
?>