it seem to be slowing my board down. The SQL backend is quite fast.
thxPHP Code:mysql_connect('','','');
mysql_select_db('');
$mins = 60;
$time = time();
$ip = $_SERVER['REMOTE_ADDR'];
$user_agent = $_SERVER["HTTP_USER_AGENT"];
$referrer = @$_SERVER['HTTP_REFERER'];
$sql = "SELECT `time` FROM `log` WHERE `ip` = '$ip' ORDER BY `time` DESC LIMIT 1"; #check if the users IP is in the DB (and if so, grap that latest timestamp)
$results = mysql_query($sql);
if (mysql_num_rows($results) != 0) { #if a row was returned
$loggedtime = mysql_fetch_array($results);
$loggedtime = $loggedtime[0]; #set to the latest time the user was on the page
}
if ($loggedtime+$mins*60 < time()) { #in english: if (the last timestamp we have for this use + the desired number of minutes * 60 is less than the current time)
$sql = "INSERT INTO `log` (`id`, `time`, `ip`, `user_agent`, `referrer`)
VALUES ('', '$time', '$ip', '$user_agent', '$referrer')";
mysql_query($sql);
}


Reply With Quote
Bookmarks