Ignore:
Timestamp:
Nov 20, 2014 11:00:32 AM (10 years ago)
Author:
dungnv
Message:
 
Location:
pro-violet-viettel/sourcecode/application/modules
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • pro-violet-viettel/sourcecode/application/modules/admin/controllers/user.php

    r459 r579  
    5959                $us = $this->user_model->get_list_users($data);
    6060                $users = array();
    61                 foreach($us as $u):
     61               
     62                foreach($us as $u) {
    6263                        $id = $u['us_id'];
    6364                        $username = $this->get_username($id);
    6465                        $u['username'] = $username;
    6566                        array_push($users, $u);
    66                 endforeach;
     67                }
    6768               
    6869                $data['users'] = $users;
  • pro-violet-viettel/sourcecode/application/modules/admin/models/cardlog_model.php

    r426 r579  
    2626                        $order = "ORDER BY " . $data['sorting_field'] . " " . $sort;
    2727                }
    28                 return $this->db->query($sql." ".$order." LIMIT ".$data['start'].", ".$data['perpage']." ")->result_array();
     28                $query = $this->db->query($sql." ".$order." LIMIT ".$data['start'].", ".$data['perpage']." ");
     29                return $query->result_array();
    2930        }
    3031       
     
    3738                                $sql.=" WHERE (sender LIKE '%".$data['keyword']."%'";
    3839                }
    39                 return $this->db->query($sql)->row_array()['total'];
     40                $query = $this->db->query($sql);
     41                $row = $query->row_array();
     42                return $row['total'];
    4043        }
    4144}
  • pro-violet-viettel/sourcecode/application/modules/admin/models/smslog_model.php

    r426 r579  
    2626                        $order = "ORDER BY " . $data['sorting_field'] . " " . $sort;
    2727                }
    28                 return $this->db->query($sql." ".$order." LIMIT ".$data['start'].", ".$data['perpage']." ")->result_array();
     28               
     29                $query = $this->db->query($sql." ".$order." LIMIT ".$data['start'].", ".$data['perpage']." ");
     30               
     31                return $query->result_array();
    2932        }
    3033       
     
    3740                                $sql.=" WHERE (sender LIKE '%".$data['keyword']."%' OR mobody LIKE '%".$data['keyword']."%' OR mtbody LIKE '%".$data['keyword']."%') ";
    3841                }
    39                 return $this->db->query($sql)->row_array()['total'];
     42               
     43                $query =  $this->db->query($sql);
     44                $row = $query->row_array();
     45                return $row['total'];
    4046        }
    4147}
  • pro-violet-viettel/sourcecode/application/modules/admin/models/user_model.php

    r459 r579  
    11<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
    22
    3 class User_model extends MY_Model
     3class User_model extends CI_Model
    44{
    55       
     
    6262                                $sql.=" WHERE (cellphone LIKE '%".$data['keyword']."%' OR collaborator LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%') ";
    6363                }
    64                 return $this->db->query($sql)->row_array()['total'];
     64               
     65                $query = $this->db->query($sql);
     66                $row = $query->row_array();
     67               
     68                return $row['total'];
    6569        }
    6670       
  • pro-violet-viettel/sourcecode/application/modules/frontend/models/user_model.php

    r574 r579  
    7171        }
    7272       
    73         public function register($username, $collaborator, &$status = '') {
     73        public function register($username, $collaborator, &$collaboratorMsg = '') {
    7474                $user = array ();
    7575                $password = $this->create_random_password ();
     
    8080                $token = md5 ( $username . self::TOKENPW );
    8181                $phone = $username;
     82                $status = 0;
    8283               
    8384                if (! is_null ( $collaborator ) || $collaborator != '') {
    8485                        if (! $this->isExistcollaborator ( $collaborator )) {
    8586                                $sms = "Khong tim thay cong tac vien nao co so dien thoai [" . $collaborator . "] tren soanbaigiang.smas.vn";
    86                                 $status = 0;
     87                                $collaboratorMsg = $status . '|'.$sms;
    8788                                return $status . '|' . $sms;
    8889                        }
     
    101102                {
    102103                        $sms = "Tam thoi Qui vi khong the dang ky duoc. Xin thu lai sau. Cam on!";
    103                         $status = 0;
     104                        $collaboratorMsg = $status . '|'.$sms;
    104105                        return $status . '|' . $sms;
    105106                }
     
    120121                                $sms = "Chuc mung Qui vi da dang ky thanh cong tai khoan Soan Bai giang Online. Hay dang nhap vao soanbaigiang.smas.vn voi ten truy nhap " . $username . ", mat khau " . $password . " de su dung.";
    121122                                $status = 1;
     123                                $collaboratorMsg = $status . '|'. 'Ban da dang ky thanh cong dich vu Soan bai giang Online cho '.$username;
    122124                                break;
    123125                        case 2 :
     
    125127                                $sms = "So dien thoai cua Qui vi da duoc dang ky";
    126128                                $status = 0;
     129                                $collaboratorMsg = $status . '|'. 'So dien thoai '.$username.' da duoc dang ky';
    127130                                break;
    128131                        default :
    129132                                $status = 0;
    130133                                $sms = $errMsg;
     134                                $collaboratorMsg = $status . '|'. $sms;
    131135                                break;
    132136                }
     
    258262               
    259263                $result = $this->get_user_by_cellphone ( $username );
     264               
    260265                if ($result) {
    261266                        $us_id = $result ['us_id'];
     
    368373                        $user ['updated_time'] = date ( 'Y-m-d H:i:s' );
    369374                        $this->updateUser ( $us_id, $user );
    370                         $sms = "Qui vi da nap thanh cong " . $amount . " VNĐ vao tai khoan " . $username . " tren soanbaigiang.smas.vn";
     375                        $sms = "Qui vi da nap thanh cong " . $amount . " VND vao tai khoan " . $username . " tren soanbaigiang.smas.vn";
    371376                        $status = 1;
    372377                } else {
  • pro-violet-viettel/sourcecode/application/modules/services/controllers/viettel.php

    r535 r579  
    5555                        $CI->load->model('Services_model');
    5656                        $CI->load->model('frontend/User_model', 'objUserModel');
    57                         $result = $CI->Services_model->processMORequest($userID, strtoupper($info));
     57                        $result = $CI->Services_model->processMORequest($userID, $info);
    5858                        $CI->objUserModel->insertSmslog($receiverID, $serviceID, $commandCode, $info, $receiveTime);
    5959                                       
  • pro-violet-viettel/sourcecode/application/modules/services/models/services_model.php

    r575 r579  
    3939                _SBG_MO_PHONENUM_CHANGE         => array('pattern' => '/^(SBG[[:blank:]])(DDT)([[:blank:]][0-9]{10,11})([[:blank:]][a-zA-Z0-9]{4,16})$/'),
    4040                _SBG_MO_PASSWORD_RECOVERY       => array('pattern' => '/^(SBG[[:blank:]])(MK)$/'),
    41                 _SBG_MO_PASSWORD_CHANGE         => array('pattern' => '/^(SBG[[:blank:]])(MK)([[:blank:]][a-zA-Z0-9]{4,16})$/'),
     41                _SBG_MO_PASSWORD_CHANGE         => array('pattern' => '/^(SBG[[:blank:]])(MK)([[:blank:]][a-zA-Z0-9~!@#$%^&*]{4,16})$/'),
    4242                _SBG_MO_VIP_REGISTER            => array('pattern' => '/^(SBG[[:blank:]])(VIP)([[:blank:]][0-9]{1,2})$/'),
    4343                _SBG_MO_PAY_TO_ACCOUNT          => array('pattern' => '/^(SBG[[:blank:]])(NAP)([[:blank:]][0-9]{3,})$/'),
     
    5050        }
    5151       
    52         private function messageAnalys ($message)
    53         {
    54                 $aryMatched = array();
     52        public function messageAnalys ($message)
     53        {
     54                $aryMatched = array(); 
     55                $aryContent = array();
    5556                $result = false;
    56                 foreach ($this->_arySmsMO as $key => $pattern)
     57               
     58                foreach ($this->_arySmsMO as $key => $pattern)
    5759                {
    58                         $result = preg_match($pattern['pattern'], $message, $aryMatched);
     60                        $result = preg_match_all ($pattern['pattern'], strtoupper($message), $aryMatched);
    5961                        if ((bool)$result) break;
    6062                }
    6163               
     64                if (count ($aryMatched) > 0) {
     65                        foreach ($aryMatched as $k => $val) {
     66                                if ($k == 0) continue;
     67                                $aryContent[] = trim($val[0]);                 
     68                        }
     69                }
     70       
    6271                $key = (bool)$result ? $key:_SBG_MO_SYNTAX_ERR;
    63                 $aryResult = (bool)$result ? array('case' => $key, 'content' => $aryMatched):array('case' => $key);
     72                if ($key == _SBG_MO_PASSWORD_CHANGE || $key == _SBG_MO_PHONENUM_CHANGE) {
     73                        $index = $key == _SBG_MO_PASSWORD_CHANGE ? 2 : 3;
     74                        $upcasePass = $aryContent[$index];
     75                        $password = substr($message, -strlen($upcasePass));
     76                        $aryContent[$index] = $password;
     77                }
     78                       
     79                $aryResult = (bool)$result ? array('case' => $key, 'content' => $aryContent):array('case' => $key);
    6480                return $aryResult;
    6581        }
     
    7591                $case = $aryMOAnalys['case'];
    7692                $aryContents = isset($aryMOAnalys['content']) ? $aryMOAnalys['content']: null;
    77                 if ($aryContents != null){
    78                         unset($aryContents[0]);
    79                         $aryTmp = array();                     
    80                         foreach ($aryContents as $key => $val)
    81                         {
    82                                 $aryTmp[] = trim($val);
    83                         }
    84                         $aryContents = $aryTmp;
    85                 }
    86                
     93                $debugMsg .= var_export($aryMOAnalys);
    8794                $this->load->model('frontend/user_model', 'objUserModel');
    8895                $debugMsg .= $case;
     
    93100                                $userName = isset($aryContents[2]) ? $this->formatPhoneNumber($aryContents[2]) : $sentNumber; 
    94101                                $collaborator = isset($aryContents[2]) ? $sentNumber:null;
    95                                 $sms = $this->objUserModel->register($userName, $collaborator);
     102                                $collaboratorMsg = '';
     103                                $sms = $this->objUserModel->register($userName, $collaborator, $collaboratorMsg);
    96104                                if ($case == _SBG_MO_REGISTER_FOR) {
    97                                         $smsReturn = '1|Ban da dang ky thanh cong dich vu Soan bai giang Online cho '. $userName;
     105                                        $smsReturn = $collaboratorMsg;
    98106                                        $arySMS = explode ('|', $sms);
    99                                         $sendMT = $this->sendMT($userName, $arySMS[1]);
     107                                        if ((int)$arySMS[0] == 1 )
     108                                                $sendMT = $this->sendMT($this->formatPhoneNumber($userName, -1), $arySMS[1]);
    100109                                }
    101110                                else {
     
    131140                                        $smsReturn = $this->objUserModel->rechargeAccount($userName, $amount);
    132141                                        if (_SBG_MO_PAY_TO_ACCOUNT_FOR) {
    133                                                 $smsMT = $smsReturn .' tu thue bao '. $sentNumber;
    134                                                 $sendMT = $this->sendMT($userName, $smsMT);
     142                                                $arySmsReturn = explode ('|', $smsReturn);
     143                                                $smsMT = $arySmsReturn[1] .' tu thue bao '. $sentNumber;
     144                                                $sendMT = $this->sendMT($this->formatPhoneNumber($userName, -1), $smsMT);
    135145                                        }
    136146                                }
     
    147157                }
    148158               
    149                 return $smsReturn;
     159                return $smsReturn.'|'.$case;
    150160        }
    151161       
     
    272282        }
    273283       
    274         public function formatPhoneNumber ($phoneNumber) {
     284        public function formatPhoneNumber ($phoneNumber, $direction = 1) {
    275285                $aryMatch = array();
    276                 if (preg_match('/^(84)([0-9]{9,10})$/', $phoneNumber, $aryMatch) == 1) {
     286                if (preg_match('/^(84)([0-9]{9,10})$/', $phoneNumber, $aryMatch) == 1 && $direction == 1) {
    277287                        $result = '0'. $aryMatch[2];
    278288                }
    279                 else if (preg_match('/^(0)([0-9]{9,10})$/', $phoneNumber)) {
     289                else if (preg_match('/^(0)([0-9]{9,10})$/', $phoneNumber) == 1 && $direction == 1) {
    280290                        $result = $phoneNumber;
    281291                }
     292                else if (preg_match('/^(84)([0-9]{9,10})$/', $phoneNumber) == 1 && $direction == -1) {
     293                        $result = $phoneNumber;
     294                }
     295                else if (preg_match('/^(0)([0-9]{9,10})$/', $phoneNumber, $aryMatch) == 1 && $direction == -1) {
     296                        $result = '84'. $aryMatch[2];
     297                }
    282298               
    283299                return $result;
Note: See TracChangeset for help on using the changeset viewer.