note 37406 added to function.eregi

From: Date: Thu, 13 Nov 2003 21:08:41 +0000
Subject: note 37406 added to function.eregi
Groups: php.notes 
Request: Send a blank email to php-notes+get-60356@lists.php.net to get a copy of this message
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; } ---- Manual Page -- http://www.php.net/manual/en/function.eregi.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+37406 Delete -- http://master.php.net/manage/user-notes.php?action=delete+37406&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+37406&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#60356) next »