Page 1 of 1

ban ip?

Posted: Sun Aug 06, 2006 10:49 pm
by Taylor Hewitt
i run an IPB forum.

i was wondering if there was anyway to ban an ip address using a simple php tag?

i also want to be able to add an if statement

i want to ban that up UNLESS they are logged in as a member or something.

i can probably figure that part out, but id like to know how to ban an IP with php.

thanks

Posted: Sun Aug 06, 2006 10:52 pm
by Benjamin

Code: Select all

if ($_SERVER['REMOTE_ADDR'] == '192.168.1.1')
{
  die();
}

Posted: Mon Aug 07, 2006 12:11 am
by s.dot
probably should set it up for future bans too. although you should pull that from a db or text file it'd look like this

Code: Select all

$banned_ips = array(
   '192.168.1.1',
   '192.168.1.101'
);

if(in_array($_SERVER['REMOTE_ADDR'],$banned_ips)){
   die('You have been banned.');
}

Posted: Mon Aug 07, 2006 12:20 am
by Benjamin
ha feature creep already lol