note 42165 deleted from function.header by tomsommer
| From: | tomsommer@php.net | Date: | Thu, 06 May 2004 05:24:07 +0000 |
| Subject: | note 42165 deleted from function.header by tomsommer | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-69265@lists.php.net to get a copy of this message | ||
Note Submitter: mrmidi.I.HATE@SPAM.mrmidi.nl
----
404 Headers are useful for hiding things from nosy visitors, like include files containing
passwords. This little script will request a non-existant file from your server and send the error
document and headers to the browser.
<?php
function gimme_a_404(){
$fp = fsockopen($_SERVER['SERVER_NAME'], $_SERVER['SERVER_PORT'], $errno,
$errstr, 30);
if ($fp) {
fputs($fp, "GET /".__FUNCTION__." HTTP/1.0\r\nHost:
$_SERVER[SERVER_NAME]\r\n\r\n");
while (!feof($fp))
$response .= fgets($fp);
fclose ($fp);
list($headers, $html) = explode("\r\n\r\n", $response);
$headers = explode("\r\n", $headers);
foreach ($headers as $header)
header($header);
die (str_replace("/".__FUNCTION__, $_SERVER['SCRIPT_NAME'], $html));
}
}
if ($_GET['php'] != 'cool')
gimme_a_404();
echo "Yep!";
?>