All pastes #620718 Raw Edit

Someone

public text v1 · immutable
·published 2007-07-15 18:18 UTC
rendered paste body
set_error_handler( 'error' );

function error ( $errno, $errmsg, $filename, $linenum )
{
	$errortype = array (
        E_ERROR              => 'Error',
        E_WARNING            => 'Warning',
        E_PARSE              => 'Parsing Error',
        E_NOTICE             => 'Notice',
        E_CORE_ERROR         => 'Core Error',
        E_CORE_WARNING       => 'Core Warning',
        E_COMPILE_ERROR      => 'Compile Error',
        E_COMPILE_WARNING    => 'Compile Warning',
        E_USER_ERROR         => 'User Error',
        E_USER_WARNING       => 'User Warning',
        E_USER_NOTICE        => 'User Notice',
        E_STRICT             => 'Runtime Notice',
        E_RECOVERABLE_ERROR  => 'Catchable Fatal Error'
    );
    
    $dt = date("Y-m-d H:i:s (T)");
    $array = array(
    	'/home/slick/public_html/henrylegge' => '/public_html'
    );
    
    foreach( $array as $old => $new )
    {
    	$filename = str_replace( $old, $new, $filename );
    }
    
    echo '<div class="error">'.$errortype[$errno].' - '.$errmsg.', on line '.$linenum.',<br />
    in '.$filename.'</div>';
    
    $errmsg = addslashes( $errmsg );
    
   	$query = $DB->Query("SELECT * FROM `errors` WHERE `errorno` = '".$errno."' AND `errortype` = '".$errortype[$errno]."' AND `errormsg` = '".$errmsg."' AND `line` = '".$linenum."' AND `file` = '".$filename."'");
   	$check = $DB->NumRows($query);
    
    if( $check == 0 )
    {
    	$DB->Query("INSERT INTO `errors` (`errorno`, `errortype`, `errormsg`, `line`, `file`, `date`, `fixed`) VALUES ('".$errno."', '".$errortype[$errno]."', '".$errmsg."', '".$linenum."', '".$filename."', '".$dt."', 'n')");
    	
    	$body = 'There has been a '.$errortype[$errno].', error in '.$filename.', on line '.$linenum."\n".$errmsg.', at '.$dt."\n\n".'Henry Legge';
    
    	$headers = 'From: no-reply@henrylegge.co.uk'."\r\n";
			
		mail('me@henrylegge.co.uk', 'Error: There has been an error on your portfolio', $body, $headers);
	}
}