Вход Регистрация
Файл: adultscript-2.0.3-pro/files/mobile/components/user_login.php
Строк: 84
<?php
defined
('_VALID') or die('Restricted Access!');
class 
VComponent_mobile_user_login extends VComponent_mobile_user
{
    public function 
__construct()
    {
        
parent::__construct();
    }

    public function 
render()
    {
        
$errors     = array();
        
$messages   = array();
        
$login       = array(
              
'username' => '',
              
'password' => ''
          
);
        
        if (isset(
$_POST['username'])) {
            
$filter     VF::factory('filter');
            
$username    $filter->get('username');
            
$password    trim($_POST['password']);
            
            if (
$username == '') {
                  
$errors[] = 'Username field cannot be left blank!';
            }
            
            if (
$password == '') {
                  
$errors[] = 'Password field cannot be left blank!';
            }
            
            if (!
$errors) {
                
$db VF::factory('database');
                
$db->query("SELECT u.user_id, u.group_id, u.username, u.password, u.email,
                                   u.name, u.gender, u.birth_date, u.country, u.city,
                                   u.zip, u.avatar, u.login_date, u.verified, u.status,
                                   p.credit, p.start_date, p.end_date, p.status as pstatus
                            FROM #__user AS u
                            LEFT JOIN #__user_premium AS p ON (p.user_id = u.user_id)
                            WHERE u.username = '"
.$db->escape($username)."'
                            LIMIT 1"
);
                if (
$db->affected_rows()) {
                      
$user    $db->fetch_assoc();
                      if (
VHash::check($password$user['password'])) {
                          
$status = (int) $user['status'];
                        if (
$status === 0) {
                            
$errors[]   = __('account-suspended');
                        } elseif (
$status === 2) {
                            
$errors[]   = __('account-approve');
                        } elseif (
$user['verified'] == '0' && VF::cfg_item('module.user.user_confirm')) {
                            
$errors[]   = __('account-confirm');
                        } else {
                            
$date                   date('Y-m-d h:i:s');
                            
$time                   time();
                            
$ip                        VServer::ip(true);

                            
$_SESSION['user_id']    = (int) $user['user_id'];
                            
$_SESSION['group_id']   = (int) $user['group_id'];
                            
$_SESSION['username']   = $user['username'];
                            
$_SESSION['email']      = $user['email'];
                            
$_SESSION['name']       = $user['name'];
                            
$_SESSION['gender']     = $user['gender'];
                            
$_SESSION['birth_date'] = $user['birth_date'];
                            
$_SESSION['avatar']     = $user['avatar'];
                            
$_SESSION['country']    = $user['country'];
                            
$_SESSION['city']       = $user['city'];
                            
$_SESSION['zip']        = $user['zip'];
                            
$_SESSION['login_date'] = $user['login_date'];
                            
$_SESSION['verified']   = (int) $user['verified'];
                            
$_SESSION['status']     = $status;
                            
$_SESSION['credit']     = $user['credit'];
                            
$_SESSION['start_date'] = $user['start_date'];
                            
$_SESSION['end_date']   = $user['end_date'];                            
                            
$_SESSION['message']    = __('welcome').' '.$user['username'].'!';
                            
                            if (
VModule::enabled('premium')) {
                                
$system VF::cfg_item('module.payment.system');
                                if (
$system == 'subscription') {
                                    
$end_time   strtotime($user['end_date']);
                                    if (
$end_time $time OR empty($user['pstatus'])) {
                                        
$group_id   VAuth::get_group_id('Registered');
                                        
$db->query("UPDATE #__user
                                                    SET group_id = "
.$group_id."
                                                    WHERE user_id = "
.$user_id."
                                                    LIMIT 1"
);
                
                                        
$_SESSION['group_id'] = $group_id;
                                    }
            
                                    
$ip VServer::ip(true);
                                    
$db->query("SELECT user_id
                                                FROM #__user_premium_ips
                                                WHERE user_id = "
.(int) $user_id."
                                                AND ip = "
.$ip."
                                                LIMIT 1"
);
                                    if (!
$db->affected_rows()) {
                                        
$db->query("INSERT INTO #__user_premium_ips
                                                    SET user_id = "
.(int) $user_id.",
                                                        ip = "
.$ip);
                                    }
                                }
                            }

                            
$db->query("UPDATE #__user
                                        SET login_ip = "
.$ip.",
                                            login_date = '"
.$date."',
                                            online = "
.$time."
                                        WHERE user_id = "
.$_SESSION['user_id']."
                                        LIMIT 1"
);
                            
                            
$URL MOBILE_URL;
                            if (isset(
$_SESSION['redirect'])) {
                                
$URL $_SESSION['redirect'];
                            }
                            
                            
VF::redirect($URL);
                        }
                      } else {
                        
$errors[] = __('login-failed');
                      }
                } else {
                    
$errors[] = __('login-failed');
                }            
            }            
        }
        
        
$this->tpl->menu        'community';
        
$this->tpl->title       __('login-title');
        
$this->tpl->meta_title    __('login-title');
        
$this->tpl->meta_desc    $this->mcfg['meta_desc'];
        
$this->tpl->meta_keys    $this->mcfg['meta_keys'];
        
$this->tpl->canonical    BASE_URL.'/user/login/';
        
$this->tpl->errors        $errors;
        
$this->tpl->messages    $messages;
        
$this->tpl->login        $login;
        
$this->tpl->load(array('header''user_login''footer'));
        
$this->tpl->display();
    }
}
Онлайн: 1
Реклама