| [5] | 1 | <cfsetting enablecfoutputonly=true> |
|---|
| 2 | <cfprocessingdirective pageencoding="utf-8"> |
|---|
| 3 | <!--- |
|---|
| 4 | Name : Contact |
|---|
| 5 | Author : Raymond Camden |
|---|
| 6 | Created : October 9, 2007 |
|---|
| 7 | Last Updated : |
|---|
| 8 | History : |
|---|
| 9 | Purpose : Sends email to blog owner |
|---|
| 10 | ---> |
|---|
| 11 | |
|---|
| 12 | <cfset showForm = true> |
|---|
| 13 | <cfparam name="form.email" default=""> |
|---|
| 14 | <cfparam name="form.name" default=""> |
|---|
| 15 | <cfparam name="form.comments" default=""> |
|---|
| 16 | <cfparam name="form.captchaText" default=""> |
|---|
| 17 | |
|---|
| 18 | <cfif structKeyExists(form, "send")> |
|---|
| 19 | <cfset aErrors = arrayNew(1) /> |
|---|
| 20 | <cfif not len(trim(form.name))> |
|---|
| 21 | <cfset arrayAppend(aErrors, rb("mustincludename")) /> |
|---|
| 22 | </cfif> |
|---|
| 23 | <cfif not len(trim(form.email)) or not isEmail(form.email)> |
|---|
| 24 | <cfset arrayAppend(aErrors, rb("mustincludeemail")) /> |
|---|
| 25 | </cfif> |
|---|
| 26 | <cfif not len(trim(form.comments))> |
|---|
| 27 | <cfset arrayAppend(aErrors, rb("mustincludecomments")) /> |
|---|
| 28 | </cfif> |
|---|
| 29 | |
|---|
| 30 | <!--- captcha validation ---> |
|---|
| 31 | <cfif application.useCaptcha> |
|---|
| 32 | <cfif not len(form.captchaText)> |
|---|
| 33 | <cfset arrayAppend(aErrors, "Please enter the Captcha text.") /> |
|---|
| 34 | <cfelseif NOT application.captcha.validateCaptcha(form.captchaHash,form.captchaText)> |
|---|
| 35 | <cfset arrayAppend(aErrors, "The captcha text you have entered is incorrect.") /> |
|---|
| 36 | </cfif> |
|---|
| 37 | </cfif> |
|---|
| 38 | |
|---|
| 39 | <cfif not arrayLen(aErrors)> |
|---|
| 40 | <cfset commentTime = dateAdd("h", application.blog.getProperty("offset"), now())> |
|---|
| 41 | <cfsavecontent variable="body"> |
|---|
| 42 | <cfoutput> |
|---|
| 43 | #rb("commentadded")#: #application.localeUtils.dateLocaleFormat(commentTime)# / #application.localeUtils.timeLocaleFormat(commentTime)# |
|---|
| 44 | #rb("commentmadeby")#: #form.name# (#form.email#) |
|---|
| 45 | #rb("ipofposter")#: #cgi.REMOTE_ADDR# |
|---|
| 46 | |
|---|
| 47 | #form.comments# |
|---|
| 48 | |
|---|
| 49 | ------------------------------------------------------------ |
|---|
| 50 | This blog powered by BlogCFC #application.blog.getVersion()# |
|---|
| 51 | Created by Raymond Camden (ray@camdenfamily.com) |
|---|
| 52 | </cfoutput> |
|---|
| 53 | </cfsavecontent> |
|---|
| 54 | |
|---|
| 55 | <cfset application.utils.mail( |
|---|
| 56 | to=application.blog.getProperty("owneremail"), |
|---|
| 57 | from=form.email, |
|---|
| 58 | subject="#rb("contactform")#", |
|---|
| 59 | body=body, |
|---|
| 60 | mailserver=application.blog.getProperty("mailserver"), |
|---|
| 61 | mailusername=application.blog.getProperty("mailusername"), |
|---|
| 62 | mailpassword=application.blog.getProperty("mailpassword") |
|---|
| 63 | )> |
|---|
| 64 | |
|---|
| 65 | <cfset showForm = false> |
|---|
| 66 | |
|---|
| 67 | </cfif> |
|---|
| 68 | |
|---|
| 69 | </cfif> |
|---|
| 70 | |
|---|
| 71 | <cfmodule template="tags/layout.cfm" title="#rb("contactowner")#"> |
|---|
| 72 | |
|---|
| 73 | |
|---|
| 74 | <cfoutput> |
|---|
| 75 | <div class="date"><b>#rb("contactowner")#</b></div> |
|---|
| 76 | |
|---|
| 77 | <div class="body"> |
|---|
| 78 | |
|---|
| 79 | <cfif showForm> |
|---|
| 80 | |
|---|
| 81 | <p> |
|---|
| 82 | #rb("contactownerform")# |
|---|
| 83 | </p> |
|---|
| 84 | |
|---|
| 85 | <cfif isDefined("aErrors") and arrayLen(aErrors)> |
|---|
| 86 | <cfoutput><b>#rb("correctissues")#:</b><ul class="error"><li>#arrayToList(aErrors, "</li><li>")#</li></ul></cfoutput> |
|---|
| 87 | </cfif> |
|---|
| 88 | |
|---|
| 89 | <form action="#cgi.script_name#?#cgi.query_string#" method="post"> |
|---|
| 90 | <fieldset id="sendForm"> |
|---|
| 91 | <div> |
|---|
| 92 | <label for="name">#rb("name")#:</label> |
|---|
| 93 | <input type="text" id="name" name="name" value="#form.name#" style="width:300px;"> |
|---|
| 94 | </div> |
|---|
| 95 | <div> |
|---|
| 96 | <label for="email">#rb("youremailaddress")#:</label> |
|---|
| 97 | <input type="text" id="email" name="email" value="#form.email#" style="width:300px;"> |
|---|
| 98 | </div> |
|---|
| 99 | <div> |
|---|
| 100 | <label for="comments">#rb("comments")#:</label> |
|---|
| 101 | <textarea name="comments" id="comments" style="width: 400px; height: 300px;">#form.comments#</textarea> |
|---|
| 102 | </div> |
|---|
| 103 | <cfif application.useCaptcha> |
|---|
| 104 | <cfset variables.captcha = application.captcha.createHashReference() /> |
|---|
| 105 | <div> |
|---|
| 106 | <input type="hidden" name="captchaHash" value="#variables.captcha.hash#" /> |
|---|
| 107 | <label for="captchaText" class="longLabel">#rb("captchatext")#:</label> |
|---|
| 108 | <input type="text" name="captchaText" size="6" /><br> |
|---|
| 109 | <img src="#application.blog.getRootURL()#showCaptcha.cfm?hashReference=#variables.captcha.hash#" vspace="5"/> |
|---|
| 110 | </div> |
|---|
| 111 | </cfif> |
|---|
| 112 | <div> |
|---|
| 113 | <input type="submit" id="submit" name="send" value="#rb("sendcontact")#"> |
|---|
| 114 | </div> |
|---|
| 115 | </fieldset> |
|---|
| 116 | |
|---|
| 117 | </form> |
|---|
| 118 | |
|---|
| 119 | <cfelse> |
|---|
| 120 | |
|---|
| 121 | <p> |
|---|
| 122 | #rb("contactsent")# |
|---|
| 123 | </p> |
|---|
| 124 | |
|---|
| 125 | </cfif> |
|---|
| 126 | |
|---|
| 127 | </div> |
|---|
| 128 | </cfoutput> |
|---|
| 129 | |
|---|
| 130 | </cfmodule> |
|---|
| 131 | |
|---|
| 132 | <cfsetting enablecfoutputonly=false> |
|---|