Hi there guys,
I'm tracking http requests, and everything seems to be working dandy. In an effort to save space, I've set it to update a hitcounter on an IP if found, instead of writing a new table entry each time.
Regardless, this file is going to get big QUICK 😃, so I need to find a way to keep it at a manageable size, like 500 entries maybe.
What's the best way to go about this? I figure I need to do the pruning at the same time as an entry, so at 500, it seems like it will remove one every time it adds one, so maybe the command needs to be integrated into that portion of the script?
/* If it's 0, then we're seeing this bot for the first time. */
if ($habitual == 0) {
$tmestamp = time();
/* Append bad bot address data to blacklist database. */
$sql = "INSERT INTO ".$zapprefix."tracker (id, hits, remote_addr, date, request_method, request_uri, server_protocol, http_referer, http_user_agent) VALUES ('NULL', '1', '$REMOTE_ADDR', '$tmestamp', '$REQUEST_METHOD', '$REQUEST_URI', '$SERVER_PROTOCOL', '$HTTP_REFERER', '$HTTP_USER_AGENT')";
$result = mysql_query($sql) or die('MySQL error: ' . mysql_error() . '<hr/>' . $sql);
}else{
any suggestions would be greatly appreciated.
thanks,
json