升级至tp8

This commit is contained in:
2023-09-04 11:50:04 +08:00
parent 3e2e401308
commit a12812d858
5 changed files with 169 additions and 170 deletions

View File

@@ -1,6 +1,5 @@
<?php
namespace app\admin\middleware;
use app\Request;
@@ -9,21 +8,19 @@ use think\facade\Request as FacadeRequest;
/**
* 系统操作日志中间件
* Class SystemLog
* @package app\admin\middleware
* Class SystemLog.
*/
class SystemLog
{
/**
* 敏感信息字段,日志记录时需要加密
* 敏感信息字段,日志记录时需要加密.
* @var array
*/
protected $sensitiveParams = [
'password',
'password_again',
'phone',
'mobile'
'mobile',
];
public function handle(Request $request, \Closure $next)
@@ -33,7 +30,7 @@ class SystemLog
unset($params['s']);
}
foreach ($params as $key => $val) {
in_array($key, $this->sensitiveParams) && $params[$key] = "***********";
in_array($key, $this->sensitiveParams) && $params[$key] = '***********';
}
$method = strtolower($request->method());
$url = $request->url();
@@ -42,17 +39,18 @@ class SystemLog
if (in_array($method, ['post', 'put', 'delete'])) {
$ip = FacadeRequest::ip();
$data = [
'admin_id' => session('admin.id'),
'url' => $url,
'method' => $method,
'ip' => $ip,
'content' => json_encode($params, JSON_UNESCAPED_UNICODE),
'useragent' => $_SERVER['HTTP_USER_AGENT'],
'admin_id' => session('admin.id'),
'url' => $url,
'method' => $method,
'ip' => $ip,
'content' => json_encode($params, JSON_UNESCAPED_UNICODE),
'useragent' => $_SERVER['HTTP_USER_AGENT'],
'create_time' => time(),
];
Log::debug($data);
Log::debug(print_r($data, true));
}
}
return $next($request);
}
}