PDA

View Full Version : [RELEASE] Ban Full/Partial Hostnames


01-03-2001, 01:33 AM
This code modification will allow you to add full or partial hostnames to your banip list found in the Control Panel's Options page. As an example, if you wanted to ban all AOL users you would make the changes below and then add .aol.com to your banip list. This can be useful when a troublesome user is using an ISP that has several netblocks and instead of adding a dozen entries into your banip list, you simply add one and the problem is solved for the time being.

The only file that needs modifying is global.php.

In the checkipban function, find:
$ipaddress=getenv("REMOTE_ADDR");

And directly below it add:
$r_hostname=@gethostbyaddr($ipaddress);

Also in the checkipban function, find:
if (strstr(" ".$ipaddress," ".trim($val))!="") {

And replace it with:
if (strstr(" ".$ipaddress," ".trim($val))!="" || eregi("$val",$r_hostname)) {

I've only been toying with PHP for a couple of weeks now so if something is done incorrectly please point it out. I've tested this code on my board and it runs fine. I ran a quick search to see if anyone has done a similiar mod yet and didn't find anything. If someone has done a similiar mod, please accept my apologies (I don't want to tread on anyone's territory).

[Edited by Jon P on 01-02-2001 at 10:35 PM]

TheDutch
08-03-2002, 10:10 AM
The file is not global.php but /admin/functions.php