Вход Регистрация
Файл: adultscript-2.0.3-pro/files/mobile/components/user_profile.php
Строк: 133
<?php
defined
('_VALID') or die('Restricted Access!');
class 
VComponent_mobile_user_profile 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'];
        
$countries  VCountry::get();
        
$locked        $this->is_locked($user_id);
        
        if (
$locked) {
            
$errors[] = __('account-locked');
        }

        if (isset(
$_POST['submit-profile']) && !$locked) {
              
$filter VF::factory('filter');
            
$name           $filter->get('name');
            
$birth_day      $filter->get('day''INTEGER');
            
$birth_month    $filter->get('month''INTEGER');
            
$birth_year     $filter->get('year''INTEGER');
            
$gender         $filter->get('gender');
            
$relation       $filter->get('relation');
            
$interested     $filter->get('interested');
            
$country        $filter->get('country');
            
$city           $filter->get('city');
            
$zip            $filter->get('zip');
            
$website        $filter->get('website');
            
$company        $filter->get('company');
            
$school         $filter->get('school');
            
$occupation     $filter->get('occupation');
            
$about          $filter->get('about');
            
$hobbies        $filter->get('hobbies');
            
$movies         $filter->get('movies');
            
$music          $filter->get('music');
            
$books          $filter->get('books');
            
$turn_on        $filter->get('turn_on');
            
$turn_off       $filter->get('turn_off');

            
$birth_date = (isset($_SESSION['birth_date'])) ? $_SESSION['birth_date'] : '0000-00-00';
            if (
$birth_day !== OR $birth_month !== OR $birth_year !== 0) {
                if (
$birth_day === OR $birth_month === OR $birth_year === 0) {
                    
$errors[] = __('birthdate-imcomplete');
                } else {
                    if (!
checkdate($birth_month$birth_day$birth_year)) {
                        
$errors[] = __('birthdate-invalid');
                    } else {
                        
$birth_date $birth_year.'-'.sprintf('%02d'$birth_month).'-'.sprintf('%02d'$birth_day);
                    }
                }
            }

            if (
$website != '') {
                if (!
VValid::url($website)) {
                        
$errors[] = __('website-invalid');
                }
            }

            if (
$gender != 'hidden') {
                if (!
in_array($gender, array('male''female'))) {
                        
$errors[] = __('gender-invalid');
                }
            }

            if (
$relation != 'hidden') {
                if (!
in_array($relation, array('single''taken''open'))) {
                        
$errors[] = __('relation-invalid');
                }
            }

            if (
$interested != 'hidden') {
                if (!
in_array($interested, array('boys''girls''boys+girls'))) {
                        
$errors[] = __('interested-invalid');
                }
            }

            if (
$country != '') {
                
$country = (isset($countries[$country])) ? $countries[$country] : '';
                if (
$country == '') {
                        
$errors[] = __('country-invalid');
                }
            }

            if (!
$errors) {
                
$this->db->query("UPDATE #__user
                                    SET name = '"
.$this->db->escape($name)."',
                                        birth_date = '"
.$this->db->escape($birth_date)."',
                                        gender = '"
.$this->db->escape($gender)."',
                                        relation = '"
.$this->db->escape($relation)."',
                                        interested = '"
.$this->db->escape($interested)."',
                                        country = '"
.$this->db->escape($country)."',
                                        city = '"
.$this->db->escape($city)."',
                                        zip = '"
.$this->db->escape($zip)."'
                                    WHERE user_id = "
.$user_id."
                                    LIMIT 1"
);
                
$this->db->query("UPDATE #__user_profile
                                    SET about = '"
.$this->db->escape($about)."',
                                        website = '"
.$this->db->escape($website)."',
                                        occupation = '"
.$this->db->escape($occupation)."',
                                        school = '"
.$this->db->escape($school)."',
                                        company = '"
.$this->db->escape($company)."',
                                        hobbies = '"
.$this->db->escape($hobbies)."',
                                        movies = '"
.$this->db->escape($movies)."',
                                        music = '"
.$this->db->escape($music)."',
                                        books = '"
.$this->db->escape($books)."',
                                        turn_on = '"
.$this->db->escape($turn_on)."',
                                        turn_off = '"
.$this->db->escape($turn_off)."'
                                    WHERE user_id = "
.$user_id."
                                    LIMIT 1"
);

                
$_SESSION['name']       = $name;
                
$_SESSION['birth_date'] = $birth_date;
                
$_SESSION['gender']     = $gender;
                
$_SESSION['country']    = $country;
                
$_SESSION['city']       = $city;
                
$_SESSION['zip']        = $zip;

                
$messages[] = __('profile-success');
            }
        }

        
$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        'profile';
        
$this->tpl->title       __('profile-title');
        
$this->tpl->active        $active;
        
$this->tpl->errors        $errors;
        
$this->tpl->messages    $messages;
        
        
$this->tpl->profile        $profile;
        
$this->tpl->countries    $countries;
        
        
$this->tpl->load(array('header''user_profile''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);
    }
}
Онлайн: 2
Реклама