humm the in array is probably a better way of doing it, although i think your syntax has problems
PHP Code:<?php
$b[] = '0.0.0.1';
$b[] = '0.0.0.2';
$b[] = '0.0.0.3';
if(in_array($_SERVER['REMOTE_ADDR'], $b)){
die("You're banned.");
}
?>

I think my syntax is fine.
Edit: http://joshjh.pwp.blueyonder.co.uk/testing.gif (PHP/5.1.2)
Last edited by nets; 31-08-2006 at 08:07 PM.
kinda quit.
This is how I'd do it.
Save this as Ban.php if you want.
Then on your index page, to check if the IP is banned... Add this code anywhere, preferably at the top.PHP Code:<?php
//Ban.php
$ip1 = 'xxx.xxx.xxx.xxx';
$ip2 = 'xxx.xxx.xxx.xxx';
$ip3 = 'xxx.xxx.xxx.xxx';
if($_SERVER['HTTP_X_FORWARDED_FOR'] == $ip1||$_SERVER['HTTP_X_FORWARDED_FOR'] == $ip2||$_SERVER['HTTP_X_FORWARDED_FOR'] == $ip3) {
echo("Sorry your banned.");
}
?>
PHP Code:<?php
include("ban.php");
?>
Last edited by lolwut; 02-09-2006 at 07:26 PM.
i've been here for over 8 years and i don't know why
Nice tut there![]()
Last edited by Eric30; 06-09-2006 at 10:13 PM.
Meh, you could use another way of doing it If you have a MySQL database and not alot of tables you can make)
PHP Code:<?php
include("configurationofmysqldatabasewithareallylongunneededname.php");
$dynamite = mysql_fetch_array(mysql_query("SELECT `ip` FROM `bannageness` ORDER BY `ip` DESC"));
$explosion = explode(";", $dynamite["ip"]);
for($num = 0; $num < count($explosion); $num++)
{
if($_SERVER["REMOTE_ADDR"] == "$explosion[$num]")
{
die("lol banned");
}
}
?>
Last edited by Jewish Bear; 22-01-2007 at 11:21 AM.
visit my internet web site on the internet
http://dong.engineer/
it is just videos by bill wurtz videos you have been warned
right, i have this problem
my ban.php is in a directory such as
1/2/3/4/5/6/7/8/9/ban.php
and if i put this incluede on my homepage
<?php
include("ban.php");
?>
it only reads the same directory as the files in. and when i try to put in the full url such as
http://www.bonxy.co.uk/1/2/3/4/5/6/7/8/9/ban.php it comes up with loads of error lines. anyone know how i can get around this problem ????
+REP TO HELPERS!!!!!!
xxxxxx
Why not also set a banned cookie and a session and make it check for that so if it has either of the 3 then your banned...?
Can clear cookies, sessions, and change my IP very easily.
I don't really think there is a decent way of banning someone!
Want to hide these adverts? Register an account for free!