]> code.citadel.org Git - citadel.git/blob - webcit/roomops.c
debugs
[citadel.git] / webcit / roomops.c
1 /* $Id$ */
2
3 #include <stdlib.h>
4 #include <string.h>
5 #ifdef HAVE_UNISTD_H
6 #include <unistd.h>
7 #endif
8 #include <stdio.h>
9 #include <signal.h>
10 #include <sys/types.h>
11 #include "webcit.h"
12 #include "child.h"
13
14 struct march {
15         struct march *next;
16         char march_name[32];
17         };
18
19 char floorlist[128][256];
20 char ugname[128];
21 long uglsn = (-1L);
22 unsigned room_flags;
23 int is_aide = 0;
24 int is_room_aide = 0;
25
26 struct march *march = NULL;
27
28 /*
29  * load the list of floors
30  */
31 void load_floorlist(void) {
32         int a;
33         char buf[256];
34
35         for (a=0; a<128; ++a) floorlist[a][0] = 0;
36
37         serv_puts("LFLR");
38         serv_gets(buf);
39         if (buf[0]!='1') {
40                 strcpy(floorlist[0],"Main Floor");
41                 return;
42                 }
43         while (serv_gets(buf), strcmp(buf,"000")) {
44                 extract(floorlist[extract_int(buf,0)],buf,1);
45                 }
46         }
47
48
49
50 /*
51  * remove a room from the march list
52  */
53 void remove_march(char *aaa)
54 {
55         struct march *mptr,*mptr2;
56
57         if (march==NULL) return;
58
59         if (!strcasecmp(march->march_name,aaa)) {
60                 mptr = march->next;
61                 free(march);
62                 march = mptr;
63                 return;
64                 }
65
66         mptr2 = march;
67         for (mptr=march; mptr!=NULL; mptr=mptr->next) {
68                 if (!strcasecmp(mptr->march_name,aaa)) {
69                         mptr2->next = mptr->next;
70                         free(mptr);
71                         mptr=mptr2;
72                         }
73                 else {
74                         mptr2=mptr;
75                         }
76                 }
77         }
78
79
80 void listrms(char *variety)
81 {
82         char buf[256];
83         char rmname[32];
84         int f;
85
86         fprintf(stderr, "doing listrms(%s)\n", variety);
87         serv_puts(variety);
88         serv_gets(buf);
89         if (buf[0]!='1') return;
90         while (serv_gets(buf), strcmp(buf,"000")) {
91                 extract(rmname,buf,0);
92                 wprintf("<A HREF=\"/dotgoto&room=");
93                 urlescputs(rmname);
94                 wprintf("\" TARGET=\"top\">");
95                 escputs1(rmname,1);
96                 f = extract_int(buf,1);
97                 if ((f & QR_DIRECTORY) && (f & QR_NETWORK)) wprintf("}");
98                 else if (f & QR_DIRECTORY) wprintf("]");
99                 else if (f & QR_NETWORK) wprintf(")");
100                 else wprintf("&gt;");
101
102                 wprintf("</A><TT> </TT>\n");
103                 };
104         wprintf("<BR>\n");
105         }
106
107
108
109 /*
110  * list all rooms by floor
111  */
112 void list_all_rooms_by_floor(void) {
113         int a;
114         char buf[256];
115
116         load_floorlist();
117
118         printf("HTTP/1.0 200 OK\n");
119         output_headers(1);
120
121         wprintf("<TABLE width=100% border><TR><TH>Floor</TH>");
122         wprintf("<TH>Rooms with new messages</TH>");
123         wprintf("<TH>Rooms with no new messages</TH></TR>\n");
124
125         for (a=0; a<128; ++a) if (floorlist[a][0]!=0) {
126
127                 /* Floor name column */
128                 wprintf("<TR><TD>");
129         
130 /* FIX ... don't link to a floor pic that doesn't exist
131                 wprintf("<IMG SRC=\"/dynamic/_floorpic_/%d\" ALT=\"%s\">",
132                         &floorlist[a][0]);
133  */
134                 escputs(&floorlist[a][0]);
135
136                 wprintf("</TD>");
137
138                 /* Rooms with new messages column */
139                 wprintf("<TD>");
140                 sprintf(buf,"LKRN %d",a);
141                 listrms(buf);
142                 wprintf("</TD><TD>\n");
143
144                 /* Rooms with old messages column */
145                 sprintf(buf,"LKRO %d",a);
146                 listrms(buf);
147                 wprintf("</TD></TR>\n");
148                 }
149         wprintf("</TABLE>\n");
150         wprintf("</BODY></HTML>\n");
151         wDumpContent();
152         }
153
154
155 /*
156  * list all forgotten rooms
157  */
158 void zapped_list(void) {
159         printf("HTTP/1.0 200 OK\n");
160         output_headers(1);
161         wprintf("<TABLE WIDTH=100% BORDER=0 BGCOLOR=770000><TR><TD>");
162         wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
163         wprintf("<B>Zapped (forgotten) rooms</B>\n");
164         wprintf("</FONT></TD></TR></TABLE><BR>\n");
165         listrms("LZRM -1");
166         wprintf("<BR><BR>\n");
167         wprintf("Click on any room to un-zap it and goto that room.\n");
168         wprintf("</BODY></HTML>\n");
169         wDumpContent();
170         }
171         
172
173 /*
174  * read this room's info file (set v to 1 for verbose mode)
175  */
176 void readinfo(int v)
177 {
178         char buf[256];
179
180         serv_puts("RINF");
181         serv_gets(buf);
182         if (buf[0]=='1') fmout(NULL);
183         else {
184                 if (v==1) wprintf("<EM>%s</EM><BR>\n",&buf[4]);
185                 }
186         }
187
188
189 /*
190  * generic routine to take the session to a new room
191  *
192  * display_name values:  0 = goto only
193  *                       1 = goto and display
194  *                       2 = display only
195  */
196 void gotoroom(char *gname, int display_name)
197 {
198         char buf[256];
199         static long ls = (-1L);
200
201
202         if (display_name) {
203                 printf("HTTP/1.0 200 OK\n");
204                 printf("Window-target: top\n");
205                 output_headers(0);
206                 wprintf("<HTML><HEAD></HEAD><BODY \n");
207         
208                 /* automatically fire up a read-new-msgs in the bottom frame */
209                 wprintf("onload=location=\"/readnew\" ");
210                 wprintf("BACKGROUND=\"/image&name=background\" TEXT=\"#000000\" LINK=\"#004400\">\n");
211                 }
212
213         if (display_name != 2) {
214                 /* store ungoto information */
215                 strcpy(ugname, wc_roomname);
216                 uglsn = ls;
217                 }
218
219         /* move to the new room */
220         serv_printf("GOTO %s", gname);
221         serv_gets(buf);
222         if (buf[0]!='2') {
223                 serv_puts("GOTO _BASEROOM_");
224                 serv_gets(buf);
225                 }
226         if (buf[0]!='2') {
227                 if (display_name) {
228                         wprintf("<EM>%s</EM><BR>\n",&buf[4]);
229                         wDumpContent();
230                         }
231                 return;
232                 }
233
234         extract(wc_roomname,&buf[4],0);
235         room_flags = extract_int(&buf[4],4);
236         /* highest_msg_read = extract_int(&buf[4],6);
237         maxmsgnum = extract_int(&buf[4],5);
238         is_mail = (char) extract_int(&buf[4],7); */
239         ls = extract_long(&buf[4], 6);
240
241         if (is_aide) is_room_aide = is_aide;
242         else is_room_aide = (char) extract_int(&buf[4],8);
243
244         remove_march(wc_roomname);
245         if (!strcasecmp(gname,"_BASEROOM_")) remove_march(gname);
246
247         /* Display the room banner */
248         if (display_name) {
249                 wprintf("<CENTER><TABLE border=0><TR>");
250
251                 if ( (strlen(ugname)>0) && (strcasecmp(ugname,wc_roomname)) ) {
252                         wprintf("<TD><A HREF=\"/ungoto\">");
253                         wprintf("<IMG SRC=\"/static/back.gif\" border=0></A></TD>");
254
255                         wprintf("<TD><H1>%s</H1>",wc_roomname);
256                         wprintf("<FONT SIZE=-1>%d new of %d messages</FONT></TD>\n",
257                                 extract_int(&buf[4],1),
258                                 extract_int(&buf[4],2));
259
260                         /* Display room graphic.  The server doesn't actually
261                          * need the room name, but we supply it in order to
262                          * keep the browser from using a cached graphic from 
263                          * another room.
264                          */
265                         serv_puts("OIMG _roompic_");
266                         serv_gets(buf);
267                         if (buf[0]=='2') {
268                                 wprintf("<TD>");
269                                 wprintf("<IMG SRC=\"/image&name=_roompic_&room=");
270                                 escputs(wc_roomname);
271                                 wprintf("\"></TD>");
272                                 serv_puts("CLOS");
273                                 serv_gets(buf);
274                                 }
275
276                         wprintf("<TD>");
277                         readinfo(0);
278                         wprintf("</TD>");
279
280                         wprintf("<TD><A HREF=\"/gotonext\">");
281                         wprintf("<IMG SRC=\"/static/forward.gif\" border=0></A></TD>");
282
283                         wprintf("</TR></TABLE></CENTER>\n");
284                         }
285                 wprintf("</BODY></HTML>\n");
286                 wDumpContent();
287                 }
288
289         strcpy(wc_roomname, wc_roomname);
290         }
291
292
293 /*
294  * operation to goto a room
295  */
296 void dotgoto(void) {
297         gotoroom(bstr("room"), 1);
298         }
299
300
301 /* Goto next room having unread messages.
302  * We want to skip over rooms that the user has already been to, and take the
303  * user back to the lobby when done.  The room we end up in is placed in
304  * newroom - which is set to 0 (the lobby) initially.
305  * We start the search in the current room rather than the beginning to prevent
306  * two or more concurrent users from dragging each other back to the same room.
307  */
308 void gotonext(void) {
309         char buf[256];
310         struct march *mptr,*mptr2;
311         char next_room[32];
312
313         /* First check to see if the march-mode list is already allocated.
314          * If it is, pop the first room off the list and go there.
315          */
316
317         if (march==NULL) {
318                 serv_puts("LKRN");
319                 serv_gets(buf);
320                 if (buf[0]=='1')
321                     while (serv_gets(buf), strcmp(buf,"000")) {
322                         mptr = (struct march *) malloc(sizeof(struct march));
323                         mptr->next = NULL;
324                         extract(mptr->march_name,buf,0);
325                         if (march==NULL) {
326                                 march = mptr;
327                                 }
328                         else {
329                                 mptr2 = march;
330                                 while (mptr2->next != NULL)
331                                         mptr2 = mptr2->next;
332                                 mptr2->next = mptr;
333                                 }
334                         }
335
336 /* add _BASEROOM_ to the end of the march list, so the user will end up
337  * in the system base room (usually the Lobby>) at the end of the loop
338  */
339                 mptr = (struct march *) malloc(sizeof(struct march));
340                 mptr->next = NULL;
341                 strcpy(mptr->march_name,"_BASEROOM_");
342                 if (march==NULL) {
343                         march = mptr;
344                         }
345                 else {
346                         mptr2 = march;
347                         while (mptr2->next != NULL)
348                                 mptr2 = mptr2->next;
349                         mptr2->next = mptr;
350                         }
351 /*
352  * ...and remove the room we're currently in, so a <G>oto doesn't make us
353  * walk around in circles
354  */
355                 remove_march(wc_roomname);
356                 }
357
358
359         if (march!=NULL) {
360                 strcpy(next_room,march->march_name);
361                 }
362         else {
363                 strcpy(next_room,"_BASEROOM_");
364                 }
365         gotoroom(next_room,1);
366    }
367
368
369
370 /*
371  * mark all messages in current room as having been read
372  */
373 void slrp_highest(void) {
374         char buf[256];
375
376         /* set pointer */
377         serv_puts("SLRP HIGHEST");
378         serv_gets(buf);
379         if (buf[0]!='2') {
380                 wprintf("<EM>%s</EM><BR>\n",&buf[4]);
381                 return;
382                 }
383         }
384
385
386 /*
387  * un-goto the previous room
388  */
389 void ungoto(void) { 
390         char buf[256];
391         
392         if (!strcmp(ugname, "")) {
393                 gotoroom(wc_roomname, 1);
394                 return;
395                 }
396         serv_printf("GOTO %s", ugname);
397         serv_gets(buf);
398         if (buf[0]!='2') {
399                 gotoroom(wc_roomname, 1);
400                 return;
401                 }
402         if (uglsn >= 0L) {
403                 serv_printf("SLRP %ld",uglsn);
404                 serv_gets(buf);
405                 }
406         strcpy(buf,ugname);
407         strcpy(ugname, "");
408         gotoroom(buf,1);
409         }
410
411 /*
412  * display the form for editing a room
413  */
414 void display_editroom(void) {
415         char buf[256];
416         char er_name[20];
417         char er_password[10];
418         char er_dirname[15];
419         char er_roomaide[26];
420         unsigned er_flags;
421
422         serv_puts("GETR");
423         serv_gets(buf);
424
425         if (buf[0]!='2') {
426                 display_error(&buf[4]);
427                 return;
428                 }
429
430         extract(er_name,&buf[4],0);
431         extract(er_password,&buf[4],1);
432         extract(er_dirname,&buf[4],2);
433         er_flags=extract_int(&buf[4],3);
434
435
436         printf("HTTP/1.0 200 OK\n");
437         output_headers(1);
438
439         wprintf("<TABLE WIDTH=100% BORDER=0 BGCOLOR=000077><TR><TD>");
440         wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
441         wprintf("<B>Edit this room</B>\n");
442         wprintf("</FONT></TD></TR></TABLE>\n");
443
444         wprintf("<FORM METHOD=\"POST\" ACTION=\"/editroom\">\n");
445
446         wprintf("<UL><LI>Name of room: ");      
447         wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\"19\">\n",er_name);
448
449         wprintf("<LI>Type of room:<UL>\n");
450
451         wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
452         if ((er_flags & QR_PRIVATE) == 0) wprintf("CHECKED ");
453         wprintf("> Public room\n");
454
455         wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"guessname\" ");
456         if ((er_flags & QR_PRIVATE)&&
457            (er_flags & QR_GUESSNAME)) wprintf("CHECKED ");
458         wprintf("> Private - guess name\n");
459
460         wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
461         if ((er_flags & QR_PRIVATE)&&
462            (er_flags & QR_PASSWORDED)) wprintf("CHECKED ");
463         wprintf("> Private - require password:\n");
464         wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n",er_password);
465
466         wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
467         if ( (er_flags & QR_PRIVATE)
468            && ((er_flags & QR_GUESSNAME) == 0)
469            && ((er_flags & QR_PASSWORDED) == 0) )
470                 wprintf("CHECKED ");
471         wprintf("> Private - invitation only\n");
472
473         wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
474         wprintf("> If private, cause current users to forget room\n");
475
476         wprintf("</UL>\n");
477
478         wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
479         if (er_flags & QR_PREFONLY) wprintf("CHECKED ");
480         wprintf("> Preferred users only\n");
481
482         wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
483         if (er_flags & QR_READONLY) wprintf("CHECKED ");
484         wprintf("> Read-only room\n");
485
486 /* directory stuff */
487         wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
488         if (er_flags & QR_DIRECTORY) wprintf("CHECKED ");
489         wprintf("> File directory room\n");
490
491         wprintf("<UL><LI>Directory name: ");
492         wprintf("<INPUT TYPE=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n",er_dirname);
493
494         wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
495         if (er_flags & QR_UPLOAD) wprintf("CHECKED ");
496         wprintf("> Uploading allowed\n");
497
498         wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
499         if (er_flags & QR_DOWNLOAD) wprintf("CHECKED ");
500         wprintf("> Downloading allowed\n");
501
502         wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
503         if (er_flags & QR_VISDIR) wprintf("CHECKED ");
504         wprintf("> Visible directory</UL>\n");
505
506 /* end of directory stuff */
507         
508         wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
509         if (er_flags & QR_NETWORK) wprintf("CHECKED ");
510         wprintf("> Network shared room\n");
511
512 /* start of anon options */
513
514         wprintf("<LI>Anonymous messages<UL>\n");
515         
516         wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
517         if ( ((er_flags & QR_ANONONLY)==0)
518            && ((er_flags & QR_ANONOPT)==0)) wprintf("CHECKED ");
519         wprintf("> No anonymous messages\n");
520
521         wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
522         if (er_flags & QR_ANONONLY) wprintf("CHECKED ");
523         wprintf("> All messages are anonymous\n");
524
525         wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
526         if (er_flags & QR_ANONOPT) wprintf("CHECKED ");
527         wprintf("> Prompt user when entering messages</UL>\n");
528
529 /* end of anon options */
530
531         wprintf("<LI>Room aide: \n");
532         serv_puts("GETA");
533         serv_gets(buf);
534         if (buf[0]!='2') {
535                 wprintf("<EM>%s</EM>\n",&buf[4]);
536                 }
537         else {
538                 extract(er_roomaide,&buf[4],0);
539                 wprintf("<INPUT TYPE=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n",er_roomaide);
540                 }
541                 
542         wprintf("</UL><CENTER>\n");
543         wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
544         wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
545         wprintf("</CENTER>\n");
546
547         wprintf("</FORM></HTML>\n");
548         wDumpContent();
549         }
550
551
552 /*
553  * save new parameters for a room
554  */
555 void editroom(void) {
556         char buf[256];
557         char er_name[20];
558         char er_password[10];
559         char er_dirname[15];
560         char er_roomaide[26];
561         unsigned er_flags;
562         int bump;
563
564
565         if (strcmp(bstr("sc"),"OK")) {
566                 display_error("Cancelled.  Changes were not saved.");
567                 return;
568                 }
569         
570         serv_puts("GETR");
571         serv_gets(buf);
572
573         if (buf[0]!='2') {
574                 display_error(&buf[4]);
575                 return;
576                 }
577
578         extract(er_name,&buf[4],0);
579         extract(er_password,&buf[4],1);
580         extract(er_dirname,&buf[4],2);
581         er_flags=extract_int(&buf[4],3);
582
583         strcpy(er_roomaide,bstr("er_roomaide"));
584         if (strlen(er_roomaide)==0) {
585                 serv_puts("GETA");
586                 serv_gets(buf);
587                 if (buf[0]!='2') {
588                         strcpy(er_roomaide,"");
589                         }
590                 else {
591                         extract(er_roomaide,&buf[4],0);
592                         }
593                 }
594
595         strcpy(buf,bstr("er_name"));            buf[20] = 0;
596         if (strlen(buf)>0) strcpy(er_name,buf);
597
598         strcpy(buf,bstr("er_password"));        buf[10] = 0;
599         if (strlen(buf)>0) strcpy(er_password,buf);
600
601         strcpy(buf,bstr("er_dirname"));         buf[15] = 0;
602         if (strlen(buf)>0) strcpy(er_dirname,buf);
603
604         strcpy(buf,bstr("type"));
605         er_flags &= !(QR_PRIVATE|QR_PASSWORDED|QR_GUESSNAME);
606
607         if (!strcmp(buf,"invonly")) {
608                 er_flags |= (QR_PRIVATE);
609                 }
610         if (!strcmp(buf,"guessname")) {
611                 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
612                 }
613         if (!strcmp(buf,"passworded")) {
614                 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
615                 }
616
617         if (!strcmp(bstr("prefonly"),"yes")) {
618                 er_flags |= QR_PREFONLY;
619                 }
620         else {
621                 er_flags &= ~QR_PREFONLY;
622                 }
623
624         if (!strcmp(bstr("readonly"),"yes")) {
625                 er_flags |= QR_READONLY;
626                 }
627         else {
628                 er_flags &= ~QR_READONLY;
629                 }
630
631         if (!strcmp(bstr("network"),"yes")) {
632                 er_flags |= QR_NETWORK;
633                 }
634         else {
635                 er_flags &= ~QR_NETWORK;
636                 }
637
638         if (!strcmp(bstr("directory"),"yes")) {
639                 er_flags |= QR_DIRECTORY;
640                 }
641         else {
642                 er_flags &= ~QR_DIRECTORY;
643                 }
644
645         if (!strcmp(bstr("ulallowed"),"yes")) {
646                 er_flags |= QR_UPLOAD;
647                 }
648         else {
649                 er_flags &= ~QR_UPLOAD;
650                 }
651
652         if (!strcmp(bstr("dlallowed"),"yes")) {
653                 er_flags |= QR_DOWNLOAD;
654                 }
655         else {
656                 er_flags &= ~QR_DOWNLOAD;
657                 }
658
659         if (!strcmp(bstr("visdir"),"yes")) {
660                 er_flags |= QR_VISDIR;
661                 }
662         else {
663                 er_flags &= ~QR_VISDIR;
664                 }
665
666         strcpy(buf,bstr("anon"));
667
668         er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
669         if (!strcmp(buf,"anononly")) er_flags |= QR_ANONONLY;
670         if (!strcmp(buf,"anon2")) er_flags |= QR_ANONOPT;
671
672         bump = 0;
673         if (!strcmp(bstr("bump"),"yes")) bump = 1;
674
675         sprintf(buf,"SETR %s|%s|%s|%u|%d",
676                 er_name,er_password,er_dirname,er_flags,bump);
677         serv_puts(buf);
678         serv_gets(buf);
679         if (buf[0]!='2') {
680                 display_error(&buf[4]);
681                 return;
682                 }
683         gotoroom(er_name, 0);
684
685         if (strlen(er_roomaide)>0) {
686                 sprintf(buf,"SETA %s",er_roomaide);
687                 serv_puts(buf);
688                 serv_gets(buf);
689                 if (buf[0]!='2') {
690                         display_error(&buf[4]);
691                         return;
692                         }
693                 }
694
695         gotoroom(er_name, 1);
696         }
697
698
699
700 /*
701  * display the form for entering a new room
702  */
703 void display_entroom(void) {
704         char buf[256];
705
706         serv_puts("CRE8 0");
707         serv_gets(buf);
708         
709         if (buf[0]!='2') {
710                 display_error(&buf[4]);
711                 return;
712                 }
713
714         printf("HTTP/1.0 200 OK\n");
715         output_headers(1);
716
717         wprintf("<TABLE WIDTH=100% BORDER=0 BGCOLOR=000077><TR><TD>");
718         wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
719         wprintf("<B>Enter (create) a new room</B>\n");
720         wprintf("</FONT></TD></TR></TABLE>\n");
721
722         wprintf("<FORM METHOD=\"POST\" ACTION=\"/entroom\">\n");
723
724         wprintf("<UL><LI>Name of room: ");      
725         wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" MAXLENGTH=\"19\">\n");
726
727         wprintf("<LI>Type of room:<UL>\n");
728
729         wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
730         wprintf("CHECKED > Public room\n");
731
732         wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"guessname\" ");
733         wprintf("> Private - guess name\n");
734
735         wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
736         wprintf("> Private - require password:\n");
737         wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
738
739         wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
740         wprintf("> Private - invitation only\n");
741
742         wprintf("<CENTER>\n");
743         wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
744         wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
745         wprintf("</CENTER>\n");
746         wprintf("</FORM></HTML>\n");
747         wDumpContent();
748         }
749
750
751
752 /*
753  * enter a new room
754  */
755 void entroom(void) {
756         char buf[256];
757         char er_name[20];
758         char er_type[20];
759         char er_password[10];
760         int er_num_type;
761
762         if (strcmp(bstr("sc"),"OK")) {
763                 display_error("Cancelled.  No new room was created.");
764                 return;
765                 }
766         
767         strcpy(er_name,bstr("er_name"));
768         strcpy(er_type,bstr("type"));
769         strcpy(er_password,bstr("er_password"));
770
771         er_num_type = 0;
772         if (!strcmp(er_type,"guessname")) er_num_type = 1;
773         if (!strcmp(er_type,"passworded")) er_num_type = 2;
774         if (!strcmp(er_type,"invonly")) er_num_type = 3;
775
776         sprintf(buf,"CRE8 1|%s|%d|%s",er_name,er_num_type,er_password);
777         serv_puts(buf);
778         serv_gets(buf);
779         if (buf[0]!='2') {
780                 display_error(&buf[4]);
781                 return;
782                 }
783         gotoroom(er_name, 1);
784         }
785
786
787 /*
788  * display the screen to enter a private room
789  */
790 void display_private(char *rname, int req_pass)
791 {
792
793         printf("HTTP/1.0 200 OK\n");
794         output_headers(1);
795
796         wprintf("<TABLE WIDTH=100% BORDER=0 BGCOLOR=770000><TR><TD>");
797         wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
798         wprintf("<B>Goto a private room</B>\n");
799         wprintf("</FONT></TD></TR></TABLE>\n");
800
801         wprintf("<CENTER>\n");
802         wprintf("If you know the name of a hidden (guess-name) or\n");
803         wprintf("passworded room, you can enter that room by typing\n");
804         wprintf("its name below.  Once you gain access to a private\n");
805         wprintf("room, it will appear in your regular room listings\n");
806         wprintf("so you don't have to keep returning here.\n");
807         wprintf("<BR><BR>");
808         
809         wprintf("<FORM METHOD=\"POST\" ACTION=\"/goto_private\">\n");
810
811         wprintf("<TABLE border><TR><TD>");
812         wprintf("Enter room name:</TD><TD>");
813         wprintf("<INPUT TYPE=\"text\" NAME=\"gr_name\" VALUE=\"%s\" MAXLENGTH=\"19\">\n",rname);
814
815         if (req_pass) {
816                 wprintf("</TD></TR><TR><TD>");
817                 wprintf("Enter room password:</TD><TD>");
818                 wprintf("<INPUT TYPE=\"password\" NAME=\"gr_pass\" MAXLENGTH=\"9\">\n");
819                 }
820
821         wprintf("</TD></TR></TABLE>\n");
822         
823         wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
824         wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
825         wprintf("</FORM></HTML>\n");
826         wDumpContent();
827         }
828
829 /* 
830  * goto a private room
831  */
832 void goto_private(void) {
833         char hold_rm[32];
834         char buf[256];
835         
836         if (strcasecmp(bstr("sc"),"OK")) {
837                 display_main_menu();
838                 return;
839                 }
840
841         strcpy(hold_rm,wc_roomname);
842         strcpy(buf,"GOTO ");
843         strcat(buf,bstr("gr_name"));
844         strcat(buf,"|");
845         strcat(buf,bstr("gr_pass"));
846         serv_puts(buf);
847         serv_gets(buf);
848
849         if (buf[0]=='2') {
850                 gotoroom(bstr("gr_name"),1);
851                 return;
852                 }
853
854         if (!strncmp(buf,"540",3)) {
855                 display_private(bstr("gr_name"),1);
856                 return;
857                 }
858
859         printf("HTTP/1.0 200 OK\n");
860         output_headers(1);
861         wprintf("%s\n",&buf[4]);
862         wDumpContent();
863         return;
864         }
865
866
867 /*
868  * display the screen to zap a room
869  */
870 void display_zap(void) {
871         printf("HTTP/1.0 200 OK\n");
872         output_headers(1);
873         
874         wprintf("<TABLE WIDTH=100% BORDER=0 BGCOLOR=770000><TR><TD>");
875         wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
876         wprintf("<B>Zap (forget) the current room</B>\n");
877         wprintf("</FONT></TD></TR></TABLE>\n");
878
879         wprintf("If you select this option, <em>%s</em> will ", wc_roomname);
880         wprintf("disappear from your room list.  Is this what you wish ");
881         wprintf("to do?<BR>\n");
882
883         wprintf("<FORM METHOD=\"POST\" ACTION=\"/zap\">\n");
884         wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
885         wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
886         wprintf("</FORM></HTML>\n");
887         wDumpContent();
888         }
889
890
891 /* 
892  * zap a room
893  */
894 void zap(void) {
895         char buf[256];
896
897         if (strcmp(bstr("sc"),"OK")) {
898                 display_main_menu();
899                 return;
900                 }
901
902         serv_printf("GOTO %s", wc_roomname);
903         serv_gets(buf);
904         if (buf[0] != '2') {
905                 display_error(&buf[4]);
906                 return;
907                 }
908
909         serv_puts("FORG");
910         serv_gets(buf);
911         if (buf[0] != '2') {
912                 display_error(&buf[4]);
913                 return;
914                 }
915
916         gotoroom(bstr("_BASEROOM_"),1);
917         }