系统设置初始化
This commit is contained in:
@@ -12,10 +12,10 @@ use think\App;
|
||||
use think\exception\ValidateException;
|
||||
use think\facade\View;
|
||||
use think\facade\Cache;
|
||||
use think\Validate;
|
||||
use app\model\Config;
|
||||
use think\facade\Route;
|
||||
use think\facade\Event;
|
||||
use think\Validate;
|
||||
use app\model\Config;
|
||||
use app\model\Hooks;
|
||||
use app\model\SeoRule;
|
||||
|
||||
@@ -59,6 +59,7 @@ class Base {
|
||||
];
|
||||
|
||||
public $data = []; //渲染数据
|
||||
public $config = [];
|
||||
|
||||
/**
|
||||
* 构造方法
|
||||
@@ -69,10 +70,10 @@ class Base {
|
||||
$this->app = $app;
|
||||
$this->request = $this->app->request;
|
||||
|
||||
$config = Cache::get('system_config_data');
|
||||
if (!$config) {
|
||||
$config = Config::getConfigList($this->request);
|
||||
Cache::set('system_config_data', $config);
|
||||
$this->config = Cache::get('system_config_data');
|
||||
if (!$this->config) {
|
||||
$this->config = Config::getConfigList($this->request);
|
||||
Cache::set('system_config_data', $this->config);
|
||||
}
|
||||
$hooks = Cache::get('sentcms_hooks');
|
||||
if (!$hooks) {
|
||||
@@ -96,7 +97,7 @@ class Base {
|
||||
|
||||
|
||||
View::assign('version', \think\facade\Env::get('VERSION'));
|
||||
View::assign('config', $config);
|
||||
View::assign('config', $this->config);
|
||||
// 控制器初始化
|
||||
$this->initialize();
|
||||
}
|
||||
|
||||
@@ -12,10 +12,11 @@ use app\model\Menu;
|
||||
use app\model\Model;
|
||||
use app\model\AuthGroup;
|
||||
use app\model\Addons;
|
||||
use think\facade\View;
|
||||
use \app\model\Form;
|
||||
use \app\controller\Base as BaseC;
|
||||
use app\model\Form;
|
||||
use app\controller\Base as BaseC;
|
||||
use think\facade\Cache;
|
||||
use think\facade\Route;
|
||||
use think\facade\View;
|
||||
|
||||
class Base extends BaseC {
|
||||
|
||||
@@ -47,9 +48,9 @@ class Base extends BaseC {
|
||||
|
||||
// 是否是超级管理员
|
||||
define('IS_ROOT', is_administrator());
|
||||
if (!IS_ROOT && \think\facade\Config::get('config.admin_allow_ip')) {
|
||||
if (!IS_ROOT && $this->config['admin_allow_ip']) {
|
||||
// 检查IP地址访问
|
||||
if (!in_array(get_client_ip(), explode(',', \think\facade\Config::get('config.admin_allow_ip')))) {
|
||||
if (!in_array(get_client_ip(), explode(',', $this->config['admin_allow_ip']))) {
|
||||
$this->error('403:禁止访问');
|
||||
}
|
||||
}
|
||||
@@ -129,8 +130,8 @@ class Base extends BaseC {
|
||||
* @author 朱亚杰 <xcoolcc@gmail.com>
|
||||
*/
|
||||
final protected function accessControl() {
|
||||
$allow = \think\facade\Config::get('allow_visit');
|
||||
$deny = \think\facade\Config::get('deny_visit');
|
||||
$allow = $this->config['allow_visit'];
|
||||
$deny = $this->config['deny_visit'];
|
||||
$check = strtolower($this->request->controller() . '/' . $this->request->action());
|
||||
if (!empty($deny) && in_array_case($check, $deny)) {
|
||||
return false; //非超管禁止访问deny中的方法
|
||||
|
||||
@@ -10,14 +10,10 @@ namespace app\controller\front;
|
||||
|
||||
use think\facade\View;
|
||||
use think\facade\Cache;
|
||||
use \app\controller\Base as BaseC;
|
||||
use app\controller\Base as BaseC;
|
||||
|
||||
class Base extends BaseC {
|
||||
|
||||
protected function initialize(){
|
||||
|
||||
}
|
||||
|
||||
protected function fetch($template = '') {
|
||||
$config = Cache::get('system_config_data');
|
||||
$this->tpl_config['view_depr'] = '_';
|
||||
|
||||
Reference in New Issue
Block a user