123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- <?php
- namespace app\admin\controller;
- use think\admin\Controller;
- use think\admin\service\AdminService;
- class Oplog extends Controller
- {
-
- private $table = 'SystemOplog';
-
- public function index()
- {
- $this->title = '系统日志管理';
- $this->isSupper = AdminService::instance()->isSuper();
- $this->actions = $this->app->db->name($this->table)->distinct(true)->column('action');
- $query = $this->_query($this->table)->order('id desc');
- $query->like('action,node,content,username,geoip')->dateBetween('create_at')->page();
- }
-
- protected function _index_page_filter(array &$data)
- {
- $ip = new \Ip2Region();
- foreach ($data as &$vo) {
- $isp = $ip->btreeSearch($vo['geoip']);
- $vo['isp'] = str_replace(['内网IP', '0', '|'], '', $isp['region'] ?? '');
- }
- }
-
- public function clear()
- {
- if ($this->app->db->name($this->table)->whereRaw('1=1')->delete() !== false) {
- sysoplog('系统运维管理', '成功清理所有日志数据');
- $this->success('日志清理成功!');
- } else {
- $this->error('日志清理失败,请稍候再试!');
- }
- }
-
- public function remove()
- {
- $this->_applyFormToken();
- $this->_delete($this->table);
- }
- }
|