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