From: Tim Düsterhus Date: Mon, 14 Dec 2020 10:51:24 +0000 (+0100) Subject: Make the ACP session access log more useful X-Git-Tag: 5.4.0_Alpha_1~545^2~1 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=2ddf23b9ec40bb24fa2fb005eb701f0458bc9fde;p=GitHub%2FWoltLab%2FWCF.git Make the ACP session access log more useful This commit intentionally overloads the existing fields to keep the change simple. The log is not really usuable for programmatic processing, due to the existing constraints. The cleanest solution probably would be storing all the loggable information as a JSON blob and then parsing that one when accessing the log and querying it with MySQL's JSON function. But the latter are not supported yet. All in all this change improves the ACP session access log a lot and that is what counts. Resolves #3537 --- diff --git a/wcfsetup/install/files/lib/system/event/listener/SessionAccessLogListener.class.php b/wcfsetup/install/files/lib/system/event/listener/SessionAccessLogListener.class.php index 82b301de3a..948862aee7 100644 --- a/wcfsetup/install/files/lib/system/event/listener/SessionAccessLogListener.class.php +++ b/wcfsetup/install/files/lib/system/event/listener/SessionAccessLogListener.class.php @@ -1,5 +1,6 @@ sessionLogID; } - // format request uri + // Fetch request URI + request ID (if available). $requestURI = UserUtil::getRequestURI(); - // remove directories - $URIComponents = explode('/', $requestURI); - $requestURI = array_pop($URIComponents); - // remove session url - $requestURI = preg_replace('/(?:\?|&)s=[a-f0-9]{40}/', '', $requestURI); + if ($requestId = \wcf\getRequestId()) { + $requestURI .= ' ('.$requestId.')'; + } + + // Get controller name + the AJAX action. + $className = get_class($eventObj); + if ($eventObj instanceof AJAXInvokeAction) { + if (isset($_REQUEST['className']) && isset($_REQUEST['actionName'])) { + $className .= ' ('.$_REQUEST['className'].':'.$_REQUEST['actionName'].')'; + } + } // save access ACPSessionAccessLogEditor::create([ 'sessionLogID' => $sessionLogID, 'ipAddress' => UserUtil::getIpAddress(), 'time' => TIME_NOW, - 'requestURI' => $requestURI, + 'requestURI' => substr($requestURI, 0, 255), 'requestMethod' => substr($_SERVER['REQUEST_METHOD'] ?? '', 0, 255), - 'className' => get_class($eventObj) + 'className' => substr($className, 0, 255) ]); } }