Selaa lähdekoodia

Move the check_cidr function

Mark Crane 11 vuotta sitten
vanhempi
commit
1b8770b9b0
1 muutettua tiedostoa jossa 7 lisäystä ja 0 poistoa
  1. 7 0
      resources/functions.php

+ 7 - 0
resources/functions.php

@@ -73,6 +73,13 @@
 		}
 		}
 	}
 	}
 
 
+	if (!function_exists('check_cidr')) {
+		function check_cidr ($cidr,$ip_address) {
+			list ($subnet, $mask) = explode ('/', $cidr);
+			return ( ip2long ($ip_address) & ~((1 << (32 - $mask)) - 1) ) == ip2long ($subnet);
+		}
+	}
+
 	if (!function_exists('fix_postback')) {
 	if (!function_exists('fix_postback')) {
 		function fix_postback($post_array) {
 		function fix_postback($post_array) {
 			foreach ($post_array as $index => $value) {
 			foreach ($post_array as $index => $value) {