note 37416 added to function.ereg
| From: | mac at aic dot at | Date: | Fri, 14 Nov 2003 08:37:49 +0000 |
| Subject: | note 37416 added to function.ereg | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-60370@lists.php.net to get a copy of this message | ||
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
----
Manual Page -- http://www.php.net/manual/en/function.ereg.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+37416
Delete -- http://master.php.net/manage/user-notes.php?action=delete+37416&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+37416&report=yes
Search -- http://master.php.net/manage/user-notes.php