From f836c2b5e3704fe788819234615b03e12e9d70a2 Mon Sep 17 00:00:00 2001 From: Neil Lathwood Date: Wed, 18 Feb 2015 23:51:49 +0000 Subject: [PATCH] Added catching php fatal exceptions --- html/index.php | 54 +++++++++++++++++++++++++++++--------------------- 1 file changed, 31 insertions(+), 23 deletions(-) diff --git a/html/index.php b/html/index.php index 037843a356..d801561d05 100755 --- a/html/index.php +++ b/html/index.php @@ -12,6 +12,37 @@ * */ +$_SERVER['PATH_INFO'] = (isset($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : $_SERVER['ORIG_PATH_INFO']); + +function logErrors($errno, $errstr, $errfile, $errline) { + global $php_debug; + $php_debug[] = array('errno' => $errno, 'errstr' => $errstr, 'errfile' => $errfile, 'errline' => $errline); +} + +function catchFatal() { + $last_error = error_get_last(); + if ($last_error['type'] == 1) { + logErrors($last_error['type'],$last_error['message'],$last_error['file'],$last_error['line']); + } +} + +if (strpos($_SERVER['PATH_INFO'], "debug")) +{ + $debug = "1"; + ini_set('display_errors', 0); + ini_set('display_startup_errors', 1); + ini_set('log_errors', 1); + ini_set('error_reporting', E_ALL); + set_error_handler('logErrors'); + register_shutdown_function('catchFatal'); +} else { + $debug = FALSE; + ini_set('display_errors', 0); + ini_set('display_startup_errors', 0); + ini_set('log_errors', 0); + ini_set('error_reporting', 0); +} + // Set variables $msg_box = array(); @@ -38,29 +69,6 @@ ob_start(); ini_set('allow_url_fopen', 0); ini_set('display_errors', 0); -$_SERVER['PATH_INFO'] = (isset($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : $_SERVER['ORIG_PATH_INFO']); - -if (strpos($_SERVER['PATH_INFO'], "debug")) -{ - $debug = "1"; - ini_set('display_errors', 1); - ini_set('display_startup_errors', 1); - ini_set('log_errors', 1); - ini_set('error_reporting', E_ALL); - set_error_handler('logErrors'); -} else { - $debug = FALSE; - ini_set('display_errors', 0); - ini_set('display_startup_errors', 0); - ini_set('log_errors', 0); - ini_set('error_reporting', 0); -} - -function logErrors($errno, $errstr, $errfile, $errline) { - global $php_debug; - $php_debug[] = array('errno' => $errno, 'errstr' => $errstr, 'errfile' => $errfile, 'errline' => $errline); -} - foreach ($_GET as $key=>$get_var) { if (strstr($key, "opt"))