/** * Creates a new Users model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Users(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } }
public function actionSignup() { $model = new Users(); //$t=Yii::$app->request->params; $t = Yii::$app->request->getQueryParams(); $data = Yii::$app->request->post(); //return $t; if (empty($data['phone']) || empty($data['pwd']) || empty($data['text'])) { return array('flag' => 0, 'msg' => 'no enough arg!'); } $userinfo = Users::findOne(['phone' => $data['phone']]); if ($userinfo) { return array('flag' => 0, 'msg' => 'already Signup!'); } $r = $this->checktext($data, 0); if ($r['flag'] == 0) { return $r; } $model->pwd = md5($data['pwd']); $model->phone = $data['phone']; $model->alliancerewards = 30; $model->created_at = time(); if ($model->save()) { $model['invitecode'] = $this->to62(5800235584 + $model['id']); $model->save(); $easeclient = new Easeapi('YXA6halokJDEEeWMRgvYONLZPQ', 'YXA6pswnZbss8mj351XE3oxuRYm6cek', '13022660999', 'allpeopleleague', 'file'); $result = $easeclient->curl('/users', array('username' => $model->id, 'password' => $data['pwd'])); //var_dump($result); $result = json_decode($result['result'], true); if (isset($result['error'])) { $model->delete(); return array('flag' => 0, 'msg' => 'Signup fail!'); } else { if ($t) { if (!$this->setfather($model, $t)) { return array('flag' => 0, 'msg' => 'Modify fail!'); } } return array('flag' => 1, 'huanxinid' => $model['id'], 'msg' => 'Signup success!'); } } else { return array('flag' => 0, 'msg' => 'Signup fail!'); } }