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