From: Alexander Ebert Date: Fri, 7 Dec 2012 19:50:32 +0000 (+0100) Subject: ACPSession uses IPv6, but displays as IPv4 if possible X-Git-Tag: 2.0.0_Beta_1~726^2~6 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=ccc092e26a137233a591baca930aeff27c948d04;p=GitHub%2FWoltLab%2FWCF.git ACPSession uses IPv6, but displays as IPv4 if possible Fixes #954 --- diff --git a/wcfsetup/install/files/acp/templates/acpSessionLogList.tpl b/wcfsetup/install/files/acp/templates/acpSessionLogList.tpl index 973221972e..d071a1e07a 100644 --- a/wcfsetup/install/files/acp/templates/acpSessionLogList.tpl +++ b/wcfsetup/install/files/acp/templates/acpSessionLogList.tpl @@ -37,7 +37,7 @@

{@$sessionLog->sessionLogID}

{if $__wcf->user->userID == $sessionLog->userID}{/if} {$sessionLog->username}

-

{$sessionLog->ipAddress}{if $sessionLog->hostname != $sessionLog->ipAddress}
{$sessionLog->hostname}{/if}

+

{$sessionLog->getIpAddress()}{if $sessionLog->hostname != $sessionLog->ipAddress}
{$sessionLog->hostname}{/if}

{$sessionLog->userAgent|truncate:75}

{@$sessionLog->time|time}

{@$sessionLog->lastActivityTime|time}

diff --git a/wcfsetup/install/files/lib/data/acp/session/log/ACPSessionLog.class.php b/wcfsetup/install/files/lib/data/acp/session/log/ACPSessionLog.class.php index 7007d91a54..a442439262 100644 --- a/wcfsetup/install/files/lib/data/acp/session/log/ACPSessionLog.class.php +++ b/wcfsetup/install/files/lib/data/acp/session/log/ACPSessionLog.class.php @@ -2,6 +2,7 @@ namespace wcf\data\acp\session\log; use wcf\data\DatabaseObject; use wcf\system\WCF; +use wcf\util\UserUtil; /** * Represents a session log entry. @@ -72,4 +73,13 @@ class ACPSessionLog extends DatabaseObject { return 0; } + + /** + * Returns the ip address and attempts to convert into IPv4. + * + * @return string + */ + public function getIpAddress() { + return UserUtil::convertIPv6To4($this->ipAddress); + } } 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 58875d0f9d..5a3b3207b8 100644 --- a/wcfsetup/install/files/lib/system/event/listener/SessionAccessLogListener.class.php +++ b/wcfsetup/install/files/lib/system/event/listener/SessionAccessLogListener.class.php @@ -5,6 +5,7 @@ use wcf\data\acp\session\log\ACPSessionLog; use wcf\data\acp\session\log\ACPSessionLogEditor; use wcf\system\event\IEventListener; use wcf\system\WCF; +use wcf\util\UserUtil; /** * Creates the session access log. @@ -46,7 +47,7 @@ class SessionAccessLogListener implements IEventListener { $sessionLog = ACPSessionLogEditor::create(array( 'sessionID' => WCF::getSession()->sessionID, 'userID' => WCF::getUser()->userID, - 'ipAddress' => WCF::getSession()->ipAddress, + 'ipAddress' => UserUtil::getIpAddress(), 'hostname' => @gethostbyaddr(WCF::getSession()->ipAddress), 'userAgent' => WCF::getSession()->userAgent, 'time' => TIME_NOW, @@ -66,7 +67,7 @@ class SessionAccessLogListener implements IEventListener { // save access ACPSessionAccessLogEditor::create(array( 'sessionLogID' => $sessionLogID, - 'ipAddress' => WCF::getSession()->ipAddress, + 'ipAddress' => UserUtil::getIpAddress(), 'time' => TIME_NOW, 'requestURI' => $requestURI, 'requestMethod' => WCF::getSession()->requestMethod, diff --git a/wcfsetup/install/files/lib/system/session/SessionHandler.class.php b/wcfsetup/install/files/lib/system/session/SessionHandler.class.php index dadeb7ee3b..eb7c367594 100644 --- a/wcfsetup/install/files/lib/system/session/SessionHandler.class.php +++ b/wcfsetup/install/files/lib/system/session/SessionHandler.class.php @@ -512,7 +512,7 @@ class SessionHandler extends SingletonFactory { // set up data $data = array( - 'ipAddress' => $this->ipAddress, + 'ipAddress' => UserUtil::getIpAddress(), 'userAgent' => $this->userAgent, 'requestURI' => $this->requestURI, 'requestMethod' => $this->requestMethod,