Snarl, hiss, growl (frustration)
| From: | Kyle Babich | Date: | Fri, 04 Jul 2003 14:33:25 +0000 |
| Subject: | Snarl, hiss, growl (frustration) | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-153996@lists.php.net to get a copy of this message | ||
Why does this not work? It is just a simple hit counter (hence the
snarls, hissing, and growling). It logs the ips address but does not
increment $current or log it. I do have counter.txt and ips.txt chmod'd
to 777. Ips.txt starts blank and counter.txt starts with just a 0 in it.
<?php $counter = fopen('counter.txt', 'r');
$current = fread($counter, filesize('counter.txt'));
fclose($counter);
$ip = getenv('REMOTE_ADDR');
$ipCheck = file('ips.txt');
if (!in_array($ip, $ipCheck)) {
$ipAdd = fopen('ips.txt', 'a');
fwrite($ipAdd, "\n$ip");
fclose($ipAdd);
$current++;
$counter = fopen('counter.txt', 'w');
fwrite($counter, $current);
fclose($counter);
}
print $current; ?>
--
Kyle