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

Last change on this file since 446 was 438, checked in by dungnv, 11 years ago
File size: 2.0 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    }
11       
12        function checkLogin ($src, $token, $username, $password)
13        {
14                $data = $this->vservices->actionExecute('login', array('src' => $src, 'token' => $token, 'username' => $username, 'password' => $password), 'user');           
15                $arr_users = explode("&", $data);
16                $str_status = "";
17                $str_fullname = "";
18                $str_usid = "";
19                $usid = "";
20                $fullname = "";
21                for ($i=0; $i<count($arr_users); $i++)
22                {
23                        if (strpos($arr_users[$i], 'status=') !== false)
24                        {
25                                $str_status = $arr_users[$i];
26                        }
27                       
28                        if (strpos($arr_users[$i], 'fullname=') !== false)
29                        {
30                                $str_fullname = $arr_users[$i];
31                        }
32                       
33                        if (strpos($arr_users[$i], 'id=') !== false)
34                        {
35                                $str_usid = $arr_users[$i];
36                        }
37                }
38                $arr_status = explode("=", $str_status);
39                if ($str_fullname != "")
40                {
41                        $arr_fullname = explode("=", $str_fullname);
42                        $fullname = $arr_fullname[1];
43                }
44                if ($str_usid !== "")
45                {
46                        $arr_usid = explode("=", $str_usid);
47                        $usid = $arr_usid[1];
48                }
49                $status = (int)$arr_status[1];
50                if ($status == 0){
51                        $us_id = (int)$usid;
52                        $query = "SELECT * FROM tbluser WHERE us_id = ?";
53                        $result = $this->db->query($query, array($us_id));
54                        if($result->num_rows() == 1){
55                                return $data;
56                        }else
57                        {
58                                return null;
59                        }
60                }else
61                {
62                        return $data;
63                }
64        }
65
66        function register ($sentNumber, $receiverID, $serviceID, $commandcode, $info, $receiveTime) {
67                //1. check collaborator info if $receiverID existed
68                //2. insert new user to database
69                //3. create random password for new user
70                //4. return sms contain password
71               
72                $username = '';
73                $collaborator = '';
74               
75                if (is_null($receiverID) || $receiverID == '') {
76                        $username = $sentNumber;
77                }
78                else {
79                        $username = $receiverID;
80                        $collaborator = $sentNumber;
81                }
82               
83               
84        }
85}
Note: See TracBrowser for help on using the repository browser.