Файл: adultscript-2.0.3-pro/files/mobile/components/pornstar_view.php
Строк: 113
<?php
defined('_VALID') or die('Restricted Access!');
class VComponent_mobile_pornstar_view extends VComponent_mobile_pornstar
{
public function __construct()
{
parent::__construct();
}
public function render()
{
$slug = VUri::request(1);
$media = (VUri::request(2) != '') ? VUri::request(2) : 'pornstar';
$page = (VUri::request(3) != '') ? (int) VUri::request(3) : 1;
if ($media != 'pornstar' && $page === 1) {
VF::redirect(MOBILE_URL.'/pornstar/'.$slug.'/', 301);
}
$url = 'pornstar/'.$slug.'/';
if ($media != 'pornstar') {
$url .= $media.'/';
if ($page > 1) {
$url .= $page.'/';
}
}
if (!VUri::match($url)) {
$this->notfound();
}
$cache_id = 'pornstar_mobile_'.$slug;
if (!$pornstar = $this->cache->get($cache_id, 7200)) {
$this->db->query("SELECT m.model_id, m.name, m.slug, m.description, m.ext, 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.natural_bust, mb.performs
FROM #__model AS m
LEFT JOIN #__model_bio AS mb ON (mb.model_id = m.model_id)
WHERE slug = '".$this->db->escape($slug)."'
AND status = '1'
LIMIT 1");
if (!$this->db->affected_rows()) {
$this->notfound();
}
$pornstar = $this->db->fetch_assoc();
$this->cache->store($cache_id, $pornstar, 7200);
}
if ($media == 'pornstar') {
if ($this->mcfg['pornstars_videos']) {
$this->get_pornstar_videos($pornstar['model_id'], $page);
}
if ($this->mcfg['pornstars_photos']) {
$this->get_pornstar_albums($pornstar['model_id'], $page);
}
} elseif ($media == 'videos') {
$this->get_pornstar_videos($pornstar['model_id'], $page);
} elseif ($media == 'photos') {
$this->get_pornstar_albums($pornstar['model_id'], $page);
} else {
$this->notfound();
}
$add_page = ($page > 1) ? ' '.ucfirst(__('page')).' '.$page : '';
$add = ($media != 'pornstar') ? ' '.__(strtolower($media)).$add_page : '';
$this->tpl->menu = 'pornstar';
$this->tpl->title = $pornstar['name'];
$this->tpl->videos_title = $pornstar['name'].' '.__('videos').$add_page;
$this->tpl->albums_title = $pornstar['name'].' '.__('albums').$add_page;
$this->tpl->meta_title = __('pornstar').' '.$pornstar['name'].$add.' - '.$this->tpl->mcfg['site_name'];
$this->tpl->meta_desc = __('watch').' '.__('pornstar').' '.$pornstar['name'].$add.'. '.$this->mcfg['meta_desc'];
$this->tpl->meta_keys = utf8_strtolower($pornstar['name']).', '.$this->mcfg['meta_keys'];
$this->tpl->canonical = BASE_URL.'/pornstar/'.$pornstar['slug'].'/';
$this->tpl->page = $page;
$this->tpl->pornstar = $pornstar;
$this->tpl->load(array('header', 'pornstar_view', 'footer'));
$this->tpl->display();
}
private function get_pornstar_videos($model_id, $page)
{
$model_id = (int) $model_id;
$sql_count = "SELECT COUNT(m.video_id) AS total_videos
FROM #__model_videos AS m
INNER JOIN #__video AS v ON (v.video_id = m.video_id AND v.mobile = '1' AND v.status = 1)
WHERE m.model_id = ".$model_id;
$total_videos = $this->db->get_field($sql_count, 'total_videos');
$pagination = VPagination::get($page, $total_videos, $this->mcfg['pornstars_videos_per_page']);
$sql = "SELECT v.video_id, v.title, v.slug, v.thumb, v.rating, v.total_views, v.duration
FROM #__model_videos AS m
INNER JOIN #__video AS v ON (v.video_id = m.video_id AND v.mobile = '1' AND v.status = 1)
WHERE m.model_id = ".$model_id."
ORDER BY v.add_time DESC
LIMIT ".$pagination['limit'];
if (!$videos = $this->cache->get($sql, 7200)) {
$this->db->query($sql);
if ($this->db->affected_rows()) {
$videos = $this->db->fetch_rows();
$this->cache->store($sql, $videos, 7200);
} else {
$videos = array();
}
}
$this->tpl->videos = $videos;
$this->tpl->vpagination = $pagination;
}
private function get_pornstar_albums($model_id, $page)
{
$model_id = (int) $model_id;
$sql_count = "SELECT COUNT(*) AS total_albums
FROM #__model_albums AS ma
INNER JOIN #__photo_albums AS a ON (a.album_id = ma.album_id AND a.mobile = '1' AND a.status = '1')
WHERE ma.model_id = ".$model_id;
$total_albums = $this->db->get_field($sql_count, 'total_albums');
$pagination = VPagination::get($page, $total_albums, $this->mcfg['pornstars_photos_per_page']);
$sql = "SELECT a.album_id, a.title, a.slug, a.total_photos, a.total_views, a.add_time
FROM #__model_albums AS m
LEFT JOIN #__photo_albums AS a ON (a.album_id = m.album_id AND a.mobile = '1' AND a.status = '1')
WHERE m.model_id = ".$model_id."
ORDER BY a.album_id DESC
LIMIT ".$pagination['limit'];
if (!$albums = $this->cache->get($sql, 7200)) {
$this->db->query($sql);
if ($this->db->affected_rows()) {
$albums = $this->db->fetch_rows();
$this->cache->store($sql, $albums, 7200);
} else {
$albums = array();
}
}
$this->tpl->albums = $albums;
$this->tpl->apagination = $pagination;
}
}