<!--- Try to decrypt and check the anti-spam keys. It is important to put CFTry / CFCatch around any and all decryption actions since the Decrypt() method will throw an error if no string (empty string) is passed to it. Seeing as we can esnure the integrity of our data, this is a possibility. ---> <cftry> <!--- Decript the spam key using our global encryption key. This will give us back our randomly generated key. ---> <cfset REQUEST.SpamKey = Decrypt( FORM.spam_key3, "nutz_4_butts", "CFMX_COMPAT", "HEX" ) /> <!--- Decrypt the cut off date using the spam key we just decrypted. This will give us back our time this form can be active. ---> <cfset REQUEST.CutOffDate = Decrypt( FORM.spam_key1, REQUEST.SpamKey, "CFMX_COMPAT", "HEX" ) /> <!--- Decrypt the required cut off date using the spam key. This will give us the time for which the form MUST be active (otherwise, submission occurred to fast). ---> <cfset REQUEST.RequiredCutOffDate = Decrypt( FORM.spam_key2, REQUEST.SpamKey, "CFMX_COMPAT", "HEX" ) /> <!--- Check to see if our anti-spam time contraints have been violated. For starters, we must check to see if the decrypted time stamps are even valid numeric dates. If they are, then check to see if "Now" falls between the required live time and active cut-off time. ---> <cfif ( (NOT IsNumericDate( REQUEST.CutOffDate )) OR (NOT IsNumericDate( REQUEST.RequiredCutOffDate )) OR (REQUEST.CutOffDate LT REQUEST.Environment.DateTime.Now) OR (REQUEST.RequiredCutOffDate GT REQUEST.Environment.DateTime.Now) )> <!--- This cut off date is not valid. ---> <cfset REQUEST.FormErrors.Add( "There was a problem submitting the form, please try again" ) /> <!--- Add an additional check to see if the form was submitted to fast. If it was, give the user some feedback as to why the form submission did not work. ---> <cfif (REQUEST.RequiredCutOffDate GT REQUEST.Environment.DateTime.Now)> <cfset REQUEST.FormErrors.Add( "The form must be active for 10 seconds before it can be submitted" ) /> </cfif> </cfif> <!--- Catch any errors that occur. ---> <cfcatch> <!--- Something went wrong. Either there was an error in the code, or the data was invalid. Either way, the anti-spamming failed. ---> <cfset REQUEST.FormErrors.Add( "There was a problem submitting the form, please try again" ) /> </cfcatch> </cftry>