I've used this function before a couple of times, but I haven't tested
it fully. Give it a go if you want.
/*** BEGIN CODE ***/
// Function get_ip
function get_ip()
{
// List of possible ip sources, in order of priority
$ip_sources = array
(
"HTTP_X_FORWARDED_FOR",
"HTTP_X_FORWARDED",
"HTTP_FORWARDED_FOR",
"HTTP_FORWARDED",
"HTTP_X_COMING_FROM",
"HTTP_COMING_FROM",
"REMOTE_ADDR",
);
foreach ($ip_sources as $ip_source)
{
// If the ip source exists, capture it
if (isset($_SERVER[$ip_source]))
{
// Beware of semicolon seperated lists
$possible_ips = explode(";", $_SERVER[$ip_source]);
// Always take just the first
$proxy_ip = $possible_ips[0];
break;
}
}
// If the ip is still not found, try the getenv() function without
error reporting (may give false)
$proxy_ip = (isset($proxy_ip)) ? $proxy_ip : @getenv("REMOTE_ADDR");
return $proxy_ip;
}
/*** END CODE ***/
On Thu, 8 Jul 2004 02:17:00 +0300, Rosen <[EMAIL PROTECTED]> wrote:
> :)
> Ok - then how linux server communicate with client - the server must have IP
> adress to whitch to send data.....
>
> "John W. Holmes" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
>
>
> > Rosen wrote:
> >
> > > IP adress not send ?!? And how server communicate with client ?
> >
> > A variety of ways. What I meant is that it's not sent in the browser's
> > headers that it sends to the site, which is where getenv() and
> > $_SERVER[] would snatch it from.
> >
> > Do not rely on IP addresses. Trust me.
> >
> > --
> > ---John Holmes...
> >
> > Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
> >
> > php|architect: The Magazine for PHP Professionals � www.phparch.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php