<?
/*
Название: WebCodePHPCounter v. 1.5
Авторы: WebCode-Command
http://wcps.ru или http://webcode-command.org.ru
Техническая Поддержка WebCode-Command:
http://support.wcps.ru
*/
$data_file="./counter_data/data.txt";
$log_file="./counter_data/log.txt";
$OpenDATA=file("$data_file");
$a_counter=explode("::", $OpenDATA[0]);
$a_counter=str_replace("","\r\n", $a_counter);
$a_counter=str_replace("","\n", $a_counter);
$a_counter=str_replace("","\r", $a_counter);
$a=$a_counter[0];
$b=$a_counter[1];
$c=$a_counter[2];
$d=$a_counter[3];
$ip=getenv("REMOTE_ADDR");
if($ip==""){$ip=getenv("HTTP_X_FORWARDED_FOR");}
$dat= date('d.m.Y');
if($a!=$dat){
$a=$dat;
$b++;
$c="1";
$d="1";
$open=fopen($log_file,"w+");
fwrite($open,"$ip\r");
fclose($open);
}
else{
$non_ip="0";
$OpenLOG=fopen($log_file, "r");
$ips="$ip\r";
while (!feof($OpenLOG)){
$strings=fgets($OpenLOG);
if(eregi($ips,$strings)){$non_ip="1";}
}
fclose($OpenLOG);
$b++;
$c++;
if($non_ip=="0"){
$open=fopen($log_file,"a");
fwrite($open,"$ip\r");
fclose($open);
$d++;
}
}
$open=fopen($data_file,"w+");
fwrite($open,"$a::$b::$c::$d");
fclose($open);
$color=$QUERY_STRING;
if (strlen($b) == "1") { $b = " $b"; }
if (strlen($b) == "2") { $b = " $b"; }
if (strlen($b) == "3") { $b = " $b"; }
if (strlen($b) == "4") { $b = " $b"; }
if (strlen($b) == "5") { $b = " $b"; }
if (strlen($b) == "6") { $b = " $b"; }
if (strlen($b) == "7") { $b = " $b"; }
if (strlen($b) == "8") { $b = " $b"; }
if (strlen($c) == "1") { $c = " $c"; }
if (strlen($c) == "2") { $c = " $c"; }
if (strlen($c) == "3") { $c = " $c"; }
if (strlen($c) == "4") { $c = " $c"; }
if (strlen($c) == "5") { $c = " $c"; }
if (strlen($c) == "6") { $c = " $c"; }
if (strlen($c) == "7") { $c = " $c"; }
if (strlen($c) == "8") { $c = " $c"; }
if (strlen($d) == "1") { $d = " $d"; }
if (strlen($d) == "2") { $d = " $d"; }
if (strlen($d) == "3") { $d = " $d"; }
if (strlen($d) == "4") { $d = " $d"; }
if (strlen($d) == "5") { $d = " $d"; }
if (strlen($d) == "6") { $d = " $d"; }
if (strlen($d) == "7") { $d = " $d"; }
if (strlen($d) == "8") { $d = " $d"; }
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Content-Type:image/png");
$color_image = "./counter_data/$color.png";
$coin = imagecreatefrompng ($color_image);
$host_color = imagecolorallocate($coin,0,0,0);
ImageString($coin, 1, 38, 2, "$b", $host_color);
ImageString($coin, 1, 38, 12, "$c", $host_color);
ImageString($coin, 1, 38, 20, "$d", $host_color);
ImagePNG ($coin);
ImageDestroy ($coin);
?>