Forum Moderators: coopster
I've done some custom 404 error messages, and this works fine, but I want to add some extra functionality to my script, too.
So, I implemented "the perfect 404" by A List Apart dot com and it works just fine, but this approach gives only the backlink where the 404 error page was triggered from by the presceding URL, so my mails I am getting from the script gives only the root link and not the link I want to know that was not correct.
So I am looking in what way I could pass some variable which contains the base url the user clicked on but since it does not exist the 404 page was triggered.
I was thinking on basename(), but am not sure is this the right way of doing it?
Err, it seems even to me that I wrote a bunch of nonsence, so I'll try this way:
My user type my base URL, www.something.com. The index.php page loads, and it contains a few linkd (link1.php, link2.php, link3.php). The links 1 and 2 exist and work fine, but if my user click on link3.php, a 404 error message comes in, and it says to user that the page link3.php does not exist and ask her kindly that she report this problem to the webmaster. Than (if she chooses to report the problem) a mail notification submits to my mailbox saying something like this:
Subject: "A problem occured at your website!"
Body: This problem came from: http://www.example.com/index.php
Link in question: http://www.example.com/404.php
Date reported: April 16th, 2007 Mon, 16 Apr 2007 18:17:20 +0200
Anyone?
[edited by: jatar_k at 4:59 pm (utc) on April 16, 2007]
[edit reason] please use example.com [/edit]
if(strpos($_SERVER['HTTP_REFERER'],$_SERVER['HTTP_HOST'])!== false) {
require_once "htmlMimeMail-2.5.2/htmlMimeMail.php";
$message = <<<EOT
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<p>Not found:<br>
{PAGE}</p>
<p>Referring page:<br>
{REFERER}</p>
</body>
</html>
EOT;$message = str_replace('{REFERER}',$_SERVER['HTTP_REFERER'],$message);
$message = str_replace('{PAGE}',$_SERVER['REDIRECT_URL'],$message);$emailer = new htmlMimeMail();
$emailer->setSMTPParams(null,null,null,true,$username,$userpass);
$emailer->setHtml($message);
$emailer->setFrom('webmaster@example.com');
$emailer->setHeader("Date",substr(gmdate("r",time()-25200),0,-5) . "-0700");
$emailer->setHeader("ReplyTo",'webmaster@example.com');
$emailer->setSubject('Error 404 at the site');
$emailer->setReturnPath('webmaster@example.com');
$result = $emailer->send(array('webmaster@example.com'),'smtp');
} // EndIf bad link from here