ereg - No Match
| From: | Tim Bautz | Date: | Tue, 18 Jul 2000 14:45:40 +0000 |
| Subject: | ereg - No Match | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-7075@lists.php.net to get a copy of this message | ||
Hi all !
can anyone figure out why the following function doesn't behave as it is
expected to ?
It should compare the the IP given in $REMOTE_ADDR with a list of
IPs from $file.
Example : $REMOTE_ADDR = 192.68.0.1
IP from file : 192.168.0
Why does it echo "No-IP-match" nevertheless ?
Thanxalot
Tim
function Zugriff_erlaubt ($file) {
global $REMOTE_ADDR;
echo "Current Ip : ";
echo $REMOTE_ADDR;
echo "<P>";
$fit=0;
$file=StrVal($file);
$zeilen = file($file);
$anzahl = count($zeilen);
$i=0;
while($i<$anzahl && !$fit){
if(ereg("^allow from",$zeilen[$i])){
$ip = ereg_replace("allow from ","",$zeilen[$i]);
echo $ip;
echo "?";
echo $REMOTE_ADDR;
if(ereg("^$ip",$REMOTE_ADDR))
{
echo " Ip-Match<P>";
$fit=1;
}
else
{
echo " No-Ip-Match<P>";
}
}
$i++;
}
return $fit;
}
--
Tim Bautz
--------------------------------
Beware the fury of a patient man
--------------------------------
e-mail : tim@tbautz.de
wwww : http://www.tbautz.de
--------------------------------