genericnumber1 Posted September 13, 2006 Share Posted September 13, 2006 [b]What the script is supposed to do[/b]It's a custom error page (404) and it basically just logs the missing page, and some other information.I'm seeing this as perhaps being a server problem? It's been driving me crazy.[b]The Script[/b][code]<?php$pageref = $_SERVER['HTTP_REFERER']; // (Not REFERRER)$date = date("m/d/y");$error = "<b>404 ERROR - $pageref - $date</b><br>";$error .= "Username: " . htmlentities($_COOKIE['u']) . "<br>";$error .= "IP Address: " . $_SERVER['REMOTE_ADDR'] . "<br>";$error .= "User Agent: " . htmlentities($_SERVER['HTTP_USER_AGENT']) . "<br><br>";$handle = fopen("logs/zomgerrors.htm", "r+");fwrite($handle, $error);?>[/code][b]Display the missing page[/b][code]<?phpecho "(" . $pageref . ")";?>[/code][b]The Problem[/b][list][*]When I echo $pageref, it is always blank or "()"[*]When it writes to the log it always writes twice, one of them without the $pageref[/list][b]A Single Log Example[/b]404 ERROR - - 09/12/06Username: GenericIP Address: -edited-User Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.6) Gecko/20060728 Firefox/1.5.0.6404 ERROR - http://www.url.com/missingpage.php - 09/12/06Username: GenericIP Address: -edited-User Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.6) Gecko/20060728 Firefox/1.5.0.6 Quote Link to comment Share on other sites More sharing options...
btherl Posted September 13, 2006 Share Posted September 13, 2006 That is very odd. Your code looks fine. I'm pretty sure it's to do with the server, and your script is being called twice for each request. You might want your script do dump the contents of $_SERVER and see if there's clues in there (use $server_vars = print_r($_SERVER, true)) Quote Link to comment Share on other sites More sharing options...
genericnumber1 Posted September 13, 2006 Author Share Posted September 13, 2006 Well, when I dumped $_SERVER I didn't notice anything odd, the referer was there etc...Proposed diagnosis:Server is tweaking out.EDIT:I originally was testing the REFERER with a link on the 404.php page, I tried actually being redirected to the 404.php from "flakneflkanfe.php" (obviously it wasnt there) but the log still posted 404 ERROR - - 09/12/06Username: GenericIP Address: -edited-User Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.6) Gecko/20060728 Firefox/1.5.0.6404 ERROR - http://www.url.com/404.php - 09/12/06Username: GenericIP Address: -edited-User Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.6) Gecko/20060728 Firefox/1.5.0.6So do you think it's a good diagnosis that for some reason it doesn't get the referrer when it is redirected to 404.php by the .htaccess file and when it gets to 404.php it posts a value with a blank referrer, then for some reason the page reloads and posts that it was referred to by 404.php? Quote Link to comment Share on other sites More sharing options...
genericnumber1 Posted September 13, 2006 Author Share Posted September 13, 2006 I stripped out every little thing except for the bare minimum (in an attempt to pull out anything that would refresh the page) and now it is only posting one log, but it doesn't have the referrer in it...I'm not just being an idiot and assuming that if I visit "alkknfelakn.php" my browser will send that as the referrer to 404.php when that's not how it works am I?EDIT:Sorry, I'm tired and I just thought "Wait.... it's a header redirect so it's not gonna have the requested page, CRAP!" So yeah, now that I've sounded quite stupid I'd like to say thanks for helping me, I'll just use the referrer to see what page had the broken link in it.. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.