Вход Регистрация
Файл: images/count.php
Строк: 140
<?php
error_reporting
(0);
Session_Name('SESID');
Session_Start();

function 
referer($q)
 {
    
$q=explode('.',strtok(preg_replace('/([a-z0-9]+://)?(wap.|www.)?/s','',strtolower(htmlspecialchars($q)),'/')));
    unset(
$q[count($q)-1]);
    return 
trim(implode($q,'.'));
 }

if(isset(
$_GET['id']))
 {
    include_once 
'../sistem/function.php';
    include_once 
'../sistem/config.php';
    include_once 
'../sistem/db.php';
    
$id=((int)abs($_GET['id']));
    
$time=time();
    
$data=date('Ymd');

    if(!empty(
$_SERVER['HTTP_REFERER']))
     {
        
$count_referer=explode('/',strtolower(strtok(preg_replace('/([a-z0-9]+://)?(wap.|www.)?/is','',htmlspecialchars($_SERVER['HTTP_REFERER'])),'?')));
        unset(
$count_referer[0]);
        
$count_referer=implode($count_referer,'/');
     }
     else
        
$count_referer=NULL;

    
$_ip=ip2long($_SERVER['REMOTE_ADDR']);
    if(!isset(
$_SERVER['HTTP_X_FORWARDED_FOR']) OR $count_ip=ip2long($_SERVER['HTTP_X_FORWARDED_FOR'])==0)
        if(!isset(
$_SERVER['HTTP_VIA']) OR $count_ip=ip2long($_SERVER['HTTP_VIA'])==0)
            if(!isset(
$_SERVER['HTTP_CLIENT_IP']) OR $count_ip=ip2long($_SERVER['HTTP_CLIENT_IP'])==0)
                if(!isset(
$_COOKIE['CLIENT_IP']) OR $count_ip=ip2long($_COOKIE['CLIENT_IP'])==0)
                    
SetCookie('CLIENT_IP',$_SERVER['REMOTE_ADDR'],time()+60*60*24);

    
$IP_SQL='`ip`=''.$_ip.'' or `via`=''.$_ip.''';
    if(
$count_ip!=0)
        
$IP_SQL.=' or `ip`=''.$count_ip.'' or `via`=''.$count_ip.''';
     else
        
$count_ip=$_ip;

    if(!empty(
$_SERVER['HTTP_X_OPERAMINI_PHONE_UA']))
        
$ua=$_SERVER['HTTP_X_OPERAMINI_PHONE_UA'];
     else
        
$ua=$_SERVER['HTTP_USER_AGENT'];
    
$ua=strtolower($us_ag=mysql_real_escape_string(filtr($ua)));
    
$us_ag=trim(substr(strtok(strtok($us_ag,'('),' '),0,22));

    if(
strpos($ua,'sonyericsson')!==false$brand 2;
    elseif(
strpos($ua,'panasonic')!==false$brand 10;
    elseif(
strpos($ua,'philips')!==false$brand 13;
    elseif(
strpos($ua,'alcatel')!==false$brand 14;
    elseif((
strpos($ua,'samsung')!==false) || (strpos($ua,'sgh-') !== false)) $brand 4;
    elseif((
strpos($ua,'mozilla')!==false) || (strpos($ua'msie') !== false) || (strpos($ua'netscape')!==false)) $brand 15;
    elseif(
strpos($ua,'sharp')!==false$brand 12;
    elseif(
strpos($ua,'sagem')!==false$brand 8;
    elseif(
strpos($ua,'opera')!==false$brand 9;
    elseif(
strpos($ua,'nokia')!==false$brand 3;
    elseif(
strpos($ua,'sie')!==false$brand 5;
    elseif(
strpos($ua,'mot')!==false$brand 6;
    elseif(
strpos($ua,'fly')!==false$brand 11;
    elseif(
strpos($ua,'lg')!==false$brand 7;
    else 
$brand=1;

    if(
mysql_num_rows($sql=mysql_query('SELECT * FROM `site` WHERE `id`=''.$id.'' LIMIT 1;'))>=1)
     {
        
$arr=mysql_fetch_assoc($sql);
        
$host=$arr['host'];
        
$hit=$arr['hit'];
        if((empty(
$_SERVER['HTTP_REFERER']) or referer($arr['url'])==referer($_SERVER['HTTP_REFERER'])) and mysql_num_rows(mysql_query('SELECT * FROM `ban_ip` WHERE `ip`=''.$_ip.'''.($_ip==$count_ip?'':' or `ip`=''.$count_ip.''').' LIMIT 1;'))==0)
         {
            if(
mysql_num_rows($sql=mysql_query('SELECT * FROM `statistic` WHERE `for`=''.$id.'' and ('.$IP_SQL.') LIMIT 1;'))>=1)
             {
                
$array=mysql_fetch_assoc($sql);
                if(
$array['time']<$time)
                    
mysql_unbuffered_query('UPDATE `statistic` SET `phone`=''.$brand.'',`hit`=(`hit`+1),`referer`=''.mysql_real_escape_string($count_referer).'',`time`=''.$time.'',`brauser`=''.$us_ag.'' WHERE `ip`=''.$array['ip'].'' and `via`=''.$array['via'].'' and `for`=''.$id.'' LIMIT 1;');
                if(
$array['time']+60>$time)
                 {
                    if(
$array['ip']!=$_ip or $array['via']!=$count_ip)
                     {
                        
mysql_unbuffered_query('insert into `ban_ip` set `id`=''.$id.'',`ip`=''.$_ip.'';');
                        if(
$_ip!=$count_ip)
                            
mysql_unbuffered_query('insert into `ban_ip` set `id`=''.$id.'',`ip`=''.$count_ip.'';');
                     }
                 }
             }
             else
                 {
                    include_once 
'../sistem/ip_isset.class.php';
                    
$class=NEW ISSET_IP;
                    
$class->long_ip($count_ip);
                    
$operator=$class->operator();
                    
$country=$class->country();
                    if(
$operator==and $count_ip!=$_ip)
                     {
                        
$class->long_ip($_ip);
                        
$operator=$class->operator();
                        
$country=$class->country();
                     }
                    
mysql_unbuffered_query('insert into `statistic` set `country`=''.$country.'',`phone`=''.$brand.'',`via`=''.$count_ip.'',`operator`=''.$operator.'',`for`=''.$id.'',`ip`=''.$_ip.'',`hit`='1',`referer`=''.mysql_real_escape_string($count_referer).'',`data`=''.$data.'',`time`=''.$time.'',`brauser`=''.$us_ag.'';');
                 }
            
$host=mysql_result($sql=mysql_query('SELECT COUNT(*),SUM(`hit`) FROM `statistic` WHERE `for`=''.$id.'';'),0,0);
            
$hit=mysql_result($sql,0,1);
            
mysql_unbuffered_query('UPDATE `site` SET `hit`=''.$hit.'',`host`=''.$host.'''.($host<=1?',`data`=''.$data.''':'').' WHERE `id`=''.$id.'' LIMIT 1;');
         }

        
$act=explode('_',$arr['count']);
        
$act=$act[0];
        
$count=str_replace('_','/',$arr['count']);

        
$img=imageCreateFromGIF($count); 
        
$color=imagecolorallocate($img,rand(0,100),255,rand(0,100));

        switch(
$act)
         {
            case 
'small'$n=1; break;
            case 
'big'$n=14; break;
         }

        
imagestring($img,1,round(16-(strlen($host)-1)*2.35),$n,$host,$color);
        
imagestring($img,1,round(50-(strlen($hit)-1)*2.35),$n,$hit,$color);

        
ob_start();
        
ImageGif($img);
        
ImageDestroy($img);
        
header("Content-Type: image/gif");
        
header('Content-Disposition: inline; filename=count_'.$id.'.gif');
        
header('Content-Length: '.ob_get_length());
        
ob_end_flush();
        exit;
     }
 }
#else
 
{
    
header('location: ../images/error.gif');
    exit;
 }
?>
Онлайн: 4
Реклама