[Pushed] [Feature Request] Add new x-remote-addr var to the get_ip() function
#1
We were having problems with user registration because all user IP was being registered as 127.0.0.1.

Then, after ask here, in the SourceForge and burn the brain a little I looked for some informations in the Admin CP and then I found the PHP Info. There I was able to see that SourceForge doesn't use the HTTP_X_FORWARDED_FOR and HTTP_X_REAL_IP as an alternative to REMOTE_ADDR as implemented in the get_ip() function - they use HTTP_X_REMOTE_ADDR.

So, the solution was to add it to the IP check in the file ./inc/functions.php, function get_ip():

Quote:    :
    if($mybb->settings['ip_forwarded_check'])

    {
        if(isset($_SERVER['HTTP_X_FORWARDED_FOR']))
        {
            preg_match_all("#[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}#s", $_SERVER['HTTP_X_FORWARDED_FOR'], $addresses);
        }
        elseif(isset($_SERVER['HTTP_X_REAL_IP']))
        {
            preg_match_all("#[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}#s", $_SERVER['HTTP_X_REAL_IP'], $addresses);
        }
        elseif(isset($_SERVER['HTTP_X_REMOTE_ADDR']))
        {
            preg_match_all("#[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}#s", $_SERVER['HTTP_X_REMOTE_ADDR'], $addresses);
        }

        if(is_array($addresses[0]))
        {
            foreach($addresses[0] as $key => $val)
            {
                if(!preg_match("#^(10|172\.(1[6-9]|2[0-9]|3[0-1])|192\.168)\.#", $val))
                {
                    $ip = $val;
                    break;
                }
            }
        }
    }
    :

It would be nice see this fix added in the future version of MyBB.

p.s. the original thread
Reply
#2
I don't see a reason against implementing this.
Support PMs will be ignored!
Reply
#3
Hi,

Thank you for your report. We have pushed this issue to our Github repository for further analysis where you can track our commits and progress with fixing this bug. Discussions regarding this bug may also take place there too.

Follow this link to visit the issue on Github: https://github.com/mybb/mybb/issues/2070

Thanks for contributing to MyBB!

Regards,
The MyBB Group
Reply
#4
Thanks for take a look on that. Smile
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)