$log = 'contador.log'; $IP = getenv('REMOTE_ADDR'); $add = true; $hits = 0; $dia = date("d"); $mes = date("n"); $ano = date("Y"); $data="$dia-$mes-$ano"; $IP="$IP/$data"; if (!file_exists ($log)) { echo "Error: $log does not exist."; exit; } $h = fopen ($log, 'r'); while (!feof ($h)) { $line = fgets ($h, 4096); $line = trim ($line); if ($line != '') $hits++; if ($line == $IP) $add = false; } fclose($h); if ($add == true) { $h = fopen ($log, 'a'); fwrite($h, " $IP"); fclose($h); $hits++; } //echo $hits; ?>
|
||||||||||