View file count/count.php

File size: 890B
<?php
$agent = htmlspecialchars(addslashes(str_replace('::','',$_SERVER['HTTP_USER_AGENT'])));
$addr = htmlspecialchars(addslashes(str_replace('::','',$_SERVER['REMOTE_ADDR'])));
$user = $agent.'::'.$addr;
$day = date('j');
if (file_get_contents('today.dat')!==$day) {
$f = @fopen('users.dat','w+');
@fwrite($f,$user);
@fclose($f);
$fp = @fopen('hits.dat','w');
@fwrite($fp,'1');
@fclose($fp);
$fr = @fopen('today.dat','w');
@fwrite($fr,$day);
@fclose($fr);
} else {
if (strstr(file_get_contents('users.dat'),$user)==false) {
$fp = @fopen('users.dat','a');
@fwrite($fp,file_get_contents('users.dat')."\r\n".$user);
@fclose($fp);
}
$hits = file_get_contents('hits.dat');
@$hits++;
$fr = @fopen('hits.dat','w');
@fwrite($fr,$hits);
@fclose($fr);
}
echo 'Хосты: '.count(file('users.dat')).'<br/>';
echo 'Хиты: '.file_get_contents('hits.dat').'<br/>';
?>