Created
March 24, 2014 23:53
-
-
Save bennadel/9752006 to your computer and use it in GitHub Desktop.
Fully Accessible Spam-Form-Submission Blocking Using ColdFusion And (X)HTML (Version III)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--- Get the de-spamming key. ---> | |
<cfset REQUEST.TestKey = ( | |
"KS" & | |
Encrypt( | |
RandRange( -30, 30 ), | |
"SECRET_KEY_GOES_HERE", | |
"CFMX_COMPAT", | |
"HEX" | |
) | |
) /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form> | |
<input type="hidden" name="test_key" value="#REQUEST.TestKey#" /> | |
<input type="hidden" name="test_email" value=" #REQUEST.TestKey# " /> | |
<!--- | |
REST OF THE FORM GOES [[ HERE ]]. | |
THIS IS THE FORM THAT THE USER ACTUALLY SEES. | |
---> | |
<!--- THIS IS AFTER THE VISIBLE FORM FIELDS. ---> | |
<div style="display: none ; visibility: hidden ;"> | |
<p> | |
NOTE: Do Not Alter These Fields: | |
</p> | |
<label> | |
Contact Email: | |
<input | |
type="text" | |
name="contact_email" | |
value="<cfif StructKeyExists( FORM, "contact_email" )>#FORM.contact_email#</cfif>" | |
/> | |
</label> | |
<label> | |
Contact Email: | |
<input | |
type="text" | |
name="contact_email2" | |
value=" #REQUEST.TestKey# " | |
/> | |
</label> | |
<label> | |
Contact Url: | |
<input | |
type="text" | |
name="contact_url" | |
value="<cfif StructKeyExists( FORM, "contact_url" )>#FORM.contact_url#</cfif>" | |
/> | |
</label> | |
<label> | |
Subscribe to Blog: | |
<input | |
type="checkbox" | |
name="contact_subscribe" | |
value="1" | |
<cfif StructKeyExists( FORM, "contact_subscribe" )>checked="true"</cfif> | |
/> | |
</label> | |
<label> | |
Remember my Info: | |
<input | |
type="checkbox" | |
name="contact_remember_info" | |
value="1" | |
<cfif StructKeyExists( FORM, "contact_remember_info" )>checked="true"</cfif> | |
/> | |
</label> | |
</div> | |
</form> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--- The following is all for de-spamming. ---> | |
<cfif ( | |
Compare( FORM.test_key, FORM.test_email ) OR | |
(NOT StructKeyExists( FORM, "contact_email" )) OR | |
Len( FORM.contact_email ) OR | |
(NOT StructKeyExists( FORM, "contact_email2" )) OR | |
Compare( FORM.contact_email2, FORM.test_email ) OR | |
(NOT StructKeyExists( FORM, "contact_url" )) OR | |
Len( FORM.contact_url ) OR | |
StructKeyExists( FORM, "contact_subscribe" ) OR | |
StructKeyExists( FORM, "contact_remember_info" ) | |
)> | |
<!--- Set error message. ---> | |
<cfset REQUEST.FormErrors.Add( | |
"There was a problem submitting the form" | |
) /> | |
</cfif> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment