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
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>
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
| Tweet |
| 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. |
Where in addcomment.cfm would I place this code?
@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!
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/...