]> code.citadel.org Git - citadel.git/blob - webcit/roomops.c
bd26fe7a1d069e82b4de17f0c1b62a650b1aebcc
[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                 /* FIX add room image here */
241
242                 wprintf("<TD>");
243                 readinfo(0);
244                 wprintf("</TD>");
245
246                 wprintf("<TD><A HREF=\"/gotonext\">");
247                 wprintf("<IMG SRC=\"/static/forward.gif\" border=0></A></TD>");
248
249                 wprintf("</TR></TABLE></CENTER>\n");
250
251                 }
252         /* highest_msg_read = extract_int(&buf[4],6);
253         maxmsgnum = extract_int(&buf[4],5);
254         is_mail = (char) extract_int(&buf[4],7); */
255         is_room_aide = (char) extract_int(&buf[4],8);
256         ls = extract_long(&buf[4],6);
257
258         strcpy(wc_roomname, wc_roomname);
259         wDumpContent();
260         }
261
262
263 /*
264  * operation to goto a room
265  */
266 void dotgoto(void) {
267         fprintf(stderr, "DOTGOTO: <%s>\n", bstr("room"));
268         gotoroom(bstr("room"),1);
269         }
270
271
272 /* Goto next room having unread messages.
273  * We want to skip over rooms that the user has already been to, and take the
274  * user back to the lobby when done.  The room we end up in is placed in
275  * newroom - which is set to 0 (the lobby) initially.
276  * We start the search in the current room rather than the beginning to prevent
277  * two or more concurrent users from dragging each other back to the same room.
278  */
279 void gotonext(void) {
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(void) {
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(void) { 
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(void) {
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(void) {
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(void) {
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(void) {
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(char *rname, int req_pass)
756 {
757
758
759         wprintf("<TABLE WIDTH=100% BORDER=0 BGCOLOR=770000><TR><TD>");
760         wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
761         wprintf("<B>Enter a private room</B>\n");
762         wprintf("</FONT></TD></TR></TABLE>\n");
763
764         wprintf("<CENTER>\n");
765         wprintf("If you know the name of a hidden (guess-name) or\n");
766         wprintf("passworded room, you can enter that room by typing\n");
767         wprintf("its name below.  Once you gain access to a private\n");
768         wprintf("room, it will appear in your regular room listings\n");
769         wprintf("so you don't have to keep returning here.\n");
770         wprintf("<BR><BR>");
771         
772         wprintf("<FORM METHOD=\"POST\" ACTION=\"/goto_private\">\n");
773
774         wprintf("<TABLE border><TR><TD>");
775         wprintf("Enter room name:</TD><TD>");
776         wprintf("<INPUT TYPE=\"text\" NAME=\"gr_name\" VALUE=\"%s\" MAXLENGTH=\"19\">\n",rname);
777
778         if (req_pass) {
779                 wprintf("</TD></TR><TR><TD>");
780                 wprintf("Enter room password:</TD><TD>");
781                 wprintf("<INPUT TYPE=\"password\" NAME=\"gr_pass\" MAXLENGTH=\"9\">\n");
782                 }
783
784         wprintf("</TD></TR></TABLE>\n");
785         
786         wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
787         wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
788         wprintf("</FORM>");
789         }
790
791 /* 
792  * goto a private room
793  */
794 int goto_private(void) {
795         char hold_rm[32];
796         char buf[256];
797         
798         if (strcmp(bstr("sc"),"OK")) {
799                 return(2);
800                 }
801
802         strcpy(hold_rm,wc_roomname);
803         strcpy(buf,"GOTO ");
804         strcat(buf,bstr("gr_name"));
805         strcat(buf,"|");
806         strcat(buf,bstr("gr_pass"));
807         serv_puts(buf);
808         serv_gets(buf);
809
810         if (buf[0]=='2') {
811                 gotoroom(bstr("gr_name"),1);
812                 return(0);
813                 }
814
815         if (!strncmp(buf,"540",3)) {
816                 display_private(bstr("gr_name"),1);
817                 return(1);
818                 }
819
820         wprintf("<EM>%s</EM>\n",&buf[4]);
821         return(2);
822         }
823
824
825 /*
826  * display the screen to zap a room
827  */
828 void display_zap(void) {
829         char zaproom[32];
830         
831         strcpy(zaproom, bstr("room"));
832         
833         wprintf("<TABLE WIDTH=100% BORDER=0 BGCOLOR=770000><TR><TD>");
834         wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
835         wprintf("<B>Zap (forget) the current room</B>\n");
836         wprintf("</FONT></TD></TR></TABLE>\n");
837
838         wprintf("If you select this option, <em>%s</em> will ", zaproom);
839         wprintf("disappear from your room list.  Is this what you wish ");
840         wprintf("to do?<BR>\n");
841
842         wprintf("<FORM METHOD=\"POST\" ACTION=\"/zap\">\n");
843         wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
844         wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
845         wprintf("</FORM>");
846         }
847
848
849 /* 
850  * zap a room
851  */
852 int zap(void) {
853         char zaproom[32];
854         char buf[256];
855
856         if (strcmp(bstr("sc"),"OK")) {
857                 return(2);
858                 }
859
860         strcpy(zaproom, bstr("room"));
861         sprintf(buf, "GOTO %s", zaproom);
862         serv_puts(buf);
863         serv_gets(buf);
864         if (buf[0] != '2') {
865                 wprintf("<EM>%s</EM>\n",&buf[4]);
866                 return(2);
867                 }
868
869         serv_puts("FORG");
870         serv_gets(buf);
871         if (buf[0] != '2') {
872                 wprintf("<EM>%s</EM>\n",&buf[4]);
873                 return(2);
874                 }
875
876         gotoroom(bstr("_BASEROOM_"),1);
877         return(0);
878         }