From: hickert Date: Wed, 8 Aug 2007 13:54:41 +0000 (+0000) Subject: Added is_ip_range function, to check foor valid ip ranges in dhcp plugin X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=73808cbb417e8a26c74c1fcaa7f36d19f684340d;p=gosa.git Added is_ip_range function, to check foor valid ip ranges in dhcp plugin git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.5@7004 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/include/functions.inc b/include/functions.inc index 1b1e03b01..50a9318b1 100644 --- a/include/functions.inc +++ b/include/functions.inc @@ -2566,5 +2566,23 @@ function get_languages($languages_in_own_language = FALSE,$strip_region_tag = FA return($ret); } + +/* Check if $ip1 and $ip2 represents a valid IP range + * returns TRUE in case of a valid range, FALSE in case of an error. + */ +function is_ip_range($ip1,$ip2) +{ + if(!is_ip($ip1) || !is_ip($ip2)){ + return(FALSE); + }else{ + $ar1 = split("\.",$ip1); + $var1 = $ar1[0] * (16777216) + $ar1[1] * (65536) + $ar1[2] * (256) + $ar1[3]; + + $ar2 = split("\.",$ip2); + $var2 = $ar2[0] * (16777216) + $ar2[1] * (65536) + $ar2[2] * (256) + $ar2[3]; + return($var1 < $var2); + } +} + // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: ?>