diff --git a/app/admin/controller/Config.php b/app/admin/controller/Config.php index b2f2dc18c..357ec7be8 100644 --- a/app/admin/controller/Config.php +++ b/app/admin/controller/Config.php @@ -96,7 +96,7 @@ class Config extends Controller $post['storage']['allow_exts'] = join(',', $exts); } foreach ($post as $name => $value) sysconf($name, $value); - sysoplog('系统配置管理', "修改存储参数成功"); + sysoplog('系统配置管理', "修改系统存储参数"); $this->success('修改文件存储成功!'); } } diff --git a/app/admin/controller/Oplog.php b/app/admin/controller/Oplog.php index a3a74df9c..d9ae1329c 100644 --- a/app/admin/controller/Oplog.php +++ b/app/admin/controller/Oplog.php @@ -68,32 +68,6 @@ class Oplog extends Controller } } - /** - * 日志行为配置 - * @auth true - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException - */ - public function config() - { - if ($this->request->isGet()) { - $this->fetch(); - } else { - $data = $this->_vali([ - 'oplog_state.in:0,1' => '日志状态值异常!', - 'oplog_state.require' => '日志状态不能为空!', - 'oplog_days.require' => '保存天数不能为空!', - ]); - foreach ($data as $name => $value) { - sysconf($name, $value); - } - $GLOBALS['oplogs'] = []; - sysoplog('系统运维管理', '修改系统日志行为配置'); - $this->success('日志配置成功!'); - } - } - /** * 清理系统日志 * @auth true diff --git a/app/admin/sys.php b/app/admin/sys.php deleted file mode 100644 index f7d48ef28..000000000 --- a/app/admin/sys.php +++ /dev/null @@ -1,72 +0,0 @@ - 0) { - /*! 数据变更批量写入 */ - app()->event->listen('HttpEnd', function () { - if (is_array($GLOBALS['oplogs']) && count($GLOBALS['oplogs']) > 0) { - foreach (array_chunk($GLOBALS['oplogs'], 100) as $items) { - app()->db->name('SystemOplog')->insertAll($items); - } - $GLOBALS['oplogs'] = []; - $days = floatval(sysconf('base.oplog_days')); - if (rand(1, 100) <= 10 && $days > 0) { - $lastdate = date('Y-m-d H:i:s', strtotime("-{$days}days")); - app()->db->name('SystemOplog')->where('create_at', '<', $lastdate)->delete(); - } - } - }); - /*! 数据操作SQL语句监听分析 */ - app()->db->listen(function ($sqlstr) { - [$type] = explode(' ', $sqlstr); - if (in_array($type, ['INSERT', 'UPDATE', 'DELETE']) && AdminService::instance()->isLogin()) { - [$sqlstr] = explode('GROUP BY', explode('ORDER BY', $sqlstr)[0]); - if (preg_match('/^INSERT\s+INTO\s+`(.*?)`\s+SET\s+(.*?)\s*$/i', $sqlstr, $matches)) { - if (stripos($matches[1] = Str::studly($matches[1]), 'SystemOplog') === false) { - $matches[2] = substr(str_replace(['`', '\''], '', $matches[2]), 0, 800); - $GLOBALS['oplogs'][] = SystemService::instance()->getOplog("添加 {$matches[1]} 数据", $matches[2]); - } - } elseif (preg_match('/^INSERT\s*INTO\s+`(.*?)`\s+(.*?)\s+VALUES\s+(.*?)\s*$/i', $sqlstr, $matches)) { - if (stripos($matches[1] = Str::studly($matches[1]), 'SystemOplog') === false) { - $matches[2] = substr(str_replace(['`', '\''], '', $matches[2]), 0, 200); - $matches[3] = substr(str_replace(['`', '\''], '', $matches[3]), 0, 600); - $GLOBALS['oplogs'][] = SystemService::instance()->getOplog("添加 {$matches[1]} 数据", "{$matches[2]} VALUES {$matches[3]}"); - } - } elseif (preg_match('/^UPDATE\s+`(.*?)`\s+SET\s+(.*?)\s+WHERE\s+(.*?)\s*$/i', $sqlstr, $matches)) { - if (stripos($matches[1] = Str::studly($matches[1]), 'SystemOplog') === false) { - $matches[3] = substr(str_replace(['`', '\''], '', $matches[3]), 0, 150); - $matches[2] = substr(str_replace(['`', '\''], '', $matches[2]), 0, 800); - $GLOBALS['oplogs'][] = SystemService::instance()->getOplog("更新 {$matches[1]} 数据 {$matches[3]}", $matches[2]); - } - } elseif (preg_match('/^DELETE\s*FROM\s*`(.*?)`\s*WHERE\s*(.*?)\s*$/i', $sqlstr, $matches)) { - if (stripos($matches[1] = Str::studly($matches[1]), 'SystemOplog') === false) { - $matches[2] = str_replace(['`', '\''], '', $matches[2]); - $GLOBALS['oplogs'][] = SystemService::instance()->getOplog("删除 {$matches[1]} 数据 {$matches[2]}", ""); - } - } - } - }); - } -} catch (\Exception $exception) { - app()->log->error($exception->getMessage()); -} \ No newline at end of file diff --git a/app/admin/view/oplog/config.html b/app/admin/view/oplog/config.html deleted file mode 100644 index 1e31ac7d2..000000000 --- a/app/admin/view/oplog/config.html +++ /dev/null @@ -1,29 +0,0 @@ -
-
-
- 记录数据变更日志 -
- {foreach [1 => '记录数据变更日志',0 => '不记录数据变更日志'] as $k=>$v} - {if intval(sysconf('base.oplog_state')) eq $k} - - {else} - - {/if}{/foreach} -
-
- -
-
- - -
-
-
\ No newline at end of file diff --git a/app/admin/view/oplog/index.html b/app/admin/view/oplog/index.html index 4037542ec..60b372242 100644 --- a/app/admin/view/oplog/index.html +++ b/app/admin/view/oplog/index.html @@ -1,9 +1,6 @@ {extend name='main'} {block name="button"} - -日志配置 - diff --git a/vendor/services.php b/vendor/services.php index c4cbf95be..14a48d30b 100644 --- a/vendor/services.php +++ b/vendor/services.php @@ -1,5 +1,5 @@ 'think\\admin\\Library',