]> code.citadel.org Git - citadel.git/blob - webcit/roomops.c
ab5aa3c9d95d5ed9d4562e57497be23231a7c867
[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>\n<BODY ");
207         
208                 /* automatically fire up a read-new-msgs in the bottom frame */
209                 wprintf("onload=location=\"/readnew\" ");
210
211                 wprintf("BACKGROUND=\"/image&name=background\" TEXT=\"#000000\" LINK=\"#004400\">\n");
212                 }
213
214         if (display_name != 2) {
215                 /* store ungoto information */
216                 strcpy(ugname, wc_roomname);
217                 uglsn = ls;
218                 }
219
220         /* move to the new room */
221         serv_printf("GOTO %s", gname);
222         serv_gets(buf);
223         if (buf[0]!='2') {
224                 serv_puts("GOTO _BASEROOM_");
225                 serv_gets(buf);
226                 }
227         if (buf[0]!='2') {
228                 if (display_name) {
229                         wprintf("<EM>%s</EM><BR></BODY></HTML>\n",&buf[4]);
230                         wDumpContent();
231                         }
232                 return;
233                 }
234
235         extract(wc_roomname,&buf[4],0);
236         room_flags = extract_int(&buf[4],4);
237         /* highest_msg_read = extract_int(&buf[4],6);
238         maxmsgnum = extract_int(&buf[4],5);
239         is_mail = (char) extract_int(&buf[4],7); */
240         ls = extract_long(&buf[4], 6);
241
242         if (is_aide) is_room_aide = is_aide;
243         else is_room_aide = (char) extract_int(&buf[4],8);
244
245         remove_march(wc_roomname);
246         if (!strcasecmp(gname,"_BASEROOM_")) remove_march(gname);
247
248         /* Display the room banner */
249         if (display_name) {
250                 wprintf("<CENTER><TABLE border=0><TR>");
251
252                 if ( (strlen(ugname)>0) && (strcasecmp(ugname,wc_roomname)) ) {
253                         wprintf("<TD><A HREF=\"/ungoto\">");
254                         wprintf("<IMG SRC=\"/static/back.gif\" border=0></A></TD>");
255                         }
256
257                 wprintf("<TD><H1>%s</H1>",wc_roomname);
258                 wprintf("<FONT SIZE=-1>%d new of %d messages</FONT></TD>\n",
259                         extract_int(&buf[4],1),
260                         extract_int(&buf[4],2));
261
262                 /* Display room graphic.  The server doesn't actually
263                  * need the room name, but we supply it in order to
264                  * keep the browser from using a cached graphic from 
265                  * another room.
266                  */
267                 serv_puts("OIMG _roompic_");
268                 serv_gets(buf);
269                 if (buf[0]=='2') {
270                         wprintf("<TD>");
271                         wprintf("<IMG SRC=\"/image&name=_roompic_&room=");
272                         escputs(wc_roomname);
273                         wprintf("\"></TD>");
274                         serv_puts("CLOS");
275                         serv_gets(buf);
276                         }
277
278                 wprintf("<TD>");
279                 readinfo(0);
280                 wprintf("</TD>");
281
282                 wprintf("<TD><A HREF=\"/gotonext\">");
283                 wprintf("<IMG SRC=\"/static/forward.gif\" border=0></A></TD>");
284                 wprintf("</TR></TABLE></CENTER>\n");
285                 wprintf("</BODY></HTML>\n");
286                 wDumpContent();
287                 }
288
289         strcpy(wc_roomname, wc_roomname);
290         }
291
292
293
294 /* Goto next room having unread messages.
295  * We want to skip over rooms that the user has already been to, and take the
296  * user back to the lobby when done.  The room we end up in is placed in
297  * newroom - which is set to 0 (the lobby) initially.
298  * We start the search in the current room rather than the beginning to prevent
299  * two or more concurrent users from dragging each other back to the same room.
300  */
301 void gotonext(void) {
302         char buf[256];
303         struct march *mptr,*mptr2;
304         char next_room[32];
305
306         /* First check to see if the march-mode list is already allocated.
307          * If it is, pop the first room off the list and go there.
308          */
309
310         if (march==NULL) {
311                 serv_puts("LKRN");
312                 serv_gets(buf);
313                 if (buf[0]=='1')
314                     while (serv_gets(buf), strcmp(buf,"000")) {
315                         mptr = (struct march *) malloc(sizeof(struct march));
316                         mptr->next = NULL;
317                         extract(mptr->march_name,buf,0);
318                         if (march==NULL) {
319                                 march = mptr;
320                                 }
321                         else {
322                                 mptr2 = march;
323                                 while (mptr2->next != NULL)
324                                         mptr2 = mptr2->next;
325                                 mptr2->next = mptr;
326                                 }
327                         }
328
329 /* add _BASEROOM_ to the end of the march list, so the user will end up
330  * in the system base room (usually the Lobby>) at the end of the loop
331  */
332                 mptr = (struct march *) malloc(sizeof(struct march));
333                 mptr->next = NULL;
334                 strcpy(mptr->march_name,"_BASEROOM_");
335                 if (march==NULL) {
336                         march = mptr;
337                         }
338                 else {
339                         mptr2 = march;
340                         while (mptr2->next != NULL)
341                                 mptr2 = mptr2->next;
342                         mptr2->next = mptr;
343                         }
344 /*
345  * ...and remove the room we're currently in, so a <G>oto doesn't make us
346  * walk around in circles
347  */
348                 remove_march(wc_roomname);
349                 }
350
351
352         if (march!=NULL) {
353                 strcpy(next_room,march->march_name);
354                 }
355         else {
356                 strcpy(next_room,"_BASEROOM_");
357                 }
358         gotoroom(next_room,1);
359    }
360
361
362
363 /*
364  * mark all messages in current room as having been read
365  */
366 void slrp_highest(void) {
367         char buf[256];
368
369         /* set pointer */
370         serv_puts("SLRP HIGHEST");
371         serv_gets(buf);
372         if (buf[0]!='2') {
373                 wprintf("<EM>%s</EM><BR>\n",&buf[4]);
374                 return;
375                 }
376         }
377
378
379 /*
380  * un-goto the previous room
381  */
382 void ungoto(void) { 
383         char buf[256];
384         
385         if (!strcmp(ugname, "")) {
386                 gotoroom(wc_roomname, 1);
387                 return;
388                 }
389         serv_printf("GOTO %s", ugname);
390         serv_gets(buf);
391         if (buf[0]!='2') {
392                 gotoroom(wc_roomname, 1);
393                 return;
394                 }
395         if (uglsn >= 0L) {
396                 serv_printf("SLRP %ld",uglsn);
397                 serv_gets(buf);
398                 }
399         strcpy(buf,ugname);
400         strcpy(ugname, "");
401         gotoroom(buf,1);
402         }
403
404 /*
405  * display the form for editing a room
406  */
407 void display_editroom(void) {
408         char buf[256];
409         char er_name[20];
410         char er_password[10];
411         char er_dirname[15];
412         char er_roomaide[26];
413         unsigned er_flags;
414
415         serv_puts("GETR");
416         serv_gets(buf);
417
418         if (buf[0]!='2') {
419                 display_error(&buf[4]);
420                 return;
421                 }
422
423         extract(er_name,&buf[4],0);
424         extract(er_password,&buf[4],1);
425         extract(er_dirname,&buf[4],2);
426         er_flags=extract_int(&buf[4],3);
427
428
429         printf("HTTP/1.0 200 OK\n");
430         output_headers(1);
431
432         wprintf("<TABLE WIDTH=100% BORDER=0 BGCOLOR=000077><TR><TD>");
433         wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
434         wprintf("<B>Edit this room</B>\n");
435         wprintf("</FONT></TD></TR></TABLE>\n");
436
437         wprintf("<FORM METHOD=\"POST\" ACTION=\"/editroom\">\n");
438
439         wprintf("<UL><LI>Name of room: ");      
440         wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\"19\">\n",er_name);
441
442         wprintf("<LI>Type of room:<UL>\n");
443
444         wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
445         if ((er_flags & QR_PRIVATE) == 0) wprintf("CHECKED ");
446         wprintf("> Public room\n");
447
448         wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"guessname\" ");
449         if ((er_flags & QR_PRIVATE)&&
450            (er_flags & QR_GUESSNAME)) wprintf("CHECKED ");
451         wprintf("> Private - guess name\n");
452
453         wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
454         if ((er_flags & QR_PRIVATE)&&
455            (er_flags & QR_PASSWORDED)) wprintf("CHECKED ");
456         wprintf("> Private - require password:\n");
457         wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n",er_password);
458
459         wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
460         if ( (er_flags & QR_PRIVATE)
461            && ((er_flags & QR_GUESSNAME) == 0)
462            && ((er_flags & QR_PASSWORDED) == 0) )
463                 wprintf("CHECKED ");
464         wprintf("> Private - invitation only\n");
465
466         wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
467         wprintf("> If private, cause current users to forget room\n");
468
469         wprintf("</UL>\n");
470
471         wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
472         if (er_flags & QR_PREFONLY) wprintf("CHECKED ");
473         wprintf("> Preferred users only\n");
474
475         wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
476         if (er_flags & QR_READONLY) wprintf("CHECKED ");
477         wprintf("> Read-only room\n");
478
479 /* directory stuff */
480         wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
481         if (er_flags & QR_DIRECTORY) wprintf("CHECKED ");
482         wprintf("> File directory room\n");
483
484         wprintf("<UL><LI>Directory name: ");
485         wprintf("<INPUT TYPE=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n",er_dirname);
486
487         wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
488         if (er_flags & QR_UPLOAD) wprintf("CHECKED ");
489         wprintf("> Uploading allowed\n");
490
491         wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
492         if (er_flags & QR_DOWNLOAD) wprintf("CHECKED ");
493         wprintf("> Downloading allowed\n");
494
495         wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
496         if (er_flags & QR_VISDIR) wprintf("CHECKED ");
497         wprintf("> Visible directory</UL>\n");
498
499 /* end of directory stuff */
500         
501         wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
502         if (er_flags & QR_NETWORK) wprintf("CHECKED ");
503         wprintf("> Network shared room\n");
504
505 /* start of anon options */
506
507         wprintf("<LI>Anonymous messages<UL>\n");
508         
509         wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
510         if ( ((er_flags & QR_ANONONLY)==0)
511            && ((er_flags & QR_ANONOPT)==0)) wprintf("CHECKED ");
512         wprintf("> No anonymous messages\n");
513
514         wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
515         if (er_flags & QR_ANONONLY) wprintf("CHECKED ");
516         wprintf("> All messages are anonymous\n");
517
518         wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
519         if (er_flags & QR_ANONOPT) wprintf("CHECKED ");
520         wprintf("> Prompt user when entering messages</UL>\n");
521
522 /* end of anon options */
523
524         wprintf("<LI>Room aide: \n");
525         serv_puts("GETA");
526         serv_gets(buf);
527         if (buf[0]!='2') {
528                 wprintf("<EM>%s</EM>\n",&buf[4]);
529                 }
530         else {
531                 extract(er_roomaide,&buf[4],0);
532                 wprintf("<INPUT TYPE=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n",er_roomaide);
533                 }
534                 
535         wprintf("</UL><CENTER>\n");
536         wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
537         wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
538         wprintf("</CENTER>\n");
539
540         wprintf("</FORM></HTML>\n");
541         wDumpContent();
542         }
543
544
545 /*
546  * save new parameters for a room
547  */
548 void editroom(void) {
549         char buf[256];
550         char er_name[20];
551         char er_password[10];
552         char er_dirname[15];
553         char er_roomaide[26];
554         unsigned er_flags;
555         int bump;
556
557
558         if (strcmp(bstr("sc"),"OK")) {
559                 display_error("Cancelled.  Changes were not saved.");
560                 return;
561                 }
562         
563         serv_puts("GETR");
564         serv_gets(buf);
565
566         if (buf[0]!='2') {
567                 display_error(&buf[4]);
568                 return;
569                 }
570
571         extract(er_name,&buf[4],0);
572         extract(er_password,&buf[4],1);
573         extract(er_dirname,&buf[4],2);
574         er_flags=extract_int(&buf[4],3);
575
576         strcpy(er_roomaide,bstr("er_roomaide"));
577         if (strlen(er_roomaide)==0) {
578                 serv_puts("GETA");
579                 serv_gets(buf);
580                 if (buf[0]!='2') {
581                         strcpy(er_roomaide,"");
582                         }
583                 else {
584                         extract(er_roomaide,&buf[4],0);
585                         }
586                 }
587
588         strcpy(buf,bstr("er_name"));            buf[20] = 0;
589         if (strlen(buf)>0) strcpy(er_name,buf);
590
591         strcpy(buf,bstr("er_password"));        buf[10] = 0;
592         if (strlen(buf)>0) strcpy(er_password,buf);
593
594         strcpy(buf,bstr("er_dirname"));         buf[15] = 0;
595         if (strlen(buf)>0) strcpy(er_dirname,buf);
596
597         strcpy(buf,bstr("type"));
598         er_flags &= !(QR_PRIVATE|QR_PASSWORDED|QR_GUESSNAME);
599
600         if (!strcmp(buf,"invonly")) {
601                 er_flags |= (QR_PRIVATE);
602                 }
603         if (!strcmp(buf,"guessname")) {
604                 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
605                 }
606         if (!strcmp(buf,"passworded")) {
607                 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
608                 }
609
610         if (!strcmp(bstr("prefonly"),"yes")) {
611                 er_flags |= QR_PREFONLY;
612                 }
613         else {
614                 er_flags &= ~QR_PREFONLY;
615                 }
616
617         if (!strcmp(bstr("readonly"),"yes")) {
618                 er_flags |= QR_READONLY;
619                 }
620         else {
621                 er_flags &= ~QR_READONLY;
622                 }
623
624         if (!strcmp(bstr("network"),"yes")) {
625                 er_flags |= QR_NETWORK;
626                 }
627         else {
628                 er_flags &= ~QR_NETWORK;
629                 }
630
631         if (!strcmp(bstr("directory"),"yes")) {
632                 er_flags |= QR_DIRECTORY;
633                 }
634         else {
635                 er_flags &= ~QR_DIRECTORY;
636                 }
637
638         if (!strcmp(bstr("ulallowed"),"yes")) {
639                 er_flags |= QR_UPLOAD;
640                 }
641         else {
642                 er_flags &= ~QR_UPLOAD;
643                 }
644
645         if (!strcmp(bstr("dlallowed"),"yes")) {
646                 er_flags |= QR_DOWNLOAD;
647                 }
648         else {
649                 er_flags &= ~QR_DOWNLOAD;
650                 }
651
652         if (!strcmp(bstr("visdir"),"yes")) {
653                 er_flags |= QR_VISDIR;
654                 }
655         else {
656                 er_flags &= ~QR_VISDIR;
657                 }
658
659         strcpy(buf,bstr("anon"));
660
661         er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
662         if (!strcmp(buf,"anononly")) er_flags |= QR_ANONONLY;
663         if (!strcmp(buf,"anon2")) er_flags |= QR_ANONOPT;
664
665         bump = 0;
666         if (!strcmp(bstr("bump"),"yes")) bump = 1;
667
668         sprintf(buf,"SETR %s|%s|%s|%u|%d",
669                 er_name,er_password,er_dirname,er_flags,bump);
670         serv_puts(buf);
671         serv_gets(buf);
672         if (buf[0]!='2') {
673                 display_error(&buf[4]);
674                 return;
675                 }
676         gotoroom(er_name, 0);
677
678         if (strlen(er_roomaide)>0) {
679                 sprintf(buf,"SETA %s",er_roomaide);
680                 serv_puts(buf);
681                 serv_gets(buf);
682                 if (buf[0]!='2') {
683                         display_error(&buf[4]);
684                         return;
685                         }
686                 }
687
688         gotoroom(er_name, 1);
689         }
690
691
692
693 /*
694  * display the form for entering a new room
695  */
696 void display_entroom(void) {
697         char buf[256];
698
699         serv_puts("CRE8 0");
700         serv_gets(buf);
701         
702         if (buf[0]!='2') {
703                 display_error(&buf[4]);
704                 return;
705                 }
706
707         printf("HTTP/1.0 200 OK\n");
708         output_headers(1);
709
710         wprintf("<TABLE WIDTH=100% BORDER=0 BGCOLOR=000077><TR><TD>");
711         wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
712         wprintf("<B>Enter (create) a new room</B>\n");
713         wprintf("</FONT></TD></TR></TABLE>\n");
714
715         wprintf("<FORM METHOD=\"POST\" ACTION=\"/entroom\">\n");
716
717         wprintf("<UL><LI>Name of room: ");      
718         wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" MAXLENGTH=\"19\">\n");
719
720         wprintf("<LI>Type of room:<UL>\n");
721
722         wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
723         wprintf("CHECKED > Public room\n");
724
725         wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"guessname\" ");
726         wprintf("> Private - guess name\n");
727
728         wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
729         wprintf("> Private - require password:\n");
730         wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
731
732         wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
733         wprintf("> Private - invitation only\n");
734
735         wprintf("<CENTER>\n");
736         wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
737         wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
738         wprintf("</CENTER>\n");
739         wprintf("</FORM></HTML>\n");
740         wDumpContent();
741         }
742
743
744
745 /*
746  * enter a new room
747  */
748 void entroom(void) {
749         char buf[256];
750         char er_name[20];
751         char er_type[20];
752         char er_password[10];
753         int er_num_type;
754
755         if (strcmp(bstr("sc"),"OK")) {
756                 display_error("Cancelled.  No new room was created.");
757                 return;
758                 }
759         
760         strcpy(er_name,bstr("er_name"));
761         strcpy(er_type,bstr("type"));
762         strcpy(er_password,bstr("er_password"));
763
764         er_num_type = 0;
765         if (!strcmp(er_type,"guessname")) er_num_type = 1;
766         if (!strcmp(er_type,"passworded")) er_num_type = 2;
767         if (!strcmp(er_type,"invonly")) er_num_type = 3;
768
769         sprintf(buf,"CRE8 1|%s|%d|%s",er_name,er_num_type,er_password);
770         serv_puts(buf);
771         serv_gets(buf);
772         if (buf[0]!='2') {
773                 display_error(&buf[4]);
774                 return;
775                 }
776         gotoroom(er_name, 1);
777         }
778
779
780 /*
781  * display the screen to enter a private room
782  */
783 void display_private(char *rname, int req_pass)
784 {
785
786         printf("HTTP/1.0 200 OK\n");
787         output_headers(1);
788
789         wprintf("<TABLE WIDTH=100% BORDER=0 BGCOLOR=770000><TR><TD>");
790         wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
791         wprintf("<B>Goto a private room</B>\n");
792         wprintf("</FONT></TD></TR></TABLE>\n");
793
794         wprintf("<CENTER>\n");
795         wprintf("If you know the name of a hidden (guess-name) or\n");
796         wprintf("passworded room, you can enter that room by typing\n");
797         wprintf("its name below.  Once you gain access to a private\n");
798         wprintf("room, it will appear in your regular room listings\n");
799         wprintf("so you don't have to keep returning here.\n");
800         wprintf("<BR><BR>");
801         
802         wprintf("<FORM METHOD=\"POST\" ACTION=\"/goto_private\">\n");
803
804         wprintf("<TABLE border><TR><TD>");
805         wprintf("Enter room name:</TD><TD>");
806         wprintf("<INPUT TYPE=\"text\" NAME=\"gr_name\" VALUE=\"%s\" MAXLENGTH=\"19\">\n",rname);
807
808         if (req_pass) {
809                 wprintf("</TD></TR><TR><TD>");
810                 wprintf("Enter room password:</TD><TD>");
811                 wprintf("<INPUT TYPE=\"password\" NAME=\"gr_pass\" MAXLENGTH=\"9\">\n");
812                 }
813
814         wprintf("</TD></TR></TABLE>\n");
815         
816         wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
817         wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
818         wprintf("</FORM></HTML>\n");
819         wDumpContent();
820         }
821
822 /* 
823  * goto a private room
824  */
825 void goto_private(void) {
826         char hold_rm[32];
827         char buf[256];
828         
829         if (strcasecmp(bstr("sc"),"OK")) {
830                 display_main_menu();
831                 return;
832                 }
833
834         strcpy(hold_rm,wc_roomname);
835         strcpy(buf,"GOTO ");
836         strcat(buf,bstr("gr_name"));
837         strcat(buf,"|");
838         strcat(buf,bstr("gr_pass"));
839         serv_puts(buf);
840         serv_gets(buf);
841
842         if (buf[0]=='2') {
843                 gotoroom(bstr("gr_name"),1);
844                 return;
845                 }
846
847         if (!strncmp(buf,"540",3)) {
848                 display_private(bstr("gr_name"),1);
849                 return;
850                 }
851
852         printf("HTTP/1.0 200 OK\n");
853         output_headers(1);
854         wprintf("%s\n",&buf[4]);
855         wDumpContent();
856         return;
857         }
858
859
860 /*
861  * display the screen to zap a room
862  */
863 void display_zap(void) {
864         printf("HTTP/1.0 200 OK\n");
865         output_headers(1);
866         
867         wprintf("<TABLE WIDTH=100% BORDER=0 BGCOLOR=770000><TR><TD>");
868         wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
869         wprintf("<B>Zap (forget) the current room</B>\n");
870         wprintf("</FONT></TD></TR></TABLE>\n");
871
872         wprintf("If you select this option, <em>%s</em> will ", wc_roomname);
873         wprintf("disappear from your room list.  Is this what you wish ");
874         wprintf("to do?<BR>\n");
875
876         wprintf("<FORM METHOD=\"POST\" ACTION=\"/zap\">\n");
877         wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
878         wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
879         wprintf("</FORM></HTML>\n");
880         wDumpContent();
881         }
882
883
884 /* 
885  * zap a room
886  */
887 void zap(void) {
888         char buf[256];
889
890         if (strcmp(bstr("sc"),"OK")) {
891                 display_main_menu();
892                 return;
893                 }
894
895         serv_printf("GOTO %s", wc_roomname);
896         serv_gets(buf);
897         if (buf[0] != '2') {
898                 display_error(&buf[4]);
899                 return;
900                 }
901
902         serv_puts("FORG");
903         serv_gets(buf);
904         if (buf[0] != '2') {
905                 display_error(&buf[4]);
906                 return;
907                 }
908
909         gotoroom(bstr("_BASEROOM_"),1);
910         }
911
912
913
914
915 /*
916  * Confirm deletion of the current room
917  */
918 void confirm_delete_room(void) {
919         char buf[256];
920         
921         serv_puts("KILL 0");
922         serv_gets(buf);
923         if (buf[0] != '2') {
924                 display_error(&buf[4]);
925                 return;
926                 }
927
928         printf("HTTP/1.0 200 OK\n");
929         output_headers(1);
930         wprintf("<TABLE WIDTH=100% BORDER=0 BGCOLOR=770000><TR><TD>");
931         wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
932         wprintf("<B>Confirm deletion of room</B>\n");
933         wprintf("</FONT></TD></TR></TABLE>\n");
934
935         wprintf("<CENTER>");
936         wprintf("<FORM METHOD=\"POST\" ACTION=\"/delete_room\">\n");
937
938         wprintf("Are you sure you want to delete <FONT SIZE=+1>");
939         escputs(wc_roomname);
940         wprintf("</FONT>?<BR>\n");
941
942         wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Delete\">");
943         wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
944
945         wprintf("</FORM></CENTER></BODY></HTML>\n");
946         wDumpContent();
947         }
948
949
950 /*
951  * Delete the current room
952  */
953 void delete_room(void) {
954         char buf[256];
955         char sc[256];
956
957         strcpy(sc, bstr("sc"));
958         
959         if (strcasecmp(sc, "Delete")) {
960                 display_error("Cancelled.  This room was not deleted.");
961                 return;
962                 }
963
964         serv_puts("KILL 1");
965         serv_gets(buf);
966         if (buf[0] != '2') {
967                 display_error(&buf[4]);
968                 }
969         else {
970                 gotoroom("_BASEROOM_", 1);
971                 }
972         }
973
974
975