* Begin migration to the new "rounded boxes" look
[citadel.git] / webcit / mainmenu.c
1 /* $Id$ */
2
3
4
5
6 #include <ctype.h>
7 #include <stdlib.h>
8 #include <unistd.h>
9 #include <stdio.h>
10 #include <fcntl.h>
11 #include <signal.h>
12 #include <sys/types.h>
13 #include <sys/wait.h>
14 #include <sys/socket.h>
15 #include <sys/time.h>
16 #include <limits.h>
17 #include <netinet/in.h>
18 #include <netdb.h>
19 #include <string.h>
20 #include <pwd.h>
21 #include <errno.h>
22 #include <stdarg.h>
23 #include <pthread.h>
24 #include <signal.h>
25 #include "webcit.h"
26
27
28
29 /*
30  * The Main Menu
31  */
32 void display_main_menu(void)
33 {
34         output_headers(1);
35
36         svprintf("BOXTITLE", WCS_STRING, "Basic commands");
37         do_template("beginbox");
38
39         wprintf("<TABLE border=0 align=center><TR>");
40         wprintf("<TD>");        /* start of first column */
41
42         wprintf("<UL>");
43         wprintf("<LI><B><A HREF=\"/knrooms\">\n");
44         wprintf("List known rooms</B></A><BR>\n");
45         wprintf("Where can I go from here?</LI>\n");
46
47         wprintf("<LI><B><A HREF=\"/gotonext\">\n");
48         wprintf("Goto next room</B></A><BR>\n");
49         wprintf("...with <EM>unread</EM> messages</LI>\n");
50
51         wprintf("<LI><B><A HREF=\"/skip\">\n");
52         wprintf("Skip to next room</B></A><BR>\n");
53         wprintf("(come back here later)</LI>\n");
54
55         if ((strlen(WC->ugname) > 0) && (strcasecmp(WC->ugname, WC->wc_roomname))) {
56                 wprintf("<LI><B><A HREF=\"/ungoto\">\n");
57                 wprintf("Ungoto</B></A><BR>\n");
58                 wprintf("(oops! Back to %s)</LI>\n", WC->ugname);
59         }
60         wprintf("</UL>\n");
61
62         wprintf("</TD><TD>\n"); /* start of second column */
63
64         wprintf("<UL>");
65         wprintf("<LI><B><A HREF=\"/readnew\">\n");
66         wprintf("Read new messages</B></A><BR>...in this room</LI>\n");
67
68         wprintf("<LI><B><A HREF=\"/readfwd\">\n");
69         wprintf("Read all messages</B></A><BR>...old <EM>and</EM> new</LI>\n");
70
71         wprintf("<LI><B><A HREF=\"/display_enter\">\n");
72         wprintf("Enter a message</B></A><BR>(post in this room)</LI>");
73         wprintf("</UL>\n");
74
75         wprintf("</TD><TD>");   /* start of third column */
76
77         wprintf("<UL>");
78         wprintf("<LI><B><A HREF=\"/summary\">\n");
79         wprintf("Summary page</B></A><BR>Summary of my account</LI>\n");
80
81         wprintf("<LI><B><A HREF=\"/userlist\">\n");
82         wprintf("User list</B></A><BR>(all registered users)</LI>\n");
83
84         wprintf("<LI><B><A HREF=\"/termquit\" TARGET=\"_top\">\n");
85         wprintf("Log off</B></A><BR>Bye!</LI>\n");
86         wprintf("</UL>\n");
87
88         wprintf("</TR></TABLE>\n");
89         do_template("endbox");
90
91         wprintf("<TABLE WIDTH=100%%><TR VALIGN=TOP><TD>");
92
93         svprintf("BOXTITLE", WCS_STRING, "Interaction");
94         do_template("beginbox");
95
96         wprintf("<UL>");
97         wprintf("<LI><A HREF=\"/whobbs\">\n");
98         wprintf("Who is online?</A><font size=-2> "
99                 "(users <EM>currently</EM> logged on)</font>\n");
100         wprintf("<LI><A HREF=\"/chat\">");
101         wprintf("Chat with other online users</A>\n");
102
103         wprintf("<LI><A HREF=\"/display_generic\">\n");
104         wprintf("<FONT SIZE=-2>Generic server command</FONT></A>\n");
105
106         wprintf("</UL>\n");
107         do_template("endbox");
108
109         wprintf("</TD><TD>");
110
111         svprintf("BOXTITLE", WCS_STRING, "Your info");
112         do_template("beginbox");
113
114         wprintf("<UL>");
115         wprintf("<LI><A HREF=\"/display_editbio\">\n");
116         wprintf("Enter your 'bio' (a few words about yourself)</A>\n");
117
118         wprintf("<LI><A HREF=\"/display_editpic\">\n");
119         wprintf("Edit your online photo</A>\n");
120
121         wprintf("<LI><A HREF=\"/display_reg\">\n");
122         wprintf("Re-enter your registration info (name, address, etc.)</A>\n");
123
124         wprintf("<LI><A HREF=\"/display_changepw\">\n");
125         wprintf("Change your password</A>\n");
126
127         wprintf("</UL>\n");
128         do_template("endbox");
129
130         wprintf("</TD></TR><TR VALIGN=TOP><TD>");
131
132         svprintf("BOXTITLE", WCS_STRING, "Advanced room commands");
133         do_template("beginbox");
134
135         wprintf("<UL>");
136         wprintf("<LI><A HREF=\"/display_private\">\n");
137         wprintf("Go to a 'hidden' room</A>\n");
138
139         wprintf("<LI><A HREF=\"/display_entroom\">");
140         wprintf("Create a new room</A>\n");
141
142         wprintf("<LI><A HREF=\"/display_zap\">");
143         wprintf("Zap (forget) this room (%s)</A>\n", WC->wc_roomname);
144
145         wprintf("<LI><A HREF=\"/display_whok\">\n");
146         wprintf("Access controls for this room</A>\n");
147
148         wprintf("<LI><A HREF=\"/zapped_list\">");
149         wprintf("List all forgotten rooms</A>\n");
150
151         wprintf("</UL>\n");
152         do_template("endbox");
153
154         wprintf("</TD><TD>");
155
156         if ((WC->axlevel >= 6) || (WC->is_room_aide)) {
157                 svprintf("BOXTITLE", WCS_STRING, "Administrative functions");
158                 do_template("beginbox");
159
160                 wprintf("<UL>");
161                 wprintf("<LI><A HREF=\"/display_editroom\">\n");
162                 wprintf("Edit or delete this room</A>\n");
163
164                 wprintf("<LI><A HREF=\"/display_siteconfig\">\n");
165                 wprintf("Edit site-wide configuration</A>\n");
166
167                 if (WC->axlevel >= 6) {
168                         wprintf("<LI><A HREF=\"/select_user_to_edit\">\n");
169                         wprintf("Add, change, delete user accounts</A>\n");
170
171                         wprintf("<LI><A HREF=\"/validate\">\n");
172                         wprintf("Validate new users</A>\n");
173
174                         wprintf("<LI><A HREF=\"/display_floorconfig\">\n");
175                         wprintf("Add, change, or delete floors</A>\n");
176
177                         wprintf("<LI><A HREF=\"/display_netconf\">\n");
178                         wprintf("Configure networking with other systems</A>\n");
179                         wprintf("<LI><A HREF=\"/static/colorpicker.html\">\n");
180                         wprintf("Reconfigure color scheme</A>\n");
181                 }
182                 wprintf("</UL>\n");
183                 do_template("endbox");
184         }
185         wprintf("</TD></TR></TABLE>");
186         wDumpContent(2);
187 }
188
189
190
191
192
193 /*
194  * Display the screen to enter a generic server command
195  */
196 void display_generic(void)
197 {
198         output_headers(1);
199
200         wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#770077\"><TR><TD>");
201         wprintf("<SPAN CLASS=\"titlebar\">Enter a server command</SPAN>\n");
202         wprintf("</TD></TR></TABLE>\n");
203
204         wprintf("<CENTER>");
205         wprintf("This screen allows you to enter Citadel server commands which are\n");
206         wprintf("not supported by WebCit.  If you do not know what that means,\n");
207         wprintf("then this screen will not be of much use to you.<BR>\n");
208
209         wprintf("<FORM METHOD=\"POST\" ACTION=\"/do_generic\">\n");
210
211         wprintf("Enter command:<BR>\n");
212         wprintf("<INPUT TYPE=\"text\" NAME=\"g_cmd\" SIZE=80 MAXLENGTH=\"250\"><BR>\n");
213
214         wprintf("Command input (if requesting SEND_LISTING transfer mode):<BR>\n");
215         wprintf("<TEXTAREA NAME=\"g_input\" ROWS=10 COLS=80 WIDTH=80></TEXTAREA><BR>\n");
216
217         wprintf("<FONT SIZE=-2>Detected host header is http://%s</FONT>\n",
218                 WC->http_host);
219         wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Send command\">");
220         wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\"><BR>\n");
221
222         wprintf("</FORM></CENTER>\n");
223         wDumpContent(1);
224 }
225
226 void do_generic(void)
227 {
228         char buf[SIZ];
229         char gcontent[SIZ];
230         char *junk;
231         size_t len;
232
233         if (strcasecmp(bstr("sc"), "Send command")) {
234                 display_main_menu();
235                 return;
236         }
237
238         output_headers(1);
239
240         serv_printf("%s", bstr("g_cmd"));
241         serv_gets(buf);
242
243         wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#770077\"><TR><TD>");
244         wprintf("<SPAN CLASS=\"titlebar\">Server command results</SPAN>\n");
245         wprintf("</TD></TR></TABLE>\n");
246
247         wprintf("<TABLE border=0><TR><TD>Command:</TD><TD><TT>");
248         escputs(bstr("g_cmd"));
249         wprintf("</TT></TD></TR><TR><TD>Result:</TD><TD><TT>");
250         escputs(buf);
251         wprintf("</TT></TD></TR></TABLE><BR>\n");
252
253         if (buf[0] == '8') {
254                 serv_printf("\n\n000");
255         }
256         if ((buf[0] == '1') || (buf[0] == '8')) {
257                 while (serv_gets(gcontent), strcmp(gcontent, "000")) {
258                         escputs(gcontent);
259                         wprintf("<BR>\n");
260                 }
261                 wprintf("000");
262         }
263         if (buf[0] == '4') {
264                 text_to_server(bstr("g_input"), 0);
265                 serv_puts("000");
266         }
267         if (buf[0] == '6') {
268                 len = atol(&buf[4]);
269                 junk = malloc(len);
270                 serv_read(junk, len);
271                 free(junk);
272         }
273         if (buf[0] == '7') {
274                 len = atol(&buf[4]);
275                 junk = malloc(len);
276                 memset(junk, 0, len);
277                 serv_write(junk, len);
278                 free(junk);
279         }
280         wprintf("<HR>");
281         wprintf("<A HREF=\"/display_generic\">Enter another command</A><BR>\n");
282         wprintf("<A HREF=\"/display_advanced\">Return to menu</A>\n");
283         wDumpContent(1);
284 }
285
286
287
288
289 /*
290  * Display the menubar.  Set as_single_page to
291  * display HTML headers and footers -- otherwise it's assumed
292  * that the menubar is being embedded in another page.
293  */
294 void display_menubar(int as_single_page) {
295
296         if (as_single_page) {
297                 output_headers(0);
298                 wprintf("<HTML>\n"
299                         "<HEAD>\n"
300                         "<TITLE>MenuBar</TITLE>\n"
301                         "<STYLE TYPE=\"text/css\">\n"
302                         "BODY   { text-decoration: none; }\n"
303                         "</STYLE>\n"
304                         "</HEAD>\n");
305                 do_template("background");
306         }
307
308         do_template("menubar");
309
310         if (as_single_page) {
311                 wDumpContent(2);
312         }
313
314
315 }
316
317