1

Topic: punbb_online table -> get_remote_address()

I'm watching my punbb_online table via phpMyAdmin and in the ident field I can find Guest's IP address (user_id = 0) that are private (not routable) IPs like 192.168.*.*

Below is the phpBB 2.0.8 code to obtain the client's IP:

if( getenv('HTTP_X_FORWARDED_FOR') != '' )
{
        $client_ip = ( !empty($HTTP_SERVER_VARS['REMOTE_ADDR']) ) ? $HTTP_SERVER_VARS['REMOTE_ADDR'] : ( ( !empty($HTTP_ENV_VARS['REMOTE_ADDR']) ) ? $HTTP_ENV_VARS['REMOTE_ADDR'] : $REMOTE_ADDR );

        $entries = explode(',', getenv('HTTP_X_FORWARDED_FOR'));
        reset($entries);
        while (list(, $entry) = each($entries)) 
        {
                $entry = trim($entry);
                if ( preg_match("/^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/", $entry, $ip_list) )
                {
                        $private_ip = array('/^0\./', '/^127\.0\.0\.1/', '/^192\.168\..*/', '/^172\.((1[6-9])|(2[0-9])|(3[0-1]))\..*/', '/^10\..*/', '/^224\.
.*/', '/^240\..*/');
                        $found_ip = preg_replace($private_ip, $client_ip, $ip_list[1]);

                        if ($client_ip != $found_ip)
                        {
                                $client_ip = $found_ip;
                                break;
                        }
                }
        }
}
else
{
        $client_ip = ( !empty($HTTP_SERVER_VARS['REMOTE_ADDR']) ) ? $HTTP_SERVER_VARS['REMOTE_ADDR'] : ( ( !empty($HTTP_ENV_VARS['REMOTE_ADDR']) ) ? $HTTP_EN
V_VARS['REMOTE_ADDR'] : $REMOTE_ADDR );
}

Re: punbb_online table -> get_remote_address()

Has been fixed in 1.2 already :)

2004-04-03
""""""""""
*  Improved get_remote_address() to disregard obviously local IP addresses.
"Programming is like sex: one mistake and you have to support it for the rest of your life."

3

Re: punbb_online table -> get_remote_address()

Ah, ok, excuse me smile
I didn't find anything searching for "online" on the forum smile

P.

Re: punbb_online table -> get_remote_address()

No worries :)

"Programming is like sex: one mistake and you have to support it for the rest of your life."