[ 'class' => AccessControl::className(), 'only' => ['logout', 'signup'], 'rules' => [ [ 'actions' => ['signup'], 'allow' => true, 'roles' => ['?'], ], [ 'actions' => ['logout'], 'allow' => true, 'roles' => ['@'], ], ], ], 'verbs' => [ 'class' => VerbFilter::className(), 'actions' => [ 'logout' => ['post'], ], ], ]; } /** * @inheritdoc */ public function actions() { return [ 'error' => [ 'class' => 'yii\web\ErrorAction', ], 'captcha' => [ 'class' => 'yii\captcha\CaptchaAction', 'fixedVerifyCode' => YII_ENV_TEST ? 'testme' : null, ], ]; } /** * Displays homepage. * * @return mixed */ public function actionIndex() { global $_HI; include_once __DIR__.'/site/index.php'; $this->getView()->params['seo'] = $seo; $this->getView()->params['pageTitle'] = $pageTitle; $this->getView()->params['title'] = $seo['title']; $this->getView()->params['pageCate'] = $pageCate; $this->getView()->params['pageOpp'] = $ac; $this->getView()->params['htmlSrc'] = $htmlSrc; $this->getView()->params['modules1'] = $modules1; $this->getView()->params['modules2'] = $modules2; $this->getView()->params['modules3'] = $modules3; $this->getView()->params['modules4'] = $modules4; $this->getView()->params['url']['product'] = Url::toRoute('product/index'); return $this->render('index'); } /** * Logs in a user. * * @return mixed */ public function actionLogin() { $this->layout = 'main'; if (!Yii::$app->user->isGuest) { return $this->goHome(); } $model = new LoginForm(); if ($model->load(Yii::$app->request->post()) && $model->login()) { return $this->goBack(); } else { return $this->render('login', [ 'model' => $model, ]); } } /** * Logs out the current user. * * @return mixed */ public function actionLogout() { Yii::$app->user->logout(); return $this->goHome(); } /** * Displays contact page. * * @return mixed */ public function actionContact() { $this->layout = 'main'; $model = new ContactForm(); if ($model->load(Yii::$app->request->post()) && $model->validate()) { if ($model->sendEmail(Yii::$app->params['adminEmail'])) { Yii::$app->session->setFlash('success', '已收到您的反馈,我们将尽快响应并联系您。'); } else { Yii::$app->session->setFlash('error', '消息发送时系统遇到错误.'); } return $this->refresh(); } else { return $this->render('contact', [ 'model' => $model, ]); } } /** * Displays about page. * * @return mixed */ public function actionAboutus() { global $_HI; include_once __DIR__.'/site/aboutus.php'; $this->getView()->params['seo'] = $seo; $this->getView()->params['pageTitle'] = $pageTitle; $this->getView()->params['title'] = $seo['title']; $this->getView()->params['pageCate'] = $pageCate; $this->getView()->params['pageOpp'] = $ac; $this->getView()->params['htmlSrc'] = $htmlSrc; $this->getView()->params['url']['product'] = fmFunc_url(Yii::$app->controller->id,'product',$isAddons=1); return $this->render('aboutus'); } public function actionPrice() { global $_HI; include_once __DIR__.'/site/price.php'; $this->getView()->params['seo'] = $seo; $this->getView()->params['pageTitle'] = $pageTitle; $this->getView()->params['title'] = $seo['title']; $this->getView()->params['pageCate'] = $pageCate; $this->getView()->params['pageOpp'] = $ac; $this->getView()->params['htmlSrc'] = $htmlSrc; $this->getView()->params['url']['product'] = fmFunc_url(Yii::$app->controller->id,'product',$isAddons=1); return $this->render('price'); } public function actionCustomization() { global $_HI; include_once __DIR__.'/site/customization.php'; $this->getView()->params['seo'] = $seo; $this->getView()->params['pageTitle'] = $pageTitle; $this->getView()->params['title'] = $seo['title']; $this->getView()->params['pageCate'] = $pageCate; $this->getView()->params['pageOpp'] = $ac; $this->getView()->params['htmlSrc'] = $htmlSrc; $this->getView()->params['url']['product'] = fmFunc_url(Yii::$app->controller->id,'product',$isAddons=1); return $this->render('customization'); } /** * Signs user up. * * @return mixed */ public function actionSignup() { $this->layout = 'main'; $model = new SignupForm(); if ($model->load(Yii::$app->request->post())) { if ($user = $model->signup()) { if (Yii::$app->getUser()->login($user)) { return $this->goHome(); } } } return $this->render('signup', [ 'model' => $model, ]); } /** * Requests password reset. * * @return mixed */ public function actionRequestPasswordReset() { $this->layout = 'main'; $model = new PasswordResetRequestForm(); if ($model->load(Yii::$app->request->post()) && $model->validate()) { if ($model->sendEmail()) { Yii::$app->session->setFlash('success', '发送完毕,请登陆您的邮箱查阅并进行接下来的操作.'); return $this->goHome(); } else { Yii::$app->session->setFlash('error', '抱歉,系统无法向您填写的邮箱发送重置邮件,请检查邮箱地址.'); } } return $this->render('requestPasswordResetToken', [ 'model' => $model, ]); } /** * Resets password. * * @param string $token * @return mixed * @throws BadRequestHttpException */ public function actionResetPassword($token) { try { $model = new ResetPasswordForm($token); } catch (InvalidParamException $e) { throw new BadRequestHttpException($e->getMessage()); } if ($model->load(Yii::$app->request->post()) && $model->validate() && $model->resetPassword()) { Yii::$app->session->setFlash('success', '新密码已保存.'); return $this->goHome(); } return $this->render('resetPassword', [ 'model' => $model, ]); } public function actionError($e){ $this->layout = 'main'; return $this->render('error',['message'=>$e]); } }