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

Размер файла: 9.34Kb
<?php
Error_Reporting(E_ALL & ~E_NOTICE);
Error_Reporting (ERROR | WARNING);
function myErrorHandler ($errno, $errstr, $errfile, $errline) {}
set_error_handler("myErrorHandler");
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 = ImageCreateFromPNG('error.png');
$color = ImagecolorAllocate($imer,255,228,181); 
Imagestring($imer,1,1,12,"",$color);
Imagestring($imer,1,1,20,"",$color);
Imagestring($imer,1,1,28,"",$color);
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'];
$ips = $sqlar['ip1'];
$cin =$sqlar['cin'];
$out =$sqlar['out'];
$allin =$sqlar['allin'];
$allout =$sqlar['allout'];
$date=date('Y-m-d',time());

if($date!=$sqlar['date'])
{
	$query = @mysql_query("SELECT `id`,`yesterday`,`bef1yes`,`bef2yes`,`today`,`counthost`,`1host`,`2host`,`3host`,`ip1`,`ip2`,`ip3`,`ip4`,`cin`,`out`,`allin`,`allout` FROM `users` WHERE 1;");
	while($updata = @mysql_fetch_array($query)) {
	@mysql_query("update `users` set `date`='".$date."',`ip1`='',`ip2`='',`ip3`='',`ip4`='',`today`=0,`counthost`=0,`yesterday`=".$updata['today'].",`bef1yes`=".$updata['yesterday'].",`bef2yes`=".$updata['bef1yes'].",`1host`=".$updata['counthost'].",`2host`=".$updata['1host'].",`3host`=".$updata['2host'].",`cin`=0,`out`=0 where `id`=".$updata['id'].";");
}
$count=0;
$counthost=0;
$cin=0;
$out=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 = 63;
if ($count >= 10 && $count < 100)
$pos = 58;
if ($count >= 100 && $count < 1000)
$pos = 53;
if ($count >= 1000 && $count < 10000)
$pos = 48;
if ($count >= 10000 && $count < 100000)
$pos = 43;
if ($count >= 100000 && $count < 1000000)
$pos = 38;
if ($count >= 1000000 && $count < 10000000)
$pos = 33;
if ($count >= 10000000 && $count < 100000000)
$pos = 28;
if ($count >= 100000000 && $count < 1000000000)
$pos = 23;
if ($count >= 1000000000 && $count < 10000000000)
$pos = 18;

if ($counthost >= 0 && $counthost < 10)
$pos_host = 63;
if ($counthost >= 10 && $counthost < 100)
$pos_host = 58;
if ($counthost >= 100 && $counthost < 1000)
$pos_host = 53;
if ($counthost >= 1000 && $counthost < 10000)
$pos_host = 48;
if ($counthost >= 10000 && $counthost < 100000)
$pos_host = 43;
if ($counthost >= 100000 && $counthost < 1000000)
$pos_host = 38;
if ($counthost >= 1000000 && $counthost < 10000000)
$pos_host = 33;
if ($counthost >= 10000000 && $counthost < 100000000)
$pos_host = 28;
if ($counthost >= 100000000 && $counthost < 1000000000)
$pos_host = 23;
if ($counthost >= 1000000000 && $counthost < 10000000000)
$pos_host = 18;

if ($count_all >= 0 && $count_all < 10)
$pos_all = 0;
if ($count_all >= 10 && $count_all < 100)
$pos_all = 0;
if ($count_all >= 100 && $count_all < 1000)
$pos_all = 0;
if ($count_all >= 1000 && $count_all < 10000)
$pos_all = 0;
if ($count_all >= 10000 && $count_all < 100000)
$pos_all = 0;
if ($count_all >= 100000 && $count_all < 1000000)
$pos_all = 0;
if ($count_all >= 1000000 && $count_all < 10000000)
$pos_all = 0;
if ($count_all >= 10000000 && $count_all < 100000000)
$pos_all = 0;
if ($count_all >= 100000000 && $count_all < 1000000000)
$pos_all = 0;
if ($count_all >= 1000000000 && $count_all < 10000000000)
$pos_all = 0;


$im = ImageCreateFromPNG('cimg.png');
$black = ImagecolorAllocate($im,255,255,0); 
$black2 = ImagecolorAllocate($im,255,0,0);
Imagestring($im,1,$pos_host+17,12,$counthost,$black2);
Imagestring($im,1,$pos+17,20,$count,$black2);
Imagestring($im,2,$pos_all+4,16,$count_all,$black);
Imagestring($im,1,1,33,"",$black);
Imagestring($im,1,1,20,"",$black2);
Imagestring($im,1,1,28,"",$black3);
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 '1':
if ($count >= 0 && $count < 10)
$pos = 63;
if ($count >= 10 && $count < 100)
$pos = 58;
if ($count >= 100 && $count < 1000)
$pos = 53;
if ($count >= 1000 && $count < 10000)
$pos = 48;
if ($count >= 10000 && $count < 100000)
$pos = 43;
if ($count >= 100000 && $count < 1000000)
$pos = 38;
if ($count >= 1000000 && $count < 10000000)
$pos = 33;
if ($count >= 10000000 && $count < 100000000)
$pos = 28;
if ($count >= 100000000 && $count < 1000000000)
$pos = 23;
if ($count >= 1000000000 && $count < 10000000000)
$pos = 18;

if ($counthost >= 0 && $counthost < 10)
$pos_host = 0;
if ($counthost >= 10 && $counthost < 100)
$pos_host = 0;
if ($counthost >= 100 && $counthost < 1000)
$pos_host = 0;
if ($counthost >= 1000 && $counthost < 10000)
$pos_host = 0;
if ($counthost >= 10000 && $counthost < 100000)
$pos_host = 0;
if ($counthost >= 100000 && $counthost < 1000000)
$pos_host = 0;
if ($counthost >= 1000000 && $counthost < 10000000)
$pos_host = 0;
if ($counthost >= 10000000 && $counthost < 100000000)
$pos_host = 0;
if ($counthost >= 100000000 && $counthost < 1000000000)
$pos_host = 0;
if ($counthost >= 1000000000 && $counthost < 10000000000)
$pos_host = 0;

if ($count_all >= 0 && $count_all < 10)
$pos_all = 63;
if ($count_all >= 10 && $count_all < 100)
$pos_all = 58;
if ($count_all >= 100 && $count_all < 1000)
$pos_all = 53;
if ($count_all >= 1000 && $count_all < 10000)
$pos_all = 48;
if ($count_all >= 10000 && $count_all < 100000)
$pos_all = 43;
if ($count_all >= 100000 && $count_all < 1000000)
$pos_all = 38;
if ($count_all >= 1000000 && $count_all < 10000000)
$pos_all = 33;
if ($count_all >= 10000000 && $count_all < 100000000)
$pos_all = 28;
if ($count_all >= 100000000 && $count_all < 1000000000)
$pos_all = 23;
if ($count_all >= 1000000000 && $count_all < 10000000000)
$pos_all = 18;




$im = ImageCreateFromPNG('cimg2.png');
$black = ImagecolorAllocate($im,255,255,0); 
$black2 = ImagecolorAllocate($im,51,0,255); 
Imagestring($im,1,$pos_host+4,14,$counthost,$black);
Imagestring($im,1,$pos+17,14,$count,$black2);
Imagestring($im,1,$pos_all+100,300,$count_all,$black);
Imagestring($im,1,1,12,"",$black);
Imagestring($im,1,1,20,"",$black);
Imagestring($im,1,1,28,"",$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;

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 = ImageCreateFromPNG('cimg3.png');
$black = ImagecolorAllocate($im,255,0,0); 
Imagestring($im,1,$pos_host+100,200,$counthost,$black);
Imagestring($im,1,$pos+100,90,$count,$black);
Imagestring($im,2,$pos_all+16,8,$count_all,$black);
Imagestring($im,1,1,12,"",$black);
Imagestring($im,1,1,20,"",$black);
Imagestring($im,1,1,28,"",$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);
?>