Error pages - send me info (read further for clarification)

dwd2000

Member
Messages
163
Reaction score
0
Points
16
Note: I'm a paying customer, so yes, I can edit my error pages.

Scenario:
Someone happens to land on an error page, for whatever reason. I would like the info automatically sent to me without the user knowing.

cPanel has the codes already available to insert into the error pages, but I would like to know what's happening. If someone is getting an error page by clicking a bad link, or a hacker trying to search for something and getting the error pages, I would like to know. I can check the e-mails to see if the same person is getting a lot of error pages, or just to fix a link.

I was thinking of incorporating a form into the page, and maybe using a "refresh"/"redirect" meta tag to get them to an html page with the same info as the original error page. As the page refreshes, the e-mail is being sent to me without the user knowing or having a chance to react or depending on him/her to actually click a "submit" button.

Any ideas???
 

marshian

New Member
Messages
526
Reaction score
9
Points
0
Well, you can use php code in your errorpage to send the mail automaticly when somebody sees the page. But php won't be able to determine it's a hacker or just a wrong link...
This would be an example of a 404 page:
PHP:
<?php
//The difference in time between you and the server. (in seconds)
$timezoneoffset = 0;
//Your emailadress
$yourmail = "you@host.com";
$requested = $_SERVER['HTTP_REFERRER'];
$ip = $_SERVER['REMOTE_ADDR'];
//Internet host name, gives some more info (isp and usually a hint of his location)
$ihn = gethostbyaddr($ip);
$time = time() + $timezoneoffset;
$date = date("Y-m-d at h:i", $time);
$mail = "<html><body>$ip ($ihn)<br>Requested the non-existing page <i>$requested</i>.<br>Time: $date<body></html>";
$headers = "From: 404 <{$_SERVER['SERVER_ADMIN']}>\r\n";
$headers .= "Content-type: text/html\r\n";
//@ makes it silent, no errors on failure
@mail($yourmail, "404 error", $mail, $headers);
?>
<html>
<head>
<title>404</title>
</head>
<body>
A HTTP 404 error has occured.
</body>
</html>
 

dwd2000

Member
Messages
163
Reaction score
0
Points
16
Well, you can use php code in your error page to send the mail automatically when somebody sees the page. But php won't be able to determine it's a hacker or just a wrong link...

I'm not worried about the code determining if it's a hacker. I can probably figure that out by the pages they are trying to get to and how many times they try.

Wouldn't I have to change the error pages to .php?

I'm using a nice form script that hides my e-mail address really well. ( Simple PHP Form Mailer http://www.onetforum.com/formmailer/) I'm hoping to find a way for a form to be sent automatically, without the "submit" button.

I will try your suggestion. Thanks.
 

marshian

New Member
Messages
526
Reaction score
9
Points
0
Yes, the syntax to do this with .htaccess files is: ErrorDocument statuscode file
example:
ErrorDocument 403 /err/403.php
 
Top