Start clean up HTML : Advanced menus
[citadel.git] / webcit / mainmenu.c
1 /*
2  * $Id$
3  */
4 /**
5  * \defgroup DispAdvancedMenu Displays the "advanced" (main) menu.
6  * \ingroup MenuInfrastructure
7  *
8  */
9 /*@{*/
10 #include "webcit.h"
11
12 /**
13  * \brief The Main Menu
14  */
15 void display_main_menu(void)
16 {
17         output_headers(1, 1, 1, 0, 0, 0);
18
19         wprintf("<div class=\"fix_scrollbar_bug\">"
20                 "<table width=100%%>"
21                 "<tr><td colspan=\"2\">\n");
22
23         svprintf("BOXTITLE", WCS_STRING, _("Basic commands"));
24         do_template("beginbox");
25
26         wprintf("\n"
27                 "<table border=0 cellspacing=1 cellpadding=1 width=100%%>"
28                 "<tr>"
29                 "<td>");        /**< start of first column */
30
31         wprintf("<a href=\"knrooms\"><span class=\"mainmenu\">");
32         wprintf(_("List known rooms"));
33         wprintf("</span></a><br /><span class=\"menudesc\">");
34         wprintf(_("Where can I go from here?"));
35         wprintf("</span><br />\n");
36
37         wprintf("<a href=\"gotonext\">"
38                 "<span class=\"mainmenu\">");
39         wprintf(_("Goto next room"));
40         wprintf("</span></a><br />"
41                 "<span class=\"menudesc\">");
42         wprintf(_("...with <em>unread</em> messages"));
43         wprintf("</span><br />\n");
44
45         wprintf("<a href=\"skip\">"
46                 "<span class=\"mainmenu\">");
47         wprintf(_("Skip to next room"));
48         wprintf("</span></a><br />"
49                 "<span class=\"menudesc\">");
50         wprintf(_("(come back here later)"));
51         wprintf("</span>\n");
52
53         if ((strlen(WC->ugname) > 0) && (strcasecmp(WC->ugname, WC->wc_roomname))) {
54                 wprintf("<br />"
55                         "<a href=\"ungoto\">"
56                         "<span class=\"mainmenu\">");
57                 wprintf(_("Ungoto"));
58                 wprintf("</span></a><br />"
59                         "<span class=\"menudesc\">");
60                 wprintf(_("(oops! Back to %s)"), WC->ugname);
61                 wprintf("</span>\n");
62         }
63
64         wprintf("</td><td>\n"); /* start of second column */
65
66         wprintf("<a href=\"readnew\">"
67                 "<span class=\"mainmenu\">");
68         wprintf(_("Read new messages"));
69         wprintf("</span></a><br />"
70                 "<span class=\"menudesc\">");
71         wprintf(_("...in this room"));
72         wprintf("</span><br />\n");
73
74         wprintf("<a href=\"readfwd\">"
75                 "<span class=\"mainmenu\">");
76         wprintf(_("Read all messages"));
77         wprintf("</span></a><br />"
78                 "<span class=\"menudesc\">");
79         wprintf(_("...old <EM>and</EM> new"));
80         wprintf("</span><br />\n");
81
82         wprintf("<a href=\"display_enter\">"
83                 "<span class=\"mainmenu\">");
84         wprintf(_("Enter a message"));
85         wprintf("</span></a><br />"
86                 "<span class=\"menudesc\">");
87         wprintf(_("(post in this room)"));
88         wprintf("</span>\n");
89
90         if (WC->room_flags & QR_VISDIR) {
91                 wprintf("<br /><a href=\"display_room_directory\">"
92                         "<span class=\"mainmenu\">");
93                 wprintf(_("File library"));
94                 wprintf("</span></a><br />"
95                         "<span class=\"menudesc\">");
96                 wprintf(_("(List files available for download)"));
97                 wprintf("</span>\n");
98         }
99
100         wprintf("</td><td>");   /* start of third column */
101
102         wprintf("<a href=\"summary\">"
103                 "<span class=\"mainmenu\">");
104         wprintf(_("Summary page"));
105         wprintf("</span></a><br />"
106                 "<span class=\"menudesc\">");
107         wprintf(_("Summary of my account"));
108         wprintf("</span><br />\n");
109
110         wprintf("<a href=\"userlist\">\n"
111                 "<span class=\"mainmenu\">");
112         wprintf(_("User list"));
113         wprintf("</span></a><br />"
114                 "<span class=\"menudesc\">");
115         wprintf(_("(all registered users)"));
116         wprintf("</span><br />\n");
117
118         wprintf("<a href=\"termquit\" TARGET=\"_top\">"
119                 "<span class=\"mainmenu\">");
120         wprintf(_("Log off"));
121         wprintf("</span></a><br />"
122                 "<span class=\"menudesc\">");
123         wprintf(_("Bye!"));
124         wprintf("</span>\n");
125
126         wprintf("</td></tr></table>\n");
127         do_template("endbox");
128
129         wprintf("</td></tr>"
130                 "<tr><td colspan=2></td></tr>"
131                 "<tr valign=top><td width=50%%>");
132
133         svprintf("BOXTITLE", WCS_STRING, _("Your info"));
134         do_template("beginbox");
135
136         wprintf("<a href=\"display_preferences\">"
137                 "<span class=\"mainmenu\">");
138         wprintf(_("Change your preferences and settings"));
139         wprintf("</span><br />\n");
140
141         wprintf("<a href=\"display_reg\">"
142                 "<span class=\"mainmenu\">");
143         wprintf(_("Update your contact information"));
144         wprintf("</span><br />\n");
145
146         wprintf("<a href=\"display_changepw\">"
147                 "<span class=\"mainmenu\">");
148         wprintf(_("Change your password"));
149         wprintf("</span></a><br />\n");
150
151         wprintf("<a href=\"display_editbio\">"
152                 "<span class=\"mainmenu\">");
153         wprintf(_("Enter your 'bio'"));
154         wprintf("</span></a><br />\n");
155
156         wprintf("<a href=\"display_editpic\">"
157                 "<span class=\"mainmenu\">");
158         wprintf(_("Edit your online photo"));
159         wprintf("</span></a><br />\n");
160
161         wprintf("<a href=\"display_sieve\">"
162                 "<span class=\"mainmenu\">");
163         wprintf(_("View/edit server-side mail filters"));
164         wprintf("</span></a>\n");
165
166         do_template("endbox");
167
168         wprintf("</td><td width=50%%>");
169
170         svprintf("BOXTITLE", WCS_STRING, _("Advanced room commands"));
171         do_template("beginbox");
172
173         if ((WC->axlevel >= 6) || (WC->is_room_aide)) {
174                 wprintf("<a href=\"display_editroom\">"
175                         "<span class=\"mainmenu\">");
176                 wprintf(_("Edit or delete this room"));
177                 wprintf("</span></a><br />\n");
178         }
179
180         wprintf("<a href=\"display_private\">"
181                 "<span class=\"mainmenu\">");
182         wprintf(_("Go to a 'hidden' room"));
183         wprintf("</span></a><br />\n");
184
185         wprintf("<a href=\"display_entroom\">"
186                 "<span class=\"mainmenu\">");
187         wprintf(_("Create a new room"));
188         wprintf("</span></a><br />\n");
189
190         wprintf("<a href=\"display_zap\">"
191                 "<span class=\"mainmenu\">");
192         wprintf(_("Zap (forget) this room (%s)"), WC->wc_roomname);
193         wprintf("</span></a><br />\n");
194
195         wprintf("<a href=\"zapped_list\">"
196                 "<span class=\"mainmenu\">");
197         wprintf(_("List all forgotten rooms"));
198         wprintf("</span></a>\n");
199
200         do_template("endbox");
201
202         wprintf("</td></tr></table></div>");
203         wDumpContent(2);
204 }
205
206
207 /**
208  * \brief System administration menu
209  */
210 void display_aide_menu(void)
211 {
212         output_headers(1, 1, 2, 0, 0, 0);
213         wprintf("<div id=\"banner\">\n"
214                 "<table class=\"mainmenu_banner\"><tr><td>"
215                 "<span class=\"titlebar\">");
216         wprintf(_("System Administration Menu"));
217         wprintf("</span>"
218                 "</td></tr></table>\n"
219                 "</div>\n<div id=\"content\">\n"
220         );
221
222         wprintf("<div class=\"fix_scrollbar_bug\">"
223                 "<table border=0 width=100%%><tr valign=top><td>");
224
225         svprintf("BOXTITLE", WCS_STRING, _("Global Configuration"));
226         do_template("beginbox");
227
228         wprintf("<a href=\"display_siteconfig\">"
229                 "<span class=\"mainmenu\">");
230         wprintf(_("Edit site-wide configuration"));
231         wprintf("</span></a><br />\n");
232
233         wprintf("<a href=\"display_inetconf\">"
234                 "<span class=\"mainmenu\">");
235         wprintf(_("Domain names and Internet mail configuration"));
236         wprintf("</span></a><br />\n");
237
238         wprintf("<a href=\"display_netconf\">"
239                 "<span class=\"mainmenu\">");
240         wprintf(_("Configure replication with other Citadel servers"));
241         wprintf("</span></a><br />\n");
242
243         wprintf("<a href=\"display_smtpqueue\">"
244                 "<span class=\"mainmenu\">");
245         wprintf(_("View the outbound SMTP queue"));
246         wprintf("</span></A>\n");
247
248         do_template("endbox");
249
250         wprintf("</td><td>");
251
252         svprintf("BOXTITLE", WCS_STRING, _("User account management"));
253         do_template("beginbox");
254
255         wprintf("<a href=\"select_user_to_edit\">"
256                 "<span class=\"mainmenu\">");
257         wprintf(_("Add, change, delete user accounts"));
258         wprintf("</span></a><br />\n");
259
260         wprintf("<a href=\"validate\">"
261                 "<span class=\"mainmenu\">");
262         wprintf(_("Validate new users"));
263         wprintf("</span></a><br />\n");
264
265         do_template("endbox");
266
267         svprintf("BOXTITLE", WCS_STRING, _("Rooms and Floors"));
268         do_template("beginbox");
269
270         wprintf("<a href=\"display_floorconfig\">"
271                 "<span class=\"mainmenu\">");
272         wprintf(_("Add, change, or delete floors"));
273         wprintf("</span></a>\n");
274
275         do_template("endbox");
276
277         wprintf("</td></tr></table></div>");
278         wDumpContent(2);
279 }
280
281
282
283
284
285 /**
286  * \brief Display the screen to enter a generic server command
287  */
288 void display_generic(void)
289 {
290         output_headers(1, 1, 2, 0, 0, 0);
291         wprintf("<div id=\"banner\">\n"
292                 "<table class=\"mainmenu_banner\"><tr><td>"
293                 "<span class=\"titlebar\">");
294         wprintf(_("Enter a server command"));
295         wprintf("</span></td></tr></table>\n"
296                 "</div>\n<div id=\"content\">\n"
297         );
298
299         wprintf("<div class=\"fix_scrollbar_bug\">"
300                 "<table class=\"mainmenu_background\"><tr><td>\n");
301
302         wprintf("<center>");
303         wprintf(_("This screen allows you to enter Citadel server commands which are "
304                 "not supported by WebCit.  If you do not know what that means, "
305                 "then this screen will not be of much use to you."));
306         wprintf("<br />\n");
307
308         wprintf("<form method=\"post\" action=\"do_generic\">\n");
309
310         wprintf(_("Enter command:"));
311         wprintf("<br /><input type=\"text\" name=\"g_cmd\" size=80 maxlength=\"250\"><br />\n");
312
313         wprintf(_("Command input (if requesting SEND_LISTING transfer mode):"));
314         wprintf("<br /><textarea name=\"g_input\" rows=10 cols=80 width=80></textarea><br />\n");
315
316         wprintf("<font size=-2>");
317         wprintf(_("Detected host header is %s://%s"), (is_https ? "https" : "http"), WC->http_host);
318         wprintf("</font>\n");
319         wprintf("<input type=\"submit\" name=\"sc_button\" value=\"%s\">", _("Send command"));
320         wprintf("&nbsp;");
321         wprintf("<input type=\"submit\" name=\"cancel_button\" value=\"%s\"><br />\n", _("Cancel"));
322
323         wprintf("</form></center>\n");
324         wprintf("</td></tr></table></div>\n");
325         wDumpContent(1);
326 }
327
328 /**
329  * \brief Interactive window to perform generic Citadel server commands.
330  */
331 void do_generic(void)
332 {
333         char buf[SIZ];
334         char gcontent[SIZ];
335         char *junk;
336         size_t len;
337
338         if (strlen(bstr("sc_button")) == 0) {
339                 display_main_menu();
340                 return;
341         }
342
343         output_headers(1, 1, 0, 0, 0, 0);
344
345         serv_printf("%s", bstr("g_cmd"));
346         serv_getln(buf, sizeof buf);
347
348         svprintf("BOXTITLE", WCS_STRING, _("Server command results"));
349         do_template("beginbox");
350
351         wprintf("<table border=0><tr><td>Command:</td><td><tt>");
352         escputs(bstr("g_cmd"));
353         wprintf("</tt></td></tr><tr><td>Result:</td><td><tt>");
354         escputs(buf);
355         wprintf("</tt></td></tr></table><br />\n");
356
357         if (buf[0] == '8') {
358                 serv_printf("\n\n000");
359         }
360         if ((buf[0] == '1') || (buf[0] == '8')) {
361                 while (serv_getln(gcontent, sizeof gcontent), strcmp(gcontent, "000")) {
362                         escputs(gcontent);
363                         wprintf("<br />\n");
364                 }
365                 wprintf("000");
366         }
367         if (buf[0] == '4') {
368                 text_to_server(bstr("g_input"));
369                 serv_puts("000");
370         }
371         if (buf[0] == '6') {
372                 len = atol(&buf[4]);
373                 junk = malloc(len);
374                 serv_read(junk, len);
375                 free(junk);
376         }
377         if (buf[0] == '7') {
378                 len = atol(&buf[4]);
379                 junk = malloc(len);
380                 memset(junk, 0, len);
381                 serv_write(junk, len);
382                 free(junk);
383         }
384         wprintf("<hr />");
385         wprintf("<a href=\"display_generic\">Enter another command</a><br />\n");
386         wprintf("<a href=\"display_advanced\">Return to menu</a>\n");
387         do_template("endbox");
388         wDumpContent(1);
389 }
390
391
392 /**
393  * \brief Display the menubar.  
394  * \param as_single_page Set to display HTML headers and footers -- otherwise it's assumed
395  * that the menubar is being embedded in another page.
396  */
397 void display_menubar(int as_single_page) {
398
399         if (as_single_page) {
400                 output_headers(0, 0, 0, 0, 0, 0);
401                 wprintf("<html>\n"
402                         "<head>\n"
403                         "<title>MenuBar</title>\n"
404                         "<style type=\"text/css\">\n"
405                         "body   { text-decoration: none; }\n"
406                         "</style>\n"
407                         "</head>\n");
408                 do_template("background");
409         }
410
411         do_template("menubar");
412
413         if (as_single_page) {
414                 wDumpContent(2);
415         }
416
417
418 }
419
420
421 /*@}*/