Hello,
I\'m trying to create an IP address logging stats script.
What I want to do is print out a report of the ip addresses that visited my website and how many times that ip address visited it.
here is what i\'m trying to work on
<?
$var_addr = getenv(\"REMOTE_ADDR\");
$addrFile = addr.log\";
// write current ip address
if (\"$var_addr\" != \"$ip_array\") {
// write the new ip address
$file=fopen(\"$addrFile\", \"w\")) {
flock($file, 2);
fputs($file, \"1|$addr\n\");
flock($file, 3);
fclose($file);
} elseif (\"$var_addr\" == \"$ip_array\") {
// increment the ip address
$file=fopen(\"$addrFile\", \"a\")) {
flock($file, 2);
flock($file, 3);
fclose($file);
} else {
echo(\"Error handling log file.\");
}
?>
yea its a bit confusing right now, but here\'s what i want to do, and i neeed help writing the code..
I want to create a log file, of ip addresses that visited my site.
If the current visitor ip matches an ip address already in the file, it will increment the count,
eg
2|xxx.xxx.xxx.xxx
if its not there, it will add it to the flat text file.
I need help doing this, checking if the two ip address match and incrementing the count.
my email is bmwguy71@hotmail.com.
I need all the help i can get.
I\'m guessing i would need to create a do or for loop to check each ip address individualy and run it through if/else
i know this takes a long time to do the check, but i need it.
Thanks