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