Вход Регистрация
Файл: adultscript-2.0.3-pro/files/modules/video/components/browse.php
Строк: 105
<?php
defined
('_VALID') or die('Restricted Access!');
class 
VComponent_video_browse extends VModule_video
{
    public function 
__construct()
    {
        
parent::__construct();
    }
    
    public function 
render()
    {
        
$args        $this->get_query();
        
$order        $args['order'];
        
$timeline    $args['timeline'];
        
$page        $args['page'];
    
        
$url $order.'/';
        
        if (
$timeline) {
            
$url .= $timeline.'/';
        }
        
        if (
$page 1) {
            
$url .= $page.'/';
        }
        
        if (!
VUri::match($url)) {
            
VModule::load('404'TRUE);
        }
        
        
VLanguage::load('frontend.video');
        
        
$sql            "SELECT v.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, v.premium,
                                  u.username
                           FROM #__video AS v
                           LEFT JOIN #__user AS u ON (u.user_id = v.user_id)
                           WHERE v.status = 1"
;
        
$sql_count        "SELECT COUNT(*) AS total_videos
                           FROM #__video AS v
                           WHERE v.status = 1"
;
        
        
$time_name        '';
        if (
$timeline) {
            switch (
$timeline) {
                case 
'today':
                      
$start_time  strtotime('today');
                      
$end_time    $start_time+86400;
                      
$sql        .= " AND v.add_time > ".$start_time." AND v.add_time < ".$end_time;
                      
$sql_count    .= " AND v.add_time > ".$start_time." AND v.add_time < ".$end_time;
                      
$time_name   __('todays').' ';
                    break;
                case 
'yesterday':
                      
$start_time  strtotime('yesterday');
                      
$end_time    $start_time+86400;
                      
$sql        .= " AND v.add_time > ".$start_time." AND v.add_time < ".$end_time;
                      
$sql_count    .= " AND v.add_time > ".$start_time." AND v.add_time < ".$end_time;
                      
$time_name   __('yesterdays').' ';
                      break;                
                case 
'week':
                    
$now         time();
                    
$start_time    = (date('w'$now) === 1) ? strtotime('today'$now) : strtotime('last Monday'$now);
                      
$sql        .= " AND v.add_time > ".$start_time;
                      
$sql_count    .= " AND v.add_time > ".$start_time;
                      
$time_name   __('this-weeks').' ';
                      break;
                case 
'month':
                    
$start_time    strtotime('first day of '.date('F Y'));
                      
$sql        .= " AND v.add_time > ".$start_time;
                      
$sql_count    .= " AND v.add_time > ".$start_time;
                      
$time_name   __('this-months').' ';                
                    break;
                case 
'year':
                    
$start_time    strtotime(date('Y').'-01-01');
                      
$sql        .= " AND v.add_time > ".$start_time;
                      
$sql_count    .= " AND v.add_time > ".$start_time;
                      
$time_name   __('this-years').' ';                
                    break;
            }
        }
        
        if (
VModule::enabled('premium') &&
            
VF::cfg_item('module.premium.browse_premium') == '0') {
            
$sql        .= " AND v.premium = '0'";
            
$sql_count    .= " AND v.premium = '0'";
        }
        
        switch (
$order) {
            case 
'recent':
                
$sql       .= ' ORDER BY v.add_time DESC';
                
$order_name    ' '.__('most-recent');
                break;
            case 
'popular':
                
$sql       .= ' ORDER BY v.total_views DESC';
                
$order_name __('popular');
                break;
            case 
'discussed':
                
$sql       .= ' ORDER BY v.total_comments DESC';
                
$order_name    __('most-discussed');
                break;
            case 
'rated':
                
$sql       .= ' ORDER BY (v.rating+v.rated_by) DESC';
                
$order_name __('top-rated');
                break;
            case 
'downloaded':
                
$sql       .= ' ORDER BY v.total_downloads DESC';
                
$order_name __('most-downloaded');
                break;
            case 
'longest':
                
$sql       .= ' ORDER BY v.duration DESC';
                
$order_name __('longest');
                break;
            case 
'watched':
                
$sql       .= ' ORDER BY v.view_time DESC';
                
$order_name    __('being-watched');
                break;
            default:
                
VModule::load('404'TRUE);
        }
        
        
$total_videos   $this->db->get_field($sql_count'total_videos');
        
$pagination     VPagination::get($page$total_videosVCfg::get('video.browse_per_page'));
        
$sql            $sql' LIMIT '.$pagination['limit'];
        if (!
$videos $this->cache->get($sql3600)) {
            
$videos            $this->db->get_rows($sql);
            
$this->cache->store($sql$videos3600);
        }
        
        
$this->tpl->menu        'video';
        
        
$page_name                = ($page ) ? ' - '.__('page').' '.$page '';
        
        
$this->tpl->title        __('browse-title', array($time_name.$order_name''));
        
$this->tpl->meta_title    __('browse-meta-title', array($time_name.$order_name$page_nameVF::cfg_item('site_name')));
        
$this->tpl->meta_desc    $this->tpl->meta_title.'. '.VF::cfg_item('meta_desc');
        
        
$this->tpl->canonical    BASE_URL.'/'.$url;
        
$this->tpl->canonicalm    MOBILE_URL.'/'.$url;
        
        if (
$page 1) {
            
$sort   '';
            if (
$order != 'recent' or $page or $timeline) {
                
$sort   $order;
            }

            
$this->tpl->prev_url    build_url($sort$timeline''$page-1);
        }

        if (
$page $pagination['total_pages']) {
            
$this->tpl->next_url    build_url($order$timeline''$page+1);
        }
                
        
$this->tpl->order        $order;
        
$this->tpl->timeline    $timeline;
        
$this->tpl->timename    $time_name;
        
$this->tpl->page        $page;
        
$this->tpl->tag            null;
        
        
$this->tpl->videos        $videos;
        
$this->tpl->pagination    $pagination;
        
        
$this->tpl->load(array('header''video_browse''footer'));
        
$this->tpl->display();
    }
}
Онлайн: 0
Реклама