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

Legend:

Unmodified
Added
Removed
  • 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.