note 37406 deleted from function.eregi by felipe
| From: | felipe@php.net | Date: | Mon, 10 Dec 2007 02:37:01 +0000 |
| Subject: | note 37406 deleted from function.eregi by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-133132@lists.php.net to get a copy of this message | ||
Note Submitter: lueck at gerwan dot de
----
Just a simple ip address validation function. The function does only check that the ip address is in
a correct format (IPv4):
function checkipaddress($checkip) {
if (eregi("^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$", $checkip)) {
for ($i = 1; $i <= 3; $i++) {
if (!(substr($checkip, 0, strpos($checkip, ".")) >= "0" &&
substr($checkip, 0, strpos($checkip, ".")) <= "255")) {
echo "Der ".$i.". Block der IP-Adresse hat kein gültiges Format!";
return false;
}
$checkip = substr($checkip, strpos($checkip, ".") + 1);
}
if (!($checkip >= "0" && $checkip <= "255")) {
echo "Der 4. Block der IP-Adresse hat kein gültiges Format!";
return false;
}
}
else {
echo "Die IP-Adresse hat kein gültiges Format!";
return false;
}
return true;
}