Вход Регистрация
Файл: image.php
Строк: 107
<?php
//header('Location: http://c.waplog.net/ru/5944.cnt');
error_reporting(0);
//===========================================//
define("ROOTPATH", getcwd());
include(
ROOTPATH."/includes/config");
//===========================================//
$data = $_SERVER['QUERY_STRING'];
list(
$id, $size) = explode(',', $data);
$id = intval($id);
// ===========================================//
$sql = mysql_query('SELECT `hosts`, `hits`, `image` FROM `'.USERS.'` WHERE `id` = '.$id.' AND `status` IN("user", "vip");');

    if(
mysql_num_rows($sql) > 0)
    {
    list(
$hosts, $hits, $real_image) = mysql_fetch_row($sql);
    if(
$real_image < 1 || $real_image > 18) $real_image = 1;
if(
stripos($_SERVER['HTTP_USER_AGENT'], 'windows') !== false)
{
header("Content-type: image/gif");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-cache, must-relative");

if(
$size == 'small')
{
echo 
file_get_contents(ROOTPATH."/images/".$real_image."_small.gif");
die();
}
else
{
$len_hits = 70 - (strlen($hits) * 5);
$len_hosts = 35 - (strlen($hosts) * 5);

$image = imagecreatefromgif(ROOTPATH."/images/".$real_image."_normal.gif");

$black = imagecolorallocate($image, 255, 255, 255);
$white = imagecolorallocate($image, 255, 255, 255);

imageString($image, 1, $len_hits, 13, $hits, $black);
imageString($image, 1, $len_hosts, 13, $hosts, $white);
imagegif($image);
imagedestroy($image);

die();

}

}
    
    
//GET Xfip
    
$xfip = sprintf("%u", ip2long(getenv('HTTP_X_FORWARDED_FOR')));
    if(!
is_numeric($xfip)) $xfip = '';

    
//USER-AGENT
    
$ua = substr(strtok(getenv('HTTP_USER_AGENT'), '/'), 0, 16);
    
$ua = htmlspecialchars(mysql_escape_string($ua), ENT_QUOTES);
    
//END USER_AGENT;

    //OPERATOR
    
$sql = mysql_query("SELECT `oid` FROM `".IP_BASE."` WHERE INET_ATON('".getenv('REMOTE_ADDR')."') BETWEEN `start` AND `finish`;") or die(mysql_error());

        if(
mysql_num_rows($sql) > 0)
        {
        
$operator = mysql_result($sql, 0);
        }
        else
        {
        
$operator = 1;
        }
//if(stripos($_SERVER['HTTP_USER_AGENT'], 'asd') !== false) { header( Location: $image; die(); }
    //BRAND
    
if(strpos($ua, "SonyEricsson") !== false) $brand = 2;
    elseif(
strpos($ua, "Nokia") !== false) $brand = 3;
    elseif((
strpos($ua, "SAMSUNG") !== false) || (strpos($ua, "Samsung") !== false) || (strpos($ua, "SGH-") !== false)) $brand = 4;
    elseif(
strpos($ua, "SIE") !== false) $brand = 5;
    elseif(
strpos($ua, "MOT") !== false) $brand = 6;
    elseif(
strpos($ua, "LG") !== false) $brand = 7;
    elseif(
strpos($ua, "SAGEM") !== false) $brand = 8;
    elseif(
strpos($ua, "Opera") !== false) $brand = 9;
    elseif(
strpos($ua, "Panasonic") !== false) $brand = 10;
    elseif(
strpos($ua, "FLY") !== false) $brand = 11;
    elseif(
strpos($ua, "SHARP") !== false) $brand = 12;
    elseif(
strpos($ua, "PHILIPS") !== false) $brand = 13;
    elseif(
strpos($ua, "Alcatel") !== false) $brand = 14;
    elseif((
strpos($ua, "Mozilla") !== false) || (strpos($ua, "MSIE") !== false) || (strpos($ua, "Netscape") !== false)) $brand = 15;
    else 
$brand = 1;
    
//END BRAND;

        
do
        {
        
$sql = mysql_query("SELECT SUM(`count`) FROM `".SHOWS."` WHERE `user_id` = ".$id." AND `ip` = INET_ATON('".getenv('REMOTE_ADDR')."') AND `date` > (".time()." - 10);");
        
$count = mysql_result($sql, 0);

        if(
$count > 5) break;

        
$sql = mysql_query("SELECT * FROM `".SHOWS."` WHERE `user_id` = ".$id." AND `ip` = INET_ATON('".getenv('REMOTE_ADDR')."') AND `user-agent` = '".$ua."' AND `date` > (".time()." - 4);");

            if(
mysql_num_rows($sql) > 0)
            {
            break;
            }
            else
            {
            
$is_hit = true;
            
$hits++;
            }

        
//HOSTS
        
$sql = mysql_query("SELECT * FROM `".SHOWS."` WHERE (`user_id` = ".$id." AND `ip` = INET_ATON('".getenv('REMOTE_ADDR')."') AND `date` > (".time()." - 300)) OR (`user_id` = ".$id." AND `ip` = INET_ATON('".getenv('REMOTE_ADDR')."') AND `user-agent` = '".$ua."' AND `date` > (".time()." - 1800));");

            if(
mysql_num_rows($sql) < 1)
            {
            
$sql = mysql_query("INSERT INTO `".SHOWS."` SET `user_id` = ".$id.", `count` = 1, `date` = ".time().", `user-agent` = '".$ua."', `brand` = ".$brand.", `ip` = INET_ATON('".getenv('REMOTE_ADDR')."'), `xfip` = '".$xfip."', `operator` = ".$operator.";");
            
$sql = mysql_query("UPDATE `".USERS."` SET `hosts` = (`hosts` + 1), `hits` = (`hits` + 1), `month_hosts` = (`month_hosts` + 1), `month_hits` = (`month_hits` + 1), `all_hosts` = (`all_hosts` + 1), `all_hits` = (`all_hits` + 1) WHERE `id` = ".$id.";");
            
$is_host = true;
            
$hosts++;
            }
            elseif(
$is_hit)
            {
            
$sql = mysql_query("UPDATE `".SHOWS."` SET `date` = ".time().", `count` = (`count` + 1) WHERE `user_id` = ".$id." AND `ip` = INET_ATON('".getenv('REMOTE_ADDR')."') AND `user-agent` = '".$ua."' AND `date` > (".time()." - 1800) LIMIT 1;");
            
$sql = mysql_query("UPDATE `".USERS."` SET `hits` = (`hits` + 1), `month_hits` = (`month_hits` + 1), `all_hits` = (`all_hits` + 1) WHERE `id` = ".$id.";");
            }
            else
            {
            break;
            }
        }
        while(
true === false);

        
//ONLINE SERVICE
        
if($is_host || $is_hit)
        {
        
$sql = mysql_query("SELECT * FROM `".ONLINE."` WHERE `user_id` = ".$id." AND `ip` = INET_ATON('".getenv('REMOTE_ADDR')."') AND `user-agent` = '".$ua."';");

            if(
mysql_num_rows($sql) > 0)
            {
            
$sql = mysql_query("UPDATE `".ONLINE."` SET `date` = ".time()." WHERE `user_id` = ".$id." AND `ip` = INET_ATON('".getenv('REMOTE_ADDR')."') AND `user-agent` = '".$ua."';");
            }
            else
            {
            
$sql = mysql_query("INSERT INTO `".ONLINE."` SET `user_id` = ".$id.", `date` = ".time().", `user-agent` = '".$ua."', `ip` = INET_ATON('".getenv('REMOTE_ADDR')."');");
            }
        }
        
//END ONLINE;
    
}
    else
    {
    
header('Location: https://'.$_SERVER['HTTP_HOST'].'/images/default.gif', true, 301);
    exit;
    }
    
    if(
$size == 'small')
    {
    
$image = imagecreatefromgif(ROOTPATH."/images/".$real_image."_small.gif");
    }
    else
    {
    
$len_hits = 70 - (strlen($hits) * 5);
    
$len_hosts = 35 - (strlen($hosts) * 5);

    
$image = imagecreatefromgif(ROOTPATH."/images/".$real_image."_normal.gif");

    
$black = imagecolorallocate($image, 255, 255, 255);
    
$white = imagecolorallocate($image, 255, 255, 255);

    
imageString($image, 1, $len_hits, 14, $hits, $black);
    
imageString($image, 1, $len_hosts, 14, $hosts, $white);
    }
    
        if(
$size == 'bn')
    {
    
$image = imagecreatefromgif(ROOTPATH."/images/banner.gif");
    }

header("Content-type: image/gif");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-cache, must-relative");
imagegif($image);
imagedestroy($image);
exit;
?>
Онлайн: 2
Реклама