'; }
global $_SCRIPT_ERRORS;
if(empty($level)) { $level = 'HIGH'; }
$_SCRIPT_ERRORS[] = array('text'=>$message,'level'=>$level); // put error in errors array
if(kDEBUG) { print 'Leaving errors_collect.
'; }
}
###################################################################################################### displays all errors according to error display level passed to function
# returns: nothing
# parameters: none
function errors_display()
{
if(kDEBUG) { print 'Entering errors_display.
'; }
global $_SCRIPT_ERRORS;
$err_num = 1;
if(empty($_SCRIPT_ERRORS)) { // if there are no errors in the errors array,
if(kDEBUG) { print 'Leaving errors_display, exiting early.
'; }
return;
} // don't try to display any
?>
\n";
$err_num++;
}
}
?>
'; }
}
#################################################################################
# #
# written by benjamin ramey #
# bsr@rameydesign.net #
# #
# This file contains: #
# Functions that handle errors throughout the script #
# #
#################################################################################
# style: all caps, underscores
# prefix: E_
####################################################################### GLOBALS #
# errors that will be displayed to the user (public)
$E_PUB_ERR = array();
# errors that will be logged, but not shown to the user (private)
$E_PRIV_ERR = array();
############################################################ FUNCTION: err_make #
function err_make($mesg,$type)
{
global $E_PUB_ERR,$E_PRIV_ERR;
# if we received a public error message...
if($type == 'pub')
{
$E_PUB_ERR[] = $mesg;
}
# or, if we received a private error message...
else if($type == 'priv')
{
$E_PRIV_ERR[] = $mesg;
}
}
######################################################## FUNCTION: err_log_priv #
function err_log_priv()
{
global $E_PRIV_ERR,$_CONFIG,$_LB;
# a nice timestamp to prepend to the error mesg
# timestamp example: [Sun, August 23, 2003 18:23:34 EST]
$err_time = '['.date("D, M d, Y G:i:s T").'] ';
# open the private error file, append the debugging msg to it, and
# then close it
$fh = fopen($_CONFIG['priv_err_file'], 'a');
foreach($E_PRIV_ERR as $error)
{
fwrite($fh,$err_time.$error.$_LB);
}
fclose($fh);
}
######################################################### FUNCTION: err_log_pub #
function err_log_pub()
{
global $E_PUB_ERR,$_CONFIG,$_LB;
# a nice timestamp to prepend to the error mesg
# timestamp example: [Sun, August 23, 2003 18:23:34 EST]
$err_time = '['.date("D, M d, Y G:i:s T").'] ';
# open the private error file, append the debugging msg to it, and
# then close it
$fh = fopen($_CONFIG['pub_err_file'], 'a');
foreach($E_PUB_ERR as $error)
{
fwrite($fh,$err_time.$error.$_LB);
}
fclose($fh);
}
########################################################### FUNCTION: err_exist #
function err_exist()
{
global $E_PUB_ERR, $E_PRIV_ERR;
# if both error arrays are empty, then
# no errors exists. otherwise, they do exist
if(empty($E_PUB_ERR) and empty($E_PRIV_ERR))
{
return(false);
}
else
{
return(true);
}
return(false);
}
?>