note 37416 deleted from function.ereg by kennyt
| From: | kennyt@php.net | Date: | Wed, 26 Jan 2005 03:47:29 +0000 |
| Subject: | note 37416 deleted from function.ereg by kennyt | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-83959@lists.php.net to get a copy of this message | ||
Note Submitter: mac at aic dot at
----
A simple IP-Check Function:
function is_ip($ip) {
$ip = trim($ip);
if (strlen($ip) < 7) $status = "false";
if (!ereg("\.",$ip)) $status = "false";
if (!ereg("[0-9.]{" . strlen($ip) . "}",$ip)) $status = "false";
$ip_arr = split("\.",$ip);
if (count($ip_arr) != 4) $status = "false";
for ($i=0;$i<count($ip_arr);$i++) {
if ((!is_numeric($ip_arr[$i])) || (($ip_arr[$i] < 0) || ($ip_arr[$i] > 255))) $status =
"false";
}
if (!$status) $status = "true";
return $status;
}
I think there would be a possibility to check if the IP-Net is private or ...
bye
mac