download this file: func.error.php view text/plain: func.error.php file encoding: EUC-KR [goback]
<?php
##
## this file name is 'func.error.php'
##
## error functions
##
## [author]
## - Chilbong Kim<san2(at)linuxchannel.net>
##
## [changes]
## - 2003.07.02 : add stderr()
## - 2003.03.13 : new build
##
## [references]
##
## [usage]
##
## [example]
##
## print to stderr such as error_log()
##
## argument :
## $error string, error message
##
## return :
## $return mixed, the number of bytes written, or FALSE on error
##
function _stderr($errstr)
{
global $_SERVER;
if($fp = fopen('php://stderr','w'))
{
## add error_log format style
##
if($_SERVER['HTTP_USER_AGENT'])
{
$head = '['.date('D M d H:i:s Y').'] [PHP-stderr] '.
'[client '.$_SERVER['REMOTE_ADDR'].'] ';
}
$return = @fwrite($fp,$head.$errstr."\n");
fclose($fp);
}
return $return;
}
function stderr($errstr)
{
return error_log($errstr,0);
}
## this alias
##
function stderror($errstr)
{
return stderr($errstr);
}
function error($str='¿¡·¯', $back=1, $exit=1)
{
//$str = "\t<font color=blue>$str</font>\n"."\t<p>\n";
//$str = urlencode($str);
ini_set('default_charset','EUC-KR');
echo '<META HTTP-EQIV="Content-Type" CONTENT="text/html; CHARSET=EUC-KR">';
alert_error($str);
if($back) history_back();
if($exit) exit;
}
function alert_error($str)
{
$str = str_replace('"','\"',$str);
echo <<<_EOP_
\n<SCRIPT LANGUAGE='javascript'>
<!--
window.alert("$str");
//-->
</SCRIPT>\n
_EOP_;
}
function history_back()
{
echo <<<_EOP_
\n<script language="javascript">
<!--
history.back();
//-->
</script>\n
_EOP_;
}
?>