Вход Регистрация
Файл: adultscript-2.0.3-pro/files/mobile/components/channel_view.php
Строк: 193
<?php
defined
('_VALID') or die('Restricted Access!');
class 
VComponent_mobile_channel_view extends VComponent_mobile_channel
{
    public function 
__construct()
    {
        
parent::__construct();
    }
    
    public function 
render()
    {
        
$slug       VUri::request(1);
        
$url        'channel/'.$slug.'/';
        if (!
VUri::match($url)) {
            
VModule::load('404'true);
        }

        
$this->db->query("
            SELECT channel_id, name, slug, description, url, thumb,
                   total_views, total_videos, total_likes, total_votes,
                   total_subscribers, last_add_time, adv_bottom_id, adv_right_id
            FROM #__channel
            WHERE slug = '"
.$this->db->escape($slug)."'
            LIMIT 1
        "
);

        if (!
$this->db->affected_rows()) {
            
VModule::load('404'true);
        }
        
        
$channel    $this->db->fetch_assoc();
        
$channel_id = (int) $channel['channel_id'];
            
        
VLanguage::load('frontend.channel');
        
        if (!
VBrowser::get('is_robot')) {
            
$this->db->query("
                UPDATE #__channel
                SET total_views = total_views+1
                WHERE channel_id = "
.$channel_id."
                LIMIT 1
            "
);
        }

        
$order      = (isset($_GET['o'])) ? trim($_GET['o']) : 'recent';
        
$orders     = array('recent' => 1'popular' => 1'discussed' => 1'rating' => 1);
        if (!isset(
$orders[$order])) {
            
VModule::load('404'true);
        }
        
        
$timeline   = (isset($_GET['t'])) ? trim($_GET['t']) : 'all';
        
$timelines  = array('today' => 1'yesterday' => 1'week' => 1'month' => 1'year' => 1);
        if (
$timeline != 'all' && !isset($timelines[$timeline])) {
            
VModule::load('404'true);
        }
        
        
$duration   = (isset($_GET['d'])) ? trim($_GET['d']) : 'all';
        
$durations  = array('short' => 1'medium' => 1'long' => 1);
        if (
$duration != 'all' && !isset($durations[$duration])) {
            
VModule::load('404'true);
        }
        
        
$page       = (isset($_GET['page'])) ? (int) trim($_GET['page']) : 1;

        
$sql        "SELECT v.video_id, v.title, v.slug, v.rating, v.rated_by, v.duration, v.thumb,
                              v.thumbs, v.total_views, v.add_time, v.ext, v.premium,
                              u.username
                       FROM #__video AS v
                       LEFT JOIN #__user AS u ON (u.user_id = v.user_id)
                       WHERE v.channel_id = "
.$channel_id."
                       AND v.status = 1"
;
        
$sql_count  "SELECT COUNT(*) AS total_videos
                       FROM #__video AS v
                       WHERE v.channel_id = "
.$channel_id."
                       AND v.status = 1"
;

        
$time_name  '';
        if (
$timeline == 'today') {
            
$sql        .= " AND v.add_time > ".strtotime('12:00:00');
            
$sql_count  .= " AND v.add_time > ".strtotime('12:00:00');
            
$time_name   __('todays').' ';
        } elseif (
$timeline == 'yesterday') {
            
$sql        .= " AND v.add_time > ".strtotime("-1 day"strtotime('12:00:00'));
            
$sql_count  .= " AND v.add_time > ".strtotime("-1 day"strtotime('12:00:00'));
            
$time_name   __('yesterdays').' ';
        } elseif (
$timeline == 'week') {
            
$start       mktime(000date("n"), date("j") - date("N") + 1);
            
$sql        .= " AND v.add_time > ".$start;
            
$sql_count  .= " AND v.add_time > ".$start;
            
$time_name   __('this-weeks').' ';
        } elseif (
$timeline == 'month') {
            
$start       mktime(000date("n"), 1);
            
$sql        .= " AND v.add_time > ".$start;
            
$sql_count  .= " AND v.add_time > ".$start;
            
$time_name   __('this-months').' ';
        } elseif (
$timeline == 'year') {
            
$start       mktime(00011date('Y'));
            
$sql        .= " AND v.add_time > ".$start;
            
$sql_count  .= " AND v.add_time > ".$start;
            
$time_name   __('this-years').' ';
        }
        
        
$duration_name  '';
        if (
$duration == 'short') {
            
$sql            .= " AND v.duration < 300";
            
$sql_count      .= " AND v.duration < 300";
            
$duration_name   __('short').' ';
        } elseif (
$duration == 'medium') {
            
$sql            .= " AND (v.duration > 300 AND v.duration < 1200)";
            
$sql_count      .= " AND (v.duration > 300 AND v.duration < 1200)";
            
$duration_name   __('medium').' ';
        } elseif (
$duration == 'long') {
            
$sql            .= " AND v.duration > 1200";
            
$sql_count      .= " AND v.duration > 1200";
            
$duration_name   __('long').' ';
        }
        
        
$order_name '';
        if (
$order == 'recent') {
            
$sql        .= " ORDER BY v.add_time DESC";
            
$order_name  __('most-recent');
        } elseif (
$order == 'popular') {
            
$sql        .= " ORDER BY v.total_views DESC";
            
$order_name  __('most-popular');
        } elseif (
$order == 'discussed') {
            
$sql        .= " ORDER BY v.total_comments DESC";
            
$order_name  __('most-discussed');
        } elseif (
$order == 'rated') {
            
$sql        .= " ORDER BY v.rating DESC";
            
$order_name  __('most-rated');
        } elseif (
$order == 'downloaded') {
            
$sql        .= " ORDER BY v.total_downloads DESC";
            
$order_name  __('most-downloads');
        } elseif (
$order == 'longest') {
            
$sql        .= " ORDER BY v.duration DESC";
            
$order_name  __('longest');
        } elseif (
$order == 'watched') {
            
$sql        .= " ORDER BY v.view_time DESC";
            
$order_name  __('watched');
        }
        
        
$total_videos   $this->db->get_field($sql_count'total_videos');
        
$pagination     VPagination::get($page$total_videos6);
        
$videos         $this->db->get_rows($sql.' LIMIT '.$pagination['limit']);

        
$page_name        = ($page 1) ? ' '.__('page').' '.$page '';

        
$this->tpl->menu        'channel';

        
$this->tpl->title_videos    $time_name.$order_name.' '.__('channel').' '.__('videos').$page_name;

        
$this->tpl->meta_title  __('channel-meta-title', array($channel['name'], VF::cfg_item('site_name')));
        
$this->tpl->meta_desc   __('channel-meta-desc', array($channel['name'], VF::cfg_item('meta_desc')));
        
$this->tpl->meta_keys   $channel['name'];        
        
        
$this->tpl->order        $order;
        
$this->tpl->orders        $orders;
        
$this->tpl->timeline    $timeline;
        
$this->tpl->timelines    $timelines;
        
$this->tpl->duration    $duration;
        
$this->tpl->durations    $durations;
        
$this->tpl->page        $page;
        
        
$this->tpl->canonical    MOBILE_URL.'/'.$url;
        
        
$this->tpl->channel        $channel;
        
$this->tpl->videos    $videos;
        
$this->tpl->pagination    $pagination;
        
        
$this->tpl->load(array('header''channel_view''footer'));
        
$this->tpl->display();
    }
}

function 
build_url($order=''$page=1$letter='')
{
    
$url MOBILE_REL.'/channels/';
    if (
$letter != '' && $letter != 'all') {
        
$url .= $letter.'/';
    }

    if (
$order != 'recent' or $page 1) {
        
$url .= $order.'/';
    }

    if (
$page === true) {
        
$url .= '#PAGE#/';
    } elseif (
$page !== 1) {
        
$url .= $page.'/';
    }

    return 
$url;
}
Онлайн: 2
Реклама