1. <!---Added to prevent an error if check box is empty--->
  2. <cfparam name="url.all" default="">
  3. <cfparam name="FORM.allst" default="">
  4. <cfparam name="FORM.all" default="no">
  5. <!--- Remember this forms email address if captcha is wrong only--->
  6. <cfif isDefined("FORM.toAddress")>
  7. <cfset SESSION.address = FORM.toAddress>
  8. <cfset toAddressPreFill = FORM.toAddress>
  9.  
  10. <!--- Pre fill to address form after captcha is wrong --->
  11. <cfelseif isDefined("SESSION.address")>
  12. <CFSET toAddressPreFill = SESSION.address>
  13.  
  14. <!--- Show empty string the first visit --->
  15. <cfelse>
  16. <cfset toAddressPreFill = "">
  17. </cfif>
  18. <!---End --->
  19.  
  20. <!--- Remember this forms subject if captcha is wrong only--->
  21. <cfif isDefined("FORM.subject")>
  22. <cfset SESSION.subject = FORM.subject>
  23. <cfset subjectPreFill = FORM.subject>
  24.  
  25. <!--- Pre fill subject form after captcha is wrong --->
  26. <cfelseif isDefined("SESSION.subject")>
  27. <CFSET subjectPreFill = SESSION.subject>
  28.  
  29. <!--- Show empty string the first visit --->
  30. <cfelse>
  31. <cfset subjectPreFill = "Request A Quote For Mailing List">
  32. </cfif>
  33. <!---End --->
  34.  
  35. <!--- Remember this forms message if captcha is wrong only--->
  36. <cfif isDefined("FORM.messageBody")>
  37. <cfset SESSION.message = FORM.messageBody>
  38. <cfset messageBodyPreFill = FORM.messageBody>
  39.  
  40. <!--- Pre fill message body form after captcha is wrong --->
  41. <cfelseif isDefined("SESSION.message")>
  42. <CFSET messageBodyPreFill = SESSION.message>
  43.  
  44. <!--- Show empty string the first visit --->
  45. <cfelse>
  46. <cfset messageBodyPreFill = "">
  47. </cfif>
  48. <!---End --->
  49.  
  50. <!---<!--- Remember this forms email address if captcha is wrong only--->
  51. <cfif isDefined("FORM.all")>
  52. <cfset SESSION.add = FORM.all>
  53. <cfset PreFill = FORM.all>
  54.  
  55. <!--- Pre fill to address form after captcha is wrong --->
  56. <cfelseif isDefined("SESSION.add")>
  57. <CFSET PreFill = SESSION.add>
  58.  
  59. <!--- Show empty string the first visit --->
  60. <cfelse>
  61. <cfset PreFill = "">
  62. </cfif>
  63. <!---End --->--->
  64.  
  65. <!---Get all US states that are active--->
  66. <cfquery name="allStates" datasource="#request.dsn#" username="#request.un#" password="#request.pw#">
  67. SELECT statename
  68. FROM states
  69. WHERE IsActive = 1
  70. AND CountryID = 1
  71. </cfquery>
  72. <div class='featurebox_left'>
  73.  
  74. <!---Added captcha test here--->
  75.  
  76. <cffunction name="makeRandomString" returnType="string" output="false">
  77. <cfset var chars = "23456789ABCDEFHJKMNPRS">
  78. <cfset var length = randRange(2,4)>
  79. <cfset var result = "">
  80. <cfset var i = "">
  81. <cfset var char = "">
  82.  
  83. <cfscript>
  84. for(i=1; i <= length; i++) {
  85. char = mid(chars, randRange(1, len(chars)),1);
  86. result&=char;
  87. }
  88. </cfscript>
  89.  
  90. <cfreturn result>
  91. </cffunction>
  92.  
  93. <cfset showForm = true>
  94.  
  95. <cfparam name="form.captcha" default="">
  96. <cfparam name="form.captchaHash" default="">
  97.  
  98. <cfif isDefined("form.send")>
  99. <cfset errors = "">
  100.  
  101. <cfif hash(ucase(form.captcha)) neq form.captchaHash>
  102. <cfset errors = errors & "You Did Not Enter The Right Text Below.">
  103. </cfif>
  104.  
  105. <cfif errors is "">
  106. <!--- do something here --->
  107. <cfset showForm = false>
  108. </cfif>
  109.  
  110. </cfif>
  111.  
  112. <cfif showForm>
  113.  
  114. <cfset captcha = makeRandomString()>
  115. <cfset captchaHash = hash(captcha)>
  116. <cfoutput>
  117. <!---End captcha test--->
  118. <!--- Provide simple form for recipient and message --->
  119.  
  120. <cfform action="#cgi.script_name#" method="post">
  121.  
  122. <table width="100%" border="0" align="center" cellpadding="2"cellspacing="2">
  123. <!--- Table row: Input for Email Address --->
  124. <tr>
  125. <td>&nbsp;</td>
  126. <td>
  127. <!--- Display Error Message--->
  128. <cfif isDefined("errors")>
  129. <img src="graphics/warning.png" hspace="5" vspace="5" align="absmiddle" /><strong>#errors#</strong>
  130. </cfif></td>
  131. </tr>
  132. <tr>
  133. <th valign="top">Email:</th>
  134. <td>
  135. <cfinput type="text"
  136. name="toAddress"
  137. value="#toAddressPreFill#"
  138. message="You must provide an email address (example@gmail.com)"
  139. validateat="onSubmit,onServer"
  140. validate="email"
  141. required="yes"
  142. size="50"> </td>
  143. </tr>
  144.  
  145. <!--- Table row: Input for E-mail Subject --->
  146. <tr>
  147. <th valign="top">Subject:</th>
  148. <td>
  149. <cfinput type="text"
  150. name="subject"
  151. value="#subjectPreFill#"
  152. required="yes"
  153. size="50" maxlength="100"
  154. message="You must provide a subject for the email. (Maximum 100 characters)"> </td>
  155. </tr>
  156.  
  157. <!--- Table row: Input for actual Message Text --->
  158. <tr>
  159. <th valign="top">Your Message:</th>
  160. <td>
  161. <cftextarea name="messageBody"
  162. cols="50"
  163. rows="5"
  164. wrap="hard"
  165. required="yes"
  166. value="#messageBodyPreFill#"
  167. maxlength="1000"
  168. message="You must provide a message body. (Maximum 1000 characters)" /> </td>
  169. </tr>
  170. <!---Table row: check box for all states --->
  171. <tr>
  172. <td><!---Howdy #session.name#---></td>
  173. <td valign="top">
  174.  
  175. <!---<cfinput type="checkbox" name="all" checked="no"> All 50 States--->
  176. <cfinput type="checkbox"
  177. name="all"
  178. checked="#isDefined('form.all')#"> All 50 States
  179.  
  180. </td>
  181. </tr>
  182. <tr>
  183. <td>&nbsp;</td>
  184. <td>
  185. <cfloop query="allstates">
  186. <input type="checkbox" name="allst" value="#statename#"> #statename#<br />
  187. </cfloop>
  188. </td>
  189. </tr>
  190. <!--- Table row: Input for captcha text --->
  191. <tr>
  192. <td valign="top">&nbsp;</td>
  193. <td>Enter Text Below:&nbsp;
  194. <cfinput type="text"
  195. name="captcha"
  196. required="yes"
  197. size="10"
  198. message="Please type the letters and numbers below.">
  199. </td>
  200. </tr>
  201. <!--- Table row: Display Captcha Image --->
  202. <tr>
  203. <td>&nbsp;</td>
  204. <td>
  205. <cfimage action="captcha" width="300" height="75" text="#captcha#">
  206. <cfinput type="hidden"
  207. name="captchaHash"
  208. value="#captchaHash#"> </td>
  209. </tr>
  210. <!--- Table row: Submit button to send message --->
  211. <tr>
  212. <td valign="top">&nbsp;</td>
  213. <td>
  214. <cfinput type="submit"
  215. name="send"
  216. validate="submitonce"
  217. value="Send Message Now"> </td>
  218. </tr>
  219. <tr>
  220. <td colspan="2" valign="top">&nbsp;</td>
  221. </tr>
  222. </table>
  223. </cfform>
  224. </cfoutput>
  225.  
  226. <cfelse>
  227. <!---Go to here if captcha is correct--->
  228.  
  229. <!--- We do not want ColdFusion to suppress whitespace here --->
  230. <cfprocessingdirective suppressWhitespace="No">
  231.  
  232. <!--- Send the mail message, based on form input --->
  233. <cfmail
  234. subject="#FORM.subject#" type="html"
  235. from='#FORM.toAddress#'
  236. to="webmaster@firefightingnews.com"
  237. bcc="mcconaghey@vzw.blackberry.net"
  238. replyto="#FORM.toAddress#"
  239. >
  240. <b>This is a message from request a quote from our fire department mailing list page on FireFightingNews.com:</b>
  241. <p></p>
  242. #FORM.messageBody#
  243. <p></p>
  244. #FORM.all#
  245. <p></p>
  246. #FORM.allst#
  247. <br />
  248. </cfmail>
  249.  
  250. </cfprocessingdirective>
  251. <!---Clear all fields if email was successful--->
  252. <cfscript>
  253. StructClear(Session);
  254. </cfscript>
  255. <!---End--->
  256.  
  257. <!--- Display "success" message to user --->
  258. <cfinclude template="email_ok.cfm">
  259.  
  260. </cfif>
  261. </div>