[439] | 1 | <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
---|
| 2 |
|
---|
| 3 | class User extends MX_Controller
|
---|
| 4 | {
|
---|
| 5 |
|
---|
| 6 | const TOKENPW = 'violet';
|
---|
| 7 |
|
---|
| 8 | public function __construct() {
|
---|
| 9 | parent::__construct();
|
---|
| 10 | }
|
---|
| 11 |
|
---|
| 12 | public function login($return_type = 'xml')
|
---|
| 13 | {
|
---|
| 14 | $user_info = $this->session->userdata('userInfo');
|
---|
| 15 | if ($user_info)
|
---|
| 16 | {
|
---|
| 17 | $user = $user_info['user'];
|
---|
| 18 | $data['content'] = $this->get_data($user);
|
---|
| 19 | if ($return_type == "xml"){
|
---|
| 20 | $this->load->view('user', $data);
|
---|
| 21 | }
|
---|
| 22 | }else
|
---|
| 23 | {
|
---|
| 24 | redirect('/frontend/home');
|
---|
| 25 | }
|
---|
| 26 | }
|
---|
| 27 |
|
---|
| 28 |
|
---|
| 29 | private function get_user($us_id)
|
---|
| 30 | {
|
---|
| 31 | $src = 'violet';
|
---|
| 32 | $token = md5($us_id.self::TOKENPW);
|
---|
| 33 | $this->load->model('user_model');
|
---|
| 34 | $data = $this->user_model->get_user_info($src, $us_id, $token);
|
---|
| 35 | return $data;
|
---|
| 36 | }
|
---|
| 37 |
|
---|
| 38 | private function get_data($user)
|
---|
| 39 | {
|
---|
| 40 | $this->load->model('us_model');
|
---|
| 41 | $arr_users = explode("&", $user);
|
---|
| 42 | $str_id = $arr_users[0];
|
---|
| 43 | $str_username = $arr_users[1];
|
---|
| 44 | $str_fullname = $arr_users[2];
|
---|
| 45 | $str_phone = $arr_users[5];
|
---|
| 46 | $str_school = $arr_users[6];
|
---|
| 47 | $str_province = $arr_users[6];
|
---|
| 48 | $str_money = $arr_users[8];
|
---|
| 49 | $str_level = $arr_users[9];
|
---|
| 50 | $arr_id = explode("=", $str_id);
|
---|
| 51 | $arr_username = explode("=", $str_username);
|
---|
| 52 | $arr_fullname = explode("=", $str_fullname);
|
---|
| 53 | $arr_phone = explode("=", $str_phone);
|
---|
| 54 | $arr_school = explode("=", $str_school);
|
---|
| 55 | $arr_province = explode("=", $str_province);
|
---|
| 56 | $arr_money = explode("=", $str_money);
|
---|
| 57 | $arr_level = explode("=", $str_level);
|
---|
| 58 | $us = $this->us_model->search_by_id($arr_id[1]);
|
---|
| 59 | return array("userId" => $arr_id[1], "userLevel" => 1, "userPhone" => $arr_phone[1], "userMoney" => $arr_money[1], "appUserName" => $arr_fullname[1], "appAddress" => $arr_school[1], "licType" => "SBG", "licCustomer" => $arr_username[1], "licCreate" => $us['created_time'], "licExpire" => $us['expire_date']);
|
---|
| 60 | }
|
---|
| 61 | } |
---|