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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.