Вход Регистрация
Файл: adultscript-2.0.3-pro/files/modules/community/community.php
Строк: 153
<?php
defined
('_VALID') or die('Restricted Access!');
class 
VModule_community
{
    public function 
__construct()
    {
    }
    
    public function 
render()
    {
        
VLanguage::load('frontend.community');
    
        
$db             VF::factory('database');
        
$cache            VF::factory('cache');
        
$ucfg            VF::cfg('module.user');
        
$countries      VCountry::get();
        
$errors            = array();
        
        
$sql            'SELECT u.user_id, u.username, u.gender, u.avatar, u.online
                           FROM #__user AS u
                           WHERE u.status = '
1'
                           ORDER BY u.popularity DESC
                           LIMIT 6'
;
        if (!
$popular $cache->get($sql86400)) {
            
$db->query($sql);
            if (
$db->affected_rows()) {
                
$popular $db->fetch_rows();
                
$cache->store($sql$popular86400);
            } else {
                
$popular = array();
            }
        }
        
        
$filter            VF::factory('filter');
        
$username        = (isset($_GET['username'])) ? $filter->get('username''STRING''GET') : '';
        
$gender            = (isset($_GET['gender'])) ? $filter->get('gender''STRING''GET') : 'all';
        
$relation        = (isset($_GET['relation'])) ? $filter->get('relation''STRING''GET') : 'all';
        
$interested        = (isset($_GET['interested'])) ? $filter->get('interested''STRING''GET') : 'all';
        
$age_start        = (isset($_GET['age_start'])) ? (int) trim($_GET['start']) : (int) $ucfg['signup_age'];
        
$age_end        = (isset($_GET['age_end'])) ? (int) trim($_GET['end']) : 99;
        
$country        = (isset($_GET['country'])) ? $filter->get('country''STRING''GET') : '';
        
$city            = (isset($_GET['city'])) ? $filter->get('city''STRING''GET') : '';
        
$online            = (isset($_GET['online'])) ? $filter->get('online''STRING''GET') : '';
        
$avatar            = (isset($_GET['avatar'])) ? $filter->get('avatar''STRING''GET') : '';
        
        
$sql_add        '';
        if (
$username != '') {
            
$sql_add .= ' AND username LIKE ''.$db->escape($username).'%'';
        }
        
        if (
$gender != 'all' && $gender != 'female' && $gender != 'male') {
            
$errors[]    = __('invalid-gender');
            
$gender        '';
        }
            
        if (
$gender != 'all') {
            
$sql_add .= ' AND gender = ''.$db->escape($gender).''';
        }
        
        if (
$relation == 'single' or $relation == 'taken' or $relation == 'open') {
            
$sql_add .= ' AND relation = ''.$db->escape($gender).''';                
        } else if (
$relation != 'all') {
            
$errors[]    = __('invalid-relation');
            
$relation    '';
        }
        
        if (
$country != '') {
            if (!isset(
$countries[$country])) {
                
$errors[] = __('invalid-country');
                
$country  '';
            } else {
                
$sql_add .= ' AND country = ''.$db->escape($countries[$country]).''';
            }
        }
        
        if (
$city != '') {
            
$sql_add .= ' AND city = ''.$db->escape($city).''';
        }
        
        if ((
$age_start !== AND $age_end !== 0) &&
            (
$age_start !== $ucfg['signup_age'] && $age_end !== 99)) {
            
$time        time();
            
$date_start    date('Y-m-d'mktime(00011, (date('Y')-$age_start)));
            
$date_end    date('Y-m-d'mktime(00011, (date('Y')-$age_end)));
            
$sql_add   .= ' AND (birth_date >= ''.date($date_end).'' AND birth_date <= ''.$date_start.'')';
        }
        
        if (
$online == 'yes') {
            
$sql_add .= ' AND online > '.(time()-900);
        }
        
        if (
$avatar == 'yes') {
            
$sql_add .= " AND avatar != ''";
        }
        
        if (
$interested == 'boys' OR $interested == 'girls' OR $interested == 'boys+girls') {
            
$sql_add .= " AND interested = '".$db->escape($interested)."'";
        } elseif (
$interested != 'all') {
            
$errors[]    = __('interested-invalid');
            
$interested    '';
        }
        
        
$page            = (isset($_GET['page'])) ? (int) $_GET['page'] : 1;
        
$sql_count        'SELECT COUNT(*) AS total_users
                           FROM #__user
                           WHERE status = '
1''.$sql_add;
        
$total_users    $db->get_field($sql_count'total_users');
        
$pagination        VPagination::get($page$total_users20);
        
$sql            'SELECT user_id, username, gender, avatar, online
                           FROM #__user
                           WHERE status = '
1''.$sql_add.'
                           ORDER BY user_id DESC
                           LIMIT '
.$pagination['limit'];
        if (!
$users $cache->get($sql3600)) {
            
$db->query($sql);
            if (
$db->affected_rows()) {
                
$users $db->fetch_rows();
                
$cache->store($sql$users3600);
            } else {
                
$users = array();
            }           
        }  
        
    
        
$tpl VF::factory('template');
        
$tpl->menu            'community';
        
$tpl->meta_title    = ($username == '')
            ? 
__('community-meta-title', array($tpl->cfg['site_name']))
            : 
__('community-search', array($tpl->cfg['site_name']));
        
$tpl->meta_desc        __('community-meta-desc', array($tpl->cfg['meta_desc']));
        
$tpl->meta_keys        __('community-meta-keys', array($tpl->cfg['meta_keys']));
        
$tpl->canonical        BASE_URL.'/community/';
        
$tpl->canonicalm     MOBILE_URL.'/community/';
        
$tpl->errors        $errors;
        
$tpl->age_range     array_fill(1875'age');
        
$tpl->countries        $countries;
        
$tpl->username        $username;
        
$tpl->gender        $gender;
        
$tpl->relation        $relation;
        
$tpl->interested    $interested;
        
$tpl->country        $country;
        
$tpl->age_start        $age_start;
        
$tpl->age_end        $age_end;
        
$tpl->city            $city;
        
$tpl->online        $online;
        
$tpl->avatar        $avatar;
        
$tpl->popular        $popular;
        
$tpl->users            $users;
        
$tpl->pagination    $pagination;
        
$tpl->load(array('header''community''footer'));
        
$tpl->display();
    }
}

function 
build_url($order)
{
}
Онлайн: 1
Реклама