How can I test to make sure that a client has cookies enabled in both
Netscape AND IE?
I use Client variables mainly for my applications, so using CFCOOKIE is a
little new to me.
I am writing a simple EmailAction.cfm to track the number of times a client
emails people in my database. If they send more than 5 emails in a day,
they are asked to come back after 24 hours to email again. My hope is that
this would be enough deterrent to keep most spammers from emailing my whole
database (at least it would slow them down). I will also have the email
form email me the IP of anyone that hits the 5 email limit.
My code looks like so:
================================================================
<!--- EmailAction.cfm - Written by John McKown---->
<!--------------------------------------
Step 1. Make sure they can accept cookies
Step 2. Check for URL Parameters
Step 3. Set cookies if they do not already have them.
Step 4. If they do have the cookie, then make sure that they are not
spamming.
If they are spamming, abort them and show an error.
Step 5. If they are not spamming, then send their email.
Step 6. Show success message.
---------------------------------------->
<!---- STEP 1. - Cookie acceptance check will go here (with your
elp) ---->
<!--- STEP 2. - Make sure that a URL variable is passed --->
<CFIF IsDefined("URL.RecordID") IS FALSE>
<BR>
<font face="verdana, arial" size="4" color="red"><B>ERROR - No Variables
Passed</b></font><br>
<CFINCLUDE TEMPLATE="index.cfm">
<CFABORT>
</CFIF>
<!--- Before Sending the email, make sure they are not spamming --->
<CFSET TodaysDate = Now()>
<CFOUTPUT>
<CFIF IsDefined("Cookie.EmailLastSent") is False>
<!-------------------------------------
STEP 3. They are a new visitor, so set some
cookies to track the number of emails they send.
--------------------------------------->
<CFCOOKIE NAME="EmailLastSent" VALUE="#TodaysDate#" EXPIRES="10">
<CFCOOKIE NAME="EmailsSent" VALUE="0" EXPIRES="10">
<CFELSE>
<!---------------------------------------
STEP 4. Otherwise they must have our cookie,
so see how many emails they have sent in the last day.
------------------------------------------>
<CFIF (#Cookie.EmailsSent# GTE '5') AND
(#DateFormat(COOKIE.TimeVisited)# LTE #DateFormat(TodaysDate)#)>
<!------- They have sent 5 emails in the last day, so stop them. ------->
<font face="verdana, arial" size="4" color="red"><B>SORRY!</b></font><br>
<font face="verdana, arial" size="2">
<B>You are sending too many emails through our system.<br>
This system is designed so that members can email each other.<br>
If you would like to partner with Blablah.com to reach more<br>
of our members, it will cost you. :)<br>
Please contact Joe Shmoe at <A
href="mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</A> for more information
<br>
on how you can partner with Blablah.com.<br>
<br>
Thanks for supporting Blablah.com!<br></b></font>
<!--- Alert the admin - I meant for this to be funny ---->
<CFMAIL
to="#[EMAIL PROTECTED]#"
from="#Form.Email#"
Subject="I am a spammer."
>
Dear Admin,
I am a slimy get rich quick spammer, or a kid with too much time on my
hands.<BR>
I just tried to send the following message to your users:<BR>
<i>#Form.Comments#</i><BR>
<BR>
My IP Address is: #Form.IPAddress#<BR>
I tried to email this to your users at #Form.EmailDateTime#<BR>
Stop me before I go too far! :)
</cfmail>
<CFELSE>
<!---------------------------------------
STEP 5. They have not spammed our users
yet, so send their email
---------------------------------------->
<CFMAIL
to="#Query.UserEmail#"
from="#Form.Email#"
Subject="BlahBlah.com Member Mail From #Form.Name#"
>
To: #Query.UserEmail#"
From: #Form.Name#
Subject: BlahBlah.com Member Mail From #Form.Name#
----------------------------------------
#Form.Comments#
</cfmail>
<!---- STEP 6. Display email success message ---->
<div align=center>
<B><font face="verdana, arial" size="4">Success!</font></B><BR>
<font face="verdana, arial" size="2"><b>Your message has ben sent.<BR>
Thank you for using BlahBlah.com.</b><P>
</div>
<CFINCLUDE TEMPLATE="index.cfm">
</CFIF><!--- Closes Spam Check if/then --->
</CFIF>
</CFOUTPUT>
================================================================
So this should work as long as they have cookies enabled. :) I need to
make sure of this with some kind of if/then in
front of the above code to make sure that a slimy spammer cannot foil this
by simply turning off cookies. Any suggustions?
Also, there is also a software package out there called BROWSER HAWK
(www.browserhawk.com) that is supposed to do
cookie validation, Flash Validation, and it also determines the client's
viewable area. Anyone have experience with it?
John McKown, VP Business Services
Delaware.Net, Inc.
30 Old Rudnick Lane, Suite 200
Dover, DE 19901
eMail: [EMAIL PROTECTED]
Phone: 302-736-5515
Fax: 302-736-5945
------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/[email protected]/
To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.