* look and feel overhaul -- almost done!
[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                 }
180                 wprintf("</UL>\n");
181                 do_template("endbox");
182         }
183         wprintf("</TD></TR></TABLE>");
184         wDumpContent(2);
185 }
186
187
188
189
190
191 /*
192  * Display the screen to enter a generic server command
193  */
194 void display_generic(void)
195 {
196         output_headers(3);
197
198         svprintf("BOXTITLE", WCS_STRING, "Enter a server command");
199         do_template("beginbox");
200
201         wprintf("<CENTER>");
202         wprintf("This screen allows you to enter Citadel server commands which are\n");
203         wprintf("not supported by WebCit.  If you do not know what that means,\n");
204         wprintf("then this screen will not be of much use to you.<BR>\n");
205
206         wprintf("<FORM METHOD=\"POST\" ACTION=\"/do_generic\">\n");
207
208         wprintf("Enter command:<BR>\n");
209         wprintf("<INPUT TYPE=\"text\" NAME=\"g_cmd\" SIZE=80 MAXLENGTH=\"250\"><BR>\n");
210
211         wprintf("Command input (if requesting SEND_LISTING transfer mode):<BR>\n");
212         wprintf("<TEXTAREA NAME=\"g_input\" ROWS=10 COLS=80 WIDTH=80></TEXTAREA><BR>\n");
213
214         wprintf("<FONT SIZE=-2>Detected host header is http://%s</FONT>\n",
215                 WC->http_host);
216         wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Send command\">");
217         wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\"><BR>\n");
218
219         wprintf("</FORM></CENTER>\n");
220         do_template("endbox");
221         wDumpContent(1);
222 }
223
224 void do_generic(void)
225 {
226         char buf[SIZ];
227         char gcontent[SIZ];
228         char *junk;
229         size_t len;
230
231         if (strcasecmp(bstr("sc"), "Send command")) {
232                 display_main_menu();
233                 return;
234         }
235
236         output_headers(3);
237
238         serv_printf("%s", bstr("g_cmd"));
239         serv_gets(buf);
240
241         svprintf("BOXTITLE", WCS_STRING, "Server command results");
242         do_template("beginbox");
243
244         wprintf("<TABLE border=0><TR><TD>Command:</TD><TD><TT>");
245         escputs(bstr("g_cmd"));
246         wprintf("</TT></TD></TR><TR><TD>Result:</TD><TD><TT>");
247         escputs(buf);
248         wprintf("</TT></TD></TR></TABLE><BR>\n");
249
250         if (buf[0] == '8') {
251                 serv_printf("\n\n000");
252         }
253         if ((buf[0] == '1') || (buf[0] == '8')) {
254                 while (serv_gets(gcontent), strcmp(gcontent, "000")) {
255                         escputs(gcontent);
256                         wprintf("<BR>\n");
257                 }
258                 wprintf("000");
259         }
260         if (buf[0] == '4') {
261                 text_to_server(bstr("g_input"), 0);
262                 serv_puts("000");
263         }
264         if (buf[0] == '6') {
265                 len = atol(&buf[4]);
266                 junk = malloc(len);
267                 serv_read(junk, len);
268                 free(junk);
269         }
270         if (buf[0] == '7') {
271                 len = atol(&buf[4]);
272                 junk = malloc(len);
273                 memset(junk, 0, len);
274                 serv_write(junk, len);
275                 free(junk);
276         }
277         wprintf("<HR>");
278         wprintf("<A HREF=\"/display_generic\">Enter another command</A><BR>\n");
279         wprintf("<A HREF=\"/display_advanced\">Return to menu</A>\n");
280         do_template("endbox");
281         wDumpContent(1);
282 }
283
284
285
286
287 /*
288  * Display the menubar.  Set as_single_page to
289  * display HTML headers and footers -- otherwise it's assumed
290  * that the menubar is being embedded in another page.
291  */
292 void display_menubar(int as_single_page) {
293
294         if (as_single_page) {
295                 output_headers(0);
296                 wprintf("<HTML>\n"
297                         "<HEAD>\n"
298                         "<TITLE>MenuBar</TITLE>\n"
299                         "<STYLE TYPE=\"text/css\">\n"
300                         "BODY   { text-decoration: none; }\n"
301                         "</STYLE>\n"
302                         "</HEAD>\n");
303                 do_template("background");
304         }
305
306         do_template("menubar");
307
308         if (as_single_page) {
309                 wDumpContent(2);
310         }
311
312
313 }
314
315