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.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
24 * List subscription handling
26 #ifndef EXPERIMENTAL_LISTSUB
34 char escaped_email[256];
35 char escaped_room[256];
41 FlushStrBuf(WC->wc_fullname);
42 FlushStrBuf(WC->wc_username);
43 FlushStrBuf(WC->wc_password);
44 FlushStrBuf(WC->CurRoom.name);
46 output_headers(1, 0, 0, 1, 1, 0);
49 wc_printf("<HTML><HEAD>\n"
50 "<meta name=\"MSSmartTagsPreventParsing\" content=\"TRUE\" />\n"
51 "<link href=\"static/styles/webcit.css\" rel=\"stylesheet\" type=\"text/css\">\n"
54 wc_printf(_("List subscription"));
55 wc_printf("</TITLE></HEAD><BODY>\n");
57 strcpy(cmd, bstr("cmd"));
58 strcpy(room, bstr("room"));
59 strcpy(token, bstr("token"));
60 strcpy(email, bstr("email"));
61 strcpy(subtype, bstr("subtype"));
63 wc_printf("<div align=center>");
64 wc_printf("<table border=0 width=75%%><tr><td>");
66 do_template("box_begin_1");
67 StrBufAppendBufPlain(WC->WBuf, _("List subscribe/unsubscribe"), -1, 0);
68 do_template("box_begin_2");
69 wc_printf("<div align=center><br>");
74 if (!strcasecmp(cmd, "subscribe")) {
75 serv_printf("SUBS subscribe|%s|%s|%s|%s/listsub",
81 serv_getln(buf, sizeof buf);
83 stresc(escaped_email, 256, email, 0, 0);
84 stresc(escaped_room, 256, room, 0, 0);
86 wc_printf("<CENTER><H1>");
87 wc_printf(_("Confirmation request sent"));
89 wc_printf(_("You are subscribing <TT>%s"
90 "</TT> to the <b>%s</b> mailing list. "
92 "sent you an e-mail with one additional "
93 "Web link for you to click on to confirm "
94 "your subscription. This extra step is for "
95 "your protection, as it prevents others from "
96 "being able to subscribe you to lists "
97 "without your consent.<br><br>"
98 "Please click on the link which is being "
99 "e-mailed to you and your subscription will "
100 "be confirmed.<br>\n"),
101 escaped_email, escaped_room);
102 wc_printf("<a href=\"listsub\">%s</A></CENTER>\n", _("Go back..."));
105 wc_printf("<FONT SIZE=+1><B>ERROR: %s</B>"
113 * Unsubscribe command
115 else if (!strcasecmp(cmd, "unsubscribe")) {
116 serv_printf("SUBS unsubscribe|%s|%s|%s/listsub",
121 serv_getln(buf, sizeof buf);
123 wc_printf("<CENTER><H1>Confirmation request sent</H1>"
124 "You are unsubscribing <TT>");
126 wc_printf("</TT> from the "");
128 wc_printf("" mailing list. The listserver has "
129 "sent you an e-mail with one additional "
130 "Web link for you to click on to confirm "
131 "your unsubscription. This extra step is for "
132 "your protection, as it prevents others from "
133 "being able to unsubscribe you from "
134 "lists without your consent.<br><br>"
135 "Please click on the link which is being "
136 "e-mailed to you and your unsubscription will "
137 "be confirmed.<br>\n"
138 "<a href=\"listsub\">Back...</A></CENTER>\n"
142 wc_printf("<FONT SIZE=+1><B>ERROR: %s</B>"
152 else if (!strcasecmp(cmd, "confirm")) {
153 serv_printf("SUBS confirm|%s|%s",
157 serv_getln(buf, sizeof buf);
159 wc_printf("<CENTER><H1>Confirmation successful!</H1>");
162 wc_printf("<CENTER><H1>Confirmation failed.</H1>"
163 "This could mean one of two things:<UL>\n"
164 "<LI>You waited too long to confirm your "
165 "subscribe/unsubscribe request (the "
166 "confirmation link is only valid for three "
167 "days)\n<LI>You have <i>already</i> "
168 "successfully confirmed your "
169 "subscribe/unsubscribe request and are "
170 "attempting to do it again.</UL>\n"
171 "The error returned by the server was: "
174 wc_printf("%s</CENTER><br>\n", &buf[4]);
178 * Any other (invalid) command causes the form to be displayed
181 FORM: wc_printf("<form method=\"POST\" action=\"listsub\">\n");
183 wc_printf("Name of list: "
184 "<select name=\"room\" size=1>\n");
187 serv_getln(buf, sizeof buf);
189 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
190 extract_token(sroom, buf, 0, '|', sizeof sroom);
191 self = extract_int(buf, 4) & QR2_SELFLIST ;
193 wc_printf("<option value=\"");
197 wc_printf("</option>\n");
201 wc_printf("</select><br><br>\n");
203 wc_printf("Your e-mail address: "
204 "<INPUT TYPE=\"text\" NAME=\"email\" "
208 wc_printf("\" maxlength=128 size=60><br><br>\n");
210 wc_printf("(If subscribing) preferred format: "
211 "<INPUT TYPE=\"radio\" NAME=\"subtype\" "
212 "VALUE=\"list\" CHECKED>One message at a time "
213 "<INPUT TYPE=\"radio\" NAME=\"subtype\" "
214 "VALUE=\"digest\">Digest format "
216 "<INPUT TYPE=\"submit\" NAME=\"cmd\""
217 " VALUE=\"subscribe\">\n"
218 "<INPUT TYPE=\"submit\" NAME=\"cmd\""
219 " VALUE=\"unsubscribe\"><br><br>\n"
223 wc_printf("<hr>When you attempt to subscribe or unsubscribe to "
224 "a mailing list, you will receive an e-mail containing"
225 " one additional web link to click on for final "
226 "confirmation. This extra step is for your "
227 "protection, as it prevents others from being able to "
228 "subscribe or unsubscribe you to lists.<br>\n"
234 do_template("box_end");
235 wc_printf("</td></tr></table></div>");
237 wc_printf("</BODY></HTML>\n");
239 end_webcit_session();
243 int Conditional_LISTSUB_EXECUTE_SUBSCRIBE(StrBuf *Target, WCTemplputParams *TP)
248 const StrBuf *Room, *Email, *SubType;
250 Room = sbstr("room");
253 ImpMsg = _("You need to specify the mailinglist to subscribe to.");
254 AppendImportantMessage(ImpMsg, -1);
257 Email = sbstr("email");
260 ImpMsg = _("You need to specify the email address you'd like to subscribe with.");
261 AppendImportantMessage(ImpMsg, -1);
264 SubType = sbstr("subtype");
267 serv_printf("SUBS subscribe|%s|%s|%s|%s/listsub",
273 StrBuf_ServGetln(Line);
274 rc = GetServerStatusMsg(Line, NULL, 1, 2);
277 putbstr("__FAIL", NewStrBufPlain(HKEY("1")));
281 int Conditional_LISTSUB_EXECUTE_UNSUBSCRIBE(StrBuf *Target, WCTemplputParams *TP)
286 const StrBuf *Room, *Email;
288 Room = sbstr("room");
291 ImpMsg = _("You need to specify the mailinglist to subscribe to.");
292 AppendImportantMessage(ImpMsg, -1);
295 Email = sbstr("email");
298 ImpMsg = _("You need to specify the email address you'd like to subscribe with.");
299 AppendImportantMessage(ImpMsg, -1);
303 serv_printf("SUBS unsubscribe|%s|%s|%s/listsub",
309 StrBuf_ServGetln(Line);
310 rc = GetServerStatusMsg(Line, NULL, 1, 2);
313 putbstr("__FAIL", NewStrBufPlain(HKEY("1")));
317 int Conditional_LISTSUB_EXECUTE_CONFIRM_SUBSCRIBE(StrBuf *Target, WCTemplputParams *TP)
322 const StrBuf *Room, *Token;
324 Room = sbstr("room");
327 ImpMsg = _("You need to specify the mailinglist to subscribe to.");
328 AppendImportantMessage(ImpMsg, -1);
331 Token = sbstr("token");
334 ImpMsg = _("You need to specify the mailinglist to subscribe to.");
335 AppendImportantMessage(ImpMsg, -1);
340 serv_printf("SUBS confirm|%s|%s",
344 StrBuf_ServGetln(Line);
345 rc = GetServerStatusMsg(Line, NULL, 1, 2);
348 putbstr("__FAIL", NewStrBufPlain(HKEY("1")));
352 #ifdef EXPERIMENTAL_LISTSUB
353 void do_listsub(void)
355 if (!havebstr("cmd"))
357 putbstr("cmd", NewStrBufPlain(HKEY("")));
359 output_headers(1, 0, 0, 0, 1, 0);
360 do_template("listsub_display");
369 RegisterConditional(HKEY("COND:LISTSUB:EXECUTE:SUBSCRIBE"), 0, Conditional_LISTSUB_EXECUTE_SUBSCRIBE, CTX_NONE);
370 RegisterConditional(HKEY("COND:LISTSUB:EXECUTE:UNSUBSCRIBE"), 0, Conditional_LISTSUB_EXECUTE_UNSUBSCRIBE, CTX_NONE);
371 RegisterConditional(HKEY("COND:LISTSUB:EXECUTE:CONFIRM:SUBSCRIBE"), 0, Conditional_LISTSUB_EXECUTE_CONFIRM_SUBSCRIBE, CTX_NONE);
373 WebcitAddUrlHandler(HKEY("listsub"), "", 0, do_listsub, ANONYMOUS|COOKIEUNNEEDED|FORCE_SESSIONCLOSE);