I have made up a textfile, called banfile.txt in which I've put the IP's of users, which I do not want to perform a certain action. To see if the users IP is in the file banfile.txt I made a function, called isbanned(), that returns either a 1 if the user is banned or a 0 if he's not.
This is de code for that function.
Code: Select all
function isbanned() {
$banfile = "banfile.txt";
$localip = $_SERVERї'REMOTE_ADDR'];
if (!file_exists("$banfile")) {
$bfp = fopen("$banfile", "a");
fclose($bfp);
}
$bfp = fopen("$banfile","r") or die ("error when opening banfile.txt");
$buffer = fgets($bfp);
while(!feof($bfp) && $buffer != $localip) {
$buffer = fgets($bfp);
}
fclose($bfp);
if ($buffer == $localip) {
return 1;
}
else {
return 0;
}
}Is there anyone that know this problem, or sees an error in my code? Please let me know.
Greetings,
Tonni Tielens