ÿØÿà JFIF ` ` ÿþ
|
Server : Apache/2.4.58 (Ubuntu) mod_fcgid/2.3.9 OpenSSL/3.0.13 System : Linux cpanel4.trivietit.net 6.8.0-85-generic #85-Ubuntu SMP PREEMPT_DYNAMIC Thu Sep 18 15:26:59 UTC 2025 x86_64 User : cungcapmhutbui ( 1010) PHP Version : 5.6.40-86+ubuntu24.04.1+deb.sury.org+1 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,exec,system,passthru,shell_exec,proc_open,popen Directory : /home/cungcapmhutbui/web/cungcapmayhutbui.com/public_html/system/application/controllers/ |
Upload File : |
<?php
require_once('indexcontroller.php');
class Users extends IndexController{
public function __construct(){
parent::__construct();
}
public function profile(){
if(!isset($_SESSION['userInfo'])||$_SESSION['userInfo']==FALSE)
redirect(base_url().'login.html');
$config = array(
array('field' => 'fullname',
'label' => lang('fullname'),
'rules' => 'required|xss_clean'),
array('field' => 'addres',
'label' => '',
'rules' => 'xss_clean'),
array('field' => 'newPass',
'label' => 'Mật khẩu mới',
'rules' => 'xss_clean|min_length[6]|matches[confirm]'),
array('field' => 'confirm',
'label' => 'Xác nhận mật khẩu',
'rules' => 'xss_clean|matches[newPass]'),
array('field' => 'telephone',
'label' => lang('telephone'),
'rules' => 'numeric'),
array('field' => 'email',
'label' => 'Email',
'rules' => 'required|valid_email|xss_clean')
);
if (!empty($_POST)) {
foreach ($_POST as $k => $v) {
$_POST[$k] = htmlentities($v);
}
}
$this->load->library('form_validation');
$this->form_validation->set_rules($config);
$this->form_validation->set_message('required','%s - '.lang('not_empty'));
$this->form_validation->set_message('valid_email','%s - '.lang('invalid'));
$this->form_validation->set_message('numeric','%s - '.lang('invalid'));
$this->form_validation->set_message('min_length','%s - Tối thiểu 6 ký tự');
$this->form_validation->set_message('matches','Xác nhận mật khẩu không đúng');
$this->form_validation->set_error_delimiters('<p class="error">', '</p>');
if($this->form_validation->run()==FALSE){
$this->data['error_fullname'] = form_error('fullname');
$this->data['error_tel'] = form_error('telephone');
$this->data['error_email'] = form_error('email');
$this->data['error_newPass'] = form_error('newPass');
$this->data['error_confirm'] = form_error('confirm');
}
else {
$this->load->model('admin/users_m');
$newPass = $this->input->post('newPass');
$confirm = $this->input->post('confirm');
if($newPass)
$password = md5($newPass);
else
$password = $_SESSION['userInfo']->password;
$data = array(
'fullname' => $this->input->post('fullname'),
'cell' => $this->input->post('telephone'),
'password' => $password,
'email' => $this->input->post('email'),
'address' => $this->input->post('address')
);
$id = $_SESSION['userInfo']->id;
if ($this->users_m->editData($data,$id) == 1) {
$_SESSION['userInfo']->fullname = $data['fullname'];
$_SESSION['userInfo']->cell = $data['cell'];
$_SESSION['userInfo']->email = $data['email'];
$_SESSION['userInfo']->address = $data['address'];
$this->data['update_profile'] = lang('update_profile_success');
}
}
$this->index('users/profile','Thông tin cá nhân');
}
public function register(){
if (isset($_SESSION['userInfo']) && $_SESSION['userInfo'] == true) {
redirect(base_url().'profile.html');
}
$config = array(
array('field' => 'fullname',
'label' => lang('fullname'),
'rules' => 'required|xss_clean'),
array('field' => 'addres',
'label' => '',
'rules' => 'xss_clean'),
array('field' => 'telephone',
'label' => lang('telephone'),
'rules' => 'numeric'),
array('field' => 'email',
'label' => 'Email',
'rules' => 'required|valid_email|xss_clean'),
array('field' => 'username',
'label' => lang('username'),
'rules' => 'required|xss_clean|trim()|min_length[4]|max_length[20]|alpha_dash|callback_check_username'),
array('field' => 'password',
'label' => lang('password'),
'rules' => 'required|xss_clean|min_length[6]|max_length[20]|md5|trim()'),
array('field' => 'confirm_pass',
'label' => lang('confirm_pass'),
'rules' => 'required|xss_clean|matches[password]'),
array('field' => 'security',
'label' => lang('security'),
'rules' => 'required|callback_check_security_code')
);
if (!empty($_POST)) {
foreach ($_POST as $k => $v) {
$_POST[$k] = htmlentities($v);
}
}
$this->load->library('form_validation');
$this->check_username($this->input->post('username'));
$this->check_security_code($this->input->post('security'));
$this->form_validation->set_rules($config);
$this->form_validation->set_message('required','%s - '.lang('not_empty'));
$this->form_validation->set_message('valid_email','%s - '.lang('invalid'));
$this->form_validation->set_message('numeric','%s - '.lang('invalid'));
$this->form_validation->set_message('matches','%s - '.lang('wrong'));
$this->form_validation->set_message('alpha_dash','%s - '.lang('alpha_dash'));
$this->form_validation->set_message('min_length','%s - '.lang('min_length'));
$this->form_validation->set_message('max_length','%s - '.lang('max_length'));
$this->form_validation->set_message('check_username','%s - '.lang('username_used'));
$this->form_validation->set_message('check_security_code','%s - '.lang('wrong'));
$this->form_validation->set_error_delimiters('<p class="error">', '</p>');
if ($this->form_validation->run() == FALSE) {
$this->data['error_fullname'] = form_error('fullname');
$this->data['error_tel'] = form_error('telephone');
$this->data['error_email'] = form_error('email');
$this->data['error_pass'] = form_error('password');
$this->data['error_confirm_pass'] = form_error('confirm_pass');
$this->data['error_username'] = form_error('username');
$this->data['error_security'] = form_error('security');
}
else {
$this->load->model('admin/users_m');
$data = array('tid' => 1,
'username' => $this->input->post('username'),
'password' => $this->input->post('password'),
'fullname' => $this->input->post('fullname'),
'cell' => $this->input->post('telephone'),
'email' => $this->input->post('email'),
'address' => $this->input->post('address'),
'date_created' => date('Y-m-d'),
'last_login' => '',
'status' => 1,
'code' => ''
);
if ($this->users_m->addData($data)) {
$this->data['fullname'] = $this->input->post('fullname');
$this->index('users/login', lang('register_success'));
}
unset($_SESSION['captcha']);
}// end els
$this->index('users/register','Đăng ký');
}
public function check_username($username){
$this->load->model('admin/users_m');
if($this->users_m->checkExist('username',$username) ==1)
return false;
else
return true;
}
public function check_security_code($code){
include_once(ROOT_PATH."/captcha/authimg.php");
$AuthImage = new AuthImage();
if(strtolower($_SESSION['captcha'])!=strtolower($code))
return false;
else
return true;
}
public function login(){
if(isset($_SESSION['userInfo'])&& $_SESSION['userInfo']==true)
redirect(base_url().'profile.html');
$configs = array(array('field' => 'username',
'label' => lang('username'),
'rules' => 'required|xss_clean|trim()'),
array('field' => 'password',
'label' => lang('password'),
'rules' => 'required|xss_clean|trim()')
);
$this->load->library('form_validation');
$this->form_validation->set_rules($configs);
$this->form_validation->set_message('required','Chưa nhập %s');
$this->form_validation->set_error_delimiters('<p class="error">','</p>');
if($this->form_validation->run()==FALSE){
$this->data['error_login_user'] = form_error('username');
$this->data['error_login_pass'] = form_error('password');
}
else{
$this->load->model('admin/users_m');
$username = $this->input->post('username');
$password = $this->input->post('password');
$userInfo = $this->users_m->checkAcountCustomer($username,$password);
if($userInfo){
$_SESSION['userInfo'] = $userInfo;
redirect($_SERVER['HTTP_REFERER']);
}
else
$this->data['error_login'] =lang('username_pass_wrong');
}
$this->index('users/login',lang('login'));
}
public function logout(){
if(isset($_SESSION['userInfo']))
unset($_SESSION['userInfo']);
//redirect(base_url().'index.html');
redirect($_SERVER['HTTP_REFERER']);
}
public function changePass(){
$this->index();
}
}
?>