- Timestamp:
- Nov 21, 2014 6:51:26 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pro-violet-viettel/sourcecode/application/modules/services/models/services_model.php
r613 r615 49 49 _SBG_MO_REGISTER => array('pattern' => '/^(SBG[[:blank:]])(DK)$/'), 50 50 _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,})$/'), 52 52 _SBG_MO_PASSWORD_RECOVERY => array('pattern' => '/^(SBG[[:blank:]])(MK)$/'), 53 53 /* _SBG_MO_PASSWORD_CHANGE => array('pattern' => '/^(SBG[[:blank:]])(MK)([[:blank:]][a-zA-Z0-9~!@#$%^&*]{4,16})$/'), */ … … 58 58 ); 59 59 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'); 65 61 66 62 public function __construct(){ … … 76 72 foreach ($this->_arySmsMO as $key => $pattern) 77 73 { 78 $result = preg_match_all ($pattern['pattern'], strtoupper( $message), $aryMatched);74 $result = preg_match_all ($pattern['pattern'], strtoupper(trim($message)), $aryMatched); 79 75 if ((bool)$result) break; 80 76 } … … 85 81 foreach ($aryMatched as $k => $val) { 86 82 if ($k == 0) continue; 83 if (count($val) == 0) { 84 $key = _SBG_MO_SYNTAX_ERR; 85 break; 86 } 87 87 $aryContent[] = trim($val[0]); 88 88 } … … 91 91 if ((bool)$result == FALSE) { 92 92 $aryContent = array(); 93 foreach(explode(' ',strtoupper( $message)) as $k => $val) {93 foreach(explode(' ',strtoupper(trim($message))) as $k => $val) { 94 94 $aryContent[] = $val; 95 95 } 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]; 103 123 $password = substr($message, -strlen($upcasePass)); 104 124 $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); 105 130 } 106 131 … … 122 147 $this->load->model('frontend/user_model', 'objUserModel'); 123 148 $debugMsg .= $case; 124 write_file('mt_log', $debugMsg);149 125 150 switch ($case) { 126 151 case _SBG_MO_REGISTER: … … 136 161 $collaborator = isset($aryContents[2]) ? $sentNumber:null; 137 162 $collaboratorMsg = ''; 163 138 164 $sms = $this->objUserModel->register($userName, $collaborator, $collaboratorMsg); 165 write_file('mt_log', $collaborator); 139 166 if ($case == _SBG_MO_REGISTER_FOR) { 140 167 $smsReturn = $collaboratorMsg; … … 152 179 break; 153 180 } 181 154 182 $oldPhoneNumber = $this->formatPhoneNumber($aryContents[2]); 155 183 $password = $aryContents[3]; 156 184 $smsReturn = $this->objUserModel->changeProfile($sentNumber, $oldPhoneNumber, $password); 185 186 $arySMS = explode('|', $smsReturn); 187 $changeResult = (int)$arySMS[0]; 188 157 189 $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) : ''; 159 191 break; 160 192 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 */); 164 196 break; 165 197 case _SBG_MO_VIP_REGISTER: … … 177 209 178 210 $amount = $aryContents[2]; 211 if (!preg_match('/^[0-9]{3,}$/', $amount)) { 212 $smsReturn = '0|So tien nap khong hop le.'; 213 break; 214 } 215 179 216 $result =$this->chargeRootAccountProcess($sentNumber, $amount, $sentNumber.' paid for SBG'); 180 217
Note: See TracChangeset
for help on using the changeset viewer.