I have made somekind of spamprotector with coldfusion in my forum, something like LylaCaptcha. That idea is simple, system sums up two number and compares that anwer and user answer.
something like generate 2 random numbers between 0 and 9. then output them as such:
what is #rand1# + #rand2#? with a text input for the user to answer (and a hidden input with the answer to match up on the action page).
And then if answer is right user can go forward and write his messages. But it not working, spam messages still comes through. here is my codes.
ask number
<cfset numero1 = "#randrange(1,10)#" /> <<<<<<<<<<<<<<<<<<<< number1
<cfset numero2 = "#randrange(1,10)#" /> <<<<<<<<<<<<<<<<<<<< number2
<CFSET yhteensa=numero1 + numero2>
<cfoutput>Seuraavaa tarkistusta käytetään "spam bottien"
estämiseen.<br>
how much is #numero1# + #numero2# ?</cfoutput><br>
<br>
Syötä vastauksesi syöttökenttä
;än ja paina ok: <br>
<input name="luku" type="text" size="10"><br> <<<<<<<<<<<<<<<<< user answer
<cfoutput>
<INPUT TYPE = "hidden" NAME="summa" Value = "#yhteensa#"> <<<<<<<<<<<<<<<<<<<< sum
</cfoutput>
action page:
<cfif(#form.luku# IS #form.summa#)>
<cfparam name="Reply" default="N">
<cfquery name="check_forum" datasource="#datasource#">
SELECT AllowHTML FROM ForumList
WHERE ForumID = #ForumID#
</cfquery>
<CFSET form.Body = replace(form.Body,"#Chr(13
)##Chr(10)
#", "<br>", "ALL")>
<cfquery name="post_topic" datasource="#datasource#">
INSERT INTO ForumThreads
(DateIn,ForumID,Thread,Par
ent, Author,LastPost,Subject,Re
ply,Body)
VALUES (#CreateODBCDateTime("#Now
()#")#,#Fo
rumID#,#Th
read#,#Thr
eadID#,'#f
orm.Author
#', #CreateODBCDateTime("#Now(
)#")#,'#fo
rm.Subject
#','#Reply
#','#form.
Body#')
</cfquery>
<cfquery name="update_forum_1" datasource="#datasource#">
SELECT ThreadID FROM ForumThreads
WHERE ForumID = #ForumID# AND Parent = 0
</cfquery>
<cfquery name="update_forum_2" datasource="#datasource#">
SELECT ThreadID FROM ForumThreads
WHERE ForumID = #ForumID#
</cfquery>
<cfquery name="update_forum_3" datasource="#datasource#">
UPDATE ForumList
Set NumOfTopics=#update_forum_
1.RecordCo
unt#,
NumOfPosts=#update_forum_2
.RecordCou
nt#,
LastPost=#CreateODBCDateTi
me("#Now()
#")#
WHERE ForumID = #ForumID#
</cfquery>
<cfquery name="update_forum_4" datasource="#datasource#">
UPDATE ForumThreads
Set LastPost=#CreateODBCDateTi
me("#Now()
#")#
WHERE Thread = #Thread# AND Parent = 0
</cfquery>
<cflocation url="katso_aihe.cfm?ForumI
D=#ForumID
#" addtoken="No">
<CFELSE>
<!-- if not equal then do this -->
<script>
alert("answer isn't right");
self.location="index.cfm";
</script>
</cfif>
Start Free Trial