Hello! Anyone with a few moments to spare? Thing is that i got a snippet that log my visitors, but its getting bigger and bigger and I want to set up a limit for it. I want it be no more than 30 posts/rows, and it should remove the oldest log if visitor 31 comes to the site.. here's what it looks like today: function logfile () { global $link_url; global $config; if ($config['log'] == 1) { $fp = fopen ('log/logfile.txt', 'a'); fwrite ($fp, 'IP of User: ' . $_SERVER['REMOTE_ADDR'] . ' - Referrer: ' . $_SERVER['HTTP_REFERER'] . ' - User Agent: ' . $_SERVER['HTTP_USER_AGENT'] . ' '); fclose ($fp); } } PHP: Regards
I have no good answer to that. I suppose I could do that, keep the access logs. But just to explain what I was looking for.. The code above logs any user, even if it's visitor 29, 30, 31, 55. What I want is to loop when it reaches 30 log posts.
before appending the log to the file, you might wanna add severeal things 1. check if has 30 logs 2. remove the first log, so only have 29 logs left. 3. add the log after the last line.