Code

Moved get_post function from setup to include.inc
[gosa.git] / include / functions.inc
index 1b1e03b011af27f823df7e953c50d5d3b17510da..15df054ccbb5e41d94779cb75eae6378024a3243 100644 (file)
@@ -2566,5 +2566,37 @@ 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);
+  }
+}
+
+/* Returns contents of the given POST variable and check magic quotes settings */
+function get_post($name)
+{
+  if(!isset($_POST[$name])){
+    trigger_error("Requested POST value (".$name.") does not exists, you should add a check to prevent this message.");
+    return(FALSE);
+  }
+  if(get_magic_quotes_gpc()){
+    return(stripcslashes($_POST[$name]));
+  }else{
+    return($_POST[$name]);
+  }
+}
+
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
 ?>