source: pro-violet-viettel/sourcecode/application/modules/frontend/models/user_model.php @ 395

Last change on this file since 395 was 393, checked in by namnd, 11 years ago
File size: 1.6 KB
Line 
1<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
2
3class 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                $arr_users = explode("&", $data);
17                $str_status = "";
18                $str_fullname = "";
19                $str_usid = "";
20                $usid = "";
21                $fullname = "";
22                for ($i=0; $i<count($arr_users); $i++)
23                {
24                        if (strpos($arr_users[$i], 'status=') !== false)
25                        {
26                                $str_status = $arr_users[$i];
27                        }
28                       
29                        if (strpos($arr_users[$i], 'fullname=') !== false)
30                        {
31                                $str_fullname = $arr_users[$i];
32                        }
33                       
34                        if (strpos($arr_users[$i], 'id=') !== false)
35                        {
36                                $str_usid = $arr_users[$i];
37                        }
38                }
39                $arr_status = explode("=", $str_status);
40                if ($str_fullname != "")
41                {
42                        $arr_fullname = explode("=", $str_fullname);
43                        $fullname = $arr_fullname[1];
44                }
45                if ($str_usid !== "")
46                {
47                        $arr_usid = explode("=", $str_usid);
48                        $usid = $arr_usid[1];
49                }
50                $status = (int)$arr_status[1];
51                if ($status == 0){
52                        $us_id = (int)$usid;
53                        $query = "SELECT * FROM tbluser WHERE us_id = ?";
54                        $result = $this->db->query($query, array($us_id));
55                        if($result->num_rows() == 1){
56                                return $data;
57                        }else
58                        {
59                                return null;
60                        }
61                }else
62                {
63                        return $data;
64                }
65               
66               
67        }
68       
69       
70       
71       
72}
Note: See TracBrowser for help on using the repository browser.