2 * $Id: listsub.c 8232 2010-01-14 21:46:39Z dothebart $
4 * Web forms for handling mailing list subscribe/unsubscribe requests.
10 * List subscription handling
19 char escaped_email[256];
20 char escaped_room[256];
26 FlushStrBuf(WC->wc_fullname);
27 FlushStrBuf(WC->wc_username);
28 FlushStrBuf(WC->wc_password);
29 FlushStrBuf(WC->CurRoom.name);
31 output_headers(1, 0, 0, 1, 1, 0);
34 wc_printf("<HTML><HEAD>\n"
35 "<meta name=\"MSSmartTagsPreventParsing\" content=\"TRUE\" />\n"
36 "<link href=\"static/styles/webcit.css\" rel=\"stylesheet\" type=\"text/css\">\n"
39 wc_printf(_("List subscription"));
40 wc_printf("</TITLE></HEAD><BODY>\n");
42 strcpy(cmd, bstr("cmd"));
43 strcpy(room, bstr("room"));
44 strcpy(token, bstr("token"));
45 strcpy(email, bstr("email"));
46 strcpy(subtype, bstr("subtype"));
48 wc_printf("<div align=center>");
49 wc_printf("<table border=0 width=75%%><tr><td>");
51 do_template("beginbox_1", NULL);
52 StrBufAppendBufPlain(WC->WBuf, _("List subscribe/unsubscribe"), -1, 0);
53 do_template("beginbox_2", NULL);
54 wc_printf("<div align=center><br>");
59 if (!strcasecmp(cmd, "subscribe")) {
60 serv_printf("SUBS subscribe|%s|%s|%s|%s://%s/listsub",
64 (is_https ? "https" : "http"),
65 ChrPtr(WC->Hdr->HR.http_host)
67 serv_getln(buf, sizeof buf);
69 stresc(escaped_email, 256, email, 0, 0);
70 stresc(escaped_room, 256, room, 0, 0);
72 wc_printf("<CENTER><H1>");
73 wc_printf(_("Confirmation request sent"));
75 wc_printf(_("You are subscribing <TT>%s"
76 "</TT> to the <b>%s</b> mailing list. "
78 "sent you an e-mail with one additional "
79 "Web link for you to click on to confirm "
80 "your subscription. This extra step is for "
81 "your protection, as it prevents others from "
82 "being able to subscribe you to lists "
83 "without your consent.<br /><br />"
84 "Please click on the link which is being "
85 "e-mailed to you and your subscription will "
86 "be confirmed.<br />\n"),
87 escaped_email, escaped_room);
88 wc_printf("<a href=\"listsub\">%s</A></CENTER>\n", _("Go back..."));
91 wc_printf("<FONT SIZE=+1><B>ERROR: %s</B>"
92 "</FONT><br /><br />\n",
101 else if (!strcasecmp(cmd, "unsubscribe")) {
102 serv_printf("SUBS unsubscribe|%s|%s|%s://%s/listsub",
105 (is_https ? "https" : "http"),
106 ChrPtr(WC->Hdr->HR.http_host)
108 serv_getln(buf, sizeof buf);
110 wc_printf("<CENTER><H1>Confirmation request sent</H1>"
111 "You are unsubscribing <TT>");
113 wc_printf("</TT> from the "");
115 wc_printf("" mailing list. The listserver has "
116 "sent you an e-mail with one additional "
117 "Web link for you to click on to confirm "
118 "your unsubscription. This extra step is for "
119 "your protection, as it prevents others from "
120 "being able to unsubscribe you from "
121 "lists without your consent.<br /><br />"
122 "Please click on the link which is being "
123 "e-mailed to you and your unsubscription will "
124 "be confirmed.<br />\n"
125 "<a href=\"listsub\">Back...</A></CENTER>\n"
129 wc_printf("<FONT SIZE=+1><B>ERROR: %s</B>"
130 "</FONT><br /><br />\n",
139 else if (!strcasecmp(cmd, "confirm")) {
140 serv_printf("SUBS confirm|%s|%s",
144 serv_getln(buf, sizeof buf);
146 wc_printf("<CENTER><H1>Confirmation successful!</H1>");
149 wc_printf("<CENTER><H1>Confirmation failed.</H1>"
150 "This could mean one of two things:<UL>\n"
151 "<LI>You waited too long to confirm your "
152 "subscribe/unsubscribe request (the "
153 "confirmation link is only valid for three "
154 "days)\n<LI>You have <i>already</i> "
155 "successfully confirmed your "
156 "subscribe/unsubscribe request and are "
157 "attempting to do it again.</UL>\n"
158 "The error returned by the server was: "
161 wc_printf("%s</CENTER><br />\n", &buf[4]);
165 * Any other (invalid) command causes the form to be displayed
168 FORM: wc_printf("<form method=\"POST\" action=\"listsub\">\n");
170 wc_printf("Name of list: "
171 "<select name=\"room\" size=1>\n");
174 serv_getln(buf, sizeof buf);
176 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
177 extract_token(sroom, buf, 0, '|', sizeof sroom);
178 self = extract_int(buf, 4) & QR2_SELFLIST ;
180 wc_printf("<option value=\"");
184 wc_printf("</option>\n");
188 wc_printf("</select><br><br>\n");
190 wc_printf("Your e-mail address: "
191 "<INPUT TYPE=\"text\" NAME=\"email\" "
195 wc_printf("\" maxlength=128 size=60><br><br>\n");
197 wc_printf("(If subscribing) preferred format: "
198 "<INPUT TYPE=\"radio\" NAME=\"subtype\" "
199 "VALUE=\"list\" CHECKED>One message at a time "
200 "<INPUT TYPE=\"radio\" NAME=\"subtype\" "
201 "VALUE=\"digest\">Digest format "
203 "<INPUT TYPE=\"submit\" NAME=\"cmd\""
204 " VALUE=\"subscribe\">\n"
205 "<INPUT TYPE=\"submit\" NAME=\"cmd\""
206 " VALUE=\"unsubscribe\"><br><br>\n"
210 wc_printf("<hr>When you attempt to subscribe or unsubscribe to "
211 "a mailing list, you will receive an e-mail containing"
212 " one additional web link to click on for final "
213 "confirmation. This extra step is for your "
214 "protection, as it prevents others from being able to "
215 "subscribe or unsubscribe you to lists.<br />\n"
221 do_template("endbox", NULL);
222 wc_printf("</td></tr></table></div>");
224 wc_printf("</BODY></HTML>\n");
226 end_webcit_session();
235 WebcitAddUrlHandler(HKEY("listsub"), "", 0, do_listsub, ANONYMOUS|COOKIEUNNEEDED|FORCE_SESSIONCLOSE);