Click to search Andy Jarrett.co.uk RSS feed

Loading Twitter

Blocking recent comment spam

There are a ton of ways to stop spam on blogs. This is my dirty (and not pretty) solution that I am adding to stop the recent wave of crap that is getting through the front end checks.

The long term plan is to put a back-end on this but for now here is v.00001

view plain print about
1<!--- Seperate with a pipe "|" as this is a regex list --->
2<cfset commentBlacklist = "coachoutletmall|wowgold" />
3<!---
4All the fields that we are going to check.
5Don't really need to check the email field as its not displayed.
6--->

7<cfset checkFields =trim(form.name) & trim(form.email) & trim(form.website) & trim(form.comments) />
8<!--- reFind to check the fields as they are past the other rules i.e. captcha --->
9<cfif reFindNoCase("#commentBlacklist#", checkFields, 1) >
10<cfoutput>Sorry deadbeat, I don't allow comment spam. If you feel you were wrongly blacklisted
11<a href="http://www.andyjarrett.com/blog/page.cfm/Contact-Me">Contact Me</a>
12</cfoutput>
13<cfabort>
14</cfif>

n.b. If you are on BlogCFC then this is for addcomment.cfm

Comments Comments (8) | Print Print | Send Send | 2269 Views

If you like what you see on the website and/or this post has helped you out in some way please consider donating to help keep me in beer vodka. The donations are made through Paypal, which accepts almost any credit card or eCheck.

(Comment Moderation is enabled. Your comment will not appear until approved.)
Nice. FWIW, if you're on BlogCFC then you already have access to CFFormProtect, which has the option to incorporate both Akismet and Project HoneyPot, both of which offer outstanding Spam control. Once I got those implemented on my blog my Spam comments went to virtually zero.
Andy,

Where in addcomment.cfm would I place this code?
Nevermind - found the spot... also - slightly modded the code to send me the poster's IP address and other info via e-mail...
@sid Glad you found it! I should of been clearer :)

@Eric You know what, I had an after thought that it might when I was adding this snippet of code. I'll have a look in to that later! Cheers for the tip!
BlogCFC not only supports cfformprotect, but also basic keyword matching. When I turned on cfformprotect and enabled akismet/honeypot, it became near perfect. :)
@Andy - Yeah I knew where the file was - was just wondering where IN the file I needed to put it - but as usual with Ray's code - I found it quick enough once I looked...
Andy,

I have a (FOSS) solution that takes pretty much the same approach but is a bit more robust. Also, you can take advantage of updated spam definitions (I try to update them at least once a month) by just reinitializing BlogCFC.

http://www.bryantwebconsulting.com/blog/index.cfm/...
Sid - you are kind. BlogCFC is NOT the best example of my code. ;)
BlogCFC by Raymond Camden + Twitter @AndyJ + ColdFusion jobs + Contact Me + Snippets/Downloads + RSS .