";
$subject = "Apache Error Generation";
$body = "";
$body .= "
";
$body .= "Apache Error";
$body .= "";
$body .= "";
$body .= "Error occurred on " . $full_date . " " .
"at " . $full_time . "
";
$body .= "Error received was a " . $error_no . " error.
";
$body .= "The page that generated the error was: " .
$request_page . "
";
$body .= "The generated error message was:" . $error_output;
$body .= "";
$body .= "";
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: Apache Error \r\n";
$headers .= "Cc: webmaster@yourdomain.com\r\n";
mail($to, $subject, $body, $headers);
}
$date = getdate();
$full_date = $date['weekday'] . ", " .
$date['month'] . " " .
$date['mday'] . ", " .
$date['year'];
$full_time = $date['hours'] . ":" .
$date['minutes'] . ":" .
$date['seconds'] . ":" .
$date['year'];
$error_no = $_SERVER['QUERY_STRING'];
$request_page = $_SERVER['REQUEST_URI'];
switch ($error_no) {
case 400:
$error_output = "\"Bad Request\" Error Page - " .
"(Error Code 400)
";
$error_output .= "The browser has made a Bad Request
";
$error_output .= "" .
"Contact the system administrator";
$error_output .= " if you feel this to be in error";
email_admin($error_no,
$error_output,
$full_date,
$full_time,
$request_page);
break;
case 401:
$error_output = "\"Authorization Required\" Error Page - " .
"(Error Code 401)
";
$error_output .= "You have supplied the wrong information to " .
"access a secure area
";
$error_output .= "" .
"Contact the system administrator";
$error_output .= " if you feel this to be in error";
email_admin($error_no,
$error_output,
$full_date,
$full_time,
$request_page);
break;
case 403:
$error_output = "\"Forbidden Access\" Error Page - " .
"(Error Code 403)
";
$error_output .= "You are denied access to this area
";
$error_output .= "" .
"Contact the system administrator";
$error_output .= " if you feel this to be in error";
email_admin($error_no,
$error_output,
$full_date,
$full_time,
$request_page);
break;
case 404:
$error_output = "\"Page Not Found\" Error Page - " .
"(Error Code 404)
";
$error_output .= "The page you are looking for " .
"cannot be found
";
$error_output .= "" .
"Contact the system administrator";
$error_output .= " if you feel this to be in error";
email_admin($error_no,
$error_output,
$full_date,
$full_time,
$request_page);
break;
case 500:
$error_output = "\"Internal Server Error\" Error Page - " .
"(Error Code 500)
";
$error_output .= "The server has encountered " .
"an internal error
";
$error_output .= "" .
"Contact the system administrator";
$error_output .= " if you feel this to be in error";
email_admin($error_no,
$error_output,
$full_date,
$full_time,
$request_page);
break;
default:
$error_output = "Error Page
";
$error_output .= "This is the custom error Page
";
$error_output .= "You should be here";
}
?>
Beginning PHP5, Apache, MySQL Web Development