/**
  * Creates a new User model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new User();
     $data = Yii::$app->request->post();
     // echo var_dump($data);
     if ($data != false) {
         $model->pwd = md5($data['User']['pwd']);
         $model->shared = $data['User']['shared'];
         $model->follower = $data['User']['follower'];
         $model->favour = $data['User']['favour'];
         $model->area = $data['User']['area'];
         $model->gender = $data['User']['gender'];
         $model->hobby = $data['User']['hobby'];
         $model->nickname = $data['User']['nickname'];
         $model->phone = $data['User']['phone'];
         $model->signature = $data['User']['signature'];
         $model->created_at = time();
         $model->updated_at = time();
         $model->thumb = $data['icon'];
         $model->job = $data['User']['job'];
         $model->authKey = 0;
         if ($model->save()) {
             return $this->redirect(['view', 'id' => $model->id]);
         }
     } else {
         return $this->render('create', ['model' => $model]);
     }
     return $this->render('create', ['model' => $model]);
 }
예제 #2
0
 /**
  * Creates a new User model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new User();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
예제 #3
0
 public function actionVerify()
 {
     $data = Yii::$app->request->post();
     $info = Vercode::find()->select('*')->where(['phone' => $data['phone']])->one();
     if ($info === false) {
         echo json_encode(array('flag' => 0, 'msg' => 'Verify failed!'));
     } else {
         if ($info['num'] == $data['num'] && time() - $info['created_at'] <= 300) {
             Vercode::deleteAll(['phone' => $data['phone']]);
             $model = new User();
             $model->phone = $data['phone'];
             $model->created_at = time();
             if (!$model->save()) {
                 echo json_encode(array('flag' => 0, 'msg' => 'write in database failed!'));
                 return;
             }
             echo json_encode(array('flag' => 1, 'msg' => 'Verify success!'));
         } else {
             if (time() - $info['created_at'] > 300) {
                 Vercode::deleteAll(['phone' => $data['phone']]);
                 echo json_encode(array('flag' => 0, 'msg' => 'Verify failed!'));
             } else {
                 echo json_encode(array('flag' => 0, 'msg' => 'Verify failed!'));
             }
         }
     }
 }