Jump to content

IP ban script


alexandom

Recommended Posts

I have a simple php code that I received from my hosting that allows me to capture information from people who visit my site.

I am now facing a problem with someone overloading my form.txt that is attached to my form.php with thousands of emails and I need to stop them. My hosting tells me that I need to look for an IP ban script. Any advise???????????

Thanks

Link to comment
https://forums.phpfreaks.com/topic/57504-ip-ban-script/
Share on other sites

IP banning is pretty unreliable. People can change their IP addresses, then just come right back and start populating your text file again.

 

Are people supposed to be able to write to your text file? If not...set it to read only, then they can't put anything in it. Maybe start storing the info in the text file in a database instead?

Link to comment
https://forums.phpfreaks.com/topic/57504-ip-ban-script/#findComment-284527
Share on other sites

Chances are, the person is using a script of some form to do it, so a CAPTCHA might stop them (Google it) along with anyone else you might have future issues with.

 

As for the IP thing, the viewer's IP is stored in $_SERVER['REMOTE_ADDR'], so you could do something like:

 

$banned = array('xxx.xxx.xxx.xxx');
if(in_array($_SERVER['REMOTE_ADDR'], $banned)) {
echo 'You\'re banned!';
exit;
}

 

Edit: fixed the syntax error.  Thanks ProjectFear ;p

Link to comment
https://forums.phpfreaks.com/topic/57504-ip-ban-script/#findComment-284528
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.