Вход Регистрация
Файл: adultscript-2.0.3-pro/files/modules/pornstar/components/view.php
Строк: 108
<?php
defined
('_VALID') or die('Restricted Access!');
class 
VComponent_pornstar_view extends VModule_pornstar
{
    public function 
__construct()
    {
        
parent::__construct();
    }
    
    public function 
render()
    {
        
$slug VUri::request(1);
        if (!
$pornstar $this->cache->get('pornstar_'.$slug3600)) {
            
$sql    "SELECT m.model_id, m.name, m.slug, m.description, m.ext, m.likes, m.rating, m.rated_by,
                              m.total_views, m.total_videos, m.total_albums, m.total_comments,
                              m.total_favorites, m.gender, mb.aliases, mb.birth_date, mb.birth_location,
                              mb.birth_name, mb.eye_color, mb.hair_color, mb.weight, mb.height,
                              mb.measurements, mb.ethnicity, mb.nationality, mb.natural_bust,
                              mb.performs, mb.links, mb.url, m.adv
                       FROM #__model AS m
                       LEFT JOIN #__model_bio AS mb ON (m.model_id = mb.model_id)
                       WHERE m.slug = '"
.$this->db->escape($slug)."'
                       AND m.status = '1'
                       LIMIT 1"
;
            
$this->db->query($sql);
            if (
$this->db->affected_rows()) {
                
$pornstar $this->db->fetch_assoc();
                
$this->cache->store('pornstar_'.$slug$pornstar3600);
            } else {
                
VModule::load('404'TRUE);
            }
        }
        
        if (!
VUri::match('pornstar/'.$slug.'/')) {
            
VF::redirect(BASE_URL.'/pornstar/'.$slug.'/'301);
        }
        
        
VLanguage::load('frontend.pornstar');
        
        
$model_id        = (int) $pornstar['model_id'];
        
$user_id        = (VAuth::loggedin()) ? (int) $_SESSION['user_id'] : 0;
        
$subscribed        = ($user_id && $this->is_subscribed($model_id$user_id)) ? true false;
        
        if (!
VBrowser::get('is_robot')) {
            
$this->db->query("UPDATE #__model
                              SET total_views = total_views+1
                              WHERE model_id = "
.$model_id."
                              LIMIT 1"
);
                              
            if (
VCfg::get('pornstar.track_views')) {
                
$this->db->query("INSERT INTO #__model_views
                                  SET model_id = "
.$model_id.",
                                      user_id = "
.$user_id.",
                                      ip = "
.VServer::ip(true).",
                                      view_time = "
.time());
            }
        }
        
        
$page        = (isset($_GET['page'])) ? (int) trim($_GET['page']) : 1;
        
$order        = (isset($_GET['o'])) ? trim($_GET['o']) : 'recent';
        
$orders        = array('recent' => __('recent'), 'popular' => __('popular'), 'rated' => __('rated'));
        if (!isset(
$orders[$order])) {
            
VModule::load('404'true);
        }
        
        if (
$order == 'recent') {
            
$sort    'v.add_time';
            
$title    __('recent');
        } elseif (
$order == 'popular') {
            
$sort    'v.total_views';
            
$title    __('popular');
        } elseif (
$order == 'rated') {
            
$sort    'v.likes';
            
$title    __('rated');
        }
        
        
$sql_count      "SELECT COUNT(*) AS total_videos
                           FROM #__model_videos AS mv
                           INNER JOIN #__video AS v ON (v.video_id = mv.video_id AND v.status = 1)
                           WHERE model_id = "
.$model_id;
        
$total_videos   $this->db->get_field($sql_count'total_videos');
        
$pagination     VPagination::get($page$total_videosVCfg::get('pornstar.videos_per_page'));
        
$sql            "SELECT mv.video_id, v.title, v.slug, v.likes, v.rating, v.rated_by, v.duration, v.thumb,
                                  v.thumbs, v.total_views, v.add_time, v.ext, v.hd, u.username
                           FROM #__model_videos AS mv
                           INNER JOIN #__video AS v ON (mv.video_id = v.video_id AND v.status = 1)
                           LEFT JOIN #__user AS u ON (v.user_id = u.user_id)
                           WHERE mv.model_id = "
.$model_id."
                           ORDER BY "
.$sort." DESC
                           LIMIT "
.$pagination['limit'];
        if (!
$videos $this->cache->get($sql3600)) {
            
$videos $this->db->get_rows($sql);
            if (
$videos) {
                
$this->cache->store($sql$videos3600);
            }
        }
        
        
$title                    $title.' '.__('videos');
        
$title_add                = ($page 1) ? ' - '.$title.' '.__('page').' '.$page ' - '.$title;
        
        
$this->tpl->menu        'pornstar';
        
        
$this->tpl->title        $pornstar['name'].' '.$title;
        
$this->tpl->meta_title     __('pornstar-meta-title', array($pornstar['name'].$title_addVF::cfg_item('site_name')));
        
$this->tpl->meta_desc    $this->tpl->meta_title.'. '.VF::cfg_item('meta_desc');
        
$this->tpl->meta_keys    strtolower($pornstar['name']).', '.VF::cfg_item('meta_keys');
        
        
$this->tpl->css            = array(TPL_REL.'/css/style_model.css');

        
$this->tpl->canonical    BASE_URL.'/pornstar/'.$slug.'/';
        
$this->tpl->canonicalm    MOBILE_URL.'/pornstar/'.$slug.'/';

        
$this->tpl->user_id        $user_id;
        
$this->tpl->pornstar    $pornstar;
        
$this->tpl->subscribed    $subscribed;
        
        
$this->tpl->order        $order;
        
$this->tpl->videos        $videos;
        
$this->tpl->pagination    $pagination;
        
        
$this->tpl->albums        $this->count_model_albums($model_id);
        
$this->tpl->comments    $this->count_model_comments($model_id);

        
$this->tpl->load(array('header''pornstar_view''footer'));
        
$this->tpl->display();
    }
    
    private function 
is_subscribed($model_id$user_id)
    {
        
$this->db->query("
            SELECT model_id
            FROM #__model_subscribers
            WHERE model_id = "
.$model_id."
            AND user_id = "
.$user_id."
            LIMIT 1
        "
);
        
        return 
$this->db->affected_rows();
    }
    
    private function 
count_model_albums($model_id)
    {
        
$sql_count                    "SELECT COUNT(*) AS total_albums
                                         FROM #__model_albums
                                         WHERE model_id = "
.$model_id;
    
        return 
$this->db->get_field($sql_count'total_albums');
    }
    
    private function 
count_model_comments($model_id)
    {
        
$sql_count                "SELECT COUNT(*) AS total_comments
                                     FROM #__model_comments
                                     WHERE model_id = "
.$model_id;
        return 
$this->db->get_field($sql_count'total_comments');
    }
}
Онлайн: 1
Реклама