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

    public function 
render()
    {
        
VAuth::check('Registered'MOBILE_URL.'/user/login/');

        
VLanguage::load('frontend.user');
    
        
$errors     = array();
        
$messages   = array();
        
$active        'information';
        
$user_id    = (int) $_SESSION['user_id'];
        
$locked        $this->is_locked($user_id);
        
        if (
$locked) {
            
$errors[] = __('account-locked');
        }
        
        if (isset(
$_POST['submit-account']) && !$locked) {
              
$filter            VF::factory('filter');
              
$username        $filter->get('username');
              
$email            $filter->get('email');
              
$password        trim($_POST['password']);
              
$password_c        trim($_POST['passwordr']);

            
$ucfg    VF::cfg('module.user');
            if (
$username == '') {
                
$errors[]   = __('username-empty');
            } elseif (!
VValid::length($username1$ucfg['username_max_length'])) {
                
$errors[]   = __('username-length', array($ucfg['username_max_length']));
            } elseif (!
VValid::aldash($username)) {
                
$errors[]   = __('username-invalid');;
            } else {
                if (
$ucfg['account_username_change'] == '1') {
                      
$this->db->query("SELECT user_id
                                      FROM #__user
                                      WHERE username = '"
.$this->db->escape($username)."'
                                      AND user_id != "
.$user_id."
                                      LIMIT 1"
);
                      if (
$this->db->affected_rows()) {
                          
$errors[] = __('username-used');
                      }
                } elseif (
$username != $_SESSION['username']) {
                      
$errors[] = __('username-changed');
                  }
            }
            
            if (
$email == '') {
                  
$errors[]   = __('email-empty');
              } elseif (!
VValid::email($email)) {
                  
$errors[]   = __('email-invalid');
              } else {
                  
$this->db->query("SELECT user_id
                                    FROM #__user
                                    WHERE email = '"
.$this->db->escape($email)."'
                                    AND user_id != "
.$user_id."
                                    LIMIT 1"
);
                  if (
$this->db->affected_rows()) {
                      
$errors[] = __('email-used');
                  }
              }
            
              if (
$password != '') {
                  if (
$password != $password_c) {
                      
$errors[] = __('password-mismatch');
                  }
              }
            
            if (!
$errors) {
                  
$sql_add '';
                if (
$password != '') {
                      
$sql_add ", password = '".VHash::encrypt($password)."'";
                }
       
                
$this->db->query("UPDATE #__user
                                  SET username = '"
.$this->db->escape($username)."',
                                      email = '"
.$this->db->escape($email)."'".$sql_add."
                                  WHERE user_id = "
.$user_id."
                                  LIMIT 1"
);
                
                
$_SESSION['username']    = $username;
                
$_SESSION['user']        = $email;        
                                  
                
$messages[] = __('account-success');
            }
            
              
$active    'account';
        }

        
$this->db->query("SELECT u.user_id, u.username, u.email, u.name, u.gender, u.relation, u.interested,
                           u.birth_date, u.country, u.city, u.zip, up.about, up.website, up.hobbies,
                           up.occupation, up.school, up.company, up.movies, up.music, up.books,
                           up.turn_on, up.turn_off, ua.total_viewed_videos
                    FROM #__user AS u
                    LEFT JOIN #__user_profile AS up ON (up.user_id = u.user_id)
                    LEFT JOIN #__user_activity AS ua ON (ua.user_id = u.user_id)
                    WHERE u.user_id = "
.$user_id."
                    LIMIT 1"
);
        if (!
$this->db->affected_rows()) {
              
$errors[] = 'Invalid username! Application error!?';
        }
        
        
$profile    $this->db->fetch_assoc();
        
        
$this->tpl->menu        'community';
        
$this->tpl->submenu        'account';
        
$this->tpl->title       __('account-title');
        
$this->tpl->active        $active;
        
$this->tpl->errors        $errors;
        
$this->tpl->messages    $messages;
        
        
$this->tpl->profile        $profile;
        
        
$this->tpl->load(array('header''user_account''footer'));
        
$this->tpl->display();
    }
    
    private function 
is_locked($user_id)
    {
        
$this->db->query("SELECT locked FROM #__user WHERE user_id = ".$user_id." LIMIT 1");
        if (
$this->db->affected_rows()) {
            return (bool) 
$this->db->fetch_field('locked');
        }

        
VModule::load('error'true);
    }
}
Онлайн: 3
Реклама