Вход Регистрация
Файл: etc/counter.php
Строк: 42
<?


 

        define
('HOME',''.$_SERVER['DOCUMENT_ROOT'].'');
        include 
HOME.'/__core/__PDO_connect.php';




        if (isset(
$_SERVER['HTTP_X_FORWARDED_FOR']) and preg_match('|^d{1,3}.d{1,3}.d{1,3}.d{1,3}$|',$_SERVER['HTTP_X_FORWARDED_FOR'])){
        
$ip trim(htmlspecialchars($_SERVER['HTTP_X_FORWARDED_FOR']));
        }elseif(isset(
$_SERVER['HTTP_CLIENT_IP']) and preg_match('|^d{1,3}.d{1,3}.d{1,3}.d{1,3}$|',$_SERVER['HTTP_CLIENT_IP'])){
        
$ip trim(htmlspecialchars($_SERVER['HTTP_CLIENT_IP']));
        }elseif(isset(
$_SERVER['REMOTE_ADDR']) and preg_match('|^d{1,3}.d{1,3}.d{1,3}.d{1,3}$|',$_SERVER['REMOTE_ADDR'])){
        
$ip trim(htmlspecialchars($_SERVER['REMOTE_ADDR']));
        }else{
        
$ip 'Скрыт';
        }


        if (isset(
$_SERVER['HTTP_X_OPERAMINI_PHONE_UA'])){
        
$ua trim(htmlspecialchars($_SERVER['HTTP_X_OPERAMINI_PHONE_UA']));
        }elseif (isset(
$_SERVER['HTTP_USER_AGENT'])){
        
$ua trim(htmlspecialchars($_SERVER['HTTP_USER_AGENT']));
        }else{
        
$ua 'Скрыт';
        }

        
$ua strtok($ua'/');
        
$ua strtok($ua' ');

        if (
preg_match('/opera min/i'$ua)) $browser 'Opera Mini';
        else if (
preg_match('/Chrome/i'$ua))$browser 'Chrome';
        else if (
preg_match('/Opera/i'$ua)) $browser 'Opera';
        else if (
preg_match('/MSIE/i'$ua)) $browser 'IE';
        else if (
preg_match('/Mozilla/i'$ua)) $browser 'Mozilla';
        else if (
preg_match('/ucweb/i'$ua)) $browser 'UCWeb';
        else 
$browser 'Неизвестно';


        
$site $db -> query
                            
("

                             SELECT `id`,`status`,`imageBig`,`imageSmall`,`userID` FROM `site` WHERE `id` = '"
.abs(intval($_GET['id']))."'  LIMIT 1

                            "
);

        if(
$site -> rowCount() == 1)

          {
            
$s $site -> fetch(PDO::FETCH_ASSOC);

            if(
$s['status'] == 1)

            {

            
$operator $db -> query
                            
("

                             SELECT `on` FROM `ip` WHERE INET_ATON('"
.$ip."') BETWEEN `min` AND `max`

                            "
);

                if(
$operator -> rowCount() > 0)

                  {
                     
$o $operator -> fetch(PDO::FETCH_ASSOC);
                     
$operator_note $o['on'];
                  }

                    else

                  {                    
$operator_note 1000;
                  }

            
$ip_isset $db -> query
                            
("

                             SELECT `id` FROM `note_host` WHERE `siteID` = '"
.$s['id']."' AND `ip` = '".$ip."' and `date`='".date("Y-m-d",time())."'

                            "
);





            if ((
$ip_isset -> rowCount()) == 0)

              {


                
$stmt $db->prepare("INSERT INTO `note_host` (`id`,`siteID`,`ip`,`browser`,`operator`,`date`,`time`) VALUES (?,?,?,?,?,?,?)");
                
$stmt -> execute(array('',''.$s['id'].'',''.$ip.'',''.$browser.'',''.$operator_note.'',''.date("Y-m-d",time()).'',''.time().''));





                
$site_h $db->exec("UPDATE `site` SET  `allHost` = (`allHost` + '1') ,`allHits` = (`allHits` + '1') WHERE `id` = '".$s['id']."' LIMIT 1");




                
$site_statistic_h $db->exec("UPDATE `site_statistic` SET  `host` = (`host` + '1'),  `hits` = (`hits` + '1')
                WHERE `siteID` = '"
.$s['id']."' and `date` = '".date("Y-m-d",time())."' LIMIT 1");

              }

                else

              {
                
$site_h $db->exec("UPDATE `site` SET  `allHits` = (`allHits` + '1') WHERE `id` = '".$s['id']."' LIMIT 1");




                
$site_statistic_h $db->exec("UPDATE `site_statistic` SET   `hits` = (`hits` + '1')
                WHERE `siteID` = '"
.$s['id']."' and `date` = '".date("Y-m-d",time())."' LIMIT 1");



              }

            }

            
header("Content-type: image/png");
            if(
$_GET['i'] == 'b')
            {




                
$ssite $db -> query
                            
("

                             SELECT `hits`,`host` FROM `site_statistic` WHERE  `siteID` = '"
.abs(intval($_GET['id']))."' and `date`='".date("Y-m-d",time())."' LIMIT 1

                            "
);


                
$ss $ssite -> fetch(PDO::FETCH_ASSOC);

                
$siteTop100 $db -> query
                            
("

                             SELECT `siteID` FROM `site_top100` WHERE  `siteID` = '"
.abs(intval($_GET['id']))."' LIMIT 1

                            "
);

                if(
$siteTop100 -> rowCount() == 1)
                {                
$img 'top100/'.$s['imageBig'].'.png';
                }

                  else

                {
                
$img 'b/'.$s['imageBig'].'.png';
                }
                
$image imagecreatefrompng($img);

                
$hits 69 - (strlen($ss['hits']) * 5);
                
$hosts 69 - (strlen($ss['host']) * 5);



                
$color imagecolorallocate($image255255255);

                
ImageString($image1$hits13$ss['hits'], $color);
                
ImageString($image1$hosts4$ss['host'], $color);



            }

              else

            if(
$_GET['i'] == 's')
            {
                
$img 's/'.$s['imageSmall'].'.png';
                
$image imagecreatefrompng($img);
            }

            
imagepng($image);
            
imageDestroy($image);



          }




?>
Онлайн: 1
Реклама