Просмотр файла rating/count.php

Размер файла: 4.01Kb
<?php
include "config.php";
$qu = @mysql_query("SELECT `id`,`date`,`countdays` FROM `rate` 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 `rate` set `date`='$date',`today`=0,`countdays`='$countdays' where 1;");
$count=0;
}
//////////////////////////////////////////////
$q = @mysql_query("SELECT `today`,`allday` FROM `rate` WHERE id='".$id."';");
$sqlid = @mysql_fetch_array($q);
//////////////////////////////////////////////
$count = $sqlid['today'];
$count_all = $sqlid['allday'];
/*$host = $sqlid['host'];
///////////////////////
$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 `rate` SET `today`=$count,`allday`=$count_all,`host`='$host',`counthost`='$chost' WHERE id=$id;");
/////////////////////////////////////////////////
/*if ($chost >= 0 && $chost < 10)
$hpos = 59;
if ($chost >= 10 && $chost < 100)
$hpos = 54;
if ($chost >= 100 && $chost < 1000)
$hpos = 49;
if ($chost >= 1000 && $chost < 10000)
$hpos = 44;
if ($chost >= 10000 && $chost < 100000)
$hpos = 39;
if ($chost >= 100000 && $chost < 1000000)
$hpos = 34;
if ($chost >= 1000000 && $chost < 10000000)
$hpos = 29;
if ($chost >= 10000000 && $chost < 100000000)
$hpos = 24;
if ($chost >= 100000000 && $chost < 1000000000)
$hpos = 19;
if ($chost >= 1000000000 && $chost < 10000000000)
$hpos = 14;
if ($chost >= 10000000000 && $chost < 100000000000)
$hpos = 9;*/
/////////////////////////////////////////////////
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;
///////////////////////////////////////////////
switch($img) {
case 'mini':
$im = @imagecreate(70, 14);
$background_color = imagecolorallocate($im, 0, 0, 0);
$text_color = imagecolorallocate($im, 255, 255, 255);
ImageString($im, 1, 3, 3, "+$count", $text_color);
ImageString($im, 1, 49, 3, "Mobilka.Us", $text_color);
header("Content-type: image/png");
ImagePNG($im);
break;
default:
$im = ImageCreateFromGIF('counter.gif');
$black = ImageColorAllocate($im,100,50,170); 
/*ImageString($im,1,$hpos,9,$chost,$black);*/
ImageString($im,1,$pos,14,$count,$black);
ImageString($im,1,$pos_all,21,$count_all,$black);
header("Content-type: image/png");
ImagePNG($im);
break;
}
}
else
{
print "ID = ???";
}
?>