The best way to do the same thing as above is to just use your server log. An apache log can be parsed using a file like this, to do the exact same thing:
<form enctype="multipart/form-data" method="post" action="<?php echo($_SERVER["PHP_SELF"]); ?>">
<input type="file" name="log">
<input type="submit" name="submit">
</form>
<?php
$iparray = array();
if (isset($_POST["submit"])) {
$fp = fopen($_FILES["log"]["tmp_name"],"rb");
$content = fread($fp,filesize($_FILES["log"]["tmp_name"]));
fclose($fp);
$contentarray = split("\n",$content);
for ($i=0;$i<count($contentarray);$i++) {
$linearray = split(" ",$contentarray[$i]);
$ip = $linearray[0];
if (!in_array($ip,$iparray)) {
$iparray[] = $ip;
}
}
for ($i=0;$i<count($iparray);$i++) {
echo($iparray[$i]."<br>\n");
}
echo("A total of ".count($iparray)." unique hits to your page.");
}
?>
You upload your log file to it and it tells you all the unique IPs. At the bottom of the page, it tells you how many unique hits you had. If you have a crapload of hits (several million or so) in your log, it will probably max out PHP. BTW, this is verrrry slow, as it goes through every line of the file.
This is what I use, if I ever want to know how many unique hits I got that day.
A word to the wise: make sure you only use a log-file for one day! It doesn't check the date.