Просмотр файла top/c.php

Размер файла: 4.37Kb
<?php
header("Content-type: image/gif");
$dbh=mysql_connect ("localhost", "amletco_nofx", "nofx")
or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("amletco_top");
$qu = @mysql_query("SELECT `id`,`date`,`all` FROM `top` WHERE id='".$id."';");
$sqlar  = @mysql_fetch_array($qu);
$date=date("Y-m-d",time());
//////////////////////////////////////////////
if(!empty($id) && $id==$sqlar['id'])
{
if($date!=$sqlar['date'])
{
$countdays = $sqlar['countdays'] + 1;
@mysql_query("update `top` set `date`='$date',`today`=0,`countdays`='$countdays' where 1;");
$count=0;
}
//////////////////////////////////////////////
$q = @mysql_query("SELECT `today`,`all`, `tops` FROM `top` WHERE id='".$id."';");
$sqlid = @mysql_fetch_array($q);
//////////////////////////////////////////////
$count = $sqlid['today'];
$count_all = $sqlid['all'];
$tops = $sqlid['tops'];
$H1=date("H",time())+1;
$i=date("i",time());
$time="$H1:$i";
$cdays = $sqlid['days'] + 1;
///////////////////////
$cagent = getenv("HTTP_USER_AGENT");
if (getenv("HTTP_X_FORWARDED_FOR"))
	$ip = getenv("HTTP_X_FORWARDED_FOR");
else
	$ip = getenv("REMOTE_ADDR");
$nhost = "[".$ip."]~".$cagent;
$hosts = @explode("([[x]])",$host);
if(!@in_array($nhost,$hosts)) $host .= "([[x]])".$nhost;
$hosts = @explode("([[x]])",$host);
$chost = count($hosts)-1;
$count++;
$count_all++;
@mysql_query("UPDATE `top` SET `today`=$count,`all`=$count_all WHERE id=$id;");



if ($time >= "24:00" && $time < "24:01")
@mysql_query("update `top` set `today`='0', `cin`='0', `out`='0', `days`='$cdays' where `id`>'0';");
/////////////////////////////////////////////////
if ($count >= 0 && $count < 10)
$pos = 64;
if ($count >= 10 && $count < 100)
$pos = 59;
if ($count >= 100 && $count < 1000)
$pos = 54;
if ($count >= 1000 && $count < 10000)
$pos = 49;
if ($count >= 10000 && $count < 100000)
$pos = 44;
if ($count >= 100000 && $count < 1000000)
$pos = 39;
if ($count >= 1000000 && $count < 10000000)
$pos = 34;
if ($count >= 10000000 && $count < 100000000)
$pos = 29;
if ($count >= 100000000 && $count < 1000000000)
$pos = 24;
if ($count >= 1000000000 && $count < 10000000000)
$pos = 19;
if ($count >= 10000000000 && $count < 100000000000)
$pos = 14;
/////////////////////////////////////////////////
if ($count_all >= 0 && $count_all < 10)
$pos_all = 64;
if ($count_all >= 10 && $count_all < 100)
$pos_all = 59;
if ($count_all >= 100 && $count_all < 1000)
$pos_all = 54;
if ($count_all >= 1000 && $count_all < 10000)
$pos_all = 49;
if ($count_all >= 10000 && $count_all < 100000)
$pos_all = 44;
if ($count_all >= 100000 && $count_all < 1000000)
$pos_all = 39;
if ($count_all >= 1000000 && $count_all < 10000000)
$pos_all = 34;
if ($count_all >= 10000000 && $count_all < 100000000)
$pos_all = 29;
if ($count_all >= 100000000 && $count_all < 1000000000)
$pos_all = 24;
if ($count_all >= 1000000000 && $count_all < 10000000000)
$pos_all = 19;
if ($count_all >= 10000000000 && $count_all < 100000000000)
$pos_all = 14;
///////////////////////////////////////////////
/////////////////////////////////////////////////
if ($tops >= 0 && $tops < 10)
$top = 64;
if ($tops >= 10 && $tops < 100)
$top = 59;
if ($tops >= 100 && $tops < 1000)
$top = 54;
if ($tops >= 1000 && $tops < 10000)
$top = 49;
if ($tops >= 10000 && $tops < 100000)
$top = 44;
if ($tops >= 100000 && $tops < 1000000)
$top = 39;
if ($tops >= 1000000 && $tops < 10000000)
$top = 34;
if ($tops >= 10000000 && $tops < 100000000)
$top = 29;
if ($tops >= 100000000 && $tops < 1000000000)
$top = 24;
if ($tops >= 1000000000 && $tops < 10000000000)
$top = 19;
if ($tops >= 10000000000 && $tops < 100000000000)
$top = 14;
$im = @ImageCreateFromGIF("counter.gif");
$background_color = imagecolorallocate($im, 0, 0, 0);
$text_color = imagecolorallocate($im, 255, 255, 250);
ImageString($im, 1, $top, 10, "$tops", $text_color);
ImageString($im, 1, $pos, 17, "$count", $text_color);
ImageString($im, 1, $pos_all, 24, "$count_all", $text_color);
ImageGIF($im);
}
else
{$im = @ImageCreateFromGIF("error.gif");
$background_color = imagecolorallocate($im, 0, 0, 0);
$text_color = imagecolorallocate($im, 255, 255, 250);
ImageString($im, 1, $top, 10, "$tops", $text_color);
ImageString($im, 1, $pos, 17, "$count", $text_color);
ImageString($im, 1, $pos_all, 24, "$count_all", $text_color);
ImageGIF($im);}
?>