From 8109bc2892ab4d2fac7225d4ece2a18e6bb9c03b Mon Sep 17 00:00:00 2001 From: flashwave Date: Tue, 5 Jul 2022 13:28:28 +0000 Subject: [PATCH] Hide errors in production. --- .gitignore | 1 + ajaxchat.php | 10 ++++++++++ public/index.php | 4 ---- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index b5cef7f..3d7b952 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ .DS_Store /config/config-db.php /public/robots.txt +/.debug diff --git a/ajaxchat.php b/ajaxchat.php index c5414fc..3ddfd2d 100644 --- a/ajaxchat.php +++ b/ajaxchat.php @@ -8,6 +8,16 @@ */ define('AJAX_CHAT_PATH', __DIR__); +define('AJAX_CHAT_DEBUG', is_file(AJAX_CHAT_PATH . '/.debug')); + +// Only show errors in debug mode: +if(AJAX_CHAT_DEBUG) { + ini_set('display_errors', 'on'); + error_reporting(-1); +} else { + ini_set('display_errors', 'off'); + error_reporting(0); +} // Include Class libraries: require_once AJAX_CHAT_PATH . '/src/AJAXChat.php'; diff --git a/public/index.php b/public/index.php index 9abd2ed..20d9879 100644 --- a/public/index.php +++ b/public/index.php @@ -7,10 +7,6 @@ * @link https://blueimp.net/ajax/ */ -// Show all errors: -ini_set('display_errors', 'On'); -error_reporting(-1); - // Include Class libraries: require_once __DIR__ . '/../ajaxchat.php';