Re: ereg - No Match

From: Date: Tue, 18 Jul 2000 18:16:32 +0000
Subject: Re: ereg - No Match
Groups: php.general 
Request: Send a blank email to php-general+get-7104@lists.php.net to get a copy of this message
In article <00071816504205.00549@nebukaddnezzar>, tim@tbautz.de (Tim Bautz) wrote: The file() command reads in a file and puts each line of the file into an array. This includes the newline. If you add in an additional ereg_replace and remove the '\n', this should work. You could also use chop() or trim(). Jeff Warrington > 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 > -------------------------------- >

« previous php.general (#7104) next »