コード例 #1
0
 public function actionVerifyWifi()
 {
     $phone = $_SESSION['phoneverifyWifiEvent'];
     if ($phone) {
         $return = array('phone' => $phone, 'error' => 0, 'msg' => '');
         if (isset($_POST['code'])) {
             $userVerify = UserVerifyModel::model()->findByAttributes(array('msisdn' => $phone, 'action' => 'register_event83'));
             if (empty($userVerify) || $userVerify->verify_code != $_POST['code']) {
                 $return['error'] = 1;
                 $return['msg'] = "Mã xác nhận của Quý Khác không chính xác!";
             } else {
                 // Xác thực thành công
                 $userVerify->delete();
                 $isUserSub = WapUserSubscribeModel::model()->chkIsSubscribe($phone);
                 /* if(!$isUserSub){//chua da dang ky
                 				try{
                 					$bmUrl = yii::app()->params['bmConfig']['remote_wsdl'];
                 					$client = new SoapClient($bmUrl, array('trace' => 1));
                 					$params = array(
                 							'phone' => $phone,
                 							'package' => 'CHACHAFUN',
                 							'source' => 'wap',
                 							'promotion' => 0
                 					);
                 					$result = $client->__soapCall('userRegister', $params);
                 				}catch (Exception $e)
                 				{
                 					//
                 				}
                 			} */
                 $identity = new UserIdentity(null, null);
                 if ($identity->userAuthenticateWifi($phone)) {
                     Yii::app()->user->login($identity);
                 }
                 if ($isUserSub) {
                     $this->redirect('/event/play');
                     Yii::app()->end();
                 } else {
                     $this->redirect('/event');
                     Yii::app()->end();
                 }
             }
         }
         $this->render('verifyWifi', $return);
     } else {
         $this->redirect('/event/register');
     }
 }
コード例 #2
0
 public function actionRepassword()
 {
     $error = "";
     $phone = Yii::app()->request->getParam('phone');
     if (Yii::app()->request->isPostRequest) {
         if (!empty($phone)) {
             $phone = Formatter::formatPhone($phone);
             if (Formatter::isPhoneNumber(Formatter::removePrefixPhone($phone))) {
                 $user = WapUserModel::model()->findByPhone($phone);
                 if (!empty($user)) {
                     // check 3 lan trong ngay
                     $action = "updatepass";
                     $check_otp = UserVerifyModel::model()->checkOtp($phone, $action);
                     if ($check_otp) {
                         // gửi ma otp xac thuc
                         $verify_code = rand(1000, 9999);
                         $userVerify = new UserVerifyModel();
                         $userVerify->msisdn = $phone;
                         $userVerify->created_time = new CDbExpression('NOW()');
                         $userVerify->verify_code = $verify_code;
                         $userVerify->action = $action;
                         $userVerify->save();
                         $sentMsg = Yii::t('wap', Yii::app()->params['subscribe']['success_otp_password'], array(":OTP" => $verify_code));
                         $smsClient = new SmsClient();
                         $smsClient->sentSmsText($phone, $sentMsg);
                         Yii::app()->session['user_phone'] = $phone;
                         $this->redirect(Yii::app()->createUrl("/account/activeOtp", array('action' => 'updatepass')));
                     } else {
                         $error = Yii::t("wap", "You only use this feature three times a day. Thank you very much.");
                     }
                 } else {
                     $error = Yii::t("wap", "Phone number not found");
                 }
             } else {
                 $error = Yii::t("wap", "Phone number incorrect!");
             }
         } else {
             $error = Yii::t("wap", "Please put your phone number");
         }
     }
     $this->render('repassword', compact('error'));
 }