note 39028 deleted from function.ereg by nlopess
| From: | nlopess@php.net | Date: | Thu, 15 Jan 2004 14:37:05 +0000 |
| Subject: | note 39028 deleted from function.ereg by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-63616@lists.php.net to get a copy of this message | ||
Note Submitter: marcus at lecter dotnet
----
Here is an optional IP-Validator-Scipt !without! the ereg-function ... may be faster - don't
know =)
//----------------------------------------
$ip = "123.123.123.123";
/* or $ip = $REMOTE_ADDR; */
function iptest ($ip) {
$ip = explode (".",$ip);
if (count($ip) != 4) {
return FALSE;
}
for ($i = 0; $i <= 3; $i++) {
if ($ip[$i] <= 255 && $ip[$i] >= 0) {
$P++;
}
}
if ($P == 4) {
return TRUE;
} else {
return FALSE;
}
}
if (iptest($ip)) {
echo "IP address is correct";
} else {
freak_out();
}
//----------------------------------------
hope it helps =)