Recent Topics

1 Jan 08, 2009 21:27    

My b2evolution Version: 2.x

I've searched high and low for this answer but have been unable to find the file with the section that I need to change.

My problem is that my host uses loadbalancers, so all the Remote IPs show up as the same IP, instead of the proper user's IP. I've found the part in _hit.class.php that refers to the REMOTE_ADDR but am unable to find the file that actually houses the function that checks for the user's IP so I can change the REMOTE_ADDR to the proper HTML header. If someone could refer me to that, I'd appreciate it!

Justin

http://www.iconocritic.com

2 Jan 09, 2009 09:52

inc/_core/_misc.funcs.php ( approx 1966 )

/**
 * Get list of client IP addresses from REMOTE_ADDR and HTTP_X_FORWARDED_FOR,
 * in this order. '' is used when no IP could be found.
 *
 * @param boolean True, to get only the first IP (probably REMOTE_ADDR)
 * @return array|string Depends on first param.
 */
function get_ip_list( $firstOnly = false )
{
	$r = array();

	if( !empty( $_SERVER['REMOTE_ADDR'] ) )
	{
		foreach( explode( ',', $_SERVER['REMOTE_ADDR'] ) as $l_ip )
		{
			$l_ip = trim($l_ip);
			if( !empty($l_ip) )
			{
				$r[] = $l_ip;
			}
		}
	}

	if( !empty($_SERVER['HTTP_X_FORWARDED_FOR']) )
	{ // IP(s) behind Proxy - this can be easily forged!
		foreach( explode( ',', $_SERVER['HTTP_X_FORWARDED_FOR'] ) as $l_ip )
		{
			$l_ip = trim($l_ip);
			if( !empty($l_ip) && $l_ip != 'unknown' )
			{
				$r[] = $l_ip;
			}
		}
	}

	if( !isset( $r[0] ) )
	{ // No IP found.
		$r[] = '';
	}

	return $firstOnly ? $r[0] : $r;
}

¥

3 Jan 09, 2009 16:23

Thanks Yabba! You rock!

4 Jan 09, 2009 18:00

such is the burden I have to bear :roll:

no worries ;)

¥

5 Jan 09, 2009 18:14

ROFL

Your life must be so difficult being the master of PHP...


Form is loading...