Quick Anti-Comment Spam Hack
-
First, the disclaimer: This hack is just that, a hack. I don’t claim that it will work, nor do I claim that it won’t. However, I can say that I currently is working for me. Also, I am aware of the fact that this is merely a short term solution. In fact publishing this method for blocking comment spam, will probably result in it becoming ineffective within a couple days. But, that could mean that we might get a couple days of rest from the comment spammers.
Here’s what I did. After checking my server logs for several weeks (I don’t get many real comments), I noticed that <b>none</b> of the spam comments had a valid referer set, while all of the valid comments did. I’m sure many of you know where I’m going now. I opened up b2comments.post.php in my favourite text editor, scrolled down to where I saw:
<pre>
</pre>
if ('closed' == $commentstatus)
die('Sorry, comments are closed for this item.');
I added a line below that test, and started typing:
<pre>
</pre>
if ( !preg_match( "/type.your.domain.here/i", $GLOBALS["HTTP_REFERER"] ) ) {
die('Sorry, your comments are blocked for spam infringement.');
}
Then I saved the file. You will want to enter your domain into the space where I typed <b>type.your.domain.here<b>, but that’s all there is to it. Granted I don’t know how well this will work for you, but it cut my little site from 2 comment spams a day, down to none since the install.
Good luck!
- The topic ‘Quick Anti-Comment Spam Hack’ is closed to new replies.