Ignore:
Timestamp:
Nov 21, 2014 6:51:26 PM (10 years ago)
Author:
dungnv
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • pro-violet-viettel/sourcecode/application/modules/services/models/services_model.php

    r613 r615  
    4949                _SBG_MO_REGISTER                        => array('pattern' => '/^(SBG[[:blank:]])(DK)$/'),
    5050                _SBG_MO_REGISTER_FOR            => array('pattern' => '/^(SBG[[:blank:]])(DK)([[:blank:]][0-9]{10,11})$/'),
    51                 _SBG_MO_PHONENUM_CHANGE         => array('pattern' => '/^(SBG[[:blank:]])(DDT)([[:blank:]][0-9]{10,11})([[:blank:]][a-zA-Z0-9~!@#$%^&*]{4,16})$/'),
     51                _SBG_MO_PHONENUM_CHANGE         => array('pattern' => '/^(SBG[[:blank:]])(DDT)([[:blank:]][0-9]{10,11})([[:blank:]][a-zA-Z0-9]{1,})$/'),
    5252                _SBG_MO_PASSWORD_RECOVERY       => array('pattern' => '/^(SBG[[:blank:]])(MK)$/'),
    5353                /* _SBG_MO_PASSWORD_CHANGE      => array('pattern' => '/^(SBG[[:blank:]])(MK)([[:blank:]][a-zA-Z0-9~!@#$%^&*]{4,16})$/'), */
     
    5858        );
    5959       
    60         private $_arySmsService = array(
    61                         'DK' => _SBG_MO_REGISTER_FOR,
    62                         'DDT' => _SBG_MO_PHONENUM_CHANGE,
    63                         'NAP' => _SBG_MO_PAY_TO_ACCOUNT_FOR,
    64         );     
     60        private $_aryServiceName = array('DK','DDT','VIP','NAP');       
    6561       
    6662        public function __construct(){
     
    7672                foreach ($this->_arySmsMO as $key => $pattern)
    7773                {
    78                         $result = preg_match_all ($pattern['pattern'], strtoupper($message), $aryMatched);
     74                        $result = preg_match_all ($pattern['pattern'], strtoupper(trim($message)), $aryMatched);
    7975                        if ((bool)$result) break;
    8076                }
     
    8581                        foreach ($aryMatched as $k => $val) {
    8682                                if ($k == 0) continue;
     83                                if (count($val) == 0) {
     84                                        $key = _SBG_MO_SYNTAX_ERR;
     85                                        break;
     86                                }
    8787                                $aryContent[] = trim($val[0]);                 
    8888                        }
     
    9191                if ((bool)$result == FALSE) {
    9292                        $aryContent = array();
    93                         foreach(explode(' ',strtoupper($message)) as $k => $val) {
     93                        foreach(explode(' ',strtoupper(trim($message))) as $k => $val) {
    9494                                $aryContent[] = $val;
    9595                        }
    96                         $key = $this->_arySmsService[$aryContent[1]];
    97                         $result = 1;
    98                 }
    99                
    100                 if ($key == _SBG_MO_PASSWORD_CHANGE || $key == _SBG_MO_PHONENUM_CHANGE) {
    101                         $index = $key == _SBG_MO_PASSWORD_CHANGE ? 2 : 3;
    102                         $upcasePass = $aryContent[$index];
     96                       
     97                        $serviceName = $aryContent[1];
     98                        if (in_array($serviceName, $this->_aryServiceName)) {
     99                                if ($serviceName == 'DK' && count($aryContent) == 3) {
     100                                        $key = _SBG_MO_REGISTER_FOR;
     101                                }
     102                                else if ($serviceName == 'DDT' && count($aryContent) == 4){
     103                                        $key = _SBG_MO_PHONENUM_CHANGE;
     104                                }
     105                                else if ($serviceName == 'VIP' && count($aryContent) == 3){
     106                                        $key = _SBG_MO_VIP_REGISTER;
     107                                }else if ($serviceName == 'NAP' && count($aryContent) == 3){
     108                                        $key = _SBG_MO_PAY_TO_ACCOUNT;
     109                                }else if ($serviceName == 'NAP' && count($aryContent) == 4){
     110                                        $key = _SBG_MO_PAY_TO_ACCOUNT_FOR;
     111                                }
     112                               
     113                                foreach ($aryContent as $k => $val) {
     114                                        $aryContent[$k] = trim($val);
     115                                }
     116                               
     117                                $result = TRUE;
     118                        }
     119                }
     120               
     121                if ($key == _SBG_MO_PHONENUM_CHANGE) {
     122                        $upcasePass = $aryContent[3];
    103123                        $password = substr($message, -strlen($upcasePass));
    104124                        $aryContent[$index] = $password;
     125                }
     126               
     127                if ($key == _SBG_MO_REGISTER || $key == _SBG_MO_PASSWORD_RECOVERY) {
     128                        $debugMsg = var_export($aryContent, TRUE);
     129                        write_file('regis_log', $debugMsg);
    105130                }
    106131                       
     
    122147                $this->load->model('frontend/user_model', 'objUserModel');
    123148                $debugMsg .= $case;
    124                 write_file('mt_log', $debugMsg);
     149               
    125150                switch ($case) {
    126151                        case _SBG_MO_REGISTER:
     
    136161                                $collaborator = isset($aryContents[2]) ? $sentNumber:null;
    137162                                $collaboratorMsg = '';
     163                               
    138164                                $sms = $this->objUserModel->register($userName, $collaborator, $collaboratorMsg);
     165                                write_file('mt_log', $collaborator);
    139166                                if ($case == _SBG_MO_REGISTER_FOR) {
    140167                                        $smsReturn = $collaboratorMsg;
     
    152179                                        break;
    153180                                }
     181                               
    154182                                $oldPhoneNumber = $this->formatPhoneNumber($aryContents[2]);
    155183                                $password = $aryContents[3];
    156184                                $smsReturn = $this->objUserModel->changeProfile($sentNumber, $oldPhoneNumber, $password);
     185                               
     186                                $arySMS = explode('|', $smsReturn);
     187                                $changeResult = (int)$arySMS[0];
     188                               
    157189                                $sms = 'Ban da doi thanh cong so dien thoai tren SBG Online sang so dien thoai ' .$sentNumber. '. Tran trong.';
    158                                 $sendMT = $this->sendMT($this->formatPhoneNumber($oldPhoneNumber, -1), $sms);
     190                                $sendMT = $changeResult == 1 ? $this->sendMT($this->formatPhoneNumber($oldPhoneNumber, -1), $sms) : '';
    159191                                break;
    160192                        case _SBG_MO_PASSWORD_RECOVERY:
    161                         case _SBG_MO_PASSWORD_CHANGE:
    162                                 $password = isset($aryContents[2]) ? $aryContents[2] : null;
    163                                 $smsReturn = $this->objUserModel->changePassword($sentNumber, $password);
     193                        /* case _SBG_MO_PASSWORD_CHANGE: */
     194                                /* $password = isset($aryContents[2]) ? $aryContents[2] : null; */
     195                                $smsReturn = $this->objUserModel->changePassword($sentNumber/* , $password */);
    164196                                break;                                         
    165197                        case _SBG_MO_VIP_REGISTER:
     
    177209                               
    178210                                $amount = $aryContents[2];
     211                                if (!preg_match('/^[0-9]{3,}$/', $amount)) {
     212                                        $smsReturn = '0|So tien nap khong hop le.';
     213                                        break;
     214                                }
     215                               
    179216                                $result =$this->chargeRootAccountProcess($sentNumber, $amount, $sentNumber.' paid for SBG');
    180217                               
Note: See TracChangeset for help on using the changeset viewer.