Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I protect my forum against spam?

I have a forum on a website I master, which gets a daily dose of pron spam. Currently I delete the spam and block the IP. But this does not work very well. The list of blocked IP's is growing quickly, but so is the number of spam posts in the forum.

The forum is entirely my own code. It is built in PHP and MySQL.

What are some concrete ways of stopping the spam?

Edit The thing I forgot to mention is that the forum needs to be open for unregistered users to post. Kinda like a blog comment.

like image 447
Marius Avatar asked Jan 27 '09 20:01

Marius


4 Answers

In a guestbook app I wrote, I implemented two features which prevent most of the spam:

  • Don't allow POST as the first request in a session

  • Require a valid HTTP Refer(r)er when posting

like image 74
devio Avatar answered Sep 23 '22 21:09

devio


One way that I know which works is to use JavaScript before submitting the form. For example, to change the method from GET to POST. ;) Spambots are lousy at executing JavaScript. Of course, this also means that non-Javascript people will not be able to use your site... if you care about them that is. ;) (Note: I don't)

like image 24
Vilx- Avatar answered Sep 22 '22 21:09

Vilx-


In my experience, the best easy defenses come from just doing something "non-standard". If you make your site non-standard, this makes it so that any automated spam would have to be coded specifically for your site, which (no offense) probably isn't worth the effort. Note that if the spam is coming from human spammers, there's not really anything you can do that won't also stop legitimate posters. So the goal is to find a solution that will throw away any "standard" posts - that is, "fill out the whole form and push submit".

A couple examples that come to mind of things that you could try:

  • Have a hidden form field with a name that sounds like something a spammer would want to fill out, like "website" or "homepage" or something like that. If the form field gets filled out, throw away the message instead of posting it, because it was a bot automatically filling in the whole form, even invisible fields.
  • You don't have to use a "real" captcha, but even something simple like "Enter the following word backwards: <random backwards word>" or "What is the domain name of this website?". Easy for a human to do, but it would require a fairly complex bot to figure out what to fill in.
like image 28
Chad Birch Avatar answered Sep 25 '22 21:09

Chad Birch


You could use a captcha, there are some good scripts like PHPCaptcha or use a spam control service, like Akismet, they have a PHP API.

like image 40
Christian C. Salvadó Avatar answered Sep 23 '22 21:09

Christian C. Salvadó