summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: b268a61)
raw | patch | inline | side by side (parent: b268a61)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 20 Feb 2008 09:53:06 +0000 (09:53 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 20 Feb 2008 09:53:06 +0000 (09:53 +0000) |
-Test if a given IP Address is within a specific range.
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8980 594d385d-05f5-0310-b6e9-bd551577e9d8
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8980 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-core/include/utils/class_tests.inc | patch | blob | history |
index ba28e05504178cdd2ae028f447dcd9fef3f65ede..4fa85ce41c677209242014e723958112cf5ee3c0 100644 (file)
return ($first < $curr&& $last > $curr);
}
+
+
+ /* Check if the specified IP address $address is inside the given network */
+ public static function is_in_ip_range($from, $to, $address)
+ {
+ $from = split('\.', $from);
+ $to = split('\.', $to);
+ $ad = split('\.', $address);
+
+ /* Transform to integer */
+ $from= $from[0] * (16777216) + $from[1] * (65536) + $from[2] * (256) + $from[3];
+ $to= $to[0] * (16777216) + $to[1] * (65536) + $to[2] * (256) + $to[3];
+ $ad= $ad[0] * (16777216) + $ad[1] * (65536) + $ad[2] * (256) + $ad[3];
+
+ return ($ad >= $from && $ad <= $to);
+ }
}
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: