Jump to content


Photo

Visitor logging script! problem HTTP_REFERRER


  • Please log in to reply
2 replies to this topic

#1 AbydosGater

AbydosGater
  • Members
  • PipPipPip
  • Advanced Member
  • 435 posts
  • LocationAlways at computer!

Posted 15 October 2006 - 09:51 PM

Hi, Im working on a script that logges all users to my site..

$date = date ("F d, Y GMT TIME??");
$ip = $_SERVER['REMOTE_ADDR'];
$referer = "User has come from " . $_SERVER['HTTP_REFERRER'];
$file = $_SERVER['PHP_SELF'];
$docRoot = $_SERVER['DOCUMENT_ROOT'];
$logFile = "logs/visitors.log";
$log = "[$date] [$ip] [$docRoot$file] [$referer] \n";
$fp = fopen($logFile, "a");
fputs($fp, $log);
fclose($fp);


Ok, and most of that works, except for one bit, when i open the file after a visitor, the $referer is empty, why is it not comming up? is it ment to have 2 'R's at the end? i tryed with one but no difference!

Oh and see for the GMT time, whats the format for GMT time?

I Would appriciate any help atall!

Thanks Abydos
www.abydosgaters.com

Current Project: Blog Application.. Undecided name.. Status: Coming along great.

#2 printf

printf
  • Staff Alumni
  • Advanced Member
  • 889 posts

Posted 16 October 2006 - 01:55 AM

$_SERVER['HTTP_REFERER'], will only be set if, (1) the browser allows it, (most users turn it off), and (2) the request came from another page, site, url of an already open browser window. In other words do not trust it, because it can be forged!


me!

#3 btherl

btherl
  • Staff Alumni
  • Advanced Member
  • 3,893 posts
  • LocationAustralia

Posted 16 October 2006 - 03:15 AM

It's $_SERVER["HTTP_REFERER"], with one R.  While it can be forged, most people don't bother.  It's perfectly fine for collecting statistics about visitors, but not useful for security.  My experience is that most users leave it on.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users