...

View Full Version : ban IP adress



muhaidib
06-16-2005, 05:08 AM
hello all,,, how can i set a simple PHP code that says


get ip
if $ip = "00.00.00.00"//the list of banned users
header("Location: banned.shtml");
else
//just carry on



you get the point :) sorry my PHP is bad lol,, :thumbsup:

gsoft
06-16-2005, 05:12 AM
Maybe this search will help http://www.codingforums.com/search.php?searchid=278729

muhaidib
06-16-2005, 06:12 AM
so do i just use this code


<?

$ip = $_SERVER['REMOTE_ADDR'];

$bannedips = array("IP HERE","IP HERE","IP HERE");

if (in_array($ip, $bannedips)) {

// disallow

} else {

// allow

}

?>

????????????

gsoft
06-16-2005, 06:18 AM
Yes that should work.

mindlessLemming
06-16-2005, 07:52 AM
That'll work, but it's not going to save you as much bandwidth as doing it in .htaccess....



<Limit GET>
order allow,deny
allow from all
deny from 000.000.0.01
deny from badserver.com
</Limit>

muhaidib
06-16-2005, 05:51 PM
allright its good :) thanx all for your help :thumbsup:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum