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