index ba28e05504178cdd2ae028f447dcd9fef3f65ede..136dca87ab87c2b393447d2f8f6a5801a04f0673 100644 (file)
public static function is_uid($uid)
{
- global $config;
-
if ($uid == ""){
return (TRUE);
}
/* Simple is domain check, it checks if the given string looks like "string(...).string" */
public static function is_domain($str)
{
- return(preg_match("/^([a-z0-9i\-]*)\.[a-z0-9]*$/i",$str));
+ return(preg_match("/^([a-z0-9\-]*)\.[a-z0-9\-]*$/i",$str));
}
*/
public static function is_ip_range($ip1,$ip2)
{
- if(!is_ip($ip1) || !is_ip($ip2)){
+ if(!tests::is_ip($ip1) || !tests::is_ip($ip2)){
return(FALSE);
}else{
$ar1 = split("\.",$ip1);
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: