Ejemplo n.º 1
0
 /**
  * 验证手机验证码
  */
 public function validateCode($attribute, $params)
 {
     try {
         $result = Port::checkPhnoe($this->username, $this->validate_code);
     } catch (ErrorException $ex) {
         $this->addError($attribute, Yii::t('app', '验证码无效,请重新获取。'));
     }
 }
Ejemplo n.º 2
0
 /**
  * 判定用短信验证码是否正确
  * @return bool
  */
 public function actionSmscode()
 {
     $phone = $_POST['phone'];
     $code = $_POST['code'];
     try {
         $res = Port::checkPhnoe($phone, $code);
     } catch (ErrorException $e) {
         return false;
         exit;
     }
     if ($res) {
         return true;
         exit;
     } else {
         return false;
         exit;
     }
 }
Ejemplo n.º 3
0
 public function actionSignup()
 {
     //判断注册URL中是否包含邀请码参数
     if (isset($_GET['code'])) {
         $code = $_GET['code'];
         //$_code_source = UcenterMember::find()->where(['invitation_code'=>$code])->one();
         //if(count($_code_source) != 1)
         $flag = \frontend\actions\app\member::verify_code($code);
         if (!$flag) {
             header("Content-type: text/html; charset=utf-8");
             echo "<script>alert('来源链接不合法!')</script>";
             echo "<script>window.location.href='" . \yii\helpers\Url::to(['site/signup']) . "'</script>";
             exit;
         }
     }
     $model = new SignupForm();
     //是否邀请注册
     $test_invite = 1;
     if ($model->load(Yii::$app->request->post())) {
         if ($_POST['SignupForm']['username'] && $_POST['SignupForm']['validate_code'] && $_POST['SignupForm']['password'] && $_POST['SignupForm']['password_repeat']) {
             $invite_code = $_POST["SignupForm"]['invitation_code'];
             //使用测试邀请码
             if ($test_invite) {
                 //使用测试邀请
                 $flag = \frontend\actions\app\member::verify_code($invite_code);
                 //验证码通过
                 if (!$flag) {
                     echo "<script>alert('" . '邀请码错误' . "')</script>";
                 }
             }
             $_phone = $_POST['SignupForm']['username'];
             $_code = $_POST['SignupForm']['validate_code'];
             try {
                 $result = Port::checkPhnoe($_phone, $_code);
                 if (is_bool($result)) {
                 }
             } catch (ErrorException $e) {
                 header("Content-type: text/html; charset=utf-8");
                 echo "<script>alert('" . $e->getMessage() . "')</script>";
                 echo "<script>location.href='" . \yii\helpers\Url::to(['site/signup']) . "'</script>";
                 exit;
             }
             $user = new UcenterMember();
             $user->username = $_POST["SignupForm"]['username'];
             $user->phone = $_POST["SignupForm"]['username'];
             $user->invitation_code = $_POST["SignupForm"]['invitation_code'];
             $password = $_POST["SignupForm"]['password'];
             $user->setPassword($password);
             $user->create_ip = Yii::$app->request->userIp;
             $app_pwd = md5(sha1($password) . time());
             $user->app_pwd = $app_pwd;
             try {
                 $area = self::get_area(Yii::$app->request->userIp);
                 $user->create_area = $area;
             } catch (ErrorException $e) {
             }
             $user->generateAuthKey();
             if ($user->save()) {
                 $uid = $user['id'];
                 if ($test_invite) {
                     //使用验证码
                     $flag = \frontend\actions\app\member::verify_code($invite_code);
                     $invite_flag = \frontend\actions\app\member::use_code($flag, $uid);
                     if (!$invite_flag) {
                         $return = array('errorNum' => '1', 'errorMsg' => '注册失败', 'data' => null);
                         return $return;
                     }
                 }
                 if (Yii::$app->getUser()->login($user)) {
                     $newModel = UcenterMember::find()->where(['id' => Yii::$app->user->id])->one();
                     //$newModel->invitation_id= \yii::$app->params['invitation_id'];
                     $invitation_code = Utils::createcode();
                     $newModel->invitation_code = $invitation_code;
                     $newModel->person_face = Setting::find()->where("code='img'")->one()->value;
                     if ($_POST['url_code']) {
                         $code_source = UcenterMember::find()->where(['invitation_code' => $_POST["url_code"]])->asArray()->one();
                         if ($code_source) {
                             $newModel->invitation_id = $code_source['id'];
                         }
                         //好友注册领取体验金
                         $rule = Rule::find()->where(['title' => '好友注册', 'status' => Rule::STATUS_ACTIVE])->one();
                         if ($rule) {
                             $rid = $rule->id;
                             $r_money = $rule->money;
                             $model_gold = new Gold();
                             $model_gold->rid = $rid;
                             $model_gold->money = $r_money;
                             $model_gold->uid = $code_source['id'];
                             $model_gold->created_at = strtotime("now");
                             $model_gold->save();
                         }
                     } elseif ($_POST['SignupForm']['invitation_code']) {
                         $code_source = UcenterMember::find()->where(['invitation_code' => $_POST["SignupForm"]["invitation_code"]])->asArray()->one();
                         if ($code_source) {
                             $newModel->invitation_id = $code_source['id'];
                         }
                         //好友注册领取体验金
                         $rule = Rule::find()->where(['title' => '好友注册', 'status' => Rule::STATUS_ACTIVE])->one();
                         if ($rule) {
                             $rid = $rule->id;
                             $r_money = $rule->money;
                             $model_gold = new Gold();
                             $model_gold->rid = $rid;
                             $model_gold->money = $r_money;
                             $model_gold->uid = $code_source['id'];
                             $model_gold->created_at = strtotime("now");
                             $model_gold->save();
                         }
                     }
                     $newModel->save(false);
                     $model_asset_info = new Info();
                     $model_asset_info->member_id = yii::$app->user->id;
                     $model_asset_info->create_at = strtotime("now");
                     $model_asset_info->save(false);
                     //手机号注册领取体验金
                     $rule = Rule::find()->where(['title' => '手机号注册', 'status' => Rule::STATUS_ACTIVE])->one();
                     if ($rule) {
                         $rid = $rule->id;
                         $r_money = $rule->money;
                         $model_gold = new Gold();
                         $model_gold->rid = $rid;
                         $model_gold->money = $r_money;
                         $model_gold->uid = $code_source['id'];
                         $model_gold->created_at = strtotime("now");
                         $model_gold->save();
                     }
                     return $this->goHome();
                 }
             }
         }
     }
     return $this->render('signup', compact("model", "code"));
 }
Ejemplo n.º 4
0
 public function actionRepass()
 {
     $uid = yii::$app->user->id;
     //判断验证码正确性
     if (isset($_POST['CellPhone']) && isset($_POST['validate_code'])) {
         $phone = $_POST['CellPhone'];
         $code = $_POST['validate_code'];
         try {
             $result = Port::checkPhnoe($phone, $code);
             if (is_bool($result)) {
                 $session = yii::$app->session;
                 $session->open();
                 $session['phone'] = $phone;
                 echo '验证通过0001';
                 exit;
             } else {
                 echo '验证失败0002';
                 exit;
             }
         } catch (ErrorException $e) {
             echo $e->getMessage();
             exit;
         }
     }
     return $this->render('repass', compact("infos_rar", "model"));
 }