Re: IP Address

From: Date: Tue, 07 Aug 2001 13:59:48 +0000
Subject: Re: IP Address
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-61619@lists.php.net to get a copy of this message
> > =====[ Get remote IP ]===== > > if(getenv(HTTP_X_FORWARDED_FOR)) > { > $ip=getenv(HTTP_X_FORWARDED_FOR); > } > else > { > $ip=getenv(REMOTE_ADDR); > } > $host = gethostbyaddr($ip); > > =========================== > Oh... btw... I just gave a real look at that piece of code. You might want to write it a bit different: if (getenv ("HTTP_X_FORWARDED_FOR")) { $ip = getenv ("HTTP_X_FORWARDED_FOR"); } else { $ip = getenv ("REMOTE_ADDR"); } $host = gethostbyaddr ($ip); The other one does work, but quoting makes a lot of difference in your logfiles. Without quoting yet get al kinds of warnings. -- * R&zE: -- »»»»»»»»»»»»»»»»»»»»»»»» -- Renze Munnik -- DataLink BV -- -- E: renze@datalink.nl -- W: +31 23 5326162 -- F: +31 23 5322144 -- M: +31 6 21811143 -- H: +31 23 5516190 -- -- Stationsplein 82 -- 2011 LM HAARLEM -- -- http://www.datalink.nl -- ««««««««««««««««««««««««

« previous php.general (#61619) next »