| Server IP : 103.48.194.25 / Your IP : 216.73.216.74 Web Server : Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/7.4.33 System : Linux VMHostDefault 3.10.0-1160.42.2.el7.x86_64 #1 SMP Tue Sep 7 14:49:57 UTC 2021 x86_64 User : sieuthimay ( 1016) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/khonguyenlieu.vn/public_html/site/controllers/ |
Upload File : |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Dangnhap extends CI_Controller
{
protected $pre_message;
function __construct()
{
parent::__construct();
$this->load->helper('mail') ;
$this->load->model('dangnhap_model','dangnhap');
}
function index()
{
$ses_login = get_ses_login() ;
if(!empty($ses_login)) redirect('thong-tin-tai-khoan.html') ;
if(isset($_POST['bt_submit']))
{
$pass = $this->input->post('cuspass');
$user = $this->input->post('cusmail');
$rs = $this->dangnhap->member_info($user); //trit($rs->cuspass.' - '.md5($pass)) ;
if(count($rs)==1 && ($rs->cuspass==md5($pass)))
{
$_SESSION['ses_login'] = $rs;
redirect('thong-tin-tai-khoan.html');
}
else
{
redirect('dang-nhap.html');
}
}
$data['error'] = $this->session->userdata('error') ;
$log['error'] = '';
$this->session->set_userdata('log') ;
$data['title'] = 'Đăng nhập - Đăng ký mới' ;
$data['page'] = 'dangnhap/login' ;
$this->load->view('html/skin', $data);
}
function register()
{
$data['title'] = 'Đăng nhập - Đăng ký thành viên' ;
if(isset($_POST['bt_submit']))
{
$this->form_validation->set_rules('pass','mật khẩu','trim|required');
$this->form_validation->set_rules('email','Email','trim|required');
if($this->form_validation->run() == FALSE)
{
$this->pre_message = validation_errors();
}
else
{
$req = $this->_frm_register() ;
if($this->dangnhap->register($req))
{
$subject = 'Dang ky tai khoan khonguyenlieu.vn' ;
$content = $this->load->view('dangnhap/mail_register',$req,true);
sendmail($rs->cusname."|".$rs->cusmail, "","", $subject, $content) ;
$rs = $this->dangnhap->member_info($req['cusmail']);
$_SESSION['ses_login'] = $rs;
redirect('thong-tin-tai-khoan.html');
}else{
redirect('dang-nhap.html') ;
}
}
}
redirect('dang-nhap.html') ;
}
function _frm_register()
{
$req['cusmail'] = (string) $this->input->post('email') ;
$req['cuspass'] = md5($this->input->post('pass')) ;
$req['cusname'] = (string) $this->input->post('fullname') ;
$req['address'] = (string) $this->input->post('address') ;
$req['cusphone'] = (string) $this->input->post('phone') ;
$req['dt_create'] = date('Y-m-d H:i:s');
$req['bl_active'] = 1 ;
$cfpass = md5($this->input->post('cfpass')) ;
if($req['cuspass']!=$cfpass)
{
$data['error'] = "Xác nhận mật khẩu không đúng" ;
$this->session->set_userdata($data) ;
redirect('dang-nhap.html');
}
$rs = $this->dangnhap->get_user_by_email($req['cusmail']);
if($rs)
{
$data['error'] = 'Email đã tồn tại trong hệ thống. Nếu đúng là email của bạn, Vui lòng dùng chức năng <a href="'.site.'quen-mat-khau.html">quên mật khẩu</a> để lấy lại mật khẩu.';
$this->session->set_userdata($data) ;
redirect('dang-nhap.html');
}
return $req ;
}
function thanhcong()
{
$data['title'] = 'Đăng ký thành công' ;
$data['cont'] = 'Đăng ký thành công';
$this->site->load('dangnhap/thanhcong', $data,'login') ;
}
function account()
{
$ses_login = get_ses_login() ;
if(empty($ses_login)) redirect('dangnhap') ;
$data['title'] = 'Thông tin thành viên' ;
$this->site->load('dangnhap/account', $data,'login');
}
function lostpass()
{
$data['title'] = 'Quên mật khẩu' ;
if(isset($_POST['bt_submit']))
{
$this->form_validation->set_rules('cusmail','Địa chỉ email','trim|required');
if($this->form_validation->run() == FALSE)
{
$this->pre_message = validation_errors();
}
else
{
$user = $this->input->post('cusmail');
$rs = $this->dangnhap->member_info($user); //trit($rs->cuspass.' - '.md5($pass)) ;
if($rs)
{
$data['cusname'] = $rs->cusname;
$data['cuspass'] = getRandomString(8);
$data['cusmail'] = $rs->cusmail;
$data['login'] = site.'dang-nhap.html';
$req['cuspass'] = md5($data['cuspass']);
$this->dangnhap->save('customer',$req,'cusid',$rs->cusid);
$subject = 'Thong tin dang nhap web khonguyenlieu.vn';
$content = $this->load->view("dangnhap/mail_lost_pass",$data, true);
sendmail($rs->cusname."|".$rs->cusmail, "","", $subject, $content) ;
$this->session->set_flashdata('message','Bạn kiểm tra email. Để lấy thông tin đăng nhập');
redirect('dang-nhap.html');
exit;
}
else
{
$this->session->set_flashdata('message','Không tìm thấy email trong hệ thống.');
redirect('dang-nhap.html');
exit;
}
}
}
$this->site->load_login('dangnhap/lostpass', $data);
}
}
?>