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