* Move iconbar font size declaration to webcit.css
[citadel.git] / webcit / listsub.c
bloba694cd227e6cf689efc6f1723c5f4559c959861c
1 /*
2 * $Id$
4 * Web forms for handling mailing list subscribe/unsubscribe requests.
5 */
7 #include "webcit.h"
9 /*
10 * List subscription handling
12 void do_listsub(void)
14 char cmd[256];
15 char room[256];
16 char token[256];
17 char email[256];
18 char subtype[256];
19 char escaped_email[256];
20 char escaped_room[256];
22 char buf[SIZ];
23 int self;
24 char sroom[SIZ];
26 FlushStrBuf(WC->wc_fullname);
27 FlushStrBuf(WC->wc_username);
28 FlushStrBuf(WC->wc_password);
29 FlushStrBuf(WC->wc_roomname);
31 output_headers(1, 0, 0, 1, 1, 0);
32 begin_burst();
34 wprintf("<HTML><HEAD>\n"
35 "<meta name=\"MSSmartTagsPreventParsing\" content=\"TRUE\" />\n"
36 "<link href=\"static/webcit.css\" rel=\"stylesheet\" type=\"text/css\">\n"
37 "<TITLE>\n"
39 wprintf(_("List subscription"));
40 wprintf("</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 wprintf("<div align=center>");
49 wprintf("<table border=0 width=75%%><tr><td>");
51 svput("BOXTITLE", WCS_STRING, _("List subscribe/unsubscribe"));
52 do_template("beginboxx", NULL);
53 wprintf("<div align=center><br>");
56 * Subscribe command
58 if (!strcasecmp(cmd, "subscribe")) {
59 serv_printf("SUBS subscribe|%s|%s|%s|%s://%s/listsub",
60 room,
61 email,
62 subtype,
63 (is_https ? "https" : "http"),
64 WC->http_host
66 serv_getln(buf, sizeof buf);
67 if (buf[0] == '2') {
68 stresc(escaped_email, 256, email, 0, 0);
69 stresc(escaped_room, 256, room, 0, 0);
71 wprintf("<CENTER><H1>");
72 wprintf(_("Confirmation request sent"));
73 wprintf("</H1>");
74 wprintf(_("You are subscribing <TT>%s"
75 "</TT> to the <b>%s</b> mailing list. "
76 "The listserver has "
77 "sent you an e-mail with one additional "
78 "Web link for you to click on to confirm "
79 "your subscription. This extra step is for "
80 "your protection, as it prevents others from "
81 "being able to subscribe you to lists "
82 "without your consent.<br /><br />"
83 "Please click on the link which is being "
84 "e-mailed to you and your subscription will "
85 "be confirmed.<br />\n"),
86 escaped_email, escaped_room);
87 wprintf("<a href=\"listsub\">%s</A></CENTER>\n", _("Go back..."));
89 else {
90 wprintf("<FONT SIZE=+1><B>ERROR: %s</B>"
91 "</FONT><br /><br />\n",
92 &buf[4]);
93 goto FORM;
98 * Unsubscribe command
100 else if (!strcasecmp(cmd, "unsubscribe")) {
101 serv_printf("SUBS unsubscribe|%s|%s|%s://%s/listsub",
102 room,
103 email,
104 (is_https ? "https" : "http"),
105 WC->http_host
107 serv_getln(buf, sizeof buf);
108 if (buf[0] == '2') {
109 wprintf("<CENTER><H1>Confirmation request sent</H1>"
110 "You are unsubscribing <TT>");
111 escputs(email);
112 wprintf("</TT> from the &quot;");
113 escputs(room);
114 wprintf("&quot; mailing list. The listserver has "
115 "sent you an e-mail with one additional "
116 "Web link for you to click on to confirm "
117 "your unsubscription. This extra step is for "
118 "your protection, as it prevents others from "
119 "being able to unsubscribe you from "
120 "lists without your consent.<br /><br />"
121 "Please click on the link which is being "
122 "e-mailed to you and your unsubscription will "
123 "be confirmed.<br />\n"
124 "<a href=\"listsub\">Back...</A></CENTER>\n"
127 else {
128 wprintf("<FONT SIZE=+1><B>ERROR: %s</B>"
129 "</FONT><br /><br />\n",
130 &buf[4]);
131 goto FORM;
136 * Confirm command
138 else if (!strcasecmp(cmd, "confirm")) {
139 serv_printf("SUBS confirm|%s|%s",
140 room,
141 token
143 serv_getln(buf, sizeof buf);
144 if (buf[0] == '2') {
145 wprintf("<CENTER><H1>Confirmation successful!</H1>");
147 else {
148 wprintf("<CENTER><H1>Confirmation failed.</H1>"
149 "This could mean one of two things:<UL>\n"
150 "<LI>You waited too long to confirm your "
151 "subscribe/unsubscribe request (the "
152 "confirmation link is only valid for three "
153 "days)\n<LI>You have <i>already</i> "
154 "successfully confirmed your "
155 "subscribe/unsubscribe request and are "
156 "attempting to do it again.</UL>\n"
157 "The error returned by the server was: "
160 wprintf("%s</CENTER><br />\n", &buf[4]);
164 * Any other (invalid) command causes the form to be displayed
166 else {
167 FORM: wprintf("<form method=\"POST\" action=\"listsub\">\n");
169 wprintf("Name of list: "
170 "<select name=\"room\" size=1>\n");
172 serv_puts("LPRM");
173 serv_getln(buf, sizeof buf);
174 if (buf[0] == '1') {
175 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
176 extract_token(sroom, buf, 0, '|', sizeof sroom);
177 self = extract_int(buf, 4) & QR2_SELFLIST ;
178 if (self) {
179 wprintf("<option value=\"");
180 escputs(sroom);
181 wprintf("\">");
182 escputs(sroom);
183 wprintf("</option>\n");
187 wprintf("</select><br><br>\n");
189 wprintf("Your e-mail address: "
190 "<INPUT TYPE=\"text\" NAME=\"email\" "
191 "VALUE=\""
193 escputs(email);
194 wprintf("\" maxlength=128 size=60><br><br>\n");
196 wprintf("(If subscribing) preferred format: "
197 "<INPUT TYPE=\"radio\" NAME=\"subtype\" "
198 "VALUE=\"list\" CHECKED>One message at a time&nbsp; "
199 "<INPUT TYPE=\"radio\" NAME=\"subtype\" "
200 "VALUE=\"digest\">Digest format&nbsp; "
201 "<br><br>\n"
202 "<INPUT TYPE=\"submit\" NAME=\"cmd\""
203 " VALUE=\"subscribe\">\n"
204 "<INPUT TYPE=\"submit\" NAME=\"cmd\""
205 " VALUE=\"unsubscribe\"><br><br>\n"
206 "</FORM>\n"
209 wprintf("<hr>When you attempt to subscribe or unsubscribe to "
210 "a mailing list, you will receive an e-mail containing"
211 " one additional web link to click on for final "
212 "confirmation. This extra step is for your "
213 "protection, as it prevents others from being able to "
214 "subscribe or unsubscribe you to lists.<br />\n"
219 wprintf("</div>");
220 do_template("endbox", NULL);
221 wprintf("</td></tr></table></div>");
223 wprintf("</BODY></HTML>\n");
224 wDumpContent(0);
225 end_webcit_session();