class error_handler { var $errors; var $debug = false; function error_handler() { if ((isset($_SERVER['QUERY_STRING']) && strpos($_SERVER['QUERY_STRING'], 'debug=') !== FALSE) || isset($_COOKIE['e107_debug_level'])) { $this->debug = true; error_reporting(E_ALL); } else { error_reporting(E_ERROR | E_PARSE); } } function handle_error($type, $message, $file, $line, $context) { switch($type) { case E_NOTICE: if ($this->debug == true) { $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['trace'] = $backtrace; $this->errors[] = $error; } break; case E_WARNING: if ($this->debug == true) { $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['trace'] = $backtrace; $this->errors[] = $error; } break; case E_USER_ERROR: if ($this->debug == true) { $error['short'] = "Internal Error Message: {$message}, Line {$line} of {$file}
\n"; $trace = debug_backtrace(); $backtrace[0] = (isset($trace[1]) ? $trace[1] : ""); $backtrace[1] = (isset($trace[2]) ? $trace[2] : ""); $error['trace'] = $backtrace; $this->errors[] = $error; } default: return true; break; } }