1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-01 20:30:39 +02:00

install shutdown error handler for php; Resolve

error reporting issue(s) by consolidating debug error
 reporting in a single Show_ALL() function.  Fixed an undefined var along the way.
This commit is contained in:
mrpete
2006-12-05 09:33:20 +00:00
parent a8f2dfe48d
commit 76c1196f3a
3 changed files with 45 additions and 47 deletions

View File

@@ -11,9 +11,9 @@
| GNU General Public License (http://gnu.org). | GNU General Public License (http://gnu.org).
| |
| $Source: /cvs_backup/e107_0.8/class2.php,v $ | $Source: /cvs_backup/e107_0.8/class2.php,v $
| $Revision: 1.2 $ | $Revision: 1.3 $
| $Date: 2006-12-03 03:26:22 $ | $Date: 2006-12-05 09:32:15 $
| $Author: mcfly_e107 $ | $Author: mrpete $
+----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+
*/ */
// //
@@ -83,7 +83,7 @@ $_SERVER['PHP_SELF'] = (($pos = strpos($_SERVER['PHP_SELF'], ".php")) !== false
// //
// D: Setup PHP error handling // D: Setup PHP error handling
// (Now we can see PHP errors) // (Now we can see PHP errors) -- but note that DEBUG is not yet enabled!
// //
$error_handler = new error_handler(); $error_handler = new error_handler();
set_error_handler(array(&$error_handler, "handle_error")); set_error_handler(array(&$error_handler, "handle_error"));
@@ -637,7 +637,7 @@ $ns=new e107table;
$e107->ban(); $e107->ban();
if($pref['force_userupdate'] && USER) { if(varset($pref['force_userupdate']) && USER) {
if(force_userupdate()) { if(force_userupdate()) {
header("Location: ".e_BASE."usersettings.php?update"); header("Location: ".e_BASE."usersettings.php?update");
} }
@@ -845,8 +845,14 @@ if (!class_exists('convert'))
//@require_once(e_HANDLER."debug_handler.php"); //@require_once(e_HANDLER."debug_handler.php");
//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------// //------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//
function js_location($qry){ function js_location($qry){
global $error_handler;
if (count($error_handler->errors)) {
echo $error_handler->return_errors();
exit;
} else {
echo "<script type='text/javascript'>document.location.href='{$qry}'</script>\n"; exit; echo "<script type='text/javascript'>document.location.href='{$qry}'</script>\n"; exit;
} }
}
function check_email($email) { function check_email($email) {
return preg_match("/^([_a-zA-Z0-9-+]+)(\.[_a-zA-Z0-9-]+)*@([a-zA-Z0-9-]+)(\.[a-zA-Z0-9-]+)*(\.[a-zA-Z]{2,6})$/" , $email) ? $email : FALSE; return preg_match("/^([_a-zA-Z0-9-+]+)(\.[_a-zA-Z0-9-]+)*@([a-zA-Z0-9-]+)(\.[a-zA-Z0-9-]+)*(\.[a-zA-Z]{2,6})$/" , $email) ? $email : FALSE;
@@ -1515,6 +1521,9 @@ class error_handler {
var $debug = false; var $debug = false;
function error_handler() { function error_handler() {
//
// This is initialized before the current debug level is known
//
if ((isset($_SERVER['QUERY_STRING']) && strpos($_SERVER['QUERY_STRING'], 'debug=') !== FALSE) || isset($_COOKIE['e107_debug_level'])) { if ((isset($_SERVER['QUERY_STRING']) && strpos($_SERVER['QUERY_STRING'], 'debug=') !== FALSE) || isset($_COOKIE['e107_debug_level'])) {
$this->debug = true; $this->debug = true;
error_reporting(E_ALL); error_reporting(E_ALL);
@@ -1524,9 +1533,10 @@ class error_handler {
} }
function handle_error($type, $message, $file, $line, $context) { function handle_error($type, $message, $file, $line, $context) {
$startup_error = (!defined('E107_DEBUG_LEVEL')); // Error before debug system initialized
switch($type) { switch($type) {
case E_NOTICE: case E_NOTICE:
if ($this->debug == true) { if ($startup_error || E107_DBG_ALLERRORS) {
$error['short'] = "Notice: {$message}, Line {$line} of {$file}<br />\n"; $error['short'] = "Notice: {$message}, Line {$line} of {$file}<br />\n";
$trace = debug_backtrace(); $trace = debug_backtrace();
$backtrace[0] = (isset($trace[1]) ? $trace[1] : ""); $backtrace[0] = (isset($trace[1]) ? $trace[1] : "");
@@ -1536,7 +1546,7 @@ class error_handler {
} }
break; break;
case E_WARNING: case E_WARNING:
if ($this->debug == true) { if ($startup_error || E107_DBG_BASIC) {
$error['short'] = "Warning: {$message}, Line {$line} of {$file}<br />\n"; $error['short'] = "Warning: {$message}, Line {$line} of {$file}<br />\n";
$trace = debug_backtrace(); $trace = debug_backtrace();
$backtrace[0] = (isset($trace[1]) ? $trace[1] : ""); $backtrace[0] = (isset($trace[1]) ? $trace[1] : "");
@@ -1563,11 +1573,19 @@ class error_handler {
function return_errors() { function return_errors() {
$index = 0; $colours[0] = "#C1C1C1"; $colours[1] = "#B6B6B6"; $index = 0; $colours[0] = "#C1C1C1"; $colours[1] = "#B6B6B6";
$ret = "<table class='fborder'>\n"; $ret = "<table class='fborder'>\n";
if (E107_DBG_ERRBACKTRACE)
{
foreach ($this->errors as $key => $value) { foreach ($this->errors as $key => $value) {
$ret .= "\t<tr>\n\t\t<td class='forumheader3' >{$value['short']}</td><td><input class='button' type ='button' style='cursor: hand; cursor: pointer;' size='30' value='Back Trace' onclick=\"expandit('bt_{$key}')\" /></td>\n\t</tr>\n"; $ret .= "\t<tr>\n\t\t<td class='forumheader3' >{$value['short']}</td><td><input class='button' type ='button' style='cursor: hand; cursor: pointer;' size='30' value='Back Trace' onclick=\"expandit('bt_{$key}')\" /></td>\n\t</tr>\n";
$ret .= "\t<tr>\n<td style='display: none;' colspan='2' id='bt_{$key}'>".print_a($value['trace'], true)."</td></tr>\n"; $ret .= "\t<tr>\n<td style='display: none;' colspan='2' id='bt_{$key}'>".print_a($value['trace'], true)."</td></tr>\n";
if($index == 0) { $index = 1; } else { $index = 0; } if($index == 0) { $index = 1; } else { $index = 0; }
} }
} else {
foreach ($this->errors as $key => $value)
{
$ret .= "<tr class='forumheader3'><td>{$value['short']}</td></tr>\n";
}
}
$ret .= "</table>"; $ret .= "</table>";
return $ret; return $ret;
} }

View File

@@ -3,7 +3,7 @@
+ ----------------------------------------------------------------------------+ + ----------------------------------------------------------------------------+
| e107 website system | e107 website system
| |
| ???Steve Dunstan 2001-2002 | <EFBFBD>Steve Dunstan 2001-2002
| http://e107.org | http://e107.org
| jalist@e107.org | jalist@e107.org
| |
@@ -11,12 +11,13 @@
| GNU General Public License (http://gnu.org). | GNU General Public License (http://gnu.org).
| |
| $Source: /cvs_backup/e107_0.8/e107_themes/templates/footer_default.php,v $ | $Source: /cvs_backup/e107_0.8/e107_themes/templates/footer_default.php,v $
| $Revision: 1.1.1.1 $ | $Revision: 1.2 $
| $Date: 2006-12-02 04:36:13 $ | $Date: 2006-12-05 09:33:20 $
| $Author: mcfly_e107 $ | $Author: mrpete $
+----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+
*/ */
if (!defined('e107_INIT')) { exit; } if (!defined('e107_INIT')) { exit; }
$In_e107_Footer = TRUE; // For registered shutdown function
global $eTraffic, $error_handler, $db_time, $sql, $sql2, $mySQLserver, $mySQLuser, $mySQLpassword, $mySQLdefaultdb, $CUSTOMFOOTER, $FOOTER, $e107; global $eTraffic, $error_handler, $db_time, $sql, $sql2, $mySQLserver, $mySQLuser, $mySQLpassword, $mySQLdefaultdb, $CUSTOMFOOTER, $FOOTER, $e107;
@@ -25,6 +26,7 @@ global $eTraffic, $error_handler, $db_time, $sql, $sql2, $mySQLserver, $mySQLuse
// //
// The following items have been carefully designed so page processing will finish properly // The following items have been carefully designed so page processing will finish properly
// Please DO NOT re-order these items without asking first! You WILL break something ;) // Please DO NOT re-order these items without asking first! You WILL break something ;)
// These letters match the USER footer (that's why there may be B.1,B.2)
// //
// A Ensure sql and traffic objects exist // A Ensure sql and traffic objects exist
// [Next few ONLY if a regular page; not done for popups] // [Next few ONLY if a regular page; not done for popups]
@@ -79,37 +81,9 @@ if(varset($e107_popup)!=1){
if ((ADMIN || $pref['developer']) && E107_DEBUG_LEVEL) { if ((ADMIN || $pref['developer']) && E107_DEBUG_LEVEL) {
global $db_debug,$ns; global $db_debug;
echo "\n<!-- DEBUG -->\n"; echo "\n<!-- DEBUG -->\n";
if (!isset($ns)) { $db_debug->Show_All();
echo "Why did ns go away?<br/>";
$ns = new e107table;
}
$tmp = $eTraffic->Display();
if (strlen($tmp)) {
$ns->tablerender('Traffic Counters', $tmp);
}
$tmp = $db_debug->Show_Performance();
if (strlen($tmp)) {
$ns->tablerender('Time Analysis', $tmp);
}
$tmp = $db_debug->Show_SQL_Details();
if (strlen($tmp)) {
$ns->tablerender('SQL Analysis', $tmp);
}
$tmp = $db_debug->Show_SC_BB();
if (strlen($tmp)) {
$ns->tablerender('Shortcodes / BBCode',$tmp);
}
$tmp = $db_debug->Show_PATH();
if (strlen($tmp)) {
$ns->tablerender('Paths', $tmp);
}
$tmp = $db_debug->Show_DEPRECATED();
if (strlen($tmp)) {
$ns->tablerender('Deprecated Function Usage', $tmp);
}
} }
/* /*
@@ -184,7 +158,8 @@ if((ADMIN == true || $pref['developer']) && $error_handler->debug == true) {
// //
// E Last themed footer code, usually JS // E Last themed footer code, usually JS
// //
if (function_exists('theme_foot')) { if (function_exists('theme_foot'))
{
echo theme_foot(); echo theme_foot();
} }
@@ -252,4 +227,7 @@ if($pref['compress_output'] == true && $server_support == true && $browser_suppo
echo $page; echo $page;
} }
unset($In_e107_Footer);
$e107_Clean_Exit=TRUE; // For registered shutdown function -- let it know all is well!
?> ?>

View File

@@ -6,9 +6,9 @@
| Released under the terms and conditions of the GNU General Public License (http://gnu.org). | Released under the terms and conditions of the GNU General Public License (http://gnu.org).
| |
| $Source: /cvs_backup/e107_0.8/e107_themes/templates/header_default.php,v $ | $Source: /cvs_backup/e107_0.8/e107_themes/templates/header_default.php,v $
| $Revision: 1.1.1.1 $ | $Revision: 1.2 $
| $Date: 2006-12-02 04:36:13 $ | $Date: 2006-12-05 09:33:20 $
| $Author: mcfly_e107 $ | $Author: mrpete $
+-----------------------------------------------------------------------------------------------+ +-----------------------------------------------------------------------------------------------+
*/ */
@@ -74,7 +74,7 @@ if (!function_exists("parseheader")) {
header("Content-type: text/html; charset=".CHARSET, true); header("Content-type: text/html; charset=".CHARSET, true);
echo (defined("STANDARDS_MODE") ? "" : "<?xml version='1.0' encoding='".CHARSET."' "."?".">")."<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\n"; echo (defined("STANDARDS_MODE") ? "" : "<?xml version='1.0' encoding='".CHARSET."' "."?".">\n")."<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\n";
// //
// C: Send start of HTML // C: Send start of HTML
@@ -188,6 +188,8 @@ echo "<meta http-equiv='content-type' content='text/html; charset=".CHARSET."' /
echo (defined("CORE_LC")) ? "<meta http-equiv='content-language' content='".CORE_LC."' />\n" : ""; echo (defined("CORE_LC")) ? "<meta http-equiv='content-language' content='".CORE_LC."' />\n" : "";
// --- Load plugin Meta files and eplug_ before others -------- // --- Load plugin Meta files and eplug_ before others --------
if (is_array($pref['e_meta_list']))
{
foreach($pref['e_meta_list'] as $val) foreach($pref['e_meta_list'] as $val)
{ {
if(is_readable(e_PLUGIN.$val."/e_meta.php")) if(is_readable(e_PLUGIN.$val."/e_meta.php"))
@@ -196,7 +198,7 @@ foreach($pref['e_meta_list'] as $val)
require_once(e_PLUGIN.$val."/e_meta.php"); require_once(e_PLUGIN.$val."/e_meta.php");
} }
} }
}
$diz_merge = (defined("META_MERGE") && META_MERGE != FALSE && $pref['meta_description'][e_LANGUAGE]) ? $pref['meta_description'][e_LANGUAGE]." " : ""; $diz_merge = (defined("META_MERGE") && META_MERGE != FALSE && $pref['meta_description'][e_LANGUAGE]) ? $pref['meta_description'][e_LANGUAGE]." " : "";
$key_merge = (defined("META_MERGE") && META_MERGE != FALSE && $pref['meta_keywords'][e_LANGUAGE]) ? $pref['meta_keywords'][e_LANGUAGE]."," : ""; $key_merge = (defined("META_MERGE") && META_MERGE != FALSE && $pref['meta_keywords'][e_LANGUAGE]) ? $pref['meta_keywords'][e_LANGUAGE]."," : "";