From 5f0cf85abe506478ae45da7b8566489db8775fd3 Mon Sep 17 00:00:00 2001 From: sld-admin Date: Tue, 4 Aug 2026 15:47:55 +0100 Subject: [PATCH] Added 'debugStatusMes function feature --- config/db.php | 1 + config/functions_init.php | 62 +++++++++++++++++++++++++++++++++++++++ config/init.php | 1 + functions/functions.php | 21 +++++++++++++ pages/db-error.php | 3 +- templates/footer.php | 2 ++ 6 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 functions/functions.php diff --git a/config/db.php b/config/db.php index ef21387..219ad75 100644 --- a/config/db.php +++ b/config/db.php @@ -13,6 +13,7 @@ try { } catch (mysqli_sql_exception $e) { // Access Deny include(PAGES_FOLD . "db-error.php"); + debugStatusMes("Database connection failed.", "High"); die(); diff --git a/config/functions_init.php b/config/functions_init.php index 55ea01a..68759a2 100644 --- a/config/functions_init.php +++ b/config/functions_init.php @@ -49,4 +49,66 @@ function resolve_page() { http_response_code(404); $GLOBALS["current_page"] = "404"; return PAGES_FOLD . "404.php"; +} + +/** +* DEBUG FUNCTIONS AND ARRAY +*/ + +$debug_messages = [ + 'High' => [], + 'Medium' => [], + 'Low' => [] +]; + +// FUNCTION TO GET DEBUG STATUS MESSAGES +function debugStatusMes( string $Message, string $intensity) { + global $debug, $debug_messages; + + // Controlla se il debug è attivo + if ($debug !== "on") { + return; + } + + // Normalizza l'intensità per evitare errori di battitura (es. "high" diventa "High") + $intensity = ucfirst(strtolower($intensity)); + + // Verifica che l'intensità sia valida prima di inserire il messaggio + if (array_key_exists($intensity, $debug_messages)) { + $debug_messages[$intensity][] = $Message; + } else { + // Se l'intensità non è corretta, la salva in una categoria generica o Low + $debug_messages['Low'][] = "[Intensità errata: $intensity] " . $Message; + } +} + +// DISPLAY DEBUG ERROR FOOTER BAR +function displayDebugFooter() { + global $debug, $debug_messages; + + if ($debug !== "on") { + return; + } + + echo ''; } \ No newline at end of file diff --git a/config/init.php b/config/init.php index 0081277..47e238b 100644 --- a/config/init.php +++ b/config/init.php @@ -22,5 +22,6 @@ } require_once(ROOT_DIR . "config/constants.php"); require_once(CONFIG_FOLD . "settings.php"); + require_once(FUNCTIONS_FOLD . "functions.php"); ?> \ No newline at end of file diff --git a/functions/functions.php b/functions/functions.php new file mode 100644 index 0000000..42184a9 --- /dev/null +++ b/functions/functions.php @@ -0,0 +1,21 @@ +Error Details: " . $e->getMessage() . "

"; - } + debugStatusMes("Database connection failed.", "High"); ?> + diff --git a/templates/footer.php b/templates/footer.php index c6b91cb..3376efc 100644 --- a/templates/footer.php +++ b/templates/footer.php @@ -1,7 +1,9 @@ + + \ No newline at end of file