- Impact
- 328
Ok, probably not the best thing in the world but I got bored. So yeah, enjoy.
(Btw, this sends email on EVERY 404, soo, if you've got a decent sized site, I'd recommend disabling that..unless you really want a bajillion emails. But oh, why did I write that in .. in the first place? I have no idea..BOREDOM :p )
.htaccess:
404.php
(Btw, this sends email on EVERY 404, soo, if you've got a decent sized site, I'd recommend disabling that..unless you really want a bajillion emails. But oh, why did I write that in .. in the first place? I have no idea..BOREDOM :p )
.htaccess:
Code:
ErrorDocument 404 /404.php
404.php
PHP:
<?php
$config['email'] = '[email protected]';
$config['site_url'] = 'http://www.mysite.com';
$config['subject'] = 'Error: 404 on MySite.com';
function get_ip()
{
$ip = '';
if(isset($_SERVER['HTTP_X_FORWARDED_FOR']))
{
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
}
else
{
$ip = $_SERVER['REMOTE_ADDR'];
}
return $ip;
}
$time_stamp = date("l F j Y - g:i:s A");
$ip = get_ip();
$user_agent = $_SERVER['HTTP_USER_AGENT'];
$req_file = $_SERVER['REQUEST_URI'];
$ref_page = $_SERVER['HTTP_REFERER'];
$headers = 'MIME-Version: 1.0'."\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1'."\r\n";
$headers .= 'From: '.$config['email'];
@mail($config['email'], $config['subject'], "
<h1>Error - 404</h1>
<b>Date/Time: </b>$time_stamp
<b>User IP: </b>$ip
<b>User's browser: </b>$user_agent
<b>Requested page: </b>$req_file
<b>Referring URL: </b>$ref_page
", $headers);
?>
<html>
<head>
<title>404 Page Not Found</title>
</head>
<body>
<p>ย </p>
<p>ย </p>
<p>ย </p>
<table cellspacing="2" cellpadding="2" style="border: 1 dashed #000000" align="center">
<tr>
<td bgcolor="#FF0000"><i><h1><font color="#FFFFFF">404 - Page Not Found</font></h1></i></td>
</tr>
<tr>
<td><p><strong>Sorry, the page you have requested, <?php echo $req_file; ?>, does not exist on this server.</strong></p>
<p>You have most likely followed a broken link or mis-typed the URL. You can check the URL and try again.<br>
However, just in case this is an error on our part, an e-mail has been dispatched to the webmaster. <a href="<?php echo $config['site_url']; ?>">Return home</a>.</p>
<p>Thank you.</p></td>
</tr>
</table>
</body>
</html>






