2 * Web forms for handling mailing list subscribe/unsubscribe requests.
4 * Copyright (c) 1996-2012 by the citadel.org team
6 * This program is open source software. You can redistribute it and/or
7 * modify it under the terms of the GNU General Public License, version 3.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
18 * List subscription handling
20 #ifndef EXPERIMENTAL_LISTSUB
28 char escaped_email[256];
29 char escaped_room[256];
35 FlushStrBuf(WC->wc_fullname);
36 FlushStrBuf(WC->wc_username);
37 FlushStrBuf(WC->wc_password);
38 FlushStrBuf(WC->CurRoom.name);
40 output_headers(1, 0, 0, 1, 1, 0);
43 wc_printf("<HTML><HEAD>\n"
44 "<meta name=\"MSSmartTagsPreventParsing\" content=\"TRUE\" />\n"
45 "<link href=\"static/styles/webcit.css\" rel=\"stylesheet\" type=\"text/css\">\n"
48 wc_printf(_("List subscription"));
49 wc_printf("</TITLE></HEAD><BODY>\n");
51 strcpy(cmd, bstr("cmd"));
52 strcpy(room, bstr("room"));
53 strcpy(token, bstr("token"));
54 strcpy(email, bstr("email"));
55 strcpy(subtype, bstr("subtype"));
57 wc_printf("<div align=center>");
58 wc_printf("<table border=0 width=75%%><tr><td>");
60 do_template("box_begin_1");
61 StrBufAppendBufPlain(WC->WBuf, _("List subscribe/unsubscribe"), -1, 0);
62 do_template("box_begin_2");
63 wc_printf("<div align=center><br>");
68 if (!strcasecmp(cmd, "subscribe")) {
69 serv_printf("SUBS subscribe|%s|%s|%s|%s/listsub",
75 serv_getln(buf, sizeof buf);
77 stresc(escaped_email, 256, email, 0, 0);
78 stresc(escaped_room, 256, room, 0, 0);
80 wc_printf("<CENTER><H1>");
81 wc_printf(_("Confirmation request sent"));
83 wc_printf(_("You are subscribing <TT>%s"
84 "</TT> to the <b>%s</b> mailing list. "
86 "sent you an e-mail with one additional "
87 "Web link for you to click on to confirm "
88 "your subscription. This extra step is for "
89 "your protection, as it prevents others from "
90 "being able to subscribe you to lists "
91 "without your consent.<br><br>"
92 "Please click on the link which is being "
93 "e-mailed to you and your subscription will "
94 "be confirmed.<br>\n"),
95 escaped_email, escaped_room);
96 wc_printf("<a href=\"listsub\">%s</A></CENTER>\n", _("Go back..."));
99 wc_printf("<FONT SIZE=+1><B>ERROR: %s</B>"
107 * Unsubscribe command
109 else if (!strcasecmp(cmd, "unsubscribe")) {
110 serv_printf("SUBS unsubscribe|%s|%s|%s/listsub",
115 serv_getln(buf, sizeof buf);
117 wc_printf("<CENTER><H1>Confirmation request sent</H1>"
118 "You are unsubscribing <TT>");
120 wc_printf("</TT> from the "");
122 wc_printf("" mailing list. The listserver has "
123 "sent you an e-mail with one additional "
124 "Web link for you to click on to confirm "
125 "your unsubscription. This extra step is for "
126 "your protection, as it prevents others from "
127 "being able to unsubscribe you from "
128 "lists without your consent.<br><br>"
129 "Please click on the link which is being "
130 "e-mailed to you and your unsubscription will "
131 "be confirmed.<br>\n"
132 "<a href=\"listsub\">Back...</A></CENTER>\n"
136 wc_printf("<FONT SIZE=+1><B>ERROR: %s</B>"
146 else if (!strcasecmp(cmd, "confirm")) {
147 serv_printf("SUBS confirm|%s|%s",
151 serv_getln(buf, sizeof buf);
153 wc_printf("<CENTER><H1>Confirmation successful!</H1>");
156 wc_printf("<CENTER><H1>Confirmation failed.</H1>"
157 "This could mean one of two things:<UL>\n"
158 "<LI>You waited too long to confirm your "
159 "subscribe/unsubscribe request (the "
160 "confirmation link is only valid for three "
161 "days)\n<LI>You have <i>already</i> "
162 "successfully confirmed your "
163 "subscribe/unsubscribe request and are "
164 "attempting to do it again.</UL>\n"
165 "The error returned by the server was: "
168 wc_printf("%s</CENTER><br>\n", &buf[4]);
172 * Any other (invalid) command causes the form to be displayed
175 FORM: wc_printf("<form method=\"POST\" action=\"listsub\">\n");
177 wc_printf("Name of list: "
178 "<select name=\"room\" size=1>\n");
181 serv_getln(buf, sizeof buf);
183 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
184 extract_token(sroom, buf, 0, '|', sizeof sroom);
185 self = extract_int(buf, 4) & QR2_SELFLIST ;
187 wc_printf("<option value=\"");
191 wc_printf("</option>\n");
195 wc_printf("</select><br><br>\n");
197 wc_printf("Your e-mail address: "
198 "<INPUT TYPE=\"text\" NAME=\"email\" "
202 wc_printf("\" maxlength=128 size=60><br><br>\n");
204 wc_printf("(If subscribing) preferred format: "
205 "<INPUT TYPE=\"radio\" NAME=\"subtype\" "
206 "VALUE=\"list\" CHECKED>One message at a time "
207 "<INPUT TYPE=\"radio\" NAME=\"subtype\" "
208 "VALUE=\"digest\">Digest format "
210 "<INPUT TYPE=\"submit\" NAME=\"cmd\""
211 " VALUE=\"subscribe\">\n"
212 "<INPUT TYPE=\"submit\" NAME=\"cmd\""
213 " VALUE=\"unsubscribe\"><br><br>\n"
217 wc_printf("<hr>When you attempt to subscribe or unsubscribe to "
218 "a mailing list, you will receive an e-mail containing"
219 " one additional web link to click on for final "
220 "confirmation. This extra step is for your "
221 "protection, as it prevents others from being able to "
222 "subscribe or unsubscribe you to lists.<br>\n"
228 do_template("box_end");
229 wc_printf("</td></tr></table></div>");
231 wc_printf("</BODY></HTML>\n");
233 end_webcit_session();
237 int Conditional_LISTSUB_EXECUTE_SUBSCRIBE(StrBuf *Target, WCTemplputParams *TP)
242 const StrBuf *Room, *Email, *SubType;
244 Room = sbstr("room");
247 ImpMsg = _("You need to specify the mailinglist to subscribe to.");
248 AppendImportantMessage(ImpMsg, -1);
251 Email = sbstr("email");
254 ImpMsg = _("You need to specify the email address you'd like to subscribe with.");
255 AppendImportantMessage(ImpMsg, -1);
258 SubType = sbstr("subtype");
261 serv_printf("SUBS subscribe|%s|%s|%s|%s/listsub",
267 StrBuf_ServGetln(Line);
268 rc = GetServerStatusMsg(Line, NULL, 1, 2);
271 putbstr("__FAIL", NewStrBufPlain(HKEY("1")));
275 int Conditional_LISTSUB_EXECUTE_UNSUBSCRIBE(StrBuf *Target, WCTemplputParams *TP)
280 const StrBuf *Room, *Email;
282 Room = sbstr("room");
285 ImpMsg = _("You need to specify the mailinglist to subscribe to.");
286 AppendImportantMessage(ImpMsg, -1);
289 Email = sbstr("email");
292 ImpMsg = _("You need to specify the email address you'd like to subscribe with.");
293 AppendImportantMessage(ImpMsg, -1);
297 serv_printf("SUBS unsubscribe|%s|%s|%s/listsub",
303 StrBuf_ServGetln(Line);
304 rc = GetServerStatusMsg(Line, NULL, 1, 2);
307 putbstr("__FAIL", NewStrBufPlain(HKEY("1")));
311 int Conditional_LISTSUB_EXECUTE_CONFIRM_SUBSCRIBE(StrBuf *Target, WCTemplputParams *TP)
316 const StrBuf *Room, *Token;
318 Room = sbstr("room");
321 ImpMsg = _("You need to specify the mailinglist to subscribe to.");
322 AppendImportantMessage(ImpMsg, -1);
325 Token = sbstr("token");
328 ImpMsg = _("You need to specify the mailinglist to subscribe to.");
329 AppendImportantMessage(ImpMsg, -1);
334 serv_printf("SUBS confirm|%s|%s",
338 StrBuf_ServGetln(Line);
339 rc = GetServerStatusMsg(Line, NULL, 1, 2);
342 putbstr("__FAIL", NewStrBufPlain(HKEY("1")));
346 #ifdef EXPERIMENTAL_LISTSUB
347 void do_listsub(void)
349 if (!havebstr("cmd"))
351 putbstr("cmd", NewStrBufPlain(HKEY("")));
353 output_headers(1, 0, 0, 0, 1, 0);
354 do_template("listsub_display");
363 RegisterConditional(HKEY("COND:LISTSUB:EXECUTE:SUBSCRIBE"), 0, Conditional_LISTSUB_EXECUTE_SUBSCRIBE, CTX_NONE);
364 RegisterConditional(HKEY("COND:LISTSUB:EXECUTE:UNSUBSCRIBE"), 0, Conditional_LISTSUB_EXECUTE_UNSUBSCRIBE, CTX_NONE);
365 RegisterConditional(HKEY("COND:LISTSUB:EXECUTE:CONFIRM:SUBSCRIBE"), 0, Conditional_LISTSUB_EXECUTE_CONFIRM_SUBSCRIBE, CTX_NONE);
367 WebcitAddUrlHandler(HKEY("listsub"), "", 0, do_listsub, ANONYMOUS|COOKIEUNNEEDED|FORCE_SESSIONCLOSE);