Initial commit,修正
This commit is contained in:
Executable
+282
@@ -0,0 +1,282 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @Author: fm453
|
||||
* @Date: 2019-06-24 14:47:57
|
||||
* @Last Modified by: fm453
|
||||
* @Last Modified time: 2021-09-10 19:41:10
|
||||
* @Email: fm453@lukegzs.com
|
||||
*/
|
||||
|
||||
namespace frontend\controllers;
|
||||
|
||||
use Yii;
|
||||
use yii\base\InvalidParamException;
|
||||
use yii\web\BadRequestHttpException;
|
||||
use yii\web\Controller;
|
||||
use yii\filters\VerbFilter;
|
||||
use yii\filters\AccessControl;
|
||||
use yii\helpers\Url;
|
||||
use frontend\models\LoginForm;
|
||||
use frontend\models\PasswordResetRequestForm;
|
||||
use frontend\models\ResetPasswordForm;
|
||||
use frontend\models\SignupForm;
|
||||
use frontend\models\ContactForm;
|
||||
|
||||
/**
|
||||
* Site controller
|
||||
*/
|
||||
class SiteController extends Controller
|
||||
{
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function behaviors()
|
||||
{
|
||||
return [
|
||||
'access' => [
|
||||
'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]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user