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