[nycphp-talk] Urgent: Help in Defending Attack
Guilherme Blanco
guilhermeblanco at gmail.com
Thu Feb 28 08:18:34 EST 2008
Randal... try this one...
function getClientIp()
{
// This function get the IP of an user, even when he's behind a simple proxy
// 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 (isset($_SERVER[$ip_source])) {
$proxy_ip = $_SERVER[$ip_source];
break;
}
}
// If the ip is still not found, try the getenv() function without
// error reporting. This will automatically provide a FALSE result
// on failure
$proxy_ip = (isset($proxy_ip)) ? $proxy_ip : @getenv("REMOTE_ADDR");
// Return the IP found
return $proxy_ip;
}
This can help you to retrieve the right requester ip.
Later give me some feedback if it worked, please.
Regards,
On Thu, Feb 28, 2008 at 10:08 AM, Randal Rust <randalrust at gmail.com> wrote:
> > just try with $_SERVER['REMOTE_ADDR'] it gives ip of client machine
>
> yeah, that's what i meant. however, i was trying to get around using
> the full IP.
>
>
>
> --
> Randal Rust
> R.Squared Communications
> www.r2communications.com
> _______________________________________________
> New York PHP Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
>
> NYPHPCon 2006 Presentations Online
> http://www.nyphpcon.com
>
> Show Your Participation in New York PHP
> http://www.nyphp.org/show_participation.php
>
--
Guilherme Blanco - Web Developer
CBC - Certified Bindows Consultant
Cell Phone: +55 (16) 9166-6902
MSN: guilhermeblanco at hotmail.com
URL: http://blog.bisna.com
São Carlos - SP/Brazil
More information about the talk
mailing list