On Thu, Mar 18, 2004 at 12:46:52AM +0200, Labunski wrote:
> I have a small problem with the script - could you hepl me, please?
> 
> I made small "kicking system" for those who tried to guess the Login
> information.
> The script below is just a part of the code, but it's not working properly.
> I tried to solve this problem in many ways, but I couldn't.
> This script should check if the visitor's IP is listed in log.txt file and
> if it is, the warning appears.
> But the problem is that the script checks only first line in the log.txt
> file, not all the lines.
> P.S.
> log.txt file has many IP addresses listed in one column.
> 
> 
> $ip = getenv ("REMOTE_ADDR");
> 
> function kick() {
>     $file_ip = file("log.txt");
>     foreach($file_ip as $value_ip ) {
>         $kick .= "$value_ip";
>     }
>     return $kick;
> }
> if ($ip == kick()){
> echo "Sorry, the access is denied.";
> 
> exit;
> }

I think you want something like:

   if (in_array($_SERVER['REMOTE_ADDRESS'], file('log.txt')))
       die("Sorry, the access is denied.");

- Rob

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to