- Timestamp:
- Nov 20, 2014 11:00:32 AM (10 years ago)
- 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 55 55 $CI->load->model('Services_model'); 56 56 $CI->load->model('frontend/User_model', 'objUserModel'); 57 $result = $CI->Services_model->processMORequest($userID, strtoupper($info));57 $result = $CI->Services_model->processMORequest($userID, $info); 58 58 $CI->objUserModel->insertSmslog($receiverID, $serviceID, $commandCode, $info, $receiveTime); 59 59 -
pro-violet-viettel/sourcecode/application/modules/services/models/services_model.php
r575 r579 39 39 _SBG_MO_PHONENUM_CHANGE => array('pattern' => '/^(SBG[[:blank:]])(DDT)([[:blank:]][0-9]{10,11})([[:blank:]][a-zA-Z0-9]{4,16})$/'), 40 40 _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})$/'), 42 42 _SBG_MO_VIP_REGISTER => array('pattern' => '/^(SBG[[:blank:]])(VIP)([[:blank:]][0-9]{1,2})$/'), 43 43 _SBG_MO_PAY_TO_ACCOUNT => array('pattern' => '/^(SBG[[:blank:]])(NAP)([[:blank:]][0-9]{3,})$/'), … … 50 50 } 51 51 52 private function messageAnalys ($message) 53 { 54 $aryMatched = array(); 52 public function messageAnalys ($message) 53 { 54 $aryMatched = array(); 55 $aryContent = array(); 55 56 $result = false; 56 foreach ($this->_arySmsMO as $key => $pattern) 57 58 foreach ($this->_arySmsMO as $key => $pattern) 57 59 { 58 $result = preg_match ($pattern['pattern'], $message, $aryMatched);60 $result = preg_match_all ($pattern['pattern'], strtoupper($message), $aryMatched); 59 61 if ((bool)$result) break; 60 62 } 61 63 64 if (count ($aryMatched) > 0) { 65 foreach ($aryMatched as $k => $val) { 66 if ($k == 0) continue; 67 $aryContent[] = trim($val[0]); 68 } 69 } 70 62 71 $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); 64 80 return $aryResult; 65 81 } … … 75 91 $case = $aryMOAnalys['case']; 76 92 $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); 87 94 $this->load->model('frontend/user_model', 'objUserModel'); 88 95 $debugMsg .= $case; … … 93 100 $userName = isset($aryContents[2]) ? $this->formatPhoneNumber($aryContents[2]) : $sentNumber; 94 101 $collaborator = isset($aryContents[2]) ? $sentNumber:null; 95 $sms = $this->objUserModel->register($userName, $collaborator); 102 $collaboratorMsg = ''; 103 $sms = $this->objUserModel->register($userName, $collaborator, $collaboratorMsg); 96 104 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; 98 106 $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]); 100 109 } 101 110 else { … … 131 140 $smsReturn = $this->objUserModel->rechargeAccount($userName, $amount); 132 141 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); 135 145 } 136 146 } … … 147 157 } 148 158 149 return $smsReturn ;159 return $smsReturn.'|'.$case; 150 160 } 151 161 … … 272 282 } 273 283 274 public function formatPhoneNumber ($phoneNumber ) {284 public function formatPhoneNumber ($phoneNumber, $direction = 1) { 275 285 $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) { 277 287 $result = '0'. $aryMatch[2]; 278 288 } 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) { 280 290 $result = $phoneNumber; 281 291 } 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 } 282 298 283 299 return $result;
Note: See TracChangeset
for help on using the changeset viewer.