1 | <?php
|
---|
2 |
|
---|
3 | if (! defined ( 'BASEPATH' ))
|
---|
4 | exit ( 'No direct script access allowed' );
|
---|
5 |
|
---|
6 | if ( ! defined('_SBG_PAIDTYPE_SMS')) define('_SBG_PAIDTYPE_SMS', 1);
|
---|
7 | if ( ! defined('_SBG_PAIDTYPE_CARD')) define('_SBG_PAIDTYPE_CARD', 2);
|
---|
8 |
|
---|
9 | class User_model extends CI_Model {
|
---|
10 | const TOKENPW = 'violet';
|
---|
11 |
|
---|
12 | public function __construct() {
|
---|
13 | parent::__construct ();
|
---|
14 | $this->vservices->setApiUrl ( $this->config->item ( 'api_url' ) );
|
---|
15 | $this->vservices->setConnection ( $this->curl );
|
---|
16 | }
|
---|
17 |
|
---|
18 | public function checkLogin($src, $token, $username, $password) {
|
---|
19 | $data = $this->vservices->actionExecute ( 'login', array (
|
---|
20 | 'src' => $src,
|
---|
21 | 'token' => $token,
|
---|
22 | 'username' => $username,
|
---|
23 | 'password' => $password
|
---|
24 | ), 'user' );
|
---|
25 | if(!($data) || is_null($data)) return array('success'=>-1, 'data'=>$data);
|
---|
26 | parse_str ( $data );
|
---|
27 | if ($status == 0 || $status == 4) {
|
---|
28 | $us_id = ( int ) $id;
|
---|
29 | $query = "SELECT * FROM tbluser WHERE us_id = ?";
|
---|
30 | $result = $this->db->query ( $query, array (
|
---|
31 | $us_id
|
---|
32 | ) );
|
---|
33 | if ($result->num_rows () == 1) {
|
---|
34 | return array('success'=>1, 'data'=>$data);
|
---|
35 | } else {
|
---|
36 | return array('success'=>0, 'data'=>$data);
|
---|
37 | }
|
---|
38 | } else {
|
---|
39 | return array('success'=>0, 'data'=>$data);
|
---|
40 | }
|
---|
41 | }
|
---|
42 |
|
---|
43 | public function register($username, $collaborator, &$collaboratorMsg = '') {
|
---|
44 | $user = array ();
|
---|
45 | $password = $this->create_random_password ();
|
---|
46 | $src = 'SBG';
|
---|
47 | $sms = '';
|
---|
48 | $id = 0;
|
---|
49 | $errMsg = '';
|
---|
50 | $token = md5 ( $username . self::TOKENPW );
|
---|
51 | $phone = $username;
|
---|
52 | $status = 0;
|
---|
53 |
|
---|
54 | if (! is_null ( $collaborator ) || $collaborator != '') {
|
---|
55 | if (! $this->isExistcollaborator ( $collaborator )) {
|
---|
56 | $sms = "Khong tim thay cong tac vien nao co so dien thoai [" . $collaborator . "] tren SBG Online.";
|
---|
57 | $collaboratorMsg = $status . '|'.$sms;
|
---|
58 | return $status . '|' . $sms;
|
---|
59 | }
|
---|
60 | }
|
---|
61 |
|
---|
62 | $data = $this->vservices->actionExecute ( 'update', array (
|
---|
63 | 'src' => $src,
|
---|
64 | 'username' => $username,
|
---|
65 | 'password' => $password,
|
---|
66 | 'fullname' => null,
|
---|
67 | 'phone' => $username,
|
---|
68 | 'token' => $token
|
---|
69 | ), 'user' );
|
---|
70 |
|
---|
71 | if(!($data) || is_null($data))
|
---|
72 | {
|
---|
73 | $sms = "Tam thoi ban khong the dang ky duoc. Xin thu lai sau. Cam on!";
|
---|
74 | $collaboratorMsg = $status . '|'.$sms;
|
---|
75 | return $status . '|' . $sms;
|
---|
76 | }
|
---|
77 |
|
---|
78 | parse_str ( $data );
|
---|
79 |
|
---|
80 | switch (( int ) $status) {
|
---|
81 | case 0 :
|
---|
82 | $us_id = $id;
|
---|
83 | $user ['created_time'] = date ( 'Y-m-d H:i:s' );
|
---|
84 | $user ['us_id'] = $us_id;
|
---|
85 | $user ['cellphone'] = $username;
|
---|
86 | if (! is_null ( $collaborator ) || $collaborator != '') {
|
---|
87 | $user ['collaborator'] = $collaborator;
|
---|
88 | }
|
---|
89 | $this->db->query ( 'UNLOCK TABLES' );
|
---|
90 | $this->db->insert ( 'tbluser', $user );
|
---|
91 | $sms = "Chuc mung ban da dang ky thanh cong tai khoan SBG Online. Hay dang nhap vao soanbaigiang.smas.vn voi ten truy nhap " . $username . ", mat khau " . $password . " de su dung. Tran trong.";
|
---|
92 | $status = 1;
|
---|
93 | $collaboratorMsg = $status . '|'. 'Ban da dang ky thanh cong dich vu SBG Online cho so dien thoai '.$username;
|
---|
94 | break;
|
---|
95 | case 2 :
|
---|
96 | case 4 :
|
---|
97 | $sms = "So dien thoai cua ban da duoc dang ky tai khoan tren SBG Online, vui long kiem tra lai. Tran trong.";
|
---|
98 | $status = 0;
|
---|
99 | $collaboratorMsg = $status . '|'. 'So dien thoai '.$username.' da duoc dang ky tai khoan tren SBG Online.';
|
---|
100 | break;
|
---|
101 | default :
|
---|
102 | $status = 0;
|
---|
103 | $sms = $errMsg;
|
---|
104 | $collaboratorMsg = $status . '|'. $sms;
|
---|
105 | break;
|
---|
106 | }
|
---|
107 |
|
---|
108 | return $status . '|' . $sms;
|
---|
109 | }
|
---|
110 |
|
---|
111 | public function create_random_password() {
|
---|
112 | // $alphabet = "abcdefghijklmnopqrstuwxyzABCDEFGHIJKLMNOPQRSTUWXYZ0123456789";
|
---|
113 | $alphabet = "0123456789";
|
---|
114 | $pass = array ();
|
---|
115 | $alphaLength = strlen ( $alphabet ) - 1;
|
---|
116 | for($i = 0; $i < 6; $i ++) {
|
---|
117 | $n = rand ( 0, $alphaLength );
|
---|
118 | $pass [] = $alphabet [$n];
|
---|
119 | }
|
---|
120 | return implode ( $pass );
|
---|
121 | }
|
---|
122 |
|
---|
123 | public function get_user_by_id($us_id) {
|
---|
124 | $this->db->query ( 'UNLOCK TABLES' );
|
---|
125 | $this->db->select ( '*' )->from ( 'tbluser' )->where ( 'us_id', $us_id );
|
---|
126 | $query = $this->db->get ();
|
---|
127 | if ($query->num_rows () > 0) {
|
---|
128 | $row = $query->row_array ();
|
---|
129 | return $row;
|
---|
130 | }
|
---|
131 | }
|
---|
132 |
|
---|
133 | public function get_user_info($src, $token, $us_id) {
|
---|
134 | $data = $this->vservices->actionExecute ( 'getinfo', array (
|
---|
135 | 'src' => $src,
|
---|
136 | 'us_id' => $us_id,
|
---|
137 | 'token' => $token
|
---|
138 | ), 'user' );
|
---|
139 | return $data;
|
---|
140 | }
|
---|
141 |
|
---|
142 | public function update_user($src, $token, $user, $us_id) {
|
---|
143 | $data = $this->vservices->actionExecute ( 'update', array (
|
---|
144 | 'src' => $src,
|
---|
145 | 'token' => $token,
|
---|
146 | 'us_id' => $us_id,
|
---|
147 | 'password' => $user ['password'],
|
---|
148 | 'fullname' => $user ['fullname'],
|
---|
149 | 'school' => $user ['school'],
|
---|
150 | 'province' => $user ['province'],
|
---|
151 | 'oldpass' => $user ['oldpass']
|
---|
152 | ), 'user' );
|
---|
153 | return $data;
|
---|
154 | }
|
---|
155 |
|
---|
156 | public function changeProfile($sentNumber, $username, $password, &$status = '') {
|
---|
157 | $user = array ();
|
---|
158 | $src = 'SBG';
|
---|
159 | $errMsg = '';
|
---|
160 | $sms = '';
|
---|
161 | $checkSentNumber = $this->get_user_by_cellphone ( $sentNumber );
|
---|
162 |
|
---|
163 | if ($checkSentNumber) {
|
---|
164 | $sms = "So dien thoai " . $sentNumber . " da dang ky tai khoan tren he thong SBG Online. Tran trong.";
|
---|
165 | $status = 0;
|
---|
166 | return $status . '|' . $sms;
|
---|
167 | }
|
---|
168 |
|
---|
169 | $result = $this->get_user_by_cellphone ( $username );
|
---|
170 |
|
---|
171 | if ($result) {
|
---|
172 |
|
---|
173 | $us_id = $result ['us_id'];
|
---|
174 | $token = md5 ( $us_id . self::TOKENPW );
|
---|
175 | $isCorrectPassword = $this->checkPassword($src, $us_id, $token, $password);
|
---|
176 | if(!$isCorrectPassword) return '0|Mat khau cua ban khong dung. Vui long kiem tra lai.';
|
---|
177 |
|
---|
178 | $data = $this->vservices->actionExecute ( 'update', array (
|
---|
179 | 'src' => $src,
|
---|
180 | 'token' => $token,
|
---|
181 | 'us_id' => $us_id,
|
---|
182 | 'username' => $sentNumber,
|
---|
183 | "password" => $password,
|
---|
184 | 'oldpass' => $password,
|
---|
185 | 'phone' => $sentNumber
|
---|
186 | ), 'user' );
|
---|
187 |
|
---|
188 | if(!($data) || is_null($data))
|
---|
189 | {
|
---|
190 | $sms = "Tam thoi ban khong the thay doi duoc so dien thoai. Xin thu lai sau. Cam on!";
|
---|
191 | $status = 0;
|
---|
192 | return $status . '|' . $sms;
|
---|
193 | }
|
---|
194 | parse_str ( $data );
|
---|
195 | switch (( int ) $status) {
|
---|
196 | case 0 :
|
---|
197 | $us_id = $id;
|
---|
198 | $user ['updated_time'] = date ( 'Y-m-d H:i:s' );
|
---|
199 | $user ['us_id'] = $us_id;
|
---|
200 | $user ['cellphone'] = $sentNumber;
|
---|
201 | $this->updateUser ( $us_id, $user );
|
---|
202 | $sms = "Ban da doi thanh cong tai khoan " .$username. " tren SBG Online sang so dien thoai " . $sentNumber. ". Tran trong.";
|
---|
203 | $status = 1;
|
---|
204 | break;
|
---|
205 | case 2:
|
---|
206 | $sms = "So dien thoai " . $sentNumber . " da dang ky tai khoan tren he thong SBG Online. Tran trong";
|
---|
207 | $status = 0;
|
---|
208 | break;
|
---|
209 | case 5 :
|
---|
210 | $sms = "So dien thoai ".$username." chua dang ky tai khoan tren he thong SBG Online. Tran trong.";
|
---|
211 | $status = 0;
|
---|
212 | break;
|
---|
213 | default :
|
---|
214 | $status = 0;
|
---|
215 | $sms = $errMsg;
|
---|
216 | break;
|
---|
217 | }
|
---|
218 | } else {
|
---|
219 | $sms = "So dien thoai ".$username." chua dang ky tai khoan tren he thong SBG Online. Tran trong.";
|
---|
220 | $status = 0;
|
---|
221 | }
|
---|
222 | return $status . '|' . $sms;
|
---|
223 | }
|
---|
224 |
|
---|
225 | public function changePassword($username, $password, &$status = '') {
|
---|
226 | $user = array ();
|
---|
227 | $src = 'SBG';
|
---|
228 | $errMsg = '';
|
---|
229 | $sms = '';
|
---|
230 | $isForgotPassword = false;
|
---|
231 | $pass = $password;
|
---|
232 |
|
---|
233 | if (is_null ( $password ) || $password == '') {
|
---|
234 | $pass = $this->create_random_password ();
|
---|
235 | $isForgotPassword = true;
|
---|
236 | }
|
---|
237 |
|
---|
238 | $result = $this->get_user_by_cellphone ( $username );
|
---|
239 |
|
---|
240 | if ($result) {
|
---|
241 | $us_id = $result ['us_id'];
|
---|
242 | $token = md5 ( $us_id . self::TOKENPW );
|
---|
243 | $data = $this->vservices->actionExecute ( 'update', array (
|
---|
244 | 'src' => $src,
|
---|
245 | 'token' => $token,
|
---|
246 | 'us_id' => $us_id,
|
---|
247 | "password" => $pass
|
---|
248 | ), 'user' );
|
---|
249 |
|
---|
250 | if(!($data) || is_null($data))
|
---|
251 | {
|
---|
252 | $sms = "Tam thoi ban khong the lay lai hoac thay doi mat khau. Xin thu lai sau. Cam on!";
|
---|
253 | $status = 0;
|
---|
254 | return $status . '|' . $sms;
|
---|
255 | }
|
---|
256 | parse_str ( $data );
|
---|
257 | switch (( int ) $status) {
|
---|
258 | case 0 :
|
---|
259 | $us_id = $id;
|
---|
260 | $user ['updated_time'] = date ( 'Y-m-d H:i:s' );
|
---|
261 | $this->updateUser ( $us_id, $user );
|
---|
262 | if ($isForgotPassword) {
|
---|
263 | $sms = "Mat khau moi cua ban tren SBG online la " . $pass. ". Tran trong.";
|
---|
264 | } else {
|
---|
265 | $sms = "Ban da doi thanh cong mat khau tren SBG Online. Mat khau moi cua ban la " .$password. ". Tran trong.";
|
---|
266 | }
|
---|
267 | $status = 1;
|
---|
268 | break;
|
---|
269 | case 5 :
|
---|
270 | $sms = "So dien thoai ".$username." chua dang ky tai khoan tren he thong SBG Online";
|
---|
271 | $status = 0;
|
---|
272 | break;
|
---|
273 | default :
|
---|
274 | $status = 0;
|
---|
275 | $sms = $errMsg;
|
---|
276 | break;
|
---|
277 | }
|
---|
278 | } else {
|
---|
279 | $sms = "So dien thoai ".$username." chua dang ky tai khoan tren he thong SBG Online";
|
---|
280 | $status = 0;
|
---|
281 | }
|
---|
282 | return $status . '|' . $sms;
|
---|
283 | }
|
---|
284 |
|
---|
285 | public function checkLicense($userId) {
|
---|
286 | $isNotExpired = false;
|
---|
287 | $userInfo = array ();
|
---|
288 | $userInfo = $this->get_user_by_id ( $userId );
|
---|
289 |
|
---|
290 | $expireDate = $userInfo ['expire_date'];
|
---|
291 |
|
---|
292 | if ((trim ( $expireDate ) == ''))
|
---|
293 | return $isNotExpired;
|
---|
294 |
|
---|
295 | $today = mktime ();
|
---|
296 | $expireTime = strtotime ( $expireDate . ' 23:59:59' );
|
---|
297 | $isNotExpired = ($today < $expireTime);
|
---|
298 | return $isNotExpired;
|
---|
299 | }
|
---|
300 |
|
---|
301 | public function registerVip($username, $p_code) {
|
---|
302 | $user = array ();
|
---|
303 | $sms = '';
|
---|
304 |
|
---|
305 | $result = $this->get_user_by_cellphone ( $username );
|
---|
306 | $package = $this->get_package ( ( int ) $p_code );
|
---|
307 | if (!$package)
|
---|
308 | {
|
---|
309 | $sms = "Khong co goi dich vu ban da dang ki tren SBG Online";
|
---|
310 | $status = 0;
|
---|
311 | return $status . '|' . $sms;
|
---|
312 | }
|
---|
313 | if ($result) {
|
---|
314 |
|
---|
315 | if ($result ['acc_balanced'] >= $package ['p_price']) {
|
---|
316 | $us_id = $result ['us_id'];
|
---|
317 | $user ['acc_balanced'] = $result ['acc_balanced'] - $package ['p_price'];
|
---|
318 | if ($this->checkLicense ( $us_id )) {
|
---|
319 | $user ['expire_date'] = date ( 'Y-m-d', strtotime ( $result ['expire_date'] . ' + ' . $package ['p_period'] . ' month' ) );
|
---|
320 | } else {
|
---|
321 | $user ['expire_date'] = date ( 'Y-m-d', strtotime ( 'now + ' . $package ['p_period'] . ' month' ) );
|
---|
322 | }
|
---|
323 |
|
---|
324 | $user ['p_id'] = $package ['p_id'];
|
---|
325 | $user ['updated_time'] = date ( 'Y-m-d H:i:s' );
|
---|
326 |
|
---|
327 | $this->updateUser ( $us_id, $user );
|
---|
328 | $sms = "Chuc mung ban da dang ky thanh cong dich vu SBG Online. Thoi han su dung dich vu cua ban la ".date ( 'd/m/Y', strtotime ( $user ['expire_date'] ) ).". Tran trong." ;
|
---|
329 | $status = 1;
|
---|
330 | } else {
|
---|
331 | $sms = "Tai khoan cua ban khong du de dang ky dich vu SBG Online. Vui long nap tien va dang ky lai. Tran trong.";
|
---|
332 | $status = 0;
|
---|
333 | }
|
---|
334 | } else {
|
---|
335 | $sms = "So dien thoai " .$username. " chua dang ky tai khoan tren he thong SBG Online. De dang ky, soan tin SBG DK gui 8062 (500d).";
|
---|
336 | $status = 0;
|
---|
337 | }
|
---|
338 | return $status . '|' . $sms;
|
---|
339 | }
|
---|
340 |
|
---|
341 | public function rechargeAccount($username, $amount) {
|
---|
342 | $user = array ();
|
---|
343 | $sms = '';
|
---|
344 | $result = $this->get_user_by_cellphone ( $username );
|
---|
345 | if ($result) {
|
---|
346 | $us_id = $result ['us_id'];
|
---|
347 | $user ['acc_balanced'] = $result ['acc_balanced'] + $amount;
|
---|
348 | $user ['updated_time'] = date ( 'Y-m-d H:i:s' );
|
---|
349 | $this->updateUser ( $us_id, $user );
|
---|
350 | $sms = "Ban da nap thanh cong " . $amount . "VND vao tai khoan " . $username . " tren SBG Online. Tran trong.";
|
---|
351 | $status = 1;
|
---|
352 | } else {
|
---|
353 | $sms = "So dien thoai " .$username. " chua dang ky tai khoan tren he thong SBG Online. De dang ky, soan tin SBG DK gui 8062 (500d).";
|
---|
354 | $status = 0;
|
---|
355 | }
|
---|
356 | return $status . '|' . $sms;
|
---|
357 | }
|
---|
358 |
|
---|
359 | public function get_user_by_cellphone($cellphone) {
|
---|
360 | $this->db->query ( 'UNLOCK TABLES' );
|
---|
361 | $sql = 'SELECT * FROM tbluser where cellphone = ? LIMIT 0,1';
|
---|
362 | $query = $this->db->query ( $sql, array (
|
---|
363 | $cellphone
|
---|
364 | ) );
|
---|
365 | $row = $query->row_array ();
|
---|
366 | return $row;
|
---|
367 | }
|
---|
368 |
|
---|
369 | public function isExistcollaborator($collaborator) {
|
---|
370 | $this->db->query ( 'UNLOCK TABLES' );
|
---|
371 | $this->db->select ( '*' )->from ( 'tblcollaborator' )->where ( 'login_name', $collaborator )->limit ( 1 );
|
---|
372 | $result = $this->db->get ()->row_array ();
|
---|
373 | if ($result)
|
---|
374 | return true;
|
---|
375 | else
|
---|
376 | return false;
|
---|
377 | }
|
---|
378 |
|
---|
379 | public function updateUser($us_id, $data) {
|
---|
380 | $this->db->query ( 'UNLOCK TABLES' );
|
---|
381 | $this->db->where ( 'us_id', $us_id );
|
---|
382 | $this->db->update ( 'tbluser', $data );
|
---|
383 | }
|
---|
384 |
|
---|
385 | public function get_package($p_code) {
|
---|
386 | $this->db->query ( 'UNLOCK TABLES' );
|
---|
387 | $sql = 'SELECT * FROM tblservicepackage where p_code = ? LIMIT 0,1';
|
---|
388 | $query = $this->db->query ( $sql, array (
|
---|
389 | $p_code
|
---|
390 | ) );
|
---|
391 | $row = $query->row_array ();
|
---|
392 | return $row;
|
---|
393 | }
|
---|
394 |
|
---|
395 | public function insertSmslog($sentNumber, $serviceID, $commandcode, $info, $receiveTime) {
|
---|
396 | if (preg_match ( '/^(84)([0-9]{9,10})$/', $sentNumber, $aryMatch ) == 1) {
|
---|
397 | $sentNumber = '0' . $aryMatch [2];
|
---|
398 | }
|
---|
399 |
|
---|
400 | try {
|
---|
401 | $user = $this->get_user_by_cellphone ( $sentNumber );
|
---|
402 | } catch ( Exception $e ) {
|
---|
403 | }
|
---|
404 |
|
---|
405 | $smslog = array ();
|
---|
406 | $smslog ['sender'] = $sentNumber;
|
---|
407 | $smslog ['us_id'] = isset ( $user ['us_id'] ) ? $user ['us_id'] : NULL;
|
---|
408 | $smslog ['service_id'] = $serviceID;
|
---|
409 | $smslog ['commandcode'] = $commandcode;
|
---|
410 | $smslog ['info'] = $info;
|
---|
411 | $smslog ['created_time'] = $receiveTime;
|
---|
412 | $this->db->query ( 'UNLOCK TABLES' );
|
---|
413 | $sql = 'INSERT INTO tblsmslog(sender, us_id, service_id, commandcode, info, created_time) VALUES(?,?,?,?,?,?)';
|
---|
414 | $query = $this->db->query($sql, $smslog);
|
---|
415 | }
|
---|
416 |
|
---|
417 | public function insertPaidlog($sentNumber, $receiveID, $paidType, $amount, $paidTime) {
|
---|
418 | if (preg_match ( '/^(84)([0-9]{9,10})$/', $sentNumber, $aryMatch ) == 1) {
|
---|
419 | $sentNumber = '0' . $aryMatch [2];
|
---|
420 | }
|
---|
421 |
|
---|
422 | try {
|
---|
423 | $user = $this->get_user_by_cellphone ( $receiveID );
|
---|
424 | } catch ( Exception $e ) {
|
---|
425 | }
|
---|
426 | $paidlog = array ();
|
---|
427 | $paidlog ['us_id'] = isset ( $user ['us_id'] ) ? $user ['us_id'] : NULL;
|
---|
428 | $paidlog ['paidType'] = $paidType;
|
---|
429 | $paidlog ['amount'] = $amount;
|
---|
430 | $paidlog['source'] = "";
|
---|
431 | if ($paidType == 1)
|
---|
432 | {
|
---|
433 | $paidlog['source'] = $sentNumber;
|
---|
434 |
|
---|
435 | }else
|
---|
436 | {
|
---|
437 | $paidlog['source'] = "Thẻ cà o";
|
---|
438 | }
|
---|
439 | $paidlog ['paidTime'] = $paidTime;
|
---|
440 | $this->db->query ( 'UNLOCK TABLES' );
|
---|
441 | $sql = 'INSERT INTO tblpaidlog(us_id, paid_type, amount, source, paid_time) VALUES (?,?,?,?,?)';
|
---|
442 | $query = $this->db->query ( $sql, $paidlog );
|
---|
443 | }
|
---|
444 |
|
---|
445 | public function insertCardlog($username, $pinCode, $serialNum, $cardValue, $receiveTime)
|
---|
446 | {
|
---|
447 | try {
|
---|
448 | $user = $this->get_user_by_cellphone ( $username );
|
---|
449 | } catch ( Exception $e ) {
|
---|
450 | }
|
---|
451 |
|
---|
452 | $cardlog = array();
|
---|
453 | $cardlog['sender'] = $username;
|
---|
454 | $cardlog['us_id'] = isset ( $user ['us_id'] ) ? $user ['us_id'] : NULL;
|
---|
455 | $cardlog['pin_code'] = $pinCode;
|
---|
456 | $cardlog['serial_num'] = $serialNum;
|
---|
457 | $cardlog['card_value'] = $cardValue;
|
---|
458 | $cardlog['created_time'] = $receiveTime;
|
---|
459 | $this->db->query ( 'UNLOCK TABLES' );
|
---|
460 | $sql = 'INSERT INTO tblcardlog(sender, us_id, pin_code, serial_num, card_value, created_time) VALUES(?,?,?,?,?,?)';
|
---|
461 | $query = $this->db->query ($sql, $cardlog);
|
---|
462 | }
|
---|
463 |
|
---|
464 | public function getPaidlog($data)
|
---|
465 | {
|
---|
466 | $us_id = $data['us_id'];
|
---|
467 | $this->db->query ( 'UNLOCK TABLES' );
|
---|
468 | $sql = "SELECT * FROM tblpaidlog where us_id = ? ORDER BY paid_time DESC LIMIT ".$data['start'].", ".$data['perpage']." ";
|
---|
469 | $query = $this->db->query ( $sql, array (
|
---|
470 | $us_id
|
---|
471 | ) );
|
---|
472 | $row = $query->result_array();
|
---|
473 | return $row;
|
---|
474 | }
|
---|
475 |
|
---|
476 | public function countPaiglogs($us_id)
|
---|
477 | {
|
---|
478 | $this->db->query ( 'UNLOCK TABLES' );
|
---|
479 | $sql="SELECT COUNT(paid_id) AS total FROM tblpaidlog WHERE us_id = ?";
|
---|
480 | $query = $this->db->query ( $sql, array (
|
---|
481 | $us_id
|
---|
482 | ) );
|
---|
483 | $result = $query->row_array();
|
---|
484 | return $result['total'];
|
---|
485 | }
|
---|
486 |
|
---|
487 | public function checkPassword($src, $us_id, $token, $password)
|
---|
488 | {
|
---|
489 | $data = $this->vservices->actionExecute ( 'getinfo', array (
|
---|
490 | 'src' => $src,
|
---|
491 | 'us_id' => $us_id,
|
---|
492 | 'token' => $token,
|
---|
493 | 'ponly'=>1
|
---|
494 | ), 'user' );
|
---|
495 |
|
---|
496 | parse_str($data);
|
---|
497 | if(md5($password) == $pencrypted) return true; else return false;
|
---|
498 | }
|
---|
499 |
|
---|
500 | public function insertRegisterVipLog($source, $p_code)
|
---|
501 | {
|
---|
502 | $createdTime = date('Y-m-d H:i:s');
|
---|
503 | $sql = 'INSERT INTO tblregisterpackagelog (source, p_code, created_time) VALUES (?,?,?)';
|
---|
504 | $query = $this->db->query ( $sql, array (
|
---|
505 | 'source'=>$source,
|
---|
506 | 'p_code'=>$p_code,
|
---|
507 | 'created_time'=>$createdTime
|
---|
508 | ) );
|
---|
509 | }
|
---|
510 | } |
---|