Stopping Comment Spam

One of the biggest issues with the Pligg CMS is SPAM.  As a Pligg powered website owner you are constantly dealing with submissions of links that are blatent spam, spam bots and spam in the comments.  To be fair, Pligg is not the only CMS that faces this issue, but it does have very little deterents in place to prevent it.

Pligg comment spamI have told you how to prevent auto-submitters or spam bots from submitting to your site by using reCaptcha on step 1 of the submission process.  If you successfully install it, you will see a drastic decrease in spam as bots will no longer be able to submit, which is the source of the most of the spam submissions.

The only other source of spam is via the comments.  This again has been a problem with Pligg since day one and if you search their forums the developers have yet to post a solution to users being able to post links in their comments.

I will show you 2 methods for dealing with comments that contain spam links.

Making comment links nofollow

Open libs/utils.php, find:

function text_to_html($string) {
        return preg_replace(‘/([hf][tps]{2,4}://[^ tnr]+[^ .t,nr()"'])/’, ‘<a href="$1">$1</a>’, $string);
}

change it to:

function text_to_html($string) {
        return preg_replace(‘/([hf][tps]{2,4}://[^ tnr]+[^ .t,nr()"'])/’, ‘<a rel="nofollow" href="$1">$1</a>’, $string);
}

Make links un-clickable:

Open libs/utils.php, find:

function text_to_html($string) {
        return preg_replace(‘/([hf][tps]{2,4}://[^ tnr]+[^ .t,nr()"'])/’, ‘<a href="$1">$1</a>’, $string);
}

change it to:

function text_to_html($string) {
        return preg_replace(‘/([hf][tps]{2,4}://[^ tnr]+[^ .t,nr()"'])/’, ‘$1′, $string);
}

That’s it.  Which method, is up to you.

Which one will you be using?


If you enjoyed this post, make sure you subscribe to my RSS feed!

  • Its a real problem, spammer are now using our own contact forms aginst us :-( The good news is that you can actually start to regain some control over what you get in your inbox.
  • sky
    Top Site Leute

    Kann sich sehen lassen
    Benutze gerade Pligg
  • stockalerts
    Thanks for providing this important information. I don't know more about coding but from here i got some useful points.
  • hiteshthakur034
    yup buddy...great knowledge you have shared with us....really creative and innovative thoughts u have said......... .....well u can visit for info about twitter followers at http://thetwittersecret.com/
  • Good information.Thank you for shairng:)
  • I have a website with a section where you can put your name, email and a comment or question that is sent to my email. I got spammed and i am getting an email every minute and don't know how to stop them.
    I searched online but what i found is how to stop spam on blog but don't know how to stop it from website.
    .-= dogs mating´s last blog ..Best pets at low prices =-.
  • This site is a great place to vent your frustrations about spam and the like. There is also practical advice for avoiding and dealing with spam. The author of the blog is hilarious and observant. Anti-spammers unite! http://www.stop-viagra-spam.com
  • I have a website with a section where you can put your name, email and a comment or question that is sent to my email. I got spammed and i am getting an email every minute and don't know how to stop them.
  • Wow !
    Thanks for sharing the code.Keep up posting the good work :)
blog comments powered by Disqus