Page 1 of 1

Help me with my IP bann script

Posted: Thu Mar 16, 2006 7:12 pm
by sleepwalker0
I got the structure from the tutorial and heres how my script looks so far

Code: Select all

<?php
$bann = fopen ("C:\www\learning%php\banned.txt", "r"); // this is line 8
$read = fread ($bann, 9000);
fclose($bann)
$badr = explode {$read};                       // this is line 11
if (in_array($REMOTE_ADDR, $badr){ 
echo "Sorry you have been banned";
die; 
}
?>
anyway I get an error on line 8 and 11, cant figure out why.

And I didnt find any info about "$REMOTE_ADDR" but I think its a built in variable for IPs connected to the server right? So yea if you could help me get rid of these errors it would help alot...Thanks.

Posted: Thu Mar 16, 2006 7:33 pm
by LiveFree

Code: Select all

<?php
$bann = fopen ("C:\www\learning%php\banned.txt", "r"); // this is line 8
$read = fread ($bann, 9000);
fclose($bann);
$badr = explode($read);                       // this is line 11
if (in_array($_SERVER['REMOTE_ADDR'], $badr){ 
echo "Sorry you have been banned";
die; 
}
?>

Posted: Thu Mar 16, 2006 10:16 pm
by sleepwalker0
your version causes error on line 12 ($SERVER[])..

"Parse error: syntax error, unexpected '{' in C:\wamp\www\learning php\ban.php on line 12"

Posted: Thu Mar 16, 2006 10:31 pm
by feyd
it's missing a second closing paren.