From e1b16e250e7f229a310b569a30bad99e7617b0e1 Mon Sep 17 00:00:00 2001 From: mischa Date: Sun, 21 Aug 2022 10:49:50 +0000 Subject: [PATCH] make debug output optional --- config.inc.php.sample | 4 ++++ functions.inc.php | 18 +++++++++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/config.inc.php.sample b/config.inc.php.sample index c9c8397..0a6ccad 100644 --- a/config.inc.php.sample +++ b/config.inc.php.sample @@ -12,6 +12,10 @@ if (preg_match("/config.inc.php/", $_SERVER['SCRIPT_NAME'])) { exit; } +// Debug mode +// Enables PHP error output +$CONF['debug'] = 'true'; + // Language config // Language files are located in './languages'. $CONF['default_language'] = 'en'; diff --git a/functions.inc.php b/functions.inc.php index 24c6ce2..6c9036f 100644 --- a/functions.inc.php +++ b/functions.inc.php @@ -7,11 +7,6 @@ // // File: functions.inc.php // -ini_set('display_errors', 1); -ini_set('display_startup_errors', 1); -error_reporting(E_ALL); -mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); - if(preg_match("/functions.inc.php/", $_SERVER['SCRIPT_NAME'])) { header("Location: login.php"); exit; @@ -19,6 +14,19 @@ if(preg_match("/functions.inc.php/", $_SERVER['SCRIPT_NAME'])) { $version = "1.0.0"; +// +// Check of debug is enabled or not +// +if ($CONF['debug'] == 'true') { + ini_set('display_errors', 1); + ini_set('display_startup_errors', 1); + error_reporting(E_ALL); + mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); +} else { + ini_set('display_errors', 0); + ini_set('display_startup_errors', 0); +} + // // check_session // Action: Check if a session already exists, if not redirect to login.php