<?php
/**
* This scpript can call directly or access as include and executed as a function.
* This script will send a standarded error 404 (Not found) an is nice for real or faked 404-errors
*
* Args:
* 1. string $logentry - if false (zero, null, 0 ...) nothing will be logged
* - if true this will be logged as a notice
*
* 2. boolean $exit - if true php will stopped after show the error
* - if false php will stopped after show the error
*
* If you have heders send this will die with a error.
* If you using a ob-buffer he will be claered. It's a good idea to use the ob-buffers if you want to fake the Error 404.
**/
$error404calledDirect = ( $_SERVER['SCRIPT_FILENAME'] == __FILE__ );
if ( $error404calledDirect ) { error404('directly called', true); }
function error404($logentry=false, $exit=true) {
trigger_error('Es kann kein Status 404 gesendet werden, weil zuvor Daten gesendet wurden.', E_USER_ERROR);
} else {
header("HTTP/1.0 404 Not Found");
?>
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<hr>
</body></html>
<?php
}
if ($logentry) {
}
if ( $exit ) {
} else {
return true;
}
}