Re: function to compare ip addr to a ip range>

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

 



On 10/13/05, Bosky, Dave <Dave.Bosky@xxxxxxxxxx> wrote:> Does anyone have a function that will check if an ip address falls with> a starting/ending ip address range>>

#!/usr/bin/php<?php
$ip = '10.0.0.1';$ip2 = '10.0.0.2';$ip3 = '10.0.0.3';
$ip = abs( ip2long( $ip ) );$ip2 = abs( ip2long( $ip2 ) );$ip3 = abs( ip2long( $ip3 ) );
if( $ip2 > $ip && $ip2 < $ip3    || $ip2 < $ip && $ip2 > $ip3 ){    echo "In range\n";}else{    echo "Not in range\n";}
?>
--Greg DonaldZend Certified EngineerMySQL Core Certificationhttp://destiney.com/

[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