1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Hide Admin / Moderator IP Address 1.0.0

Hide Admin / Moderator IP Address

  1. semprot
    Compatible XF Versions:
    • 1.5
    License:
    Creative Commons license
    No download is needed :)
    ___________________

    This is how to hide IP address of Admin / Moderator's / Any other user that you pick (as long as you have defined specific user ID).
    Well, it is not "hiding", actually it is overwriting their IP data in the database with a fake IP.

    This modification needs file editing to core Xenforo file, which is located in :
    Code:
    /library/Xenforo/Model/Ip.php
    Please make a backup copy of that file before proceeding ;)

    But please note :
    • The file change will be overwriten if you upload new Xenforo files while upgrading the board.
    • Even when you undo the file edit, the fake IP data will not be replaced with the real IP. This is one-way replacement.
    • This mod does not replace IP data which was recorded before this mod is activated.
      So if you want to replace your old IP data, you have to run a SQL query such as this :
      Code:
      UPDATE xf_ip SET ip =  'cccc' WHERE user_id =1
      (cccc means 99.99.99.99, if you wonder)
    ~~~~~~~~~~~
    First, you have to decide which fake IP do you want to use. 99.99.99.99, or 88.88.88.88 or something else.
    Please note : i noticed that some IP such as 1.1.1.1 won't work, which means NULL will be recorded as the IP.
    I don't know why that happens.
    I pick 99.99.99.99 :D

    Second, here goes the file editing, for example you want to set user ID 1 to have IP 99.99.99.99

    Search for this
    PHP:
        public function logIp($userId$contentType$contentId$action$ipAddress null$date null)
        {
            
    $ipAddress XenForo_Helper_Ip::getBinaryIp(null$ipAddress);
            if (!
    $ipAddress)
            {
                return 
    0;
            }

            if (
    $date === null)
            {
                
    $date XenForo_Application::$time;
            }

            
    $this->_getDb()->insert('xf_ip', array(
                
    'user_id' => $userId,
                
    'content_type' => $contentType,
                
    'content_id' => $contentId,
                
    'action' => $action,
                
    'ip' => $ipAddress,
                
    'log_date' => max(0$date)
            ));

            return 
    $this->_getDb()->lastInsertId();
        }
    Replace with this :
    PHP:
        public function logIp($userId$contentType$contentId$action$ipAddress null$date null)
        {
            if (
    == $userId) {/* Semprot modification */
                
    $ipAddress '99.99.99.99';
            }

            
    $ipAddress XenForo_Helper_Ip::getBinaryIp(null$ipAddress);
            if (!
    $ipAddress)
            {
                return 
    0;
            }

            if (
    $date === null)
            {
                
    $date XenForo_Application::$time;
            }

            
    $this->_getDb()->insert('xf_ip', array(
                
    'user_id' => $userId,
                
    'content_type' => $contentType,
                
    'content_id' => $contentId,
                
    'action' => $action,
                
    'ip' => $ipAddress,
                
    'log_date' => max(0$date)
            ));

            return 
    $this->_getDb()->lastInsertId();
        }
    If you want to hide IP of some user IDs (1, 22, 192, 391) :
    Replace with this :
    PHP:
        public function logIp($userId$contentType$contentId$action$ipAddress null$date null)
        {
            if (
    in_array($userId, array(122192391))) {/* Semprot modification */
                
    $ipAddress '99.99.99.99';
            }

            
    $ipAddress XenForo_Helper_Ip::getBinaryIp(null$ipAddress);
            if (!
    $ipAddress)
            {
                return 
    0;
            }

            if (
    $date === null)
            {
                
    $date XenForo_Application::$time;
            }

            
    $this->_getDb()->insert('xf_ip', array(
                
    'user_id' => $userId,
                
    'content_type' => $contentType,
                
    'content_id' => $contentId,
                
    'action' => $action,
                
    'ip' => $ipAddress,
                
    'log_date' => max(0$date)
            ));

            return 
    $this->_getDb()->lastInsertId();
        }
    • Tested on Xenforo 1.5.11
    • This modification is free, and you can use this code in your add on for free, just PM me first ;)