|
Posted by "Richard Lynch" on 10/13/05 20:23
On Thu, October 13, 2005 9:26 am, Bosky, Dave wrote:
> Does anyone have a function that will check if an ip address falls
> with
> a starting/ending ip address range>>
If you are using PostgreSQL, it has a built-in IP address data type
which almost for sure does this. :-)
Maybe what you want to do is just convert the IP to an integer.
function ipd($ip){
list($a, $b, $c, $c) = explode('.', $ip);
$ipd = $a * 0x1000000 + $b * 0x10000 + $c * 0x100 + $d;
return $ipd;
}
Now you can just compare idp() of any IP addresses to see if they are
in a 'range'
There's probably a better way.
And you should probably use bit-shifting operators (<< and >>) insted
of my * 0x1000000 method, as it might be faster.
--
Like Music?
http://l-i-e.com/artists.htm
[Back to original message]
|