diff --git a/class2.php b/class2.php index 247733123..ac1586fd2 100644 --- a/class2.php +++ b/class2.php @@ -2068,11 +2068,22 @@ class error_handler var $errors; var $debug = false; + protected $xdebug = false; + protected $docroot = ''; + protected $label = array(); - function error_handler() + function __construct() { - // + $this->label = array(E_NOTICE => "Notice", E_WARNING => "Warning", E_DEPRECATED => "Deprecated", E_STRICT => "Strict"); + $this->color = array(E_NOTICE=> 'info', E_WARNING=>'warning', E_DEPRECATED => 'danger', E_STRICT => 'primary'); + $this->docroot = dirname(realpath(__FILE__)).DIRECTORY_SEPARATOR; + // This is initialized before the current debug level is known + if(function_exists('xdebug_get_function_stack')) + { + $this->xdebug = true; + } + // global $_E107; if(isset($_E107['debug'])) @@ -2100,16 +2111,31 @@ class error_handler function handle_error($type, $message, $file, $line, $context) { $startup_error = (!defined('E107_DEBUG_LEVEL')); // Error before debug system initialized - - + + + switch($type) { case E_NOTICE: + case E_DEPRECATED: + // case E_STRICT: + if ($startup_error || E107_DBG_ALLERRORS || E107_DBG_ERRBACKTRACE) { - $error['short'] = "Notice: {$message}, Line {$line} of {$file}
\n"; - $trace = debug_backtrace(); - $backtrace[0] = (isset($trace[1]) ? $trace[1] : ""); - $backtrace[1] = (isset($trace[2]) ? $trace[2] : ""); + + + $error['short'] = "".$this->label[$type]." {$message}, Line {$line} of {$file}
\n"; + + if($this->xdebug) + { + $backtrace = xdebug_get_function_stack(); + } + else + { + $trace = debug_backtrace(); + $backtrace[0] = (isset($trace[1]) ? $trace[1] : ""); + $backtrace[1] = (isset($trace[2]) ? $trace[2] : ""); + } + $error['trace'] = $backtrace; $this->errors[] = $error; } @@ -2117,10 +2143,20 @@ class error_handler case E_WARNING: if ($startup_error || E107_DBG_BASIC || E107_DBG_ERRBACKTRACE) { - $error['short'] = "Warning: {$message}, Line {$line} of {$file}
\n"; - $trace = debug_backtrace(); - $backtrace[0] = (isset($trace[1]) ? $trace[1] : ""); - $backtrace[1] = (isset($trace[2]) ? $trace[2] : ""); + // $error['short'] = "Warning: {$message}, Line {$line} of {$file}
\n"; + $error['short'] = "".$this->label[$type]." {$message}, Line {$line} of {$file}
\n"; + + if($this->xdebug) + { + $backtrace = xdebug_get_function_stack(); + } + else + { + $trace = debug_backtrace(); + $backtrace[0] = (isset($trace[1]) ? $trace[1] : ""); + $backtrace[1] = (isset($trace[2]) ? $trace[2] : ""); + } + $error['trace'] = $backtrace; $this->errors[] = $error; } @@ -2141,6 +2177,44 @@ class error_handler } } + + + function render_trace($array) + { + if($this->xdebug == false) + { + return print_a($array, true); + } + + array_pop($array); + + + $text = " + "; + foreach($array as $key=>$val) + { + $text .= " + + + + + "; + } + + $text .= "
#FunctionLocation
".$key.""; + $text .= !empty($val['class']) ? $val['class']."->" : ''; + $text .= !empty($val['include_filename']) ? "include: ". str_replace($this->docroot,'', $val['include_filename']) : ''; + $text .= !empty($val['function']) ? $val['function']."(" : ""; + $text .= !empty($val['params']) ? print_r($val['params'],true) : ''; + $text .= !empty($val['function']) ? ")" : ""; + $text .=""; + $text .= str_replace($this->docroot,'', $val['file']).":".$val['line']; + $text .= "
"; + + return $text; + + } + function return_errors() { $index = 0; $colours[0] = "#C1C1C1"; $colours[1] = "#B6B6B6"; @@ -2150,10 +2224,13 @@ class error_handler if (E107_DBG_ERRBACKTRACE) { + + + foreach ($this->errors as $key => $value) { $ret .= "\t\n\t\t{$value['short']}\n"; - $ret .= "\t\n".print_a($value['trace'], true)."\n"; + $ret .= "\t\n".$this->render_trace($value['trace'])."\n"; $ret .= "\n\t"; if($index == 0) { $index = 1; } else { $index = 0; } } diff --git a/e107_admin/admin.php b/e107_admin/admin.php index a29d4710f..d1ef36036 100644 --- a/e107_admin/admin.php +++ b/e107_admin/admin.php @@ -207,6 +207,8 @@ class admin_start e_ADMIN."download.php", e_PLUGIN."banner/config.php", e_PLUGIN."forum/newforumposts_menu_config.php", + e_PLUGIN."forum/e_latest.php", + e_PLUGIN."forum/e_status.php" ); diff --git a/e107_handlers/e107_class.php b/e107_handlers/e107_class.php index 3dfec1e38..f793aa8a7 100644 --- a/e107_handlers/e107_class.php +++ b/e107_handlers/e107_class.php @@ -3274,7 +3274,10 @@ class e107 define('e_UC_ADMIN', 254); define('e_UC_NOBODY', 255); - + if(!defined('e_DEBUG')) + { + define('e_DEBUG', false); + } return $this; } @@ -3632,8 +3635,6 @@ class e107 - - unset($requestUrl, $requestUri); // END request uri/url detection, XSS protection diff --git a/e107_handlers/menu_class.php b/e107_handlers/menu_class.php index fa309165c..f275af76a 100644 --- a/e107_handlers/menu_class.php +++ b/e107_handlers/menu_class.php @@ -521,7 +521,8 @@ class e_menu $e107_debug ? include(e_PLUGIN.$mpath.$mname.'.php') : @include(e_PLUGIN.$mpath.$mname.'.php'); } e107::getDB()->db_Mark_Time("(After ".$mname.")"); - if($error_handler->debug==true) + + if(e_DEBUG === true) { echo "\n\n"; }