summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 063a8d4)
raw | patch | inline | side by side (parent: 063a8d4)
author | cajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Thu, 9 Aug 2007 10:44:07 +0000 (10:44 +0000) | ||
committer | cajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Thu, 9 Aug 2007 10:44:07 +0000 (10:44 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.5@7027 594d385d-05f5-0310-b6e9-bd551577e9d8
include/functions.inc | patch | blob | history |
diff --git a/include/functions.inc b/include/functions.inc
index 15df054ccbb5e41d94779cb75eae6378024a3243..e9e3622ac726f45629a4e2cd2bcef4c907f4784a 100644 (file)
--- a/include/functions.inc
+++ b/include/functions.inc
}
}
+
+/* Check if the specified IP address $address is inside the given network */
+function is_in_network($network, $netmask, $address)
+{
+ $nw= split('\.', $network);
+ $nm= split('\.', $netmask);
+ $ad= split('\.', $address);
+
+ /* Generate inverted netmask */
+ for ($i= 0; $i<4; $i++){
+ $ni[$i]= 255-$nm[$i];
+ $la[$i]= $nw[$i] | $ni[$i];
+ }
+
+ /* Transform to integer */
+ $first= $nw[0] * (16777216) + $nw[1] * (65536) + $nw[2] * (256) + $nw[3];
+ $curr= $ad[0] * (16777216) + $ad[1] * (65536) + $ad[2] * (256) + $ad[3];
+ $last= $la[0] * (16777216) + $la[1] * (65536) + $la[2] * (256) + $la[3];
+
+ return ($first < $curr&& $last > $curr);
+}
+
+
/* Returns contents of the given POST variable and check magic quotes settings */
function get_post($name)
{