Размер файла: 1.27Kb
<?php
if (trim(file_get_contents('cgf/count/glob_day.txt')) != date("d-m-Y"))
{
$fp = fopen ('cgf/count/glob_day.txt', "w+");
fwrite ($fp, date("d-m-Y"));
fclose ($fp);
$fp = fopen('cgf/count/host.txt', "w+");
flock($fp, LOCK_EX);
fwrite($fp, 1);
flock($fp, LOCK_UN);
fclose($fp);
$fp = fopen('cgf/count/hit.txt', "w+");
flock($fp, LOCK_EX);
fwrite($fp, 1);
flock($fp, LOCK_UN);
fclose($fp);
}
if ($_SESSION['posetitel'] == '')
{
$count = file_get_contents('cgf/count/host.txt');
$count++;
$fp = fopen('cgf/count/host.txt', "w+");
flock($fp, LOCK_EX);
fwrite($fp, $count);
flock($fp, LOCK_UN);
fclose($fp);
$count = file_get_contents('cgf/count/host_glob.txt');
$count++;
$fp = fopen('cgf/count/host_glob.txt', "w+");
flock($fp, LOCK_EX);
fwrite($fp, $count);
flock($fp, LOCK_UN);
fclose($fp);
$_SESSION['posetitel'] = '1';
}
// считаем обращения к сайту
{
$count = file_get_contents('cgf/count/hit.txt');
$count++;
$fp = fopen('cgf/count/hit.txt', "w+");
flock($fp, LOCK_EX);
fwrite($fp, $count);
flock($fp, LOCK_UN);
fclose($fp);
{
$count = file_get_contents('cgf/count/hit_glob.txt');
$count++;
$fp = fopen('cgf/count/hit_glob.txt', "w+");
flock($fp, LOCK_EX);
fwrite($fp, $count);
flock($fp, LOCK_UN);
fclose($fp);
}
}
?>