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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to