File size: 1.98Kb
<?php
########################################
## WAP-ENGINE ##
########################################
## ##
## Автор : CHUMA (Токарев Владимир) ##
## e-mail : [email protected] ##
## WAP : http://wap-engine.ru ##
## ##
########################################
## ВЫ НЕ ИМЕЕТЕ ПРАВО ##
## ИЗМЕНЯТЬ КОД СКРИПТА ##
## ДЛЯ ДАЛЬНЕЙШЕГО РАСПРОСТРАНЕНИЯ! ##
########################################
$ip = $_SERVER['REMOTE_ADDR'];
$date = date('d.m.Y', time() + ($sdvigclock*3600));
$data_ip = $dob_url.'/data/ip.txt';
$data_count = $dob_url.'/data/counter.txt';
$count_arr = file($data_count);
$d = trim($count_arr['0']);
$hosts = trim($count_arr['1']);
$hits = trim($count_arr['2']);
$total_hits = trim($count_arr['3']);
$total_hosts = trim($count_arr['4']);
if(empty($d))
{
$d = '01.01.2001';
}
if(empty($hosts))
{
$hosts = 0;
}
if(empty($hits))
{
$hits = 0;
}
if(empty($total_hosts))
{
$total_hosts = 0;
}
if(empty($total_hits))
{
$total_hits = 0;
}
if ($d != $date)
{
$d = $date;
$hits = 0;
$hosts = 0;
write_to_file($data_ip, '');
}
$ip_arr = file($data_ip);
$count_ip = count($ip_arr);
for($i = 0; $i <= $count_ip; $i++)
{
if(empty($ip_arr[$i]))
{
$ip_est = 0;
break;
}
if(trim($ip_arr[$i]) == $ip)
{
$ip_est = 1;
break;
}
else
{
$ip_est = 0;
}
}
if($ip_est == 0)
{
$file_ip = fopen($data_ip,'a');
flock($file_ip, LOCK_EX);
fputs($file_ip, $ip."\r\n");
fflush ($file_ip);
flock($file_ip, LOCK_UN);
fclose($file_ip);
$total_hosts++;
$total_hits++;
$hits++;
$hosts++;
}
else
{
$total_hits++;
$hits++;
}
write_to_file($data_count, $d."\r\n".$hosts."\r\n".$hits."\r\n".$total_hits."\r\n".$total_hosts);
echo 'Счетчик: '.$hosts.'|'.$hits.'<br />Всего: '.$total_hits.'<br />';
?>