-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Labunski wrote:
| $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;
| }In the function you seem to be appending all the ip addresses in the file to $kick. When you return kick it will hold all of the ips and not just and will therefore not be equal to $ip.
You might want to try something like this:
$ip = getenv ("REMOTE_ADDR");
function kick($ip) {
~ $file_ip = file("log.txt") or die("Can't open file");
~ foreach ($file_ip as $value_ip) {
$value_ip = preg_replace("/\n/", "", $value_ip);
~ if ($ip == $value_ip) {
return true;
}
~ }
~ return false;
}if (kick($ip)) {
echo "Sorry, the access is denied.";
}It seems each ip address in the $file_ip has a new line on the end too, so you need to remove that before the current ip address in $ip will match anything that is in the file.
Hope this helps.
- -- Jason Giangrande <[EMAIL PROTECTED]> http://www.giangrande.org http://www.dogsiview.com -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFAWN6GjfevYzbk95IRAvx3AJ9jVbiSI0gyf50AkeJD63Z8LHT0ggCfQEqE RGunvEgTHkKJylmnywLxseM= =LJd1 -----END PGP SIGNATURE-----
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

