Authored by wuxiao

添加backend/components/filters/AccessControl.php

<?php
namespace backend\components\filters;
use Yii;
use yii\base\ActionFilter;
/**
*
* @author wuxiao
*/
class AccessControl extends \yii\filters\AccessControl
//class AccessControl extends ActionFilter
{
public function init()
{
parent::init();
}
public function beforeAction($action)
{
return parent::beforeAction($action);
}
}
\ No newline at end of file
... ...
... ... @@ -3,6 +3,8 @@ namespace backend\controllers;
use Yii;
use yii\web\Controller;
use yii\helpers\ArrayHelper;
use backend\components\filters\AccessControl;
/**
* Site controller
... ... @@ -26,6 +28,25 @@ class BaseController extends Controller
parent::init();
}
/**
* @inheritdoc
*/
public function behaviors()
{
return [];
return ArrayHelper::merge(parent::behaviors(), [
[
'class' => AccessControl::className(),
'rules' => [
[
'allow' => true,
'roles' => ['@'],
],
],
],
]);
}
public function beforeAction($action) {
Yii::setAlias('@web', Yii::getAlias('@admin'));
Yii::$app->setHomeUrl(Yii::getAlias('@web'));
... ...
... ... @@ -4,7 +4,7 @@
<img class="img-circle" src="/images/photos/profile.png" alt="">
</a>
<div class="media-body">
<h4 class="media-heading"><?=Yii::$app->user->getIdentity()->username?></h4>
<h4 class="media-heading"><?=Yii::$app->user->isGuest ? 'Guest' : Yii::$app->user->getIdentity()->username?></h4>
<small class="text-muted">超级管理员</small>
</div>
</div><!-- media -->
... ...
... ... @@ -22,28 +22,6 @@ class LivingController extends BaseController
return parent::beforeAction($action);
}
public function behaviors()
{
return [];
return [
[
'class' => 'yii\filters\PageCache',
'only' => ['detail'],
'duration' => 3600,
'cache' => 'pageCache',
'variations' => [
$this->requests('room_id',0),
$this->requests('video_id',0),
],
/*'dependency' => [
'class' => 'yii\caching\DbDependency',
'sql' => 'SELECT COUNT(*) FROM post',
'sql' => 'SELECT MAX(updated_at) FROM post',
],*/
],
];
}
/**
* 精选房间
*/
... ... @@ -299,13 +277,14 @@ class LivingController extends BaseController
$this->renderJson(Yii::$app->params['success_code'],'',$ret);
}elseif ($video_id = $this->requests('video_id'))
{//重播视频详情
$key = __CLASS__.__FUNCTION__.'video_id'.$room_id;
$key = __CLASS__.__FUNCTION__.'video_id'.$video_id;
if (!$ret = $this->cache->get($key)){
if (!$model = Video::findOne(['id'=>$video_id])){
$this->renderJson(Yii::$app->params['failed_code'],'找不到该回放');
}
$ret = [
'video_id'=>$model->id,
'master_pic'=>'',
'master_name'=>'',
'master_meta'=>'',
... ...