init
This commit is contained in:
30
app/admin/behavior/CheckIp.php
Executable file
30
app/admin/behavior/CheckIp.php
Executable file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\behavior;
|
||||
|
||||
use think\Request;
|
||||
use think\Config;
|
||||
|
||||
load_trait('controller/Jump');
|
||||
|
||||
/**
|
||||
* Description of CheckIp
|
||||
* 检测用户访问的ip
|
||||
*/
|
||||
class CheckIp {
|
||||
|
||||
use \traits\controller\Jump;
|
||||
|
||||
/**
|
||||
* 检测用户IP
|
||||
*/
|
||||
public function run() {
|
||||
$allow_ip = Config::get('admin_allow_ip');
|
||||
$ip = Request::instance()->ip();
|
||||
if (!is_administrator() && $allow_ip) {
|
||||
!in_array($ip, explode(',', $allow_ip)) && $this->error('禁止访问'); // 检查IP地址访问
|
||||
}
|
||||
\think\Log::record("[ 访问者IP ]:" . $ip);
|
||||
}
|
||||
|
||||
}
|
||||
28
app/admin/behavior/SystemConfig.php
Executable file
28
app/admin/behavior/SystemConfig.php
Executable file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\behavior;
|
||||
|
||||
use think\Config;
|
||||
use think\Cache;
|
||||
use think\Loader;
|
||||
use think\App;
|
||||
use think\Log;
|
||||
|
||||
class SystemConfig {
|
||||
|
||||
/**
|
||||
* 系统配置读取并缓存
|
||||
*/
|
||||
public function run() {
|
||||
$config = Cache::get('admin_config_data');
|
||||
if (empty($config)) {
|
||||
$config = Loader::model('Sysconfig')->configLists();
|
||||
Cache::tag('sysconfig')->set('admin_config_data', $config);
|
||||
App::$debug && Log::record("[ 系统配置 ]:初始化成功");
|
||||
}
|
||||
//header('content-type:text/html;charset=utf-8;');
|
||||
//var_export($config);exit;
|
||||
Config::set($config);
|
||||
}
|
||||
|
||||
}
|
||||
47
app/admin/behavior/UserAction.php
Executable file
47
app/admin/behavior/UserAction.php
Executable file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\behavior;
|
||||
|
||||
use think\Log;
|
||||
use think\Request;
|
||||
use think\Session;
|
||||
|
||||
class UserAction {
|
||||
|
||||
private $Request;
|
||||
|
||||
/**
|
||||
* 日志记录
|
||||
*/
|
||||
public function run($call) {
|
||||
$this->Request = Request::instance();
|
||||
$domainurl = $this->Request->url(true);
|
||||
$module = $this->Request->module();
|
||||
$controller = $this->Request->controller();
|
||||
$action = $this->Request->action();
|
||||
$method = $this->Request->method();
|
||||
switch ($controller) {
|
||||
case 'Translate':
|
||||
action_log($controller . '控制器' . $action . '动作操作记录', "翻译操作记录{$module}-{$controller}-{$action}-{$method}-" . date('Y-m-d H:i:s'), null);
|
||||
break;
|
||||
case 'Webuploader':
|
||||
action_log($controller . '控制器' . $action . '动作操作记录', "文件管理操作记录{$module}-{$controller}-{$action}-{$method}-" . date('Y-m-d H:i:s'), null);
|
||||
break;
|
||||
case 'Dbmanager':
|
||||
action_log($controller . '控制器' . $action . '动作操作记录', "数据管理操作记录{$module}-{$controller}-{$action}-{$method}-" . date('Y-m-d H:i:s'), null);
|
||||
break;
|
||||
case 'Sysconfig':
|
||||
action_log($controller . '控制器' . $action . '动作操作记录', "系统配置管理操作记录{$module}-{$controller}-{$action}-{$method}-" . date('Y-m-d H:i:s'), null);
|
||||
break;
|
||||
case 'Ueditor':
|
||||
action_log($controller . '控制器' . $action . '动作操作记录', "编辑器操作记录{$module}-{$controller}-{$action}-{$method}-" . date('Y-m-d H:i:s'), null);
|
||||
break;
|
||||
default:
|
||||
$actions = ['create', 'update', 'delete', 'deletes', 'distory', 'distorys', 'recovery', 'recoverys', 'setting', 'recycle', 'recommends'];
|
||||
if (in_array($action, $actions) || stripos($action, 'toggle') === 0 || stripos($action, 'update') === 0) {
|
||||
action_log($controller . '控制器' . $action . '动作操作记录', "{$module}-{$controller}-{$action}-{$method}-" . date('Y-m-d H:i:s'), null);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user