What i'm trying to do, is create a logfile on my site, where it logs peoples visits.
This works, however it creates an entry everytime the user refreshes the page, which I don't want it to do. I only want it to put an entry into my log.html file for that ip address once every half hour.
heres my php script I use for logging.
<?
$time = date("F jS Y, h:iA"); //using the date() function
$ip = $REMOTE_ADDR;
//$remote_addr is PHP variable to get ip address
$referer = $HTTP_REFERER;
//$http_referer is PHP variable to get referer
//OS Detection
$agent = $HTTP_USER_AGENT;
if ( strstr($agent, "Mac") ) $os = "Using Mac";
elseif ( strstr($agent, "Win98") ) $os = "Using Windows 98";
elseif ( strstr($agent, "WinME") ) $os = "Using Windows ME";
elseif ( strstr($agent, "Win95") ) $os = "Using Windows 95";
elseif ( strstr($agent, "NT 4") ) $os = "Using Windows NT";
elseif ( strstr($agent, "NT 5.0") ) $os = "Using Windows 2000";
elseif ( strstr($agent, "NT 5.1") ) $os = "Using Windows XP";
elseif ( strstr($agent, "Win") ) $os = "Using Windows";
elseif ( strstr($agent, "Linux") ) $os = "Using Linux";
else $os = "";
// Now the browser type
if ( strstr($agent, "MSIE 5") ) $browser = "using IE 5";
elseif ( strstr($agent, "MSIE 6") ) $browser = "using IE 6";
elseif ( strstr($agent, "MSIE 4") ) $browser = "using IE 4";
elseif ( strstr($agent, "Firebird") ) $browser = "using Firebird";
elseif ( strstr($agent, "Safari") ) $browser = "using Safari";
elseif ( strstr($agent, "Mozilla/5") ) $browser = "using Mozilla/Netscape 5";
elseif ( strstr($agent, "Mozilla/6") ) $browser = "using Netscape 6";
elseif ( strstr($agent, "Mozilla/4") ) $browser = "using Netscape 4";
elseif ( strstr($agent, "Opera") ) $browser = "using Opera";
else $browser = "";
$fp = fopen("log.html", "a");
//use the fopen() function
fputs($fp, "
<b>Time:</b> $time<br>
<b>IP:</b>$ip<br>
<b>Referer:</b> $referer<br>
<b>Browser:</b> $browser<br>
<b>Os:</b>$os<br>
<br>
");
//using the fputs() function
fclose($fp);
//closing the function
?>