Re: Small Problem - could you help me, please?
| From: | Jake McHenry | Date: | Wed, 17 Mar 2004 23:05:11 +0000 |
| Subject: | Re: Small Problem - could you help me, please? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-180764@lists.php.net to get a copy of this message | ||
----- Original Message -----
From: "Labunski" <romans@skulme.lv>
To: <php-general@lists.php.net>
Sent: Wednesday, March 17, 2004 5:46 PM
Subject: [PHP] Small Problem - could you help me, please?
> $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'm assuming your log.txt is in format of
xxx.xxx.xxx.xxx
xxx.xxx.xxx.xxx
xxx.xxx.xxx.xxx
etc, which will create the array in $file_ip. try changing to this:
function kick($ip)
{
$file_ip = file('log.txt');
$access = 'yes';
foreach($file_ip as $value_ip)
{
if ($ip == $file_ip)
{
$access = 'no';
}
}
}
if (kick($ip) == 'yes')
{
your_allowed_in;
}
else
{
your not allowed;
}
that help?
Jake