View file top/count.php

File size: 8.65Kb
<?php




include 'config2.php';
$link=mysql_connect ($DB_HOST, $DB_USER, $DB_PASS);
mysql_select_db($DB_NAME);

$qu = @mysql_query("SELECT * FROM `users` WHERE id='".$id."' limit 1;");
if(mysql_affected_rows()==0)
{
$imer = ImageCreateFromGIF('error.gif');
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");
ImagePng($imer);
} else {

//cleaning up:)
$sqlar  = @mysql_fetch_array($qu);
$count = $sqlar['today'];
$count_all = $sqlar['allday'];
$counthost = $sqlar['counthost'];




$hourdiff = "9";
$timeadjust = ($hourdiff * 60 * 60); 
 



$date=date('Y-m-d',time() + $timeadjust);

if($date!=$sqlar['date'])
{
	$query = @mysql_query("SELECT `id`,`yesterday`,`bef1yes`,`bef2yes`,`today`,`counthost`,`1host`,`2host`,`3host`,`ip1`,`ip2`,`ip3`,`ip4` FROM `users` WHERE 1;");
	while($updata = @mysql_fetch_array($query)) {
	@mysql_query("update `users` set `date`='".$date."',`ip1`='',`ip2`='',`ip3`='',`ip4`='',`today`=0,`cin`=0,`out`=0,`counthost`=0,`yesterday`=".$updata['today'].",`bef1yes`=".$updata['yesterday'].",`bef2yes`=".$updata['bef1yes'].",`1host`=".$updata['counthost'].",`2host`=".$updata['1host'].",`3host`=".$updata['2host']." where `id`=".$updata['id'].";");
}
$count=0;
$counthost=0;
}
//end of cleaning

//count hosts
global $REMOTE_ADDR;
global $HTTP_USER_AGENT;

$cip = $_SERVER['REMOTE_ADDR'];
      if(($sqlar['ip1'] != $cip)&&($sqlar['ip2'] != $cip)&&($sqlar['ip3'] != $cip)&&($sqlar['ip4'] != $cip)) {
         ++$counthost;
         @mysql_query("update `users` set `counthost`=`counthost`+'1',`ip4`=`ip3`,`ip3`=`ip2`,`ip2`=`ip1`,`ip1`='".$cip."' where `id`='".$id."';");
      }
$counthost = $sqlar['counthost'];
//end hosts

@mysql_query("UPDATE `users` SET `today`=`today`+'1',`allday`=`allday`+'1' WHERE id='".$id."';");
++$count;
++$count_all;

switch($img) {
default:
if ($count >= 0 && $count < 10)
$pos = 61;
if ($count >= 10 && $count < 100)
$pos = 56;
if ($count >= 100 && $count < 1000)
$pos = 51;
if ($count >= 1000 && $count < 10000)
$pos = 46;
if ($count >= 10000 && $count < 100000)
$pos = 41;
if ($count >= 100000 && $count < 1000000)
$pos = 36;
if ($count >= 1000000 && $count < 10000000)
$pos = 31;
if ($count >= 10000000 && $count < 100000000)
$pos = 26;
if ($count >= 100000000 && $count < 1000000000)
$pos = 21;
if ($count >= 1000000000 && $count < 10000000000)
$pos = 16;

if ($counthost >= 0 && $counthost < 10)
$pos_host = 61;
if ($counthost >= 10 && $counthost < 100)
$pos_host = 56;
if ($counthost >= 100 && $counthost < 1000)
$pos_host = 51;
if ($counthost >= 1000 && $counthost < 10000)
$pos_host = 46;
if ($counthost >= 10000 && $counthost < 100000)
$pos_host = 41;
if ($counthost >= 100000 && $counthost < 1000000)
$pos_host = 36;
if ($counthost >= 1000000 && $counthost < 10000000)
$pos_host = 31;
if ($counthost >= 10000000 && $counthost < 100000000)
$pos_host = 26;
if ($counthost >= 100000000 && $counthost < 1000000000)
$pos_host = 21;
if ($counthost >= 1000000000 && $counthost < 10000000000)
$pos_host = 16;

if ($count_all >= 0 && $count_all < 10)
$pos_all = 61;
if ($count_all >= 10 && $count_all < 100)
$pos_all = 56;
if ($count_all >= 100 && $count_all < 1000)
$pos_all = 51;
if ($count_all >= 1000 && $count_all < 10000)
$pos_all = 46;
if ($count_all >= 10000 && $count_all < 100000)
$pos_all = 41;
if ($count_all >= 100000 && $count_all < 1000000)
$pos_all = 36;
if ($count_all >= 1000000 && $count_all < 10000000)
$pos_all = 31;
if ($count_all >= 10000000 && $count_all < 100000000)
$pos_all = 26;
if ($count_all >= 100000000 && $count_all < 1000000000)
$pos_all = 21;
if ($count_all >= 1000000000 && $count_all < 10000000000)
$pos_all = 16;

$im = ImageCreateFromGIF('cimg.gif');
$green = ImagecolorAllocate($im,0,0,0); 
Imagestring($im,1,$pos_host,3,$counthost,$green);
Imagestring($im,1,$pos,11,$count,$green);
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");
ImagePng($im);
break;

case 'wab':
if ($count >= 0 && $count < 10)
$pos = 61;
if ($count >= 10 && $count < 100)
$pos = 56;
if ($count >= 100 && $count < 1000)
$pos = 51;
if ($count >= 1000 && $count < 10000)
$pos = 46;
if ($count >= 10000 && $count < 100000)
$pos = 41;
if ($count >= 100000 && $count < 1000000)
$pos = 36;
if ($count >= 1000000 && $count < 10000000)
$pos = 31;
if ($count >= 10000000 && $count < 100000000)
$pos = 26;
if ($count >= 100000000 && $count < 1000000000)
$pos = 21;
if ($count >= 1000000000 && $count < 10000000000)
$pos = 16;

if ($counthost >= 0 && $counthost < 10)
$pos_host = 61;
if ($counthost >= 10 && $counthost < 100)
$pos_host = 56;
if ($counthost >= 100 && $counthost < 1000)
$pos_host = 51;
if ($counthost >= 1000 && $counthost < 10000)
$pos_host = 46;
if ($counthost >= 10000 && $counthost < 100000)
$pos_host = 41;
if ($counthost >= 100000 && $counthost < 1000000)
$pos_host = 36;
if ($counthost >= 1000000 && $counthost < 10000000)
$pos_host = 31;
if ($counthost >= 10000000 && $counthost < 100000000)
$pos_host = 26;
if ($counthost >= 100000000 && $counthost < 1000000000)
$pos_host = 21;
if ($counthost >= 1000000000 && $counthost < 10000000000)
$pos_host = 16;

if ($count_all >= 0 && $count_all < 10)
$pos_all = 61;
if ($count_all >= 10 && $count_all < 100)
$pos_all = 56;
if ($count_all >= 100 && $count_all < 1000)
$pos_all = 51;
if ($count_all >= 1000 && $count_all < 10000)
$pos_all = 46;
if ($count_all >= 10000 && $count_all < 100000)
$pos_all = 41;
if ($count_all >= 100000 && $count_all < 1000000)
$pos_all = 36;
if ($count_all >= 1000000 && $count_all < 10000000)
$pos_all = 31;
if ($count_all >= 10000000 && $count_all < 100000000)
$pos_all = 26;
if ($count_all >= 100000000 && $count_all < 1000000000)
$pos_all = 21;
if ($count_all >= 1000000000 && $count_all < 10000000000)
$pos_all = 16;

$im = ImageCreateFromGIF('cimg2.gif');
$green = ImagecolorAllocate($im,0,0,0); 
Imagestring($im,1,$pos_host,3,$counthost,$green);
Imagestring($im,1,$pos,10,$count,$green);
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");
ImagePng($im);
break;

case '2':
if ($count >= 0 && $count < 10)
$pos = 61;
if ($count >= 10 && $count < 100)
$pos = 56;
if ($count >= 100 && $count < 1000)
$pos = 51;
if ($count >= 1000 && $count < 10000)
$pos = 46;
if ($count >= 10000 && $count < 100000)
$pos = 41;
if ($count >= 100000 && $count < 1000000)
$pos = 36;
if ($count >= 1000000 && $count < 10000000)
$pos = 31;
if ($count >= 10000000 && $count < 100000000)
$pos = 26;
if ($count >= 100000000 && $count < 1000000000)
$pos = 21;
if ($count >= 1000000000 && $count < 10000000000)
$pos = 16;

if ($counthost >= 0 && $counthost < 10)
$pos_host = 61;
if ($counthost >= 10 && $counthost < 100)
$pos_host = 56;
if ($counthost >= 100 && $counthost < 1000)
$pos_host = 51;
if ($counthost >= 1000 && $counthost < 10000)
$pos_host = 46;
if ($counthost >= 10000 && $counthost < 100000)
$pos_host = 41;
if ($counthost >= 100000 && $counthost < 1000000)
$pos_host = 36;
if ($counthost >= 1000000 && $counthost < 10000000)
$pos_host = 31;
if ($counthost >= 10000000 && $counthost < 100000000)
$pos_host = 26;
if ($counthost >= 100000000 && $counthost < 1000000000)
$pos_host = 21;
if ($counthost >= 1000000000 && $counthost < 10000000000)
$pos_host = 16;

if ($count_all >= 0 && $count_all < 10)
$pos_all = 61;
if ($count_all >= 10 && $count_all < 100)
$pos_all = 56;
if ($count_all >= 100 && $count_all < 1000)
$pos_all = 51;
if ($count_all >= 1000 && $count_all < 10000)
$pos_all = 46;
if ($count_all >= 10000 && $count_all < 100000)
$pos_all = 41;
if ($count_all >= 100000 && $count_all < 1000000)
$pos_all = 36;
if ($count_all >= 1000000 && $count_all < 10000000)
$pos_all = 31;
if ($count_all >= 10000000 && $count_all < 100000000)
$pos_all = 26;
if ($count_all >= 100000000 && $count_all < 1000000000)
$pos_all = 21;
if ($count_all >= 1000000000 && $count_all < 10000000000)
$pos_all = 16;

$im = ImageCreateFromGIF('cimg3.gif');
$black = ImagecolorAllocate($im,0,0,0); 
Imagestring($im,3,$pos_host,0,$counthost,$black);
Imagestring($im,3,$pos_all,9,$count_all,$black);
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");
ImagePng($im);
break;
}
}
mysql_close($link);
?>