constants.cfm
##################
<cfset filepath='e:\website\htdocs\guestship'>
<cfset maxmessage=450>
<cfset email=''>
getfata.cfm
##################
<cfinclude template="constants.cfm">
<cfdirectory directory="#filepath#" filter="data.txt" name="mydir">
<cfif mydir.name is not ''>
<cfinclude template="data.txt">
</cfif>
index.cfm
##################
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Tom's Cold Fusion Guestbook</title>
</head>
<body bgcolor="#DDffcc">
<font size="-1" face="Arial,helvetica"><center><h3>Tom's Cold Fusion Guestbook</h3>
<p>
<!---- NEWENTRY.CFM is the file used to gather the guest book entry information --->
<font size="-1">[ <a href="newentry.cfm">Add a new entry</a> ]</font></center>
<!-------- Do not remove this line ----------->
<cfinclude template="getdata.cfm">
<p>
<hr>
<!---------- Please tell people where you got this! Thanks! ------------------>
<center><font size="-1">Copyright <cfoutput>#year(now())#</cfoutput>, All Rights Reserved. <a href="mailto:tom@toshop.com">Tom Nunamaker</a><br>
Creator of "<a href="http://toshop.com/guest/">Tom's Cold Fusion Guest Book!</a>"</font></center>
</font></body>
</html>
newentry.cfm
#################
<!----- Make sure the form fields are all there ------->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Tom's Cold Fusion Guestbook - New Entry</title>
</head>
<body bgcolor="#DDffcc"><font size="-1" face="Arial,helvetica">
<center><h3>Tom's Cold Fusion Guestbook - New Entry</h3>
<font size="-1">[ <a href="index.cfm">Return to guest book</a> ]
<p>NOTE: Only comments are required. All other fields are optional!<p></font></center>
<form action="process.cfm" method="POST">
<center><table border="0" cellpadding="3">
<tr><td>Your name</td><td><input type="Text" name="name" size="25" maxlength="25"></td></tr>
<tr><td>Email address</td><td><input type="Text" name="email" size="50" maxlength="50"></td></tr>
<tr><td>Your web site title</td><td><input type="Text" name="websitetitle" size="55" maxlength="75"></td></tr>
<tr><td>Your web site address</td><td><input type="Text" name="websiteaddress" size="55" maxlength="75" value="http://"></td></tr>
<tr><td valign="TOP">Your comments<br><font size="-1"><i> <b>No HTML Please!</b></i></font></td><td><textarea name="comment" cols="60" rows="12" wrap="VIRTUAL"></textarea></td></tr>
<tr><td> </td><td><input type="Submit" value="Record my entry!"></td></tr>
</table>
<!---- Here's how to make fields required ------>
<!--- <input type="hidden" name="name_required"> --->
<!--- <input type="hidden" name="email_required"> --->
<!--- <input type="hidden" name="websitetitle_required"> --->
<!--- <input type="hidden" name="websiteaddress_required"> --->
</center></form></font>
</body>
</html>
process.cfm
###################
<cfinclude template="constants.cfm">
<cfparam name="email" default="">
<cfparam name="maxmessage" default=450>
<cfif ParameterExists(Cookie.madeentryhere)>
<cflocation url="index.cfm">
</cfif>
<cfdirectory directory="#filepath#" filter="lastaccesses.txt" name="mydir">
<cfif mydir.name is not ''>
<cffile action="READ" file="#filepath#\lastaccesses.txt" variable="lastaccess">
<cfset guestIP = #CGI.REMOTE_ADDR#>
<cfset stopIP = Find('.',guestIP,1) + 1>
<cfset stopIP = Find('.',guestIP, stopIP)>
<cfset guestIP = Mid(guestIP, 1, stopIP)>
<cfloop index="myindex" list="#lastaccess#">
<cfif myindex contains guestIP>
<cflocation url="index.cfm">
</cfif>
</cfloop>
</cfif>
<cfset datastr = trim(form.name)>
<cfset newstr = "">
<cfset strlen=Len(datastr)>
<cfif strlen GT 35>
<cflocation url="index.cfm">
</cfif>
<cfloop index="myindex" from="1" to="#strlen#">
<cfset tempvar = Asc(datastr)>
<cfif ((tempvar GTE 65 AND tempvar LTE 90) OR (tempvar GTE 97 AND tempvar LTE 122)) OR (tempvar IS 32) OR (tempvar IS 45)>
<cfif myindex GT 1>
<cfif tempvar is 32>
<cfif left(newstr,1) IS ' '><cfbreak></cfif>
</cfif>
</cfif>
<cfset newstr = newstr & left(datastr,1)>
<cfset datastr = RemoveChars(datastr,1,1)>
<cfelse>
<cflocation url="index.cfm">
</cfif>
</cfloop>
<cfif len(newstr) GT 0>
<cfset name= newstr>
<cfelse>
<cfset name="">
</cfif>
<cfset datastr = trim(form.email)>
<cfif datastr contains '@' AND datastr contains '.' AND Len(datastr) GTE 10>
<cfset newstr = "">
<cfset strlen=Len(datastr)>
<cfif strlen GT 60>
<cflocation url="index.cfm">
</cfif>
<cfif strlen LT 8><cflocation url="index.cfm"></cfif>
<cfloop index="myindex" from="1" to="#strlen#">
<cfset tempvar = Asc(datastr)>
<cfif ((tempvar GTE 65 AND tempvar LTE 90) OR (tempvar GTE 97 AND tempvar LTE 122)) OR (tempvar GTE 48 AND tempvar LTE 57) OR (tempvar IS 46) OR (tempvar IS 64)>
<cfset newstr = newstr & left(datastr,1)>
<cfset datastr = RemoveChars(datastr,1,1)>
<cfelse>
<cfset newstr=''>
<cfbreak>
</cfif>
</cfloop>
<cfif len(newstr) GT 0>
<cfset email= newstr>
<cfelse>
<cfset email="">
</cfif>
<cfelse>
<cfset email="">
</cfif>
<cfif (Len(name) IS 0) AND (len(email) GT 0)>
<cfset name="#email#">
</cfif>
<cfset datastr = trim(form.websitetitle)>
<cfset newstr = "">
<cfset strlen=Len(datastr)>
<cfif strlen GT 75>
<cflocation url="index.cfm">
</cfif>
<cfloop index="myindex" from="1" to="#strlen#">
<cfset tempvar = Asc(datastr)>
<cfif (tempvar GTE 65 AND tempvar LTE 90) OR (tempvar GTE 33 AND tempvar LTE 59) OR (tempvar GTE 97 AND tempvar LTE 122) OR (tempvar GTE 47 AND tempvar LTE 58) OR (tempvar IS 46) OR (tempvar IS 64) OR (tempvar IS 32)>
<cfif myindex GT 1>
<cfif tempvar is 32>
<cfif left(newstr,1) IS ' '><cfbreak></cfif>
</cfif>
</cfif>
<cfset newstr = newstr & left(datastr,1)>
<cfset datastr = RemoveChars(datastr,1,1)>
<cfelse>
<cfset website="">
<cfbreak>
</cfif>
</cfloop>
<cfif len(newstr) GT 0>
<cfset website= newstr>
<cfelse>
<cfset website="">
</cfif>
<cfset datastr = trim(form.websiteaddress)>
<cfset newstr = "">
<cfset strlen=Len(datastr)>
<cfif strlen GT 80>
<cflocation url="index.cfm">
</cfif>
<cfloop index="myindex" from="1" to="#strlen#">
<cfset tempvar = Asc(datastr)>
<cfif (tempvar GTE 65 AND tempvar LTE 90) OR (tempvar GTE 97 AND tempvar LTE 122) OR (tempvar GTE 47 AND tempvar LTE 58) OR (tempvar IS 46) OR (tempvar IS 64) OR (tempvar IS 32)>
<cfif myindex GT 1>
<cfif tempvar is 32>
<cfif left(newstr,1) IS ' '><cfbreak></cfif>
</cfif>
</cfif>
<cfset newstr = newstr & left(datastr,1)>
<cfset datastr = RemoveChars(datastr,1,1)>
<cfelse>
<cfset websiteaddress="">
<cfbreak>
</cfif>
</cfloop>
<cfif len(newstr) GT 0>
<cfset websiteaddress= newstr>
<cfelse>
<cfset websiteaddress="">
</cfif>
<cfif Len(websiteaddress) LTE 7>
<cfset website = ''>
<cfset websiteaddress = ''>
</cfif>
<cfif (Len(website) IS 0) AND (len(websiteaddress) GT 0)>
<cfset website="#websiteaddress#">
</cfif>
<cfset datastr = trim(form.comment)>
<cfset newstr = "">
<cfset brcount = 0>
<cfset strlen=Len(datastr)>
<cfif strlen GT maxmessage>
<cfset datastr = Left(datastr,maxmessage)>
<cfset strlen = Len(datastr)>
</cfif>
<cfloop index="myindex" from="1" to="#strlen#">
<cfset tempvar = Asc(datastr)>
<cfif ((tempvar GTE 32) AND (tempvar LTE 253) AND (tempvar IS NOT 60) AND (tempvar IS NOT 62) AND (tempvar IS NOT 127) AND (tempvar IS NOT 128) AND (tempvar IS NOT 129) AND (tempvar IS NOT 157) AND (tempvar IS NOT 158) AND (tempvar IS NOT 160)) OR (tempvar is 13) OR (tempvar is 10)>
<cfif tempvar is 13>
<cfset newstr = newstr & '<br>'>
<cfset brcount = brcount + 1>
<cfif brcount GT 9>
<cfdirectory directory="#filepath#" filter="lastaccesses.txt" name="mydir">
<cfif mydir.name is not ''>
<cffile action="READ" file="#filepath#\lastaccesses.txt" variable="lastaccess">
<cfset lastaccess = Replace(lastaccess,chr(10),'','ALL')>
<cfset lastaccess = Replace(lastaccess,chr(13),'','ALL')>
<cfelse>
<cfset lastaccess="">
</cfif>
<cfset IPaddr = CGI.REMOTE_ADDR>
<cfset lastaccess = ListAppend(lastaccess,"#IPaddr#")>
<cfset lastaccess = trim(lastaccess)>
<cfset lastaccess = Replace(lastaccess,chr(10),'','ALL')>
<cfset lastaccess = Replace(lastaccess,chr(13),'','ALL')>
<cffile action="WRITE" file="#filepath#\lastaccesses.txt" output="#lastaccess#">
<cflocation url="index.cfm">
</cfif>
<cfelse>
<cfset newstr = newstr & left(datastr,1)>
</cfif>
<cfset datastr = RemoveChars(datastr,1,1)>
<cfelse>
<cflocation url="index.cfm">
</cfif>
</cfloop>
<cfif len(newstr) GT 0>
<cfset olddata=''>
<cfdirectory directory="#filepath#" filter="data.txt" name="mydir">
<cfif mydir.name is not ''>
<CFFILE ACTION="Read" FILE="#filepath#\data.txt" VARIABLE="olddata">
</cfif>
<cfset datastr = "<hr>">
<cfif email is not ''> <cfset datastr = datastr & '<a href="mailto:' & email & '">' > </cfif>
<cfif name is not ''> <cfset datastr = datastr & name > </cfif>
<cfif email is not ''> <cfset datastr = datastr & "</a>"> </cfif>
<cfif website is not ''> <cfset datastr = datastr & ', ' & '<a href="' & websiteaddress & '">' & website & "</a>"></cfif>
<cfset datastr = datastr & " " & #Dateformat(now(),'dd mmm yy')# & " " &#TimeFormat(now(),'HH:mm')# & "<BR><B>" & newstr & "</b>" & chr(13) & olddata>
<cfset datastr = trim(datastr)>
<cfset datastr = Replace(datastr,chr(13),"","ALL")>
<cffile action="WRITE" file="#filepath#\data.txt" output="#datastr#">
<cfset newstr = "GSSLTM398">
<cffile action="WRITE" file="#filepath#\valid9933.txt" output="#newstr#">
<cfdirectory directory="#filepath#" filter="lastaccesses.txt" name="mydir">
<cfif mydir.name is not ''>
<cffile action="READ" file="#filepath#\lastaccesses.txt" variable="lastaccess">
<cfset lastaccess = Replace(lastaccess,chr(10),'','ALL')>
<cfset lastaccess = Replace(lastaccess,chr(13),'','ALL')>
<cfelse>
<cfset lastaccess="">
</cfif>
<cfset IPaddr = CGI.REMOTE_ADDR>
<cfset lastaccess = ListAppend(lastaccess,"#IPaddr#")>
<cfset lastaccess = trim(lastaccess)>
<cfset lastaccess = Replace(lastaccess,chr(10),'','ALL')>
<cfset lastaccess = Replace(lastaccess,chr(13),'','ALL')>
<cffile action="WRITE" file="#filepath#\lastaccesses.txt" output="#lastaccess#">
<cfif ListLen(lastaccess) GT 2>
<cfset lastaccess = ListRest(lastaccess)>
</cfif>
<cffile action="WRITE" file="#filepath#\lastaccesses.txt" output="#lastaccess#">
<cflocation url="success.cfm">
</cfif>
<cflocation url="index.cfm">
success.cfm
###################
<!---- Don't remove this line ---->
<cfinclude template="validate.cfm">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Tom's Cold Fusion Guestbook</title>
<!------------ Don't remove this line..it takes the user back to the beginning ------------->
<META HTTP-EQUIV=Refresh CONTENT="5;URL=index.cfm">
</head>
<body bgcolor="#DDffcc">
<center><h3>Tom's Cold Fusion Guestbook</h3>
Thanks for making an entry in the guest book!
<p>
Your entry was successfully entered into the guestbook. <p>
If your web browser doesn't automatically bring you back to the guestbook, <a href="index.cfm">click here</a></p>
</center>
</body>
</html>
validate.cfm
#####################
Allaire Cold Fusion Template
Header Size: 54
5YvyO
‏‏{ְ׃+›wp3ׁ
GJ⥢
9!€g״A$z>lַOOֻ״ cT)״pװQA־Cְ18fֽY౷Q 5ֺ–ֹֽWh‘6ֲ1dַַV"ִpAַ#‏‎ 2;{
”r$׳-ˆ–9VS\˜`”ְײ\-s mִ[cI
)5ֹ($fֽY౷QZ83‹)8Y;EI€MH3\;{
”D|MENA…(.¿¯Cl\GMA״v-ֱ>˜>ֿO[mmT\GMA״v-ֱ>˜>•?†›.u/G1ƒY;ְ‰6DKG5ֹ
`€G,׳V‰׃N :ֲ]jױ”&irֺ‡ֹ‏iֺO6ֱZ<B=I;bWJ\
ֻ^'I;W“€UnF~a0ֻ”‏ױGJ–ֿYnֻ¿G,‏•{”~>‎ׂ
##################################
|