root/trunk/website/blog/addsub.cfm @ 15

Revision 5, 4.0 kB (checked in by DanWilson, 17 years ago)

Initial Commit Of ModelGlue? Website (upgrade to blogcfc 511)

Line 
1<cfprocessingdirective pageencoding="utf-8">
2<!---
3        Name         : addsub.cfm
4        Author       : Raymond Camden
5        Created      : July 1, 2008
6        Last Updated :
7        History      :
8        Purpose          : Allows you to subscribe to a comment
9--->
10
11<cfif not isDefined("form.addsub")>
12        <cfif isDefined("cookie.blog_email")>
13                <cfset form.email = cookie.blog_email>
14                <cfset form.rememberMe = true>
15        </cfif>
16</cfif>
17
18<cfparam name="form.email" default="">
19<cfparam name="form.rememberMe" default="false">
20<cfparam name="form.captchaText" default="">
21
22<cfset closeMe = false>
23<cfif not isDefined("url.id")>
24        <cfset closeMe = true>
25<cfelse>
26        <cftry>
27                <cfset entry = application.blog.getEntry(url.id,true)>
28                <cfcatch>
29                        <cfset closeMe = true>
30                </cfcatch>
31        </cftry>
32</cfif>
33<cfif closeMe>
34        <cfoutput>
35        <script>
36        window.close();
37        </script>
38        </cfoutput>
39        <cfabort>
40</cfif>
41
42<cfif isDefined("form.addsub") and entry.allowcomments>
43        <cfset form.email = trim(form.email)>
44
45       
46        <cfset errorStr = "">
47
48        <cfif not len(form.email) or not isEmail(form.email)>
49                <cfset errorStr = errorStr & rb("mustincludeemail") & "<br>">
50        </cfif>
51
52        <!--- captcha validation --->
53        <cfif application.useCaptcha>
54                <cfif not len(form.captchaText)>
55                   <cfset errorStr = errorStr & "Please enter the Captcha text.<br>">
56                <cfelseif NOT application.captcha.validateCaptcha(form.captchaHash,form.captchaText)>
57                   <cfset errorStr = errorStr & "The captcha text you have entered is incorrect.<br>">
58                </cfif>
59        </cfif>
60               
61        <cfif not len(errorStr)>
62       
63                <!--- Subs basically use the comment system with an empty comment and a commentonly flag. --->
64                <cfset commentID = application.blog.addComment(url.id,'', left(form.email,50), '', '', true,true)>
65
66                <!--- clear form data --->
67                <cfif form.rememberMe>
68                        <cfcookie name="blog_email" value="#trim(htmlEditFormat(form.email))#" expires="never">
69                <cfelse>
70                        <cfcookie name="blog_email" expires="now">
71                        <!--- RBB 11/02/2005: Added new website form var --->
72                        <cfset form.email = "">
73                </cfif>
74               
75                <cfoutput>
76                <script>
77                window.close();
78                </script>
79                </cfoutput>
80                <cfabort>
81               
82        </cfif>
83</cfif>
84
85<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" />
86
87<html>
88<head>
89        <cfoutput><title>#application.blog.getProperty("blogTitle")# : #rb("addsub")#</title></cfoutput>
90        <link rel="stylesheet" href="includes/style.css" type="text/css"/>
91        <meta content="text/html; charset=UTF-8" http-equiv="content-type">
92</head>
93
94<body id="popUpFormBody">
95
96<cfoutput>
97<div class="date">#rb("comments")#: #entry.title#</div>
98<div class="body">
99</cfoutput>
100
101<cfif entry.allowcomments>
102       
103        <cfif isDefined("errorStr") and len(errorStr)>
104                <cfoutput><b>#rb("correctissues")#:</b><ul>#errorStr#</ul></cfoutput>
105        </cfif>
106        <cfoutput>
107        <form action="#application.rootURL#/addsub.cfm?#cgi.query_string#" method="post">
108
109  <fieldset id="commentForm">
110        <legend>#rb("addsub")#</legend>
111  <div>
112                <label for="email">#rb("emailaddress")#:</label>
113                <input type="text" id="email" name="email" value="#form.email#">
114  </div>
115        <cfif application.useCaptcha>
116    <div>
117                <cfset variables.captcha = application.captcha.createHashReference() />
118                <input type="hidden" name="captchaHash" value="#variables.captcha.hash#" />
119                <label for="captchaText" class="longLabel">#rb("captchatext")#:</label>
120                <input type="text" name="captchaText" size="6" /><br>
121                <img src="#application.blog.getRootURL()#showCaptcha.cfm?hashReference=#variables.captcha.hash#" align="right" vspace="5"/>
122  </div>
123        </cfif>
124  <div>
125                <label for="rememberMe" class="longLabel">#rb("remembermyinfo")#:</label>
126                <input type="checkbox" class="checkBox" id="rememberMe" name="rememberMe" value="1" <cfif isBoolean(form.rememberMe) and form.rememberMe>checked</cfif>>
127  </div>
128  <div style="text-align:center">
129                <input type="reset" id="reset" value="#rb("cancel")#" onClick="if(confirm('#rb("cancelconfirm")#')) { window.close(); } else { return false; }"> <input type="submit" id="submit" name="addsub" value="#rb("subscribe")#">
130    </div>
131</fieldset>
132        </form>
133        </cfoutput>
134       
135<cfelse>
136
137        <cfoutput>
138        <p>#rb("subnotallowed")#</p>
139        </cfoutput>
140       
141</cfif>
142</div>
143
144</body>
145</html>
Note: See TracBrowser for help on using the browser.