From 8882b85f4beee27fc6d4fbb5cf276adcbc2aeb71 Mon Sep 17 00:00:00 2001 From: Gabriel Wicke Date: Mon, 8 Mar 2004 18:44:20 +0000 Subject: [PATCH] support for second-tier squids in the ip parsing function --- includes/Setup.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) 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; -- 2.20.1