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