Esempio n. 1
0
 /**
  * 判定用户手机验证码是否正确
  * @return bool
  */
 public function actionCodecheck()
 {
     $phone = $_POST['CellPhone'];
     $code = $_POST['code'];
     $return = \frontend\actions\app\Port::checkPhnoe($phone, $code);
     if ($return['errorNum'] == 0) {
         return true;
         exit;
     } else {
         return false;
         exit;
     }
 }
Esempio n. 2
0
 public function actionForgotfinish()
 {
     if ($_POST) {
         $real_name = $_POST['real_name'];
         $idcard = $_POST['idcard'];
         $phone = $_POST['phone'];
         //$return = member::resetwechatPassword($session->get('phone'),$_POST['password'],$_POST['repassword'],$session->get('code'));
         $password = $_POST['password'];
         $repeatpassword = $_POST['repassword'];
         $code = $_POST['code'];
         $result = Port::checkPhnoe($phone, $code);
         if ($result['errorNum'] == 1) {
             return $this->goBack(['info' => $result['errorMsg']], Url::to(['forgot']));
         } else {
             $model = UcenterMember::find()->where(['phone' => $phone, 'real_name' => $real_name, 'idcard' => $idcard])->one();
             $row = UcenterMember::find()->where(['phone' => $phone, 'real_name' => $real_name, 'idcard' => $idcard])->count();
             if ($row == 1) {
                 $model->password_hash = yii::$app->security->generatePasswordHash($password);
                 $app_pwd = md5(sha1($password) . time());
                 $model->app_pwd = $app_pwd;
                 if ($model->save(false)) {
                     header("Content-type: text/html; charset=utf-8");
                     echo "<script>alert('密码修改成功')</script>";
                     return $this->view('signin');
                     exit;
                 }
             } else {
                 header("Content-type: text/html; charset=utf-8");
                 echo "<script>alert('密码修改失败,请联系客服!')</script>";
                 echo "<script>window.location.href='" . \yii\helpers\Url::to(['forgot']) . "'</script>";
                 exit;
             }
         }
     }
 }
Esempio n. 3
0
 /**
  *以后做推广活动进行的注册操作
  * @param $phone 手机号
  * @param $pwd  密码
  * @param $phone_code 手机验证码
  * @param $from 用户来源
  * @param string  $userIp 注册ip
  * @param string  $from  注册来源
  * @return array
  */
 public static function the_promotion_register($phone, $pwd, $phone_code, $from)
 {
     //注册来源
     $from = $from;
     //判定手机号是否注册
     $flag = self::phoneIsRegister($phone);
     if ($flag) {
         $return = array('errorNum' => '1', 'errorMsg' => '此手机号已注册,请直接登录', 'data' => null);
         return $return;
     } elseif (!preg_match('/^(?![0-9]+$)(?![a-z]+$)(?![A-Z]+$)[0-9a-zA-Z]{6,16}$/', $pwd)) {
         $return = array('errorNum' => '1', 'errorMsg' => '密码应该是数字、字母组成的6到16位字符', 'data' => null);
         return $return;
     }
     //手机短息验证码验证
     $check = Port::checkPhnoe($phone, $phone_code);
     $session_key = "";
     //生成app的密码
     $app_pwd = md5(sha1($pwd) . time());
     // 根据ip获取地区---Yii::$app->request->userIp
     $userIp = Yii::$app->request->userIp;
     $area = self::get_area($userIp);
     $area = $area ? $area : '地球';
     if (!$check['errorNum']) {
         //事物回滚
         $transaction = \Yii::$app->db->beginTransaction();
         try {
             $user = new UcenterMember();
             $user->username = $phone;
             $user->phone = $phone;
             $user->setPassword(trim($pwd));
             $user->create_ip = $userIp;
             $user->create_area = $area;
             $user->create_channel = (int) $from;
             $user->status = UcenterMember::STATUS_ACTIVE;
             $user->lock = UcenterMember::TYPE_UNLOCK;
             //app密码设定
             $user->app_pwd = $app_pwd;
             ///
             $user->generateAuthKey();
             if ($user->save()) {
                 //生成邀请码
                 $new_uid = $user->id;
                 $invitation_code = 'v' . $new_uid * 99;
                 $user->invitation_code = $invitation_code;
                 $user->save();
                 //初始换用户账户
                 $asset_info = new Info();
                 $asset_info->member_id = $user['id'];
                 $asset_info->balance = 0;
                 $asset_info->freeze = 0;
                 if ($asset_info->save()) {
                     $uid = $user['id'];
                     //注册动作完成---进行登录操作
                     $log = new Log();
                     $log->member_id = $uid;
                     $log->login_ip = Yii::$app->request->userIp;
                     $log->login_time = time();
                     $log->login_area = $area;
                     $log->status = self::LOG_CONFIM;
                     $res = $log->save();
                     if ($res) {
                         $session_key = self::verification($uid) . '--' . $from;
                         $session = new Sessionkey();
                         $session->uid = $uid;
                         $session->sessionkey = $session_key;
                         $session->status = self::STATUS_ACTIVE;
                         $res = $session->save();
                         if ($res) {
                             $log->status = self::LOG_SUSSESS;
                             $log->save();
                             //新用户注册送体验金---6666
                             self::give_experience_gold(1, $user['id']);
                         } else {
                             $return = array('errorNum' => '1', 'errorMsg' => '登陆失败', 'data' => null);
                             return $return;
                         }
                     } else {
                         $return = array('errorNum' => '1', 'errorMsg' => '登陆记录失败', 'data' => null);
                         return $return;
                     }
                 } else {
                     $return = array('errorNum' => '1', 'errorMsg' => '账户初始化失败', 'data' => null);
                     return $return;
                 }
             } else {
                 $return = array('errorNum' => '1', 'errorMsg' => '注册失败', 'data' => null);
                 return $return;
             }
             $transaction->commit();
             //事务成功提交后返回数据
             $data = array('sessionkey' => $session_key, 'balance' => 0, 'phone' => $phone, 'app_pwd' => $app_pwd);
             $return = array('errorNum' => '0', 'errorMsg' => 'success', 'data' => $data);
             return $return;
         } catch (\Exception $e) {
             $transaction->rollBack();
             $remark = $e->getMessage();
             $result = array('errorNum' => '1', 'errorMsg' => $remark, 'data' => null);
             return $result;
         }
     } else {
         $return = array('errorNum' => '1', 'errorMsg' => $check['errorMsg'], 'data' => null);
         return $return;
     }
 }