[503] | 1 | <?php
|
---|
[556] | 2 | if (! defined ( 'BASEPATH' ))
|
---|
| 3 | exit ( 'No direct script access allowed' );
|
---|
[503] | 4 |
|
---|
[293] | 5 | /**
|
---|
| 6 | * Home Class
|
---|
[556] | 7 | *
|
---|
[293] | 8 | * @author dzungnv02
|
---|
[556] | 9 | *
|
---|
[293] | 10 | */
|
---|
[503] | 11 | class Home extends MX_Controller {
|
---|
[556] | 12 | const TOKENPW = 'violet';
|
---|
| 13 | public function __construct() {
|
---|
| 14 | parent::__construct ();
|
---|
| 15 | $this->load->helper ( 'cookie' );
|
---|
[636] | 16 | $this->load->helper('language');
|
---|
| 17 | $this->lang->load('messages', 'message');
|
---|
[556] | 18 | }
|
---|
| 19 |
|
---|
| 20 | public function index() {
|
---|
| 21 | $user_info = $this->session->userdata ( 'userInfo' );
|
---|
| 22 | if ($user_info) {
|
---|
| 23 | redirect ( '/frontend/lecture' );
|
---|
| 24 | } else {
|
---|
| 25 | $cookie_name = "siteCookie";
|
---|
| 26 | if (isset ( $_COOKIE [$cookie_name] )) {
|
---|
| 27 | $arr_user = parse_str ( $_COOKIE [$cookie_name] );
|
---|
| 28 | $user_info = array (
|
---|
| 29 | 'username' => $arr_user ['username'],
|
---|
| 30 | 'user' => $arr_user ['user'],
|
---|
| 31 | 'us_id' => $arr_user ['us_id'],
|
---|
[671] | 32 | 'is_viettel' => $arr_user ['is_viettel'],
|
---|
[556] | 33 | 'logined_in' => TRUE
|
---|
| 34 | );
|
---|
| 35 | $this->session->set_userdata ( 'userInfo', $user_info );
|
---|
| 36 | redirect ( '/frontend/lecture' );
|
---|
| 37 | } else {
|
---|
| 38 | $this->load->view ( 'home' );
|
---|
| 39 | }
|
---|
| 40 | }
|
---|
| 41 | }
|
---|
| 42 |
|
---|
| 43 | public function signin() {
|
---|
| 44 | $username = $this->input->post ( 'username', TRUE );
|
---|
| 45 | $password = $this->input->post ( 'password', TRUE );
|
---|
| 46 | $autologin = ($this->input->post ( 'remember_me' ) == 'on') ? 1 : 0;
|
---|
[540] | 47 | $src = 'SBG';
|
---|
[556] | 48 | $token = md5 ( $username . self::TOKENPW );
|
---|
| 49 | $this->load->model ( array (
|
---|
| 50 | 'user_model'
|
---|
| 51 | ) );
|
---|
[633] | 52 | $result = $this->user_model->checkLogin ( $src, $token, $username, $password );
|
---|
| 53 | if ($result['success'] == -1)
|
---|
| 54 | {
|
---|
| 55 | $this->session->set_flashdata ( 'login_api_error', TRUE );
|
---|
| 56 | redirect ( '/frontend/home' );
|
---|
| 57 |
|
---|
| 58 | }else if ($result['success'] == 0)
|
---|
| 59 | {
|
---|
[556] | 60 | $this->session->set_flashdata ( 'login_error', TRUE );
|
---|
| 61 | redirect ( '/frontend/home' );
|
---|
[633] | 62 | }else{
|
---|
| 63 | parse_str ( $result['data'] );
|
---|
[556] | 64 | $is_viettel = $this->is_viettel ( $phone );
|
---|
[633] | 65 | if ($autologin == 1) {
|
---|
| 66 | $cookie_name = 'siteCookie';
|
---|
| 67 | // $cookie_time = 7200;
|
---|
| 68 | $cookie_time = 3600 * 24 * 30;
|
---|
| 69 | setcookie ( $cookie_name, 'username=' . $username . '&user=' . $result['data'] . '&us_id=' . $id, time () + $cookie_time );
|
---|
[556] | 70 | }
|
---|
[633] | 71 | $userdata = array (
|
---|
| 72 | 'username' => $username,
|
---|
| 73 | 'user' => $result['data'],
|
---|
| 74 | 'us_id' => $id,
|
---|
| 75 | 'logined_in' => TRUE,
|
---|
| 76 | 'is_viettel' => $is_viettel
|
---|
| 77 | );
|
---|
| 78 | $this->session->set_userdata ( 'userInfo', $userdata );
|
---|
| 79 | redirect ( '/frontend/lecture' );
|
---|
[556] | 80 | }
|
---|
| 81 | }
|
---|
[540] | 82 |
|
---|
[556] | 83 | public function signout() {
|
---|
| 84 | $this->session->sess_destroy ();
|
---|
| 85 | // unset($this->session->userdata);
|
---|
| 86 | $cookie_name = "siteCookie";
|
---|
| 87 | setcookie ( $cookie_name, 'username=' . "", time () - 3600 );
|
---|
| 88 | redirect ( '/frontend/home' );
|
---|
| 89 | }
|
---|
| 90 |
|
---|
| 91 | public function register() {
|
---|
| 92 | $this->load->model ( 'user_model' );
|
---|
[636] | 93 | $collaborator = '0979947802';
|
---|
[556] | 94 | $serviceID = 1;
|
---|
[636] | 95 | $username = '0978618113';
|
---|
[556] | 96 | $commandcode = 'commandcode1';
|
---|
| 97 | $info = 'ABCD';
|
---|
| 98 | // $receiveTime = time();
|
---|
| 99 | $receiveTime = date ( "Y-m-d H:i:s" );
|
---|
[636] | 100 | $data = $this->user_model->register ( $username, $collaborator );
|
---|
[556] | 101 | echo $data;
|
---|
| 102 | }
|
---|
| 103 |
|
---|
| 104 | public function change_profile() {
|
---|
| 105 | $this->load->model ( 'user_model' );
|
---|
| 106 | $sentNumber = '0979947802';
|
---|
| 107 | $serviceID = 1;
|
---|
[636] | 108 | $password = '2933369';
|
---|
[556] | 109 | $commandcode = "SBG";
|
---|
[590] | 110 | $receiveID = '0977274183';
|
---|
[556] | 111 | $info = "SBG TD";
|
---|
| 112 | $receiveTime = date ( "Y-m-d H:i:s" );
|
---|
| 113 | $status = 0;
|
---|
| 114 | $data = $this->user_model->changeProfile ( $sentNumber, $receiveID, $password, $status );
|
---|
| 115 | echo $data;
|
---|
| 116 | }
|
---|
| 117 |
|
---|
| 118 | public function change_password() {
|
---|
| 119 | $this->load->model ( 'user_model' );
|
---|
[625] | 120 | $sentNumber = '0979947802';
|
---|
| 121 | $password = '935322';
|
---|
| 122 | $data = $this->user_model->changePassword ( $sentNumber, $password );
|
---|
[556] | 123 | echo $data;
|
---|
| 124 | }
|
---|
| 125 |
|
---|
| 126 | public function register_vip() {
|
---|
| 127 | $this->load->model ( 'user_model' );
|
---|
[590] | 128 | $sentNumber = '0979947802';
|
---|
| 129 | $p_code = 1;
|
---|
[556] | 130 | $serviceID = 1;
|
---|
| 131 | $commandcode = "SBG";
|
---|
[540] | 132 | $vipNum = 1;
|
---|
| 133 | $mainAccBalanced = 15000;
|
---|
| 134 | $info = "SBG DK VIP1";
|
---|
[556] | 135 | $receiveTime = date ( "Y-m-d H:i:s" );
|
---|
[540] | 136 | $status = 0;
|
---|
[590] | 137 | $data = $this->user_model->registerVip ( $sentNumber, $p_code );
|
---|
[540] | 138 | echo $data;
|
---|
| 139 | }
|
---|
| 140 |
|
---|
[556] | 141 | public function recharge_account() {
|
---|
| 142 | $this->load->model ( 'user_model' );
|
---|
[540] | 143 | $sentNumber = '0979947802';
|
---|
| 144 | $receiveID = '01662860000';
|
---|
| 145 | $serviceID = 1;
|
---|
| 146 | $commandcode = "SBG";
|
---|
| 147 | $vipNum = 1;
|
---|
| 148 | $mainAccBalanced = 15000;
|
---|
[636] | 149 | $amount = 1000;
|
---|
| 150 | $info = "SBG NAP 10000";
|
---|
[540] | 151 | $status = 0;
|
---|
[590] | 152 | $receiveTime = date ( "Y-m-d H:i:s" );
|
---|
[636] | 153 | $data = $this->user_model->rechargeAccount ( $sentNumber, $amount );
|
---|
| 154 | //$data = $this->user_model->insertPaidlog($sentNumber, $sentNumber, 2, $amount, $receiveTime);
|
---|
[540] | 155 | echo $data;
|
---|
| 156 | }
|
---|
[556] | 157 |
|
---|
| 158 | public function is_viettel($number) {
|
---|
| 159 | $viettel = array (
|
---|
| 160 | '096',
|
---|
| 161 | '097',
|
---|
| 162 | '098',
|
---|
| 163 | '0163',
|
---|
| 164 | '0164',
|
---|
| 165 | '0165',
|
---|
| 166 | '0166',
|
---|
| 167 | '0167',
|
---|
| 168 | '0168',
|
---|
| 169 | '0169'
|
---|
| 170 | );
|
---|
| 171 | foreach ( $viettel as $num ) {
|
---|
| 172 | if (strpos ( $number, $num ) === 0) {
|
---|
[671] | 173 | return 1;
|
---|
[556] | 174 | }
|
---|
| 175 | }
|
---|
[671] | 176 | return 0;
|
---|
[556] | 177 | }
|
---|
[293] | 178 | }
|
---|
| 179 |
|
---|
| 180 | /* End of file home.php */
|
---|
| 181 | /* Location: ./application/modules/frontend/controllers/home.php */ |
---|