Вход Регистрация
Файл: adultscript-2.0.3-pro/files/modules/video/components/playlist.php
Строк: 89
<?php
defined
('_VALID') or die('Restricted Access!');
class 
VComponent_video_playlist extends VModule_video
{
    public function 
__construct()
    {
        
parent::__construct();
    }
    
    public function 
render()
    {
        if (!
VCfg::get('video.playlists')) {
            
VModule::load('404'true);
        }
    
        if (
VCfg::get('video.view_access') != 'all' && !VBrowser::get('is_robot')) {
            
VAuth::check($this->vcfg['view_access'], NULL'Please login as a '.$this->vcfg['view_access'].' to watch videos!');
        }
        
        
$errors            = array();
        
$messages        = array();
        
$playlist_id    VUri::request(1);
        
        
$cache_id        'playlist-'.$playlist_id;
        if (!
$playlist $this->cache->get($cache_id3600)) {
              
$this->db->query("SELECT p.playlist_id, p.user_id, p.name, p.slug, p.type, p.add_time,
                                       p.total_videos, p.duration, p.total_views, p.total_favorites,
                                       p.likes, p.rated_by, u.username
                                FROM #__playlist AS p
                                INNER JOIN #__user AS u ON (u.user_id = p.user_id AND u.status = '1')
                                WHERE p.playlist_id = '"
.$this->db->escape($playlist_id)."'
                                LIMIT 1"
);
              if (
$this->db->affected_rows()) {
                  
$playlist    $this->db->fetch_assoc();
                  
$this->cache->store($cache_id$playlist3600);
              }
        }
        
        if (!
$playlist) {
              
VModule::load('404'true);
        }
        
        
VLanguage::load('frontend.video');
        
        
$user_id    = (VAuth::loggedin()) ? (int) $_SESSION['user_id'] : 0;
        
$owner_id   = (int) $playlist['user_id'];
        
$friends    true;
        if (
$user_id) {
            if (
$playlist['type'] == 'private' &&
                
$user_id !== (int) $owner_id) {
                
$this->db->query("SELECT user_id
                                  FROM #__user_friends
                                  WHERE user_id = "
.$owner_id."
                                  AND friend_id = "
.$user_id."
                                  AND status = 'approved'
                                  LIMIT 1"
);
                if (!
$this->db->affected_rows()) {
                    
$friends false;
                }
            }
        } else {
            if (
$playlist['type'] == 'private') {
                
$friends false;
            }
        }
        
        
$videos    = array();
        if (!
VBrowser::get('is_robot') && $friends === true) {
              
$this->db->query("UPDATE #__playlist
                                SET total_views = total_views+1
                                WHERE playlist_id = "
.$playlist_id."
                                LIMIT 1"
);
        }
        
        if (
$friends === true) {
              
$cache_id        'playlist-videos-'.$playlist_id;
              if (!
$videos $this->cache->get($cache_id3600)) {
                  
$this->db->query("SELECT p.video_id, v.title, v.slug, v.description, v.duration, v.thumb, v.thumbs,
                                           v.likes, v.rating, v.rated_by, v.hd, v.ext, v.add_time, v.total_views
                                    FROM #__playlist_videos AS p
                                    INNER JOIN #__video AS v ON (v.video_id = p.video_id AND v.status = 1)
                                    WHERE p.playlist_id = "
.$playlist_id."
                                    ORDER BY p.add_time ASC"
);
                  if (
$this->db->affected_rows()) {
                      
$videos    $this->db->fetch_rows();
                      
$this->cache->store($cache_id$videos3600);
                  }
              }
          }
          
          
$this->get_comments($playlist_id);
    
        
$this->tpl->menu        'video';
        
$this->tpl->cmenu        'video';
        
        
$this->tpl->meta_title    __('playlist-meta-title', array($playlist['name'], VF::cfg_item('site_name')));
        
$this->tpl->meta_desc    __('playlist-meta-desc', array($playlist['name'], VF::cfg_item('site_name')));
        
        
$this->tpl->canonical    BASE_URL.'/playlist/'.$playlist_id.'/'.$playlist['slug'].'/';
        
$this->tpl->mcanonical    MOBILE_URL.'/playlist/'.$playlist_id.'/'.$playlist['slug'].'/';
                
        
$this->tpl->errors        $errors;
        
$this->tpl->messages    $messages;
        
        
$this->tpl->friends        $friends;
        
$this->tpl->playlist    $playlist;
        
$this->tpl->videos        $videos;
        
        
$this->tpl->load(array('header''video_playlist''footer'));
        
$this->tpl->display();
    }
    
    private function 
get_comments($playlist_id)
    {
        
$sql_count      "SELECT COUNT(comment_id) AS total_comments
                           FROM #__playlist_comments 
                           WHERE playlist_id = "
.$playlist_id."
                           AND status = '1'"
;
        
$total_comments $this->db->get_field($sql_count'total_comments');
        
$pagination     VPagination::get(1$total_commentsVCfg::get('video.playlist_comments_per_page'));
        
$sql            "SELECT c.comment_id, c.parent_id, c.user_id,
                                  c.comment, c.add_time, c.nickname,
                                  c.likes, c.rated_by,
                                  u.username, u.gender, u.avatar
                           FROM #__playlist_comments AS c
                           LEFT JOIN #__user AS u ON (u.user_id = c.user_id)
                           WHERE c.playlist_id = "
.$playlist_id."
                           AND c.status = '1'
                           ORDER BY c.comment_id DESC
                           LIMIT "
.$pagination['limit'];
        
$cache_id       $sql.$total_comments;
        if (!
$comments $this->cache->get($cache_id3600)) {
            
$comments $this->db->get_rows($sql);
            if (
$this->db->affected_rows()) {
                
$this->cache->store($cache_id$comments, (3600));
            }
        }
        
        
$this->tpl->comments        $comments;
        
$this->tpl->total_comments  $total_comments;
        
$this->tpl->pagination      $pagination;
    }    
}
Онлайн: 0
Реклама