public function actionGrab() { $session = \Yii::$app->session; $id = $session->get('user_id'); if (empty($id)) { echo 3; die; } else { $model = new User(); $list = $model->usertype($id); if ($list['user_type'] == "1") { echo 1; } else { echo 2; } } }
public function actionPositionList() { $model = new User(); $data = $model->partlist(); return $this->render('position-list', ['data' => $data]); }
public function actionSaveMessages() { $model = new User(); $request = \YII::$app->request; $type = $request->post('type'); $password = $request->post('user_password'); $new_password = $request->post('new_password'); //修改登陆密码 if ($type == 1) { $isPassword = $model->checkPassword(1, md5($password)); if (!$isPassword) { echo "<script>alert('温馨提示:你输入的旧密码不存在!');location.href='student-update?type=1'</script>"; } else { $savePassword = $model->savePassword(1, md5($new_password)); echo "<script>alert('修改成功');location.href='student-update?type=1'</script>"; } } else { if ($type == 2) { $user_phone = $request->post('user_phone'); $checkPhone = $model->checkPhone(1, $user_phone); if ($checkPhone) { echo "<script>alert('温馨提示:你输入的手机号已经存在!');location.href='student-update?type=2'</script>"; } else { $user = new User(); $mobile_code = $user->random(4, 1); //要发送的验证码 $config = \Yii::$app->params['SMSverification']; //获取配置文件的信息 $post_data = "account=" . $config['account'] . "&password="******"&mobile=" . $user_phone . "&content=" . rawurlencode("您的验证码是:" . $mobile_code . "。请不要把验证码泄露给其他人。"); $target = "http://106.ihuyi.cn/webservice/sms.php?method=Submit"; $gets = $user->xml_to_array($user->Post($post_data, $target)); if ($gets['SubmitResult']['code'] == 2) { $session = Yii::$app->session; $session->set($phone, $mobile_code); echo $gets['SubmitResult']['msg']; } } } } }