[310] | 1 | <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
---|
[293] | 2 | /**
|
---|
| 3 | * Home Class
|
---|
| 4 | *
|
---|
| 5 | * @author dzungnv02
|
---|
| 6 | *
|
---|
| 7 | */
|
---|
| 8 |
|
---|
[305] | 9 | class Home extends MX_Controller
|
---|
[293] | 10 | {
|
---|
| 11 |
|
---|
[314] | 12 | const TOKENPW = 'violet';
|
---|
| 13 |
|
---|
[293] | 14 | public function __construct()
|
---|
| 15 | {
|
---|
| 16 | parent::__construct();
|
---|
[314] | 17 | $this->load->helper('cookie');
|
---|
| 18 | $this->load->library('session');
|
---|
[293] | 19 | }
|
---|
| 20 |
|
---|
| 21 | public function index()
|
---|
| 22 | {
|
---|
[314] | 23 | $user_info = $this->session->userdata('userInfo');
|
---|
| 24 | if ($user_info)
|
---|
| 25 | {
|
---|
| 26 | redirect('/frontend/home/lectureeditor');
|
---|
| 27 | }else{
|
---|
| 28 | $this->load->view ( 'home');
|
---|
| 29 | if (isset($_POST['submit'])){
|
---|
| 30 | $this->signin();
|
---|
| 31 | }
|
---|
| 32 | }
|
---|
[311] | 33 | }
|
---|
| 34 |
|
---|
| 35 | public function test()
|
---|
| 36 | {
|
---|
[310] | 37 | if (isset($_POST['submit'])){
|
---|
| 38 | $this->signin();
|
---|
| 39 | }
|
---|
[293] | 40 | }
|
---|
| 41 |
|
---|
| 42 | public function signin()
|
---|
| 43 | {
|
---|
[310] | 44 | $username = $this->input->post('username', TRUE);
|
---|
| 45 | $password = $this->input->post('password', TRUE);
|
---|
[314] | 46 | $token = md5($username.self::TOKENPW);
|
---|
[305] | 47 | $this->load->model(array('user_model'));
|
---|
[310] | 48 | $data = $this->user_model->checkLogin('violet', $token, $username, $password);
|
---|
[314] | 49 | $arr_users = explode("&", $data);
|
---|
| 50 | $str_status = "";
|
---|
| 51 | $str_fullname = "";
|
---|
| 52 | $fullname = "";
|
---|
| 53 | for ($i=0; $i<count($arr_users); $i++)
|
---|
| 54 | {
|
---|
| 55 | if (strpos($arr_users[$i], 'status=') !== false)
|
---|
| 56 | {
|
---|
| 57 | $str_status = $arr_users[$i];
|
---|
| 58 | }
|
---|
| 59 | if (strpos($arr_users[$i], 'fullname=') !== false)
|
---|
| 60 | {
|
---|
| 61 | $str_fullname = $arr_users[$i];
|
---|
| 62 | }
|
---|
| 63 | }
|
---|
| 64 | $arr_status = explode("=", $str_status);
|
---|
| 65 | if ($str_fullname != ""){
|
---|
| 66 | $arr_fullname = explode("=", $str_fullname);
|
---|
| 67 | $fullname = $arr_fullname[1];
|
---|
| 68 | }
|
---|
| 69 | $status = (int)$arr_status[1];
|
---|
| 70 | switch($status)
|
---|
| 71 | {
|
---|
| 72 | case 0:
|
---|
| 73 | $userdata = array('username' => $username, "logined_in" => TRUE);
|
---|
| 74 | $this->session->set_userdata('userInfo', $userdata);
|
---|
| 75 | redirect('/frontend/home/lectureeditor');
|
---|
| 76 | break;
|
---|
| 77 | case 1:
|
---|
| 78 | echo "Thiếu thông tin đăng nhập !";
|
---|
| 79 | break;
|
---|
| 80 | case 2:
|
---|
| 81 | echo "Sai username hoặc password !";
|
---|
| 82 | break;
|
---|
| 83 | case 3:
|
---|
| 84 | echo "Sai username hoặc password !";
|
---|
| 85 | break;
|
---|
| 86 | case 4:
|
---|
| 87 | echo "Tài khoản chưa được Activated";
|
---|
| 88 | break;
|
---|
| 89 | case 10:
|
---|
| 90 | echo "Sai Token";
|
---|
| 91 | break;
|
---|
| 92 | default:
|
---|
| 93 | break;
|
---|
| 94 | }
|
---|
[293] | 95 | }
|
---|
| 96 |
|
---|
| 97 | public function signout()
|
---|
| 98 | {
|
---|
| 99 |
|
---|
| 100 | }
|
---|
| 101 |
|
---|
[314] | 102 | public function lectureeditor()
|
---|
| 103 | {
|
---|
| 104 | $this->load->view('lecture_editor');
|
---|
| 105 | }
|
---|
[293] | 106 | }
|
---|
| 107 |
|
---|
| 108 | /* End of file home.php */
|
---|
| 109 | /* Location: ./application/modules/frontend/controllers/home.php */ |
---|