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

Posted: 22-Jun-2010

View: 3489

Permalink: here

Comments

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.

#1 Eric Cobb
22/Jun/10 8:12 PM

Andy,

Where in addcomment.cfm would I place this code?

#2 Sid Wing
22/Jun/10 8:14 PM

Nevermind - found the spot... also - slightly modded the code to send me the poster's IP address and other info via e-mail...

#3 Sid Wing
22/Jun/10 9:04 PM

@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!

#4 Andy Jarrett
22/Jun/10 9:04 PM

BlogCFC not only supports cfformprotect, but also basic keyword matching. When I turned on cfformprotect and enabled akismet/honeypot, it became near perfect. :)

#5 Raymond Camden
22/Jun/10 9:13 PM

@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...

#6 Sid Wing
22/Jun/10 9:19 PM

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/...

#7 Steve Bryant
22/Jun/10 9:56 PM

Sid - you are kind. BlogCFC is NOT the best example of my code. ;)

#8 Raymond Camden
22/Jun/10 11:40 PM