ACPSession uses IPv6, but displays as IPv4 if possible
authorAlexander Ebert <ebert@woltlab.com>
Fri, 7 Dec 2012 19:50:32 +0000 (20:50 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Fri, 7 Dec 2012 19:50:32 +0000 (20:50 +0100)
Fixes #954

wcfsetup/install/files/acp/templates/acpSessionLogList.tpl
wcfsetup/install/files/lib/data/acp/session/log/ACPSessionLog.class.php
wcfsetup/install/files/lib/system/event/listener/SessionAccessLogListener.class.php
wcfsetup/install/files/lib/system/session/SessionHandler.class.php

index 973221972e293560a140538a992c06bf6ca24d14..d071a1e07ae1e2d4c790f587cfef1695b80ec121 100644 (file)
@@ -37,7 +37,7 @@
                                                <tr class="{if $sessionLog->active} activeContainer{/if}">
                                                        <td class="columnID columnSessionLogID"><p>{@$sessionLog->sessionLogID}</p></td>
                                                        <td class="columnTitle columnUsername"><p>{if $__wcf->user->userID == $sessionLog->userID}<img src="{@$__wcf->getPath()}icon/user.svg" alt="" class="icon16" />{/if} <a href="{link controller='ACPSessionLog' id=$sessionLog->sessionLogID}{/link}">{$sessionLog->username}</a></p></td>
-                                                       <td class="columnSmallText columnIpAddress"><p><a href="{link controller='ACPSessionLog' id=$sessionLog->sessionLogID}{/link}">{$sessionLog->ipAddress}</a>{if $sessionLog->hostname != $sessionLog->ipAddress}<br /><a href="{link controller='ACPSessionLog' id=$sessionLog->sessionLogID}{/link}">{$sessionLog->hostname}</a>{/if}</p></td>
+                                                       <td class="columnSmallText columnIpAddress"><p><a href="{link controller='ACPSessionLog' id=$sessionLog->sessionLogID}{/link}">{$sessionLog->getIpAddress()}</a>{if $sessionLog->hostname != $sessionLog->ipAddress}<br /><a href="{link controller='ACPSessionLog' id=$sessionLog->sessionLogID}{/link}">{$sessionLog->hostname}</a>{/if}</p></td>
                                                        <td class="columnSmallText columnUserAgent" title="{$sessionLog->userAgent}"><p><a href="{link controller='ACPSessionLog' id=$sessionLog->sessionLogID}{/link}">{$sessionLog->userAgent|truncate:75}</a></p></td>
                                                        <td class="columnDate columnTime"><p>{@$sessionLog->time|time}</p></td>
                                                        <td class="columnDate columnLastActivityTime"><p>{@$sessionLog->lastActivityTime|time}</p></td>
index 7007d91a541ad0dcaa52789c8b9643d58a43e88d..a4424392628159eee1e3b6a75f0b309b1fb3eae2 100644 (file)
@@ -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);
+       }
 }
index 58875d0f9d8d1599023280398f7b2646f854f631..5a3b3207b8bccc96d2b0f49489504cc338d8599e 100644 (file)
@@ -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,
index dadeb7ee3b81621f1d72ba23966fc95bf017dd52..eb7c36759412233fe1e54819bb1e98df6125c26c 100644 (file)
@@ -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,