Re: How to ask "if private IP"?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



i did this once

$ip = sprintf("%u",intval(ip2long($_SERVER['REMOTE_ADDR'])));

and then did checks to see if it was between the ranges for 10.0.0.0,
192.168 etc...

apparently i lost that code. but it was pretty simple.
http://www.faqs.org/rfcs/rfc1918.html

     10.0.0.0        -   10.255.255.255  (10/8 prefix)
     172.16.0.0      -   172.31.255.255  (172.16/12 prefix)
     192.168.0.0     -   192.168.255.255 (192.168/16 prefix)

and then what, 224.0.0.0-255.255.255.255? and not 0.0.0.0.

i had it all figured out... just print out what the 10.0.0.0 is in
integer, and 10.255.255.255 and such, and then just check if the
integer is between any of the "invalid" ranges. the integer math
should be very fast.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux