Re: How to ask "if private IP"?
| From: | William Betts | Date: | Mon, 26 Nov 2007 17:13:39 +0000 |
| Subject: | Re: How to ask "if private IP"? | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-265031@lists.php.net to get a copy of this message | ||
Below is a quick example. This isn't the best way to do it, just
another way. I personally would convert them to integers then compare
instead of doing it the way I'm doing it below.
<?php
function privateIP($ip)
{
if ( (($ip >= "10.0.0.0") && ($ip <= "10.255.255.255")) ||
(($ip >= "192.168.0.0") && ($ip <=
"192.168.255.255")) ||
(($ip >= "172.16.0.0") && ($ip <= "172.31.255.255"))
) {
return true;
}
return false;
}
if (privateIP("192.168.1.1")) {
print "hmm";
}
?>
William Betts
http://www.phpbakery.com
On Nov 26, 2007 6:08 AM, Jochem Maas <jochem@iamjochem.com> wrote:
> Ronald, I really dont care if my email doesn't reach you, making normal people jump
> through hoops because you want to avoid spam is not the right way to do things,
> next time I'll remember not to answer your questions as your not going to
> ['be able to'] read my answers:
>
> <BLA BLA BLA>
> This message was created automatically by mail delivery software (TMDA).
>
> Your message attached below is being held because the address
> <jochem@iamjochem.com> has not been verified.
>
> To release your message for delivery, please send an empty message
> to the following address, or use your mailer's "Reply" feature.
>
> ronald-confirm-1196077490.5142.da0db9@elmit.com
>
> This confirmation verifies that your message is legitimate and not
> junk-mail. You should only have to confirm your address once.
>
> If you do not respond to this confirmation request within 14 days,
> your message will not be delivered.
> </BLA BLA BLA>
>
>
>
> Jochem Maas wrote:
> > Ronald Wiplinger wrote:
> >> I use $aa=$_SERVER["REMOTE_ADDR"];
> >>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>