Stop accessing the ->ipAddress property of the session
authorTim Düsterhus <duesterhus@woltlab.com>
Wed, 14 Oct 2020 12:18:53 +0000 (14:18 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Thu, 15 Oct 2020 14:14:14 +0000 (16:14 +0200)
Use UserUtil::getIpAddress() instead.

wcfsetup/install/files/lib/form/RegisterForm.class.php
wcfsetup/install/files/lib/system/WCF.class.php
wcfsetup/install/files/lib/system/event/listener/SessionAccessLogListener.class.php

index 6509b57724e73040ad97c8c3d7f61e9bf464ab8f..1bffc5af22656a2b36f92fcc866c62f7571b2daa 100644 (file)
@@ -447,7 +447,7 @@ class RegisterForm extends UserAddForm {
                $registerVia3rdParty = $eventParameters['registerVia3rdParty'];
                
                $this->additionalFields['languageID'] = $this->languageID;
-               if (LOG_IP_ADDRESS) $this->additionalFields['registrationIpAddress'] = WCF::getSession()->ipAddress;
+               if (LOG_IP_ADDRESS) $this->additionalFields['registrationIpAddress'] = UserUtil::getIpAddress();
                
                // generate activation code
                $addDefaultGroups = true;
index db9326cd6078d1987f661e586ce7e05539130745..3ec0af5d03531fa24bbd677f7a4d194f65bd41dc 100644 (file)
@@ -487,7 +487,7 @@ class WCF {
                $isAjax = isset($_SERVER['HTTP_X_REQUESTED_WITH']) && ($_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest');
                
                if (defined('BLACKLIST_IP_ADDRESSES') && BLACKLIST_IP_ADDRESSES != '') {
-                       if (!StringUtil::executeWordFilter(UserUtil::convertIPv6To4(self::getSession()->ipAddress), BLACKLIST_IP_ADDRESSES)) {
+                       if (!StringUtil::executeWordFilter(UserUtil::convertIPv6To4(UserUtil::getIpAddress()), BLACKLIST_IP_ADDRESSES)) {
                                if ($isAjax) {
                                        throw new AJAXException(self::getLanguage()->getDynamicVariable('wcf.ajax.error.permissionDenied'), AJAXException::INSUFFICIENT_PERMISSIONS);
                                }
@@ -495,7 +495,7 @@ class WCF {
                                        throw new PermissionDeniedException();
                                }
                        }
-                       else if (!StringUtil::executeWordFilter(self::getSession()->ipAddress, BLACKLIST_IP_ADDRESSES)) {
+                       else if (!StringUtil::executeWordFilter(UserUtil::getIpAddress(), BLACKLIST_IP_ADDRESSES)) {
                                if ($isAjax) {
                                        throw new AJAXException(self::getLanguage()->getDynamicVariable('wcf.ajax.error.permissionDenied'), AJAXException::INSUFFICIENT_PERMISSIONS);
                                }
@@ -515,7 +515,7 @@ class WCF {
                        }
                }
                if (defined('BLACKLIST_HOSTNAMES') && BLACKLIST_HOSTNAMES != '') {
-                       if (!StringUtil::executeWordFilter(@gethostbyaddr(self::getSession()->ipAddress), BLACKLIST_HOSTNAMES)) {
+                       if (!StringUtil::executeWordFilter(@gethostbyaddr(UserUtil::getIpAddress()), BLACKLIST_HOSTNAMES)) {
                                if ($isAjax) {
                                        throw new AJAXException(self::getLanguage()->getDynamicVariable('wcf.ajax.error.permissionDenied'), AJAXException::INSUFFICIENT_PERMISSIONS);
                                }
index 775b1c5fd50ab64057dfae5b00d32984b6bd76fd..2135cae4465c7a0f51479f79e8826d7e759c524f 100644 (file)
@@ -43,7 +43,7 @@ class SessionAccessLogListener implements IParameterizedEventListener {
                                        'sessionID' => WCF::getSession()->sessionID,
                                        'userID' => WCF::getUser()->userID,
                                        'ipAddress' => UserUtil::getIpAddress(),
-                                       'hostname' => @gethostbyaddr(WCF::getSession()->ipAddress),
+                                       'hostname' => @gethostbyaddr(UserUtil::getIpAddress()),
                                        'userAgent' => WCF::getSession()->userAgent,
                                        'time' => TIME_NOW,
                                        'lastActivityTime' => TIME_NOW