2 * Web forms for handling mailing list subscribe/unsubscribe requests.
4 * Copyright (c) 1996-2011 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 as
8 * published by the Free Software Foundation; either version 3 of the
9 * License, or (at your option) any later version.
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.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 * List subscription handling
33 char escaped_email[256];
34 char escaped_room[256];
40 FlushStrBuf(WC->wc_fullname);
41 FlushStrBuf(WC->wc_username);
42 FlushStrBuf(WC->wc_password);
43 FlushStrBuf(WC->CurRoom.name);
45 output_headers(1, 0, 0, 1, 1, 0);
48 wc_printf("<HTML><HEAD>\n"
49 "<meta name=\"MSSmartTagsPreventParsing\" content=\"TRUE\" />\n"
50 "<link href=\"static/styles/webcit.css\" rel=\"stylesheet\" type=\"text/css\">\n"
53 wc_printf(_("List subscription"));
54 wc_printf("</TITLE></HEAD><BODY>\n");
56 strcpy(cmd, bstr("cmd"));
57 strcpy(room, bstr("room"));
58 strcpy(token, bstr("token"));
59 strcpy(email, bstr("email"));
60 strcpy(subtype, bstr("subtype"));
62 wc_printf("<div align=center>");
63 wc_printf("<table border=0 width=75%%><tr><td>");
65 do_template("box_begin_1");
66 StrBufAppendBufPlain(WC->WBuf, _("List subscribe/unsubscribe"), -1, 0);
67 do_template("box_begin_2");
68 wc_printf("<div align=center><br>");
73 if (!strcasecmp(cmd, "subscribe")) {
74 serv_printf("SUBS subscribe|%s|%s|%s|%s/listsub",
80 serv_getln(buf, sizeof buf);
82 stresc(escaped_email, 256, email, 0, 0);
83 stresc(escaped_room, 256, room, 0, 0);
85 wc_printf("<CENTER><H1>");
86 wc_printf(_("Confirmation request sent"));
88 wc_printf(_("You are subscribing <TT>%s"
89 "</TT> to the <b>%s</b> mailing list. "
91 "sent you an e-mail with one additional "
92 "Web link for you to click on to confirm "
93 "your subscription. This extra step is for "
94 "your protection, as it prevents others from "
95 "being able to subscribe you to lists "
96 "without your consent.<br><br>"
97 "Please click on the link which is being "
98 "e-mailed to you and your subscription will "
99 "be confirmed.<br>\n"),
100 escaped_email, escaped_room);
101 wc_printf("<a href=\"listsub\">%s</A></CENTER>\n", _("Go back..."));
104 wc_printf("<FONT SIZE=+1><B>ERROR: %s</B>"
112 * Unsubscribe command
114 else if (!strcasecmp(cmd, "unsubscribe")) {
115 serv_printf("SUBS unsubscribe|%s|%s|%s/listsub",
120 serv_getln(buf, sizeof buf);
122 wc_printf("<CENTER><H1>Confirmation request sent</H1>"
123 "You are unsubscribing <TT>");
125 wc_printf("</TT> from the "");
127 wc_printf("" mailing list. The listserver has "
128 "sent you an e-mail with one additional "
129 "Web link for you to click on to confirm "
130 "your unsubscription. This extra step is for "
131 "your protection, as it prevents others from "
132 "being able to unsubscribe you from "
133 "lists without your consent.<br><br>"
134 "Please click on the link which is being "
135 "e-mailed to you and your unsubscription will "
136 "be confirmed.<br>\n"
137 "<a href=\"listsub\">Back...</A></CENTER>\n"
141 wc_printf("<FONT SIZE=+1><B>ERROR: %s</B>"
151 else if (!strcasecmp(cmd, "confirm")) {
152 serv_printf("SUBS confirm|%s|%s",
156 serv_getln(buf, sizeof buf);
158 wc_printf("<CENTER><H1>Confirmation successful!</H1>");
161 wc_printf("<CENTER><H1>Confirmation failed.</H1>"
162 "This could mean one of two things:<UL>\n"
163 "<LI>You waited too long to confirm your "
164 "subscribe/unsubscribe request (the "
165 "confirmation link is only valid for three "
166 "days)\n<LI>You have <i>already</i> "
167 "successfully confirmed your "
168 "subscribe/unsubscribe request and are "
169 "attempting to do it again.</UL>\n"
170 "The error returned by the server was: "
173 wc_printf("%s</CENTER><br>\n", &buf[4]);
177 * Any other (invalid) command causes the form to be displayed
180 FORM: wc_printf("<form method=\"POST\" action=\"listsub\">\n");
182 wc_printf("Name of list: "
183 "<select name=\"room\" size=1>\n");
186 serv_getln(buf, sizeof buf);
188 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
189 extract_token(sroom, buf, 0, '|', sizeof sroom);
190 self = extract_int(buf, 4) & QR2_SELFLIST ;
192 wc_printf("<option value=\"");
196 wc_printf("</option>\n");
200 wc_printf("</select><br><br>\n");
202 wc_printf("Your e-mail address: "
203 "<INPUT TYPE=\"text\" NAME=\"email\" "
207 wc_printf("\" maxlength=128 size=60><br><br>\n");
209 wc_printf("(If subscribing) preferred format: "
210 "<INPUT TYPE=\"radio\" NAME=\"subtype\" "
211 "VALUE=\"list\" CHECKED>One message at a time "
212 "<INPUT TYPE=\"radio\" NAME=\"subtype\" "
213 "VALUE=\"digest\">Digest format "
215 "<INPUT TYPE=\"submit\" NAME=\"cmd\""
216 " VALUE=\"subscribe\">\n"
217 "<INPUT TYPE=\"submit\" NAME=\"cmd\""
218 " VALUE=\"unsubscribe\"><br><br>\n"
222 wc_printf("<hr>When you attempt to subscribe or unsubscribe to "
223 "a mailing list, you will receive an e-mail containing"
224 " one additional web link to click on for final "
225 "confirmation. This extra step is for your "
226 "protection, as it prevents others from being able to "
227 "subscribe or unsubscribe you to lists.<br>\n"
233 do_template("box_end");
234 wc_printf("</td></tr></table></div>");
236 wc_printf("</BODY></HTML>\n");
238 end_webcit_session();
247 WebcitAddUrlHandler(HKEY("listsub"), "", 0, do_listsub, ANONYMOUS|COOKIEUNNEEDED|FORCE_SESSIONCLOSE);