<?include'cfg.inc.php';error_reporting(0);//Все хиты
$base=file($hit_data);$cnt=$base[0]+1;$ft=fopen($hit_data,'w');flock($ft,2);fputs($ft,"$cnt");flock($ft,3);fclose($ft);//Что,где,когда
$date=date('d-m-Y',time());$a_date=file($date_data);//Реффереры
if(isset($jreferer)&&!ereg("$url",$jreferer)&&!ereg("$url_",$jreferer)):$refs=file($refferer_data);$d=count($refs);for($i=0;$i<$d;$i++){list($refferer,$ref_cnt)=explode('::',"$refs[$i]");if($refferer!=''&&$ref_cnt!=''):if($jreferer==$refferer):$new_ref_cnt=$ref_cnt+1;$puts[]="$jreferer::$new_ref_cnt::::\r\n";else:$puts[]="$refferer::$ref_cnt::::\r\n";endif;endif}if(!isset($new_ref_cnt)){$new_ref_cnt=1}if(isset($puts)):foreach($puts as$i=>$str){if($str=="$jreferer::$new_ref_cnt::::\r\n"){$ok=$i;break;}}foreach($puts as$j=>$str){if($ok==$j){$puts[$ok]="$jreferer::$new_ref_cnt::::\r\n"; break;}}endif;$fr=fopen($refferer_data,'w');flock($fr,2);if(isset($puts)):foreach($puts as$put){fputs($fr,$put)}else:fputs($fr,"$jreferer::1::::\r\n");endif;flock($fr,3);fclose($fr);endif;//Браузеры
if(isset($HTTP_USER_AGENT)):switch(true){case(eregi('msie',$HTTP_USER_AGENT)):$browser_='Internet Explorer';break;case(eregi('opera',$HTTP_USER_AGENT)):$browser_='Opera';break;case(eregi('netscape',$HTTP_USER_AGENT)):$browser_='Netscape';break;default:$browser_='Другой';break}$brows=file($browser_data);$d=count($brows);for($n=0;$n<$d;$n++){list($browser,$br_cnt)=explode('::',"$brows[$n]");if($browser!=''&&$br_cnt!=''):if($browser_==$browser):$new_br_cnt=$br_cnt+1;$bputs[]="$browser_::$new_br_cnt::::\r\n";else:$bputs[]="$browser::$br_cnt::::\r\n";endif;endif}if(!isset($new_br_cnt)){$new_br_cnt=1}if(isset($bputs)):foreach($bputs as$m=>$str){if($str=="$browser_::$new_br_cnt::::\r\n"){$ok_=$m;break;}}foreach($bputs as$k=>$str){if($ok_==$k){$bputs[$ok_]="$browser_::$new_br_cnt::::\r\n";break;}}endif;$fr=fopen($browser_data,'w');flock($fr,2);if(isset($bputs)):foreach($bputs as$put){fputs($fr,$put)}else:fputs($fr,"$browser_::1::::\r\n");endif;flock($fr,3);fclose($fr);endif;//Операционные системы
if(isset($HTTP_USER_AGENT)):switch(true){case(eregi('win',$HTTP_USER_AGENT)):$jos='Windows';break;case(eregi('linux',$HTTP_USER_AGENT)):$jos='Linux';break;case(eregi('mac',$HTTP_USER_AGENT)):$jos='Mac';break;default:$jos='Другая';break}$aos=file($os_data);$s=count($aos);for($n=0;$n<$s;$n++){list($os,$os_cnt)=explode('::',"$aos[$n]");if($os!=''&&$os_cnt!=''):if($jos==$os):$new_os_cnt=$os_cnt+1;$osputs[]="$jos::$new_os_cnt::::\r\n";else:$osputs[]="$os::$os_cnt::::\r\n";endif;endif}if(!isset($new_os_cnt)){$new_os_cnt=1}if(isset($osputs)):foreach($osputs as$o=>$str){if($str=="$jos::$new_os_cnt::::\r\n"){$ok_=$o;break;}}foreach($osputs as$oo=>$str){if($ok_==$oo){$osputs[$ok_]="$jos::$new_os_cnt::::\r\n";break;}}endif;$fr=fopen($os_data,'w');flock($fr,2);if(isset($osputs)):foreach($osputs as$put){fputs($fr,$put)}else:fputs($fr,"$jos::1::::\r\n");endif;flock($fr,3);fclose($fr);endif;//Языки
if(isset($HTTP_ACCEPT_LANGUAGE)):switch(true){case(ereg('ru',$HTTP_ACCEPT_LANGUAGE)):$what_lang='Русский';break;case(ereg('en',$HTTP_ACCEPT_LANGUAGE)):$what_lang='Английский';break;default:$what_lang='Другой';break}$langs=file($lang_data);$ll=count($langs);for($l=0;$l<$ll;$l++){list($lang_,$lang_cnt)=explode('::',"$langs[$l]");if($lang_!=''&&$lang_cnt!=''):if($what_lang==$lang_):$new_lang_cnt=$lang_cnt+1;$lputs[]="$what_lang::$new_lang_cnt::::\r\n";else:$lputs[]="$lang_::$lang_cnt::::\r\n";endif;endif}if(!isset($new_lang_cnt)){$new_lang_cnt=1}if(isset($lputs)):foreach($lputs as$la=>$str){if($str=="$what_lang::$new_lang_cnt::::\r\n"){$o_k=$la;break;}}foreach($lputs as$lu=>$str){if($o_k==$lu){$lputs[$o_k]="$what_lang::$new_lang_cnt::::\r\n";break;}}endif;$fr=fopen($lang_data,'w');flock($fr,2);if(isset($lputs)):foreach($lputs as$lput){fputs($fr,$lput)}else:fputs($fr,"$what_lang::1::::\r\n");endif;flock($fr,3);fclose($fr);endif;//JavaScript
if(isset($js)):$js_array=file($js_data);foreach($js_array as$i=>$javas){list($java,$jscnt)=explode('::',$javas);$temp[$java]=$jscnt;}if($js=='on'){$temp['on']++}if($js=='off'){$temp['off']++}$fj=fopen($js_data,'w');flock($fj,2);foreach($temp as$c=>$put){fputs($fj,"$c::$put::::\r\n")}flock($fj,3);fclose($fj);endif;if($a_date[0]==$date)://Сегодняшние хосты
$fu=fopen($daylog_data,'a');flock($fu,2);fputs($fu,"$REMOTE_ADDR\r\n");flock($fu,3);fclose($fu);elseif($a_date[0]!=$date)://Хосты всего
$daylog_array=file($daylog_data);$host_yesterday=count(array_unique($daylog_array));$host_array=file($host_data);$temp=$host_yesterday+$host_array[0];$fe=fopen($host_data,'w');flock($fe,2);fputs($fe,$temp);flock($fe,3);fclose($fe);//Начало daylog.dat сегодня
$fu=fopen($daylog_data,'w');flock($fu,2);fputs($fu,"$REMOTE_ADDR\r\n");flock($fu,3);fclose($fu);//Какое число сегодня?
$fd=fopen($date_data,'w');flock($fd,2);fputs($fd,$date);flock($fd,3);fclose($fd);endif?>