From: Gabriel Wicke Date: Mon, 8 Mar 2004 18:44:20 +0000 (+0000) Subject: support for second-tier squids in the ip parsing function X-Git-Tag: 1.3.0beta1~830 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/pie.php?a=commitdiff_plain;h=8882b85f4beee27fc6d4fbb5cf276adcbc2aeb71;p=lhc%2Fweb%2Fwiklou.git support for second-tier squids in the ip parsing function --- diff --git a/includes/Setup.php b/includes/Setup.php index d39465d1e4..d7fc9da2cf 100644 --- a/includes/Setup.php +++ b/includes/Setup.php @@ -20,14 +20,20 @@ if ( $wgProfiling and (0 == rand() % $wgProfileSampleRate ) ) { /* collect the originating ips */ -$wgIP = getenv("REMOTE_ADDR"); if( $wgUseSquid && isset( $_SERVER["HTTP_X_FORWARDED_FOR"] ) ) { # If the web server is behind a reverse proxy, we need to find # out where our requests are really coming from. - $wgIP = trim( preg_replace( "/^(.*, )?([^,]+)$/", "$2", - $_SERVER['HTTP_X_FORWARDED_FOR'] ) ); + $hopips = split(', ', $_SERVER['HTTP_X_FORWARDED_FOR'] ); + + while(in_array(trim(end($hopips)), $wgSquidServers)){ + array_pop($hopips); + } + $wgIP = trim(end($hopips)); +} else { + $wgIP = getenv("REMOTE_ADDR"); } + $fname = "Setup.php"; wfProfileIn( $fname ); global $wgUseDynamicDates;