1 | <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); |
---|
2 | |
---|
3 | class User_model extends CI_Model |
---|
4 | { |
---|
5 | |
---|
6 | function __construct(){ |
---|
7 | parent::__construct(); |
---|
8 | $this->vservices->setApiUrl($this->config->item('api_url')); |
---|
9 | $this->vservices->setConnection($this->curl); |
---|
10 | //$this->vservices->setUserId(33); |
---|
11 | } |
---|
12 | |
---|
13 | function checkLogin ($src, $token, $username, $password) |
---|
14 | { |
---|
15 | $data = $this->vservices->actionExecute('login', array('src' => $src, 'token' => $token, 'username' => $username, 'password' => $password), 'user'); |
---|
16 | //return $data; |
---|
17 | $arr_users = explode("&", $data); |
---|
18 | $str_status = ""; |
---|
19 | $str_fullname = ""; |
---|
20 | $str_usid = ""; |
---|
21 | $usid = ""; |
---|
22 | $fullname = ""; |
---|
23 | for ($i=0; $i<count($arr_users); $i++) |
---|
24 | { |
---|
25 | if (strpos($arr_users[$i], 'status=') !== false) |
---|
26 | { |
---|
27 | $str_status = $arr_users[$i]; |
---|
28 | } |
---|
29 | |
---|
30 | if (strpos($arr_users[$i], 'fullname=') !== false) |
---|
31 | { |
---|
32 | $str_fullname = $arr_users[$i]; |
---|
33 | } |
---|
34 | |
---|
35 | if (strpos($arr_users[$i], 'us_id=') !== false) |
---|
36 | { |
---|
37 | $str_usid = $arr_users[$i]; |
---|
38 | } |
---|
39 | } |
---|
40 | $arr_status = explode("=", $str_status); |
---|
41 | if ($str_fullname != "") |
---|
42 | { |
---|
43 | $arr_fullname = explode("=", $str_fullname); |
---|
44 | $fullname = $arr_fullname[1]; |
---|
45 | } |
---|
46 | if ($str_usid !== "") |
---|
47 | { |
---|
48 | $arr_usid = explode("=", $str_usid); |
---|
49 | $usid = $arr_usid[1]; |
---|
50 | } |
---|
51 | |
---|
52 | $status = (int)$arr_status[1]; |
---|
53 | if ($status == 0){ |
---|
54 | $us_id = (int)$usid; |
---|
55 | $query = "SELECT * FROM tbluser WHERE us_id = ?"; |
---|
56 | $result = $this->db->query($query, array($us_id)); |
---|
57 | if($result->num_rows() == 1){ |
---|
58 | return $data; |
---|
59 | }else |
---|
60 | { |
---|
61 | return null; |
---|
62 | } |
---|
63 | }else |
---|
64 | { |
---|
65 | return $data; |
---|
66 | } |
---|
67 | |
---|
68 | |
---|
69 | } |
---|
70 | |
---|
71 | |
---|
72 | |
---|
73 | |
---|
74 | } |
---|