Вход Регистрация
Файл: adultscript-2.0.3-pro/files/modules/adv/adv.php
Строк: 13
<?php
defined
('_VALID') or die('Restricted Access!');
class 
VModule_adv
{
    private 
$db;
    public function 
__construct()
    {
    }
    
    public function 
render()
    {
        
$id        = (int) VUri::request(1);
        
$type    = (isset($_GET['type'])) ? trim($_GET['type']) : 'default';
        if (
$id) {
            
$this->db VF::factory('database');
            if (
$type == 'default') {
                
$this->process_adv($id);
            } elseif (
$type == 'player') {
                
$this->process_player_adv($id);
            }
        }
        
        
VF::close();
    }
    
    private function 
process_adv($adv_id)
    {
        
$this->db->query("SELECT url
                          FROM #__adv
                          WHERE adv_id = "
.$adv_id."
                          LIMIT 1"
);
        if (
$this->db->affected_rows()) {
            
$url    $this->db->fetch_field('url');
            
$this->db->query("UPDATE #__adv
                              SET clicks = clicks+1
                              WHERE adv_id = "
.$adv_id."
                              LIMIT 1"
);
            
$this->db->query("INSERT INTO #__adv_clicks
                              SET adv_id = "
.$adv_id.",
                                  ip = "
.VServer::ip(TRUE).",
                                  referer = '"
.$this->db->escape(VServer::get('HTTP_REFERER'))."',
                                  click_date = '"
.date('Y-m-d h:i:s')."'");
            
            
VF::redirect($url'302');
        }
    }
    
    private function 
process_player_adv($adv_id)
    {
        
$this->db->query("SELECT url
                          FROM #__adv_player
                          WHERE adv_id = "
.$adv_id."
                          LIMIT 1"
);
        if (
$this->db->affected_rows()) {
            
$url    $this->db->fetch_field('url');
            
$this->db->query("UPDATE #__adv_player
                              SET clicks = clicks+1
                              WHERE adv_id = "
.$adv_id."
                              LIMIT 1"
);
            
$this->db->query("INSERT INTO #__adv_player_clicks
                              SET adv_id = "
.$adv_id.",
                                  ip = "
.VServer::ip(TRUE).",
                                  referer = '"
.$this->db->escape(VServer::get('HTTP_REFERER'))."',
                                  click_date = '"
.date('Y-m-d h:i:s')."'");
            
            
VF::redirect($url'302');
        }
    }
}
?>
Онлайн: 1
Реклама