Вход Регистрация
Файл: adultscript-2.0.3-pro/files/modules/photo/components/slideshow.php
Строк: 47
<?php
defined
('_VALID') or die('Restricted Access!');
class 
VComponent_photo_slideshow extends VModule_photo
{
    private 
$album_id;
    public function 
__construct()
    {
        
parent::__construct();

        
$this->album_id    VUri::request(1);
    }
    
    public function 
render()
    {
        
VLanguage::load('frontend.photo');
        
        
$access    VCfg::get('photo.view_access');
        if (
$access != 'all') {
            
VAuth::check(ucfirst($accessNULL__('album-access', array($access))));
        }
    
        
$errors        = array();
        
$messages    = array();
        
$cache_id     'album_'.$this->album_id;
        if (!
$album $this->cache->get($cache_id3600)) {
            
$this->db->query("SELECT a.album_id, a.user_id, a.title, a.slug, a.description,
                                     a.add_time, a.total_views, a.likes, a.rating, a.rated_by,
                                     a.total_photos, a.password, a.type, u.username,
                                     GROUP_CONCAT(DISTINCT c.cat_id) AS categories,
                                     GROUP_CONCAT(DISTINCT c.slug) AS cslug,
                                     GROUP_CONCAT(DISTINCT c.name) AS name,
                                     GROUP_CONCAT(DISTINCT t.name) AS tags
                              FROM #__photo_albums AS a
                              LEFT JOIN #__photo_category AS pc ON (pc.album_id = a.album_id)
                              LEFT JOIN #__photo_categories AS c ON (c.cat_id = pc.cat_id)
                              LEFT JOIN #__photo_tags AS t ON (t.album_id = a.album_id)
                              LEFT JOIN #__user AS u ON (u.user_id = a.user_id)
                              WHERE a.album_id = "
.$this->album_id."
                              AND a.status = '1'
                              GROUP BY a.album_id
                              LIMIT 1"
);
            if (
$this->db->affected_rows()) {
                
$album $this->db->fetch_assoc();
                
$this->cache->store($cache_id$album3600);
            } else {
                
VModule::load('404'TRUE);
            }
        }
        
        
$url    'photo/'.$album['album_id'].'/'.$album['slug'].'/slideshow/';
        if (!
VUri::match($url)) {
            
VF::redirect(BASE_URL.'/'.$url'301');
        }
        
        if (
VCfg::get('photo.allow_password')) {
            
$allowed    = (isset($_SESSION['albums']) && isset($_SESSION['albums'][$this->album_id])) ? true false;
            if (isset(
$_POST['submit-password']) && !$allowed) {
                
$password    trim($_POST['password']);
                echo 
VF::debug($password);
                if (
VHash::check($password$album['password'])) {
                    if (!isset(
$_SESSION['albums'])) {
                        
$_SESSION['albums']    = array();
                    }
                
                    
$_SESSION['albums'][$this->album_id] = 1;
            
                    
$messages[]    = __('password-accept');
                    
$allowed    true;
                } else {
                    
$errors[]    = __('password-invalid');
                }            
            }
        
            if (
$album['password'] != '' && !$allowed) {
                
$this->tpl->menu        'photo';
                
$this->tpl->title        $album['title'];
                
$this->tpl->meta_title    __('album-meta-title', array($album['title'], $this->tpl->cfg['site_name']));
                
$this->tpl->css            = array(TPL_REL.'/css/style_photo.css');
                
$this->tpl->errors        $errors;
                
$this->tpl->album        $album;
                
$this->tpl->load(array('header''photo_album_password''footer'));
                
$this->tpl->display();
                exit;
            }
        }
        
        
$ip             VServer::ip(true);
        
$user_id        = (VAuth::loggedin()) ? (int) $_SESSION['user_id'] : 0;
        
$friends        TRUE;
        if (
$album['type'] == 'private') {
            if (
$user_id) {
                
$owner_id = (int) $album['user_id'];
                if (
$owner_id !== $user_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 {
                
$friends FALSE;
            }
        }        
        
        
$sql            "SELECT photo_id, caption, total_views, total_comments, likes, rating, rated_by
                           FROM #__photo
                           WHERE album_id = "
.$this->album_id."
                           AND status = '1'
                           ORDER BY photo_id ASC"
;
        if (!
$photos $this->cache->get($sql3600)) {
            
$this->db->query($sql);
            if (
$this->db->affected_rows()) {
                
$photos    $this->db->fetch_rows();
                
$this->cache->store($sql$photos3600);
            } else {
                
VModule::load('404'TRUE);
            }
        }
        
        if (!
VBrowser::get('is_robot')) {
            
$this->db->query("UPDATE #__photo_albums
                              SET total_views = total_views+1
                              WHERE album_id = "
.$this->album_id."
                              LIMIT 1"
);
                              
            if (
VCfg::get('photo.track_views')) {
                
$this->db->query("INSERT INTO #__photo_album_views
                                  SET album_id = "
.$this->album_id.",
                                      user_id = "
.$user_id.",
                                      ip = "
.$ip.",
                                      view_time = "
.time());
            }
        }
        
        
$this->tpl->menu        'photo';
        
        
$this->tpl->title        $album['title'];
        
$this->tpl->meta_title    __('slideshow-meta-title', array($album['title'], VF::cfg_item('site_name')));
        
        
$this->tpl->css            = array(TPL_REL.'/css/style_photo.css');

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

        
$this->tpl->errors        $errors;
        
$this->tpl->messages    $messages;

        
$this->tpl->friends        $friends;
        
$this->tpl->album        $album;
        
$this->tpl->photos        $photos;
        
        
$this->tpl->load(array('header''photo_album''footer'));
        
$this->tpl->display();
    }
}
Онлайн: 0
Реклама