| Server IP : 103.48.194.25 / Your IP : 216.73.217.33 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 : 8.2.20 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/hocthongminh.net-bk/public_html/site/controllers/ |
Upload File : |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class profile extends CI_Controller
{
protected $_templates;
protected $account ;
function __construct()
{
parent::__construct();
$this->load->model('profile_model','profile');
$this->account = get_ses_login() ;
if(empty($this->account)) redirect('dangnhap');
}
public function index()
{
$data['msg'] = '';
if(isset($_POST['bt_submit']))
{
$this->form_validation->set_rules('cusname','Họ tên','trim|required');
$this->form_validation->set_rules('address','Địa chỉ','trim|required');
$this->form_validation->set_rules('cusphone','Điện thoại','trim|required');
if($this->form_validation->run()== FALSE){
$this->pre_message = validation_errors();
}else{
$req = $this->_build_form();
if($this->profile->save($req, $this->account->cusid))
{
redirect('profile');
//$data['msg'] = 'Đã cập nhật';
}
}
}
$data['title'] = 'Thông tin thành viên' ;
$data['cusname'] = $this->account->cusname ;
// $data['op_town'] = op_town() ;
$data['rs'] = $this->profile->get_id($this->account->cusid) ;
$this->site->load('profile/account', $data,'login');
}
function _build_form()
{
$req['cusmail'] = $this->input->post('cusmail') ;
$req['cusname'] = $this->input->post('cusname') ;
$req['address'] = $this->input->post('address') ;
$req['cusphone'] = $this->input->post('cusphone') ;
$req['gender'] = $this->input->post('gender') ;
$req['birthday'] = datevn2mysql($this->input->post('birthday')) ;
$req['town_id'] = $this->input->post('town_id') ;
$req['dt_modify'] = date('Y-m-d H:i:s') ;
$req['bl_active'] = 1 ;
return $req ;
}
function changepass()
{
$data['error'] = '' ;
$data['title'] = 'Đổi mật khẩu' ;
if(isset($_POST['bt_submit']))
{
$this->form_validation->set_rules('oldpass','Mật khẩu cũ','trim|required');
$this->form_validation->set_rules('newpass','Mật khẩu mới','trim|required');
$this->form_validation->set_rules('cfpass','Xác nhận','trim|required');
if($this->form_validation->run()== FALSE){
$this->pre_message = validation_errors();
}else{
$req['oldpass'] = $this->input->post('oldpass') ;
$req['newpass'] = $this->input->post('newpass') ;
$req['cfpass'] = $this->input->post('cfpass') ;
if($req['newpass']==$req['cfpass'])
{
$rs = $this->profile->get_id($this->account->cusid);
if(md5($req['oldpass'])==$rs->cuspass)
{
if($this->profile->update_password($this->account->cusid))
redirect('profile') ;
}
else $data['error'] = 'Nhập mật khẩu không đúng' ;
}
else $data['error'] = 'Xác nhận mật khẩu không trùng khớp' ;
}
}
$data['cusname'] = $this->account->cusname ;
$this->site->load('profile/changepass', $data,'login');
}
function shopping()
{
$data['title'] = 'Shopping cart' ;
$data['cusname'] = $this->account->cusname ;
$this->site->load('profile/shopping', $data, 'login');
}
function sendcart()
{
$this->load->model('sanpham_model','sanpham');
if(!empty($this->account))
{
$oid = time();
$cart = get_ses_cart() ;
for($i=0;$i<count($cart);$i++)
{
$req = $this->_frm_cart($i, $cart, $oid, $this->account->cusid) ;
$this->sanpham->save_cart($req);
}
$this->load->helper('mail') ;
$subject = 'Dat hang tại www.quatangmythuat.com';
$content = 'Bạn đã đặt hàng thành công tại <a href="http://www.quatangmythuat.com">www.quatangmythuat.com</a><br><br><br>
Click vào link dưới đay để xác nhận lại:<br>
<a href="http://www.quatangmythuat.com/confirm/order/'.$oid.'">www.quatangmythuat.com/confirm/order/'.$oid.'</a><br>
<br>
Cảm ơn bạn đã đặt hàng tại <a href="http://www.quatangmythuat.com">www.quatangmythuat.com</a>.<br>
Chúc sức khõe.';
sendmail($this->account->cusmail, $this->account->cusname, $subject, $content) ;
//sendmail($req['cusmail'], $req['cusname'], $subject, $content) ;
sendmail('quatangmythuat@gmail.com', 'www.quatangmythuat.com', 'Dat hang tai www.quatangmythuat.com', 'Co đơn hang moi tai www.quatangmythuat.com') ;
$_SESSION['cart'] = array();
redirect('profile/thanhcong') ;
}
}
function _frm_cart($i, $cart, $oid='', $cusid='')
{
$data['oid'] = $oid ;
$data['cusid'] = $this->account->cusid ;
$data['cusname'] = $this->account->cusname ;
$data['address'] = $this->account->address ;
$data['email'] = $this->account->cusmail ;
$data['phone'] = $this->account->cusphone ;
$data['proid'] = $cart[$i]['proid'] ;
$data['pro_name'] = $cart[$i]['pro_name'] ;
$data['pro_img'] = $cart[$i]['pro_img'] ;
$data['pro_price'] = $cart[$i]['pro_price'] ;
$data['nb_order'] = $cart[$i]['nb_order'] ;
$data['bl_name'] = $this->input->post('bl_name') ;
$data['bl_address'] = $this->input->post('bl_address') ;
$data['bl_email'] = $this->input->post('bl_email') ;
$data['bl_phone'] = $this->input->post('bl_phone') ;
$data['cusnote'] = $this->input->post('bl_note') ;
$data['dt_create'] = date('Y-m-d H:i:s') ;
$data['dt_modify'] = date('Y-m-d H:i:s') ;
return $data ;
}
function thanhcong()
{
$data['title'] = 'Đặt hàng thành công' ;
$data['cont'] = 'Cảm ơn bạn đã mua hàng tại website. Chúng tôi sẽ liên hệ trong thời gian sớm nhất';
$this->site->load('sanpham/thanhcong', $data,'product') ;
}
function nguoinhan()
{
$data['title'] = 'Người nhận quà' ;
$data['cusname'] = $this->account->cusname ;
$this->site->load('profile/form', $data,'login');
}
function history()
{
$data['title'] = 'Lịch sử mua hàng' ;
$data['cusname'] = $this->account->cusname ;
$data['list'] = $this->profile->get_history($this->account->cusid);
$this->site->load('profile/history', $data,'login');
}
}
?>