Hi all
I’m using the following php code in my custom 404 page with a notification sent to my email with the error and requested page or file that was missing.
here is the code:
[code=php]
<?php
$emailaddress = “[email protected]”;
putenv(‘TZ=EST5EDT’); // eastern time
$errortime = (date(” F d h:ia”));
$browser = $_SERVER[‘HTTP_USER_AGENT’];
$domain = $_SERVER[‘HTTP_HOST’];
$page = $_SERVER[‘REQUEST_URI’];
$referer = $_SERVER[‘HTTP_REFERER’];
$IP = $_SERVER[‘REMOTE_ADDR’];
$message = “”;
$message .= “Time of the error: $errortimenn”;
$message .= “browser: $browsernn”;
$message .= “Page Requested: $domain$pagenn”;
$message .= “Referer: $referernn”;
$message .= “IP Address: $IPnn”;
$name = gethostbyaddr($IP);
$message .= “Hostname: $namenn”;
mail($emailaddress, “404 Error” , $message, “From: Website <>”);
?>
<html>
<head>
<title>404 – where oh where?</title>
<style type=”text/css”>
<!–
A:link {text-decoration: none; font-weight:bold; color: blue}
A:active {text-decoration: none; font-weight:bold; color: blue}
A:visited {text-decoration: none; font-weight:bold; color: blue}
A:hover {text-decoration: none; font-weight:bold; color: red}
.style1 {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
}
.style2 {
font-size: 30px;
font-weight: bold;
font-family: Arial, Helvetica, sans-serif;
}
–>
</style>
</head>
<body>
<table align=left width=100% border=0>
<tr>
<td>
<span class=”style2″>Not Found.<br>
<br>
</span>
<span class=”style1″>(oops)
<br>
<br>
it appears you were looking for:<br>
<FONT COLOR=teal>
<?=$domain?>
<?=$page?>
</font>
<br>
<br>
however, since you are here, it is clear you did not get what you wanted.
<br>
<br>
the problem has been reported so any broken links can be found and repaired.
<br>
<br>
you can click <a href=”javascript:history.go(-1)”>here</a> to go back to your previous page.<br>
<br>
</span>
<hr>
<span class=”style1″></span></td>
</tr></table>
</body>
</html>
It works great accept I keep get this in an email:
[CODE]
Time of the error: September 24 11:40am
browser: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7) Gecko/20040707 Firefox/0.9.2
Page Requested: mydomainname.com/favicon.ico
Referer:
IP Address: 80.800.8.800
Hostname: host80-800-8-800.range80-800.btcentralplus.com
this is the bit that gets to me: favicon.ico
I’m not using a favicon.ico so why is it saying the site is trying to find it?
if know one knows then how do I tell the script to ignore “favicon.ico” and not to send me the email.
also….how do I change the date in the script to be “GMT” time instead of “eastern time” ?
Cheers
Chris