Advertisement
Guest User

Untitled

a guest
May 11th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.76 KB | None | 0 0
  1. <?
  2. class Login extends Controller
  3. {
  4.  
  5.     private $params;
  6.     private $username;
  7.     private $password;
  8.     private $user_info;
  9.  
  10.     function Login()
  11.     {
  12.         parent::Controller();
  13.         $this->load->model('login/loginModel');
  14.     }
  15.  
  16.     function Index()
  17.     {
  18.  
  19.         if ($this->auth->check_logged(TRUE) == true){
  20.             redirect('/home', 'refresh');
  21.         } else {
  22.            
  23.             $this->load->helper('form');
  24.    
  25.             if ($_POST) {
  26.    
  27.                 $this->username = $this->input->post('frm-login-user', true);
  28.                 $this->password = $this->input->post('frm-login-pass', true);
  29.    
  30.    
  31.                 if (!empty($this->username) || !empty($this->password)) {
  32.    
  33.                     if ($this->user_info = $this->loginModel->checkLogin($this->username, $this->
  34.                         password)) {
  35.    
  36.                         if ($this->user_info->status == 3) {
  37.    
  38.                             alertSetMsg('Sua conta está identificada como SOB AVISO por motivos administrativos. Infelizmente durante este período você não poderá efetuar a identificação e ter acesso.',
  39.                                 'error');
  40.                             redirect('/login/', 'refresh');
  41.    
  42.                         } elseif ($this->user_info->status == 2) {
  43.    
  44.                             alertSetMsg('Sua conta está identificada como SUSPENSA por motivos administrativos. Aguarde o contato do administrador ou algumas horas para liberação da mesma',
  45.                                 'error');
  46.                             redirect('/login/', 'refresh');
  47.    
  48.    
  49.                         } elseif ($this->user_info->status == 1) {
  50.                            
  51.                             $this->session->set_userdata('user_logged', array('user_id' => $this->user_info->
  52.                                 id, 'user_name' => $this->user_info->name, 'user_email' => $this->user_info->
  53.                                 email, 'user_status' => $this->user_info->status, 'user_privileges' => $this->
  54.                                 user_info->privileges, 'logged' => 1, 'login_start' => date('Y-m-d H:i:s')));
  55.                            
  56.                             redirect('/home/', 'refresh');
  57.    
  58.                         }
  59.                    
  60.                     } else {
  61.                         alertSetMsg("E-mail/Senha inválidos, tente novamente.");
  62.                         redirect('/login/', 'refresh');
  63.                    }
  64.    
  65.                 } else {
  66.                     alertSetMsg("Preencha todos os campos corretamente.");
  67.                     redirect('/login/', 'refresh');
  68.                 }
  69.             } else {
  70.                 $this->load->view('login/login');
  71.             }
  72.         }
  73.     }
  74.  
  75.     function logout()
  76.     {
  77.  
  78.         if ($this->loginModel->logout()) {
  79.  
  80.             redirect('/login/', 'refresh');
  81.  
  82.         } else {
  83.  
  84.             redirect('home/', 'refresh');
  85.  
  86.         }
  87.  
  88.  
  89.     }
  90.  
  91. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement