Hello everyone,
I recently have been trying to develop a php script that would record ips of people who have visited my site. The script needs to not only log the ips into a file, but I dont want it to log the ips more than once. For example, if 12.34.56.78 is in the file and someone with that ip goes to my site, it should not record it again.
Here is my script so far:
[code]<?php
$ip = getenv(‘REMOTE_ADDR’);
$message = “$ipn”;
$file123 = ‘log.txt’;
$pos = strpos($file123, ‘$ip’);
if ($pos === false) {
$Open = fopen($file123, “a”);
fwrite($Open, “$message”);
fclose ($Open);
} else {
break;
}[/code]
I really dont see whats wrong. It writes everything to the file fine, but it always returns the conditional statement as false (meaning it records the ips more than once.
If someone could help me figure this out, than that would be great. I also need a way to clear the file every 24 hours. If you know how to do that as well then it would be greatly appreciated.
Thanks,
~Thorlax402