View file wapus top english version/count.php

File size: 14.54Kb
<?php
//=============================
#Version WapuS_ToP_final
#Script By: Black1992
#Email: skyangel15@inbox.lv
#Icq: 414454754
#Url: http://WaPuS.pp.Ru
//=============================
error_reporting(0);
//---------------------------------------------------------------
if (file_exists("config.php")){include("config.php");}else{echo "Error!";}
if (file_exists("inc/config.inc.php")){include("inc/config.inc.php");}else{echo "Error!";}
if (file_exists("inc/functions.inc.php")){include("inc/functions.inc.php");}else{echo "Error!";}
//---------------------------------------------------------------
connect_to_db();
//---------------------------------------------------------------
if (empty($_GET['uid'])) exit;
$uid = (int) $_GET['uid'];
$result = mysql_query("SELECT link FROM users WHERE uid=$uid");
$row=mysql_fetch_row($result);
if (empty($row)) exit;
//---------------------------------------------------------------
$time_stamp = time ();
$day_time	= 24*60*60;
mysql_query("
	UPDATE `users`
	SET `date` = $time_stamp
	WHERE (`date` + $day_time) < $time_stamp AND `uid` = $uid
	LIMIT 1;
");
//---------------------------------------------------------------
$ip = $_SERVER['REMOTE_ADDR'];
$ua = $_SERVER['HTTP_USER_AGENT'];
//---------------------------------------------------------------
$browser  = explode("/",$ua);
$user_browser = (string)$browser[0];
//---------------------------------------------------------------
if (file_exists("mod_telinfo.php")){include("mod_telinfo.php");}else{echo "Error!";}
//---------------------------------------------------------------
if (file_exists("mod_operators.php")){include("mod_operators.php");}else{echo "Error!";}
//---------------------------------------------------------------
$hour = date("H");
$day = date("d");
$today = date("Ymd");
//---------------------------------------------------------------
$result = mysql_query("SELECT time FROM hits_time WHERE uid=$uid");
$row=mysql_fetch_row($result);
//---------------------------------------------------------------
if(empty($row)){
        @mysql_query("INSERT INTO hits_time VALUES ($uid,$today)");
        $reset_time = $today;
} else $reset_time = $row[0];
//---------------------------------------------------------------
if($today != $reset_time){
     @mysql_query("DELETE FROM hits_ip WHERE uid=$uid");
     @mysql_query("UPDATE hits_time SET time = $today WHERE uid=$uid");
}
//---------------------------------------------------------------
$result = mysql_query("SELECT count,host FROM count_24 WHERE hour=$hour AND date=$today AND uid=$uid");
$row=mysql_fetch_row($result);
//---------------------------------------------------------------
if (empty($row))
{
	$res = mysql_query("SELECT count(*) FROM count_24 WHERE uid=$uid");
	$data = mysql_fetch_row($res);
	$count_rows = $data[0];
	if ($count_rows >= 24) @mysql_query("DELETE FROM count_24 WHERE uid=$uid ORDER BY id ASC LIMIT 1;");
	@mysql_query("INSERT INTO count_24 VALUES ('',$uid,$today,$hour,0,0);");
	$hour_count = 0;
	$hour_host = 0;
}else
	{
		$hour_count = $row[0];
		$hour_host = $row[1];
	}
$hour_count++;

//---------------------------------------------------------------
$today = date("Ym");
//---------------------------------------------------------------
$result = mysql_query("SELECT count,host FROM months WHERE date=$today AND uid=$uid");
$row=mysql_fetch_row($result);
//---------------------------------------------------------------
if (empty($row))
{
	@mysql_query("INSERT INTO months VALUES ('',$uid,$today,0,0);");
	$this_month_count = 0;
	$this_month_host = 0;
}else{
		$this_month_count = $row[0];
		$this_month_host = $row[1];
	}
$this_month_count++;

//---------------------------------------------------------------
$week_day = date("w");
$today = date("Ymd");
//---------------------------------------------------------------
$result = mysql_query("SELECT next_mon FROM weeks WHERE uid=$uid ORDER BY id ASC LIMIT 1");
$row=mysql_fetch_row($result);
if (empty($row))
{
//---------------------------------------------------------------
    $dayNext =$week_day + 7;
    if ($dayNext > 7){
        $dayNext-=7;
    }
    $cntDay=8-$dayNext;
    $nextMonday=date("Ymd",mktime(0,0,0,date("m"),date("d")+$cntDay));

}
else $nextMonday = $row[0];
//---------------------------------------------------------------
if ($today >= $nextMonday)
{
//---------------------------------------------------------------
    $dayNext =$week_day + 7;
    if ($dayNext > 7){
        $dayNext-=7;
    }
    $cntDay=8-$dayNext;
    $nextMonday=date("Ymd",mktime(0,0,0,date("m"),date("d")+$cntDay));
//---------------------------------------------------------------
    @mysql_query("DELETE FROM `weeks` WHERE uid = $uid");
    @mysql_query("DELETE FROM `top_operators_stat` WHERE uid = $uid");
//---------------------------------------------------------------
    $time_stamp = time ();
    $week_time	= 7*24*60*60;
    $sql_result = mysql_query("
    	SELECT `uid` FROM `users`
    	WHERE ($time_stamp - `users`.`date`) > $week_time
    ");
    while ($result = mysql_fetch_assoc($sql_result))
    {
    	$del_uid = $result['uid'];
    	@mysql_query("DELETE FROM `users` WHERE uid = $del_uid");
    	@mysql_query("DELETE FROM `count_24` WHERE uid = $del_uid");
    	@mysql_query("DELETE FROM `hits_ip` WHERE uid = $del_uid");
    	@mysql_query("DELETE FROM `hits_time` WHERE uid = $del_uid");
    	@mysql_query("DELETE FROM `months` WHERE uid = $del_uid");
    	@mysql_query("DELETE FROM `online_ip` WHERE uid = $del_uid");
    	@mysql_query("DELETE FROM `top_operators_stat` WHERE uid = $del_uid");
    	@mysql_query("DELETE FROM `weeks` WHERE uid = $del_uid");
    }
}
//---------------------------------------------------------------
$result = mysql_query("SELECT count,host FROM weeks WHERE date=$today AND day_week=$week_day AND uid=$uid LIMIT 1");
$row=mysql_fetch_row($result);
if (empty($row))
{
//---------------------------------------------------------------
    $dayNext =$week_day + 7;
    if ($dayNext > 7)
    {
        $dayNext-=7;
    }
    $cntDay=8-$dayNext;
    $nextMonday=date("Ymd",mktime(0,0,0,date("m"),date("d")+$cntDay));
    				$razdel_data = mysql_query("SELECT razdel FROM users WHERE uid=$uid");
					$razdel_data_row = mysql_fetch_array($razdel_data);
					$razd = $razdel_data_row['razdel'];
    @mysql_query("INSERT INTO weeks VALUES ('',$uid,$razd,$nextMonday,$today,$week_day,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)");
    $week_day_count = 0;
    $week_day_host = 0;
} else{
		$week_day_count = $row[0];
		$week_day_host = $row[1];
	}
$week_day_count++;

//---------------------------------------------------------------
$result = mysql_query("SELECT `ip` FROM `hits_ip` WHERE (`ip`='$ip' AND `ua`='$ua') AND `uid`=$uid");
$row=mysql_fetch_row($result);
//---------------------------------------------------------------
if(empty($row))
{
//---------------------------------------------------------------
    $result = mysql_query("SELECT `ip` FROM `hits_ip` WHERE `uid`=$uid ORDER BY `time` DESC  LIMIT 1;");
	$row = mysql_fetch_array($result);
	if (empty($row) || ($row['ip'] != $ip))
	{
		$hour_host++;
		$week_day_host++;
		$this_month_host++;
		mysql_query("INSERT INTO `hits_ip` VALUES ($uid,'$ip','$ua',".time().")");
	}
}
//---------------------------------------------------------------
@mysql_query("UPDATE count_24 SET count=$hour_count,host=$hour_host WHERE hour=$hour AND date=$today AND uid=$uid");
@mysql_query("UPDATE weeks SET count=$week_day_count,host=$week_day_host WHERE date=$today AND day_week=$week_day AND uid=$uid LIMIT 1");
$today = date("Ym");
@mysql_query("UPDATE months SET count=$this_month_count,host=$this_month_host WHERE date=$today AND uid=$uid");
//---------------------------------------------------------------
$count_today = $week_day_count;
$host_today = $week_day_host;
//---------------------------------------------------------------
$today = date("Ymd");
$now=date("ymdHi");
//---------------------------------------------------------------
$del_time = date("ymdHi", mktime(date("H"), date("i")-$online_time));
@mysql_query("DELETE FROM `online_ip` WHERE `uid`=$uid AND `time` <= $del_time");
//---------------------------------------------------------------
$sql = "SELECT ip FROM online_ip WHERE ip='$ip' AND uid=$uid";
$result = mysql_query($sql);
$row=mysql_fetch_row($result);
//---------------------------------------------------------------
if(empty($row)){
    mysql_query("INSERT INTO online_ip VALUES ($uid,'$ip',$now,'$user_browser')");
}
//---------------------------------------------------------------
		$result = mysql_query("SELECT count(ip) FROM online_ip WHERE uid=$uid");
		$row=mysql_fetch_row($result);
		$online=(int)$row[0];
//---------------------------------------------------------------
		$today = date("Ymd");
		$hour = date("H");
		$result = mysql_query("SELECT sum(count) FROM count_24 WHERE ((date=$today-1 AND hour>$hour) OR (date=$today AND hour<=$hour)) AND uid=$uid");
		$row = mysql_fetch_row($result);
		$count_24 = (int)$row[0];
//---------------------------------------------------------------
		$result = mysql_query("SELECT sum(count) FROM months WHERE uid=$uid");
		$row=mysql_fetch_row($result);
		$all_count = (int)$row[0];
//---------------------------------------------------------------
$result = mysql_query("SELECT type FROM users WHERE uid=$uid");
$type=mysql_fetch_row($result);
$result = mysql_query("SELECT typeStat FROM users WHERE uid=$uid");
$typeStat=mysql_fetch_row($result);

$image=$type[0];
if($type[0]==2 or $type[0]==3 or $type[0]==4 or $type[0]==5){
        $image.=$typeStat[0];
}
$img = @imageCreateFromGIF("img/".$image.".gif");
$color = imagecolorallocate($img, 0,0,0);
$color2 = imagecolorallocate($img, 255,255,255);
//---------------------------------------------------------------
//средний
if($image==41)
	{
	//$x1 = (ImageSX($img) - 5*strlen("$count_today")-3);
	$x2 = (ImageSX($img) - 5*strlen("$host_today")-3);
	$x3 = (ImageSX($img) - 5*strlen("$count_today")-3);
	$y = 3;
	//imageString($img, 1, $x1, $y,"$count_today", $color);
	imageString($img, 1, $x2-35, $y+12,"$host_today", $color);
	imageString($img, 1, $x3+1, $y+12,"$count_today", $color2);
	}
	
//средний
if($image==42)
	{
	//$x1 = (ImageSX($img) - 5*strlen("$count_today")-3);
	$x2 = (ImageSX($img) - 5*strlen("$host_today")-3);
	$x3 = (ImageSX($img) - 5*strlen("$count_today")-3);
	$y = 3;
	//imageString($img, 1, $x1, $y,"$count_today", $color);
	imageString($img, 1, $x2-35, $y+12,"$host_today", $color);
	imageString($img, 1, $x3+1, $y+12,"$count_today", $color2);
	}
	
//средний
if($image==43)
	{
	//$x1 = (ImageSX($img) - 5*strlen("$count_today")-3);
	$x2 = (ImageSX($img) - 5*strlen("$host_today")-3);
	$x3 = (ImageSX($img) - 5*strlen("$count_today")-3);
	$y = 3;
	//imageString($img, 1, $x1, $y,"$count_today", $color);
	imageString($img, 1, $x2-35, $y+12,"$host_today", $color);
	imageString($img, 1, $x3+1, $y+12,"$count_today", $color2);
	}
	
//средний
if($image==44)
	{
	//$x1 = (ImageSX($img) - 5*strlen("$count_today")-3);
	$x2 = (ImageSX($img) - 5*strlen("$host_today")-3);
	$x3 = (ImageSX($img) - 5*strlen("$count_today")-3);
	$y = 3;
	//imageString($img, 1, $x1, $y,"$count_today", $color);
	imageString($img, 1, $x2-35, $y+12,"$host_today", $color);
	imageString($img, 1, $x3+1, $y+12,"$count_today", $color2);
	}
	
//средний
if($image==45)
	{
	//$x1 = (ImageSX($img) - 5*strlen("$count_today")-3);
	$x2 = (ImageSX($img) - 5*strlen("$host_today")-3);
	$x3 = (ImageSX($img) - 5*strlen("$count_today")-3);
	$y = 3;
	//imageString($img, 1, $x1, $y,"$count_today", $color);
	imageString($img, 1, $x2-35, $y+12,"$host_today", $color);
	imageString($img, 1, $x3+1, $y+12,"$count_today", $color2);
	}
############################################################

/* Вывод текста закрыт
//полный
if($image==51)
	{
	//$x1 = (ImageSX($img) - 5*strlen("$count_today")-3);
	$x2 = (ImageSX($img) - 5*strlen("$host_today")-3);
	$x3 = (ImageSX($img) - 5*strlen("$online")-3);
	$x4 = (ImageSX($img) - 5*strlen("$count_24")-3);
	$x5 = (ImageSX($img) - 5*strlen("$all_count")-3);
	$y = 3;
	//imageString($img, 1, $x1, $y,"$count_today", $color);
	imageString($img, 1, $x2+2, $y+12,"$host_today", $color2);
	imageString($img, 1, $x3+2, $y+19,"$online", $color2);
	imageString($img, 1, $x4+2, $y+26,"$count_24", $color2);
	imageString($img, 1, $x5+2, $y+33,"$all_count", $color2);
	}
	
//полный
if($image==52)
	{
	//$x1 = (ImageSX($img) - 5*strlen("$count_today")-3);
	$x2 = (ImageSX($img) - 5*strlen("$host_today")-3);
	$x3 = (ImageSX($img) - 5*strlen("$online")-3);
	$x4 = (ImageSX($img) - 5*strlen("$count_24")-3);
	$x5 = (ImageSX($img) - 5*strlen("$all_count")-3);
	$y = 3;
	//imageString($img, 1, $x1, $y,"$count_today", $color);
	imageString($img, 1, $x2+2, $y+12,"$host_today", $color2);
	imageString($img, 1, $x3+2, $y+19,"$online", $color2);
	imageString($img, 1, $x4+2, $y+26,"$count_24", $color2);
	imageString($img, 1, $x5+2, $y+33,"$all_count", $color2);
	}
	
//полный
if($image==53)
	{
	//$x1 = (ImageSX($img) - 5*strlen("$count_today")-3);
	$x2 = (ImageSX($img) - 5*strlen("$host_today")-3);
	$x3 = (ImageSX($img) - 5*strlen("$online")-3);
	$x4 = (ImageSX($img) - 5*strlen("$count_24")-3);
	$x5 = (ImageSX($img) - 5*strlen("$all_count")-3);
	$y = 3;
	//imageString($img, 1, $x1, $y,"$count_today", $color);
	imageString($img, 1, $x2+2, $y+12,"$host_today", $color2);
	imageString($img, 1, $x3+2, $y+19,"$online", $color2);
	imageString($img, 1, $x4+2, $y+26,"$count_24", $color2);
	imageString($img, 1, $x5+2, $y+33,"$all_count", $color2);
	}
	
//полный
if($image==54)
	{
	//$x1 = (ImageSX($img) - 5*strlen("$count_today")-3);
	$x2 = (ImageSX($img) - 5*strlen("$host_today")-3);
	$x3 = (ImageSX($img) - 5*strlen("$online")-3);
	$x4 = (ImageSX($img) - 5*strlen("$count_24")-3);
	$x5 = (ImageSX($img) - 5*strlen("$all_count")-3);
	$y = 3;
	//imageString($img, 1, $x1, $y,"$count_today", $color);
	imageString($img, 1, $x2+2, $y+12,"$host_today", $color2);
	imageString($img, 1, $x3+2, $y+19,"$online", $color2);
	imageString($img, 1, $x4+2, $y+26,"$count_24", $color2);
	imageString($img, 1, $x5+2, $y+33,"$all_count", $color2);
	}
	
//полный
if($image==55)
	{
	//$x1 = (ImageSX($img) - 5*strlen("$count_today")-3);
	$x2 = (ImageSX($img) - 5*strlen("$host_today")-3);
	$x3 = (ImageSX($img) - 5*strlen("$online")-3);
	$x4 = (ImageSX($img) - 5*strlen("$count_24")-3);
	$x5 = (ImageSX($img) - 5*strlen("$all_count")-3);
	$y = 3;
	//imageString($img, 1, $x1, $y,"$count_today", $color);
	imageString($img, 1, $x2+2, $y+12,"$host_today", $color2);
	imageString($img, 1, $x3+2, $y+19,"$online", $color2);
	imageString($img, 1, $x4+2, $y+26,"$count_24", $color2);
	imageString($img, 1, $x5+2, $y+33,"$all_count", $color2);
	}

*/
#############
//---------------------------------------------------------------
Header("Content-type: image/gif");
ImageGIF($img);
ImageDestroy($img);

?>