From 3af9846d4ecc1e0274833740fd21012afe9ef51f Mon Sep 17 00:00:00 2001 From: jhunkeler Date: Sun, 20 Dec 2009 20:34:08 +0000 Subject: Error handling functions added, and applied git-svn-id: http://svn.3rd-infantry-division.org/testing/branches/Bayonet CMS v2@380 c5b2fb0a-d05d-0410-98c8-828840a80ff6 --- includes/functions.php | 28 ++++++++++++++++++++++++++++ index.php | 16 ++++++++++++---- modules.php | 14 ++++++++++++++ 3 files changed, 54 insertions(+), 4 deletions(-) diff --git a/includes/functions.php b/includes/functions.php index cd25792..0203d34 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -322,6 +322,34 @@ function CloseBlock() echo ""; CloseTable(); } + +static $error_stack_messages = array(); //global stack of errors accumulated throughout execution +function push_error_stack($message) +{ + global $error_stack_messages; + array_push($error_stack_messages, $message); +} + +function fatal_error_handler($buffer) { + if (ereg("(error:)(.+)(/","",$regs[2]); + //ReportError($err); + } + return $buffer; +} + +function handle_error ($errno, $errstr, $errfile, $errline) +{ + //error_log("$errstr in $errfile on line $errline"); + //ReportError("
$errstr
"); + push_error_stack("Error Number: $errno
Error: $errstr
In File: $errfile
Line: $errline"); + if($errno == FATAL || $errno == ERROR){ + push_error_stack($errstr); + ob_end_flush(); + exit(0); + } +} + /** * ReportError() * diff --git a/index.php b/index.php index e1ded92..3687f0d 100644 --- a/index.php +++ b/index.php @@ -1,4 +1,3 @@ - Connect( $config['sql']['hostname'], @@ -22,7 +28,6 @@ $db->Connect( ); $db->Select_db($config['sql']['database']); - include 'header.php'; //session_start(); ?> @@ -54,7 +59,10 @@ include 'header.php'; - $error) + { + $messageBuffer .= "

Stack Order:$order
$error

"; + } + ReportError($messageBuffer); + //exit(1); +} + if(isset($load) && !empty($load) && !isset($file)) { if(file_exists("modules/" . $load)) -- cgit