]> code.citadel.org Git - citadel.git/blob - webcit/roomops.c
* Moved room access controls out of the admin menu and into the room commands
[citadel.git] / webcit / roomops.c
1 /* $Id$ */
2
3
4 #include <ctype.h>
5 #include <stdlib.h>
6 #include <unistd.h>
7 #include <stdio.h>
8 #include <fcntl.h>
9 #include <signal.h>
10 #include <sys/types.h>
11 #include <sys/wait.h>
12 #include <sys/socket.h>
13 #include <sys/time.h>
14 #include <limits.h>
15 #include <netinet/in.h>
16 #include <netdb.h>
17 #include <string.h>
18 #include <pwd.h>
19 #include <errno.h>
20 #include <stdarg.h>
21 #include <pthread.h>
22 #include <signal.h>
23 #include "webcit.h"
24
25
26
27
28
29
30
31 char floorlist[128][SIZ];
32
33
34 /*
35  * load the list of floors
36  */
37 void load_floorlist(void)
38 {
39         int a;
40         char buf[SIZ];
41
42         for (a = 0; a < 128; ++a)
43                 floorlist[a][0] = 0;
44
45         serv_puts("LFLR");
46         serv_gets(buf);
47         if (buf[0] != '1') {
48                 strcpy(floorlist[0], "Main Floor");
49                 return;
50         }
51         while (serv_gets(buf), strcmp(buf, "000")) {
52                 extract(floorlist[extract_int(buf, 0)], buf, 1);
53         }
54 }
55
56
57 /*
58  * remove a room from the march list
59  */
60 void remove_march(char *aaa)
61 {
62         struct march *mptr, *mptr2;
63
64         if (WC->march == NULL)
65                 return;
66
67         if (!strcasecmp(WC->march->march_name, aaa)) {
68                 mptr = WC->march->next;
69                 free(WC->march);
70                 WC->march = mptr;
71                 return;
72         }
73         mptr2 = WC->march;
74         for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
75                 if (!strcasecmp(mptr->march_name, aaa)) {
76                         mptr2->next = mptr->next;
77                         free(mptr);
78                         mptr = mptr2;
79                 } else {
80                         mptr2 = mptr;
81                 }
82         }
83 }
84
85
86
87
88
89 void room_tree_list(struct roomlisting *rp)
90 {
91         char rmname[64];
92         int f;
93
94         if (rp == NULL)
95                 return;
96
97         if (rp->lnext != NULL) {
98                 room_tree_list(rp->lnext);
99         }
100         strcpy(rmname, rp->rlname);
101         f = rp->rlflags;
102
103         wprintf("<A HREF=\"/dotgoto&room=");
104         urlescputs(rmname);
105         wprintf("\"");
106         wprintf(">");
107         escputs1(rmname, 1);
108         if ((f & QR_DIRECTORY) && (f & QR_NETWORK))
109                 wprintf("}");
110         else if (f & QR_DIRECTORY)
111                 wprintf("]");
112         else if (f & QR_NETWORK)
113                 wprintf(")");
114         else
115                 wprintf("&gt;");
116         wprintf("</A><TT> </TT>\n");
117
118         if (rp->rnext != NULL) {
119                 room_tree_list(rp->rnext);
120         }
121         free(rp);
122 }
123
124
125 /* 
126  * Room ordering stuff (compare first by floor, then by order)
127  */
128 int rordercmp(struct roomlisting *r1, struct roomlisting *r2)
129 {
130         if ((r1 == NULL) && (r2 == NULL))
131                 return (0);
132         if (r1 == NULL)
133                 return (-1);
134         if (r2 == NULL)
135                 return (1);
136         if (r1->rlfloor < r2->rlfloor)
137                 return (-1);
138         if (r1->rlfloor > r2->rlfloor)
139                 return (1);
140         if (r1->rlorder < r2->rlorder)
141                 return (-1);
142         if (r1->rlorder > r2->rlorder)
143                 return (1);
144         return (0);
145 }
146
147
148 /*
149  * Common code for all room listings
150  */
151 void listrms(char *variety)
152 {
153         char buf[SIZ];
154         int num_rooms = 0;
155
156         struct roomlisting *rl = NULL;
157         struct roomlisting *rp;
158         struct roomlisting *rs;
159
160
161         /* Ask the server for a room list */
162         serv_puts(variety);
163         serv_gets(buf);
164         if (buf[0] != '1') {
165                 wprintf("&nbsp;");
166                 return;
167         }
168         while (serv_gets(buf), strcmp(buf, "000")) {
169                 ++num_rooms;
170                 rp = malloc(sizeof(struct roomlisting));
171                 extract(rp->rlname, buf, 0);
172                 rp->rlflags = extract_int(buf, 1);
173                 rp->rlfloor = extract_int(buf, 2);
174                 rp->rlorder = extract_int(buf, 3);
175                 rp->lnext = NULL;
176                 rp->rnext = NULL;
177
178                 rs = rl;
179                 if (rl == NULL) {
180                         rl = rp;
181                 } else
182                         while (rp != NULL) {
183                                 if (rordercmp(rp, rs) < 0) {
184                                         if (rs->lnext == NULL) {
185                                                 rs->lnext = rp;
186                                                 rp = NULL;
187                                         } else {
188                                                 rs = rs->lnext;
189                                         }
190                                 } else {
191                                         if (rs->rnext == NULL) {
192                                                 rs->rnext = rp;
193                                                 rp = NULL;
194                                         } else {
195                                                 rs = rs->rnext;
196                                         }
197                                 }
198                         }
199         }
200
201         room_tree_list(rl);
202
203         /* If no rooms were listed, print an nbsp to make the cell
204          * borders show up anyway.
205          */
206         if (num_rooms == 0) wprintf("&nbsp;");
207 }
208
209
210
211
212
213
214
215
216
217 /*
218  * list all rooms by floor
219  */
220 void list_all_rooms_by_floor(void)
221 {
222         int a;
223         char buf[SIZ];
224
225         load_floorlist();
226
227         output_headers(1);
228
229         wprintf("<TABLE width=100%% border><TR><TH>Floor</TH>");
230         wprintf("<TH>Rooms with new messages</TH>");
231         wprintf("<TH>Rooms with no new messages</TH></TR>\n");
232
233         for (a = 0; a < 128; ++a)
234                 if (floorlist[a][0] != 0) {
235
236                         /* Floor name column */
237                         wprintf("<TR><TD>");
238
239                         serv_printf("OIMG _floorpic_|%d", a);
240                         serv_gets(buf);
241                         if (buf[0] == '2') {
242                                 serv_puts("CLOS");
243                                 serv_gets(buf);
244                                 wprintf("<IMG SRC=\"/image&name=_floorpic_&parm=%d\" ALT=\"%s\">",
245                                         a, &floorlist[a][0]);
246                         } else {
247                                 escputs(&floorlist[a][0]);
248                         }
249
250                         wprintf("</TD>");
251
252                         /* Rooms with new messages column */
253                         wprintf("<TD>");
254                         sprintf(buf, "LKRN %d", a);
255                         listrms(buf);
256                         wprintf("</TD>\n<TD>");
257
258                         /* Rooms with old messages column */
259                         sprintf(buf, "LKRO %d", a);
260                         listrms(buf);
261                         wprintf("</TD></TR>\n");
262                 }
263         wprintf("</TABLE>\n");
264         wDumpContent(1);
265 }
266
267
268 /*
269  * list all forgotten rooms
270  */
271 void zapped_list(void)
272 {
273         output_headers(1);
274         wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=770000><TR><TD>");
275         wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
276         wprintf("<B>Zapped (forgotten) rooms</B>\n");
277         wprintf("</TD></TR></TABLE><BR>\n");
278         listrms("LZRM -1");
279         wprintf("<BR><BR>\n");
280         wprintf("Click on any room to un-zap it and goto that room.\n");
281         wDumpContent(1);
282 }
283
284
285 /*
286  * read this room's info file (set v to 1 for verbose mode)
287  */
288 void readinfo(void)
289 {
290         char buf[SIZ];
291
292         serv_puts("RINF");
293         serv_gets(buf);
294         if (buf[0] == '1') {
295                 wprintf("<FONT SIZE=-1>");
296                 fmout(NULL);
297                 wprintf("</FONT>");
298         }
299 }
300
301
302
303
304 /* Display room graphic.  The server doesn't actually
305  * need the room name, but we supply it in order to
306  * keep the browser from using a cached graphic from 
307  * another room.
308  */
309 void embed_room_graphic(void) {
310         char buf[SIZ];
311
312         serv_puts("OIMG _roompic_");
313         serv_gets(buf);
314         if (buf[0] == '2') {
315                 wprintf("<TD>");
316                 wprintf("<IMG SRC=\"/image&name=_roompic_&room=");
317                 urlescputs(WC->wc_roomname);
318                 wprintf("\"></TD>");
319                 serv_puts("CLOS");
320                 serv_gets(buf);
321         }
322
323 }
324
325
326 /* Let the user know if new mail has arrived 
327  */
328 void embed_newmail_button(void) {
329         if ( (WC->new_mail > WC->remember_new_mail) && (WC->new_mail>0) ) {
330                 wprintf("<TD VALIGN=TOP>"
331                         "<A HREF=\"/dotgoto?room=_MAIL_\">"
332                         "<IMG SRC=\"/static/mail.gif\" border=0 "
333                         "ALT=\"You have new mail\">"
334                         "<BR><BLINK>%d</BLINK>", WC->new_mail);
335                 wprintf("<FONT SIZE=-2> new mail messages</FONT></A></TD>");
336                 WC->remember_new_mail = WC->new_mail;
337         }
338 }
339
340
341
342 void embed_room_banner(char *got) {
343         char fakegot[SIZ];
344
345         /* We need to have the information returned by a GOTO server command.
346          * If it isn't supplied, we fake it by issuing our own GOTO.
347          */
348         if (got == NULL) {
349                 serv_printf("GOTO %s", WC->wc_roomname);
350                 serv_gets(fakegot);
351                 got = fakegot;
352         }
353
354         /* Check for new mail. */
355         WC->new_mail = extract_int(&got[4], 9);
356
357         svprintf("ROOMNAME", WCS_STRING, "%s", WC->wc_roomname);
358         svprintf("NEWMSGS", WCS_STRING, "%d", extract_int(&got[4], 1));
359         svprintf("TOTALMSGS", WCS_STRING, "%d", extract_int(&got[4], 2));
360         svcallback("ROOMPIC", embed_room_graphic);
361         svcallback("ROOMINFO", readinfo);
362         svcallback("YOUHAVEMAIL", embed_newmail_button);
363
364         do_template("roombanner.html");
365         clear_local_substs();
366 }
367
368
369
370
371
372 /*
373  * generic routine to take the session to a new room
374  *
375  * display_name values:  0 = goto only
376  *                       1 = goto and display
377  *                       2 = display only
378  */
379 void gotoroom(char *gname, int display_name)
380 {
381         char buf[SIZ];
382         static long ls = (-1L);
383
384
385         if (display_name) {
386                 output_headers(0);
387                 wprintf("Pragma: no-cache\n");
388                 wprintf("Cache-Control: no-store\n");
389
390                 wprintf("<HTML><HEAD>\n"
391                         "<META HTTP-EQUIV=\"refresh\" CONTENT=\"500363689;\">\n"
392                         "<META HTTP-EQUIV=\"Pragma\" CONTENT=\"no-cache\">\n"
393                         "<META HTTP-EQUIV=\"expired\" CONTENT=\"28-May-1971 18:10:00 GMT\">\n"
394                         "<meta name=\"MSSmartTagsPreventParsing\" content=\"TRUE\">\n"
395                         "</HEAD>\n");
396                 do_template("background.html");
397         }
398         if (display_name != 2) {
399                 /* store ungoto information */
400                 strcpy(WC->ugname, WC->wc_roomname);
401                 WC->uglsn = ls;
402         }
403         /* move to the new room */
404         serv_printf("GOTO %s", gname);
405         serv_gets(buf);
406         if (buf[0] != '2') {
407                 serv_puts("GOTO _BASEROOM_");
408                 serv_gets(buf);
409         }
410         if (buf[0] != '2') {
411                 if (display_name) {
412                         wprintf("<EM>%s</EM><BR>\n", &buf[4]);
413                         wDumpContent(1);
414                 }
415                 return;
416         }
417         extract(WC->wc_roomname, &buf[4], 0);
418         WC->room_flags = extract_int(&buf[4], 4);
419         /* highest_msg_read = extract_int(&buf[4],6);
420            maxmsgnum = extract_int(&buf[4],5);
421            is_mail = (char) extract_int(&buf[4],7); */
422         ls = extract_long(&buf[4], 6);
423
424         if (WC->is_aide)
425                 WC->is_room_aide = WC->is_aide;
426         else
427                 WC->is_room_aide = (char) extract_int(&buf[4], 8);
428
429         remove_march(WC->wc_roomname);
430         if (!strcasecmp(gname, "_BASEROOM_"))
431                 remove_march(gname);
432
433         /* Display the room banner */
434         if (display_name) {
435                 embed_room_banner(buf);
436                 wDumpContent(1);
437         }
438         strcpy(WC->wc_roomname, WC->wc_roomname);
439 }
440
441
442 /*
443  * Locate the room on the march list which we most want to go to.  Each room
444  * is measured given a "weight" of preference based on various factors.
445  */
446 char *pop_march(int desired_floor)
447 {
448         static char TheRoom[64];
449         int TheFloor = 0;
450         int TheOrder = 32767;
451         int TheWeight = 0;
452         int weight;
453         struct march *mptr = NULL;
454
455         strcpy(TheRoom, "_BASEROOM_");
456         if (WC->march == NULL)
457                 return (TheRoom);
458
459         for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
460                 weight = 0;
461                 if ((strcasecmp(mptr->march_name, "_BASEROOM_")))
462                         weight = weight + 10000;
463                 if (mptr->march_floor == desired_floor)
464                         weight = weight + 5000;
465
466                 weight = weight + ((128 - (mptr->march_floor)) * 128);
467                 weight = weight + (128 - (mptr->march_order));
468
469                 if (weight > TheWeight) {
470                         TheWeight = weight;
471                         strcpy(TheRoom, mptr->march_name);
472                         TheFloor = mptr->march_floor;
473                         TheOrder = mptr->march_order;
474                 }
475         }
476         return (TheRoom);
477 }
478
479
480
481 /* Goto next room having unread messages.
482  * We want to skip over rooms that the user has already been to, and take the
483  * user back to the lobby when done.  The room we end up in is placed in
484  * newroom - which is set to 0 (the lobby) initially.
485  * We start the search in the current room rather than the beginning to prevent
486  * two or more concurrent users from dragging each other back to the same room.
487  */
488 void gotonext(void)
489 {
490         char buf[SIZ];
491         struct march *mptr, *mptr2;
492         char next_room[32];
493
494         /* First check to see if the march-mode list is already allocated.
495          * If it is, pop the first room off the list and go there.
496          */
497
498         if (WC->march == NULL) {
499                 serv_puts("LKRN");
500                 serv_gets(buf);
501                 if (buf[0] == '1')
502                         while (serv_gets(buf), strcmp(buf, "000")) {
503                                 mptr = (struct march *) malloc(sizeof(struct march));
504                                 mptr->next = NULL;
505                                 extract(mptr->march_name, buf, 0);
506                                 mptr->march_floor = extract_int(buf, 2);
507                                 mptr->march_order = extract_int(buf, 3);
508                                 if (WC->march == NULL) {
509                                         WC->march = mptr;
510                                 } else {
511                                         mptr2 = WC->march;
512                                         while (mptr2->next != NULL)
513                                                 mptr2 = mptr2->next;
514                                         mptr2->next = mptr;
515                                 }
516                         }
517 /* add _BASEROOM_ to the end of the march list, so the user will end up
518  * in the system base room (usually the Lobby>) at the end of the loop
519  */
520                 mptr = (struct march *) malloc(sizeof(struct march));
521                 mptr->next = NULL;
522                 strcpy(mptr->march_name, "_BASEROOM_");
523                 if (WC->march == NULL) {
524                         WC->march = mptr;
525                 } else {
526                         mptr2 = WC->march;
527                         while (mptr2->next != NULL)
528                                 mptr2 = mptr2->next;
529                         mptr2->next = mptr;
530                 }
531 /*
532  * ...and remove the room we're currently in, so a <G>oto doesn't make us
533  * walk around in circles
534  */
535                 remove_march(WC->wc_roomname);
536         }
537         if (WC->march != NULL) {
538                 strcpy(next_room, pop_march(-1));
539         } else {
540                 strcpy(next_room, "_BASEROOM_");
541         }
542
543
544         smart_goto(next_room);
545 }
546
547
548 void smart_goto(char *next_room) {
549         gotoroom(next_room, 0);
550         readloop("readnew");
551 }
552
553
554
555 /*
556  * mark all messages in current room as having been read
557  */
558 void slrp_highest(void)
559 {
560         char buf[SIZ];
561
562         /* set pointer */
563         serv_puts("SLRP HIGHEST");
564         serv_gets(buf);
565         if (buf[0] != '2') {
566                 wprintf("<EM>%s</EM><BR>\n", &buf[4]);
567                 return;
568         }
569 }
570
571
572 /*
573  * un-goto the previous room
574  */
575 void ungoto(void)
576 {
577         char buf[SIZ];
578
579         if (!strcmp(WC->ugname, "")) {
580                 smart_goto(WC->wc_roomname);
581                 return;
582         }
583         serv_printf("GOTO %s", WC->ugname);
584         serv_gets(buf);
585         if (buf[0] != '2') {
586                 smart_goto(WC->wc_roomname);
587                 return;
588         }
589         if (WC->uglsn >= 0L) {
590                 serv_printf("SLRP %ld", WC->uglsn);
591                 serv_gets(buf);
592         }
593         strcpy(buf, WC->ugname);
594         strcpy(WC->ugname, "");
595         smart_goto(buf);
596 }
597
598 /*
599  * display the form for editing a room
600  */
601 void display_editroom(void)
602 {
603         char buf[SIZ];
604         char cmd[SIZ];
605         char node[SIZ];
606         char recp[SIZ];
607         char er_name[20];
608         char er_password[10];
609         char er_dirname[15];
610         char er_roomaide[26];
611         unsigned er_flags;
612         int er_floor;
613         int i, j;
614         char *tab;
615         char *shared_with;
616         char *not_shared_with;
617
618         tab = bstr("tab");
619         if (strlen(tab) == 0) tab = "admin";
620
621         serv_puts("GETR");
622         serv_gets(buf);
623
624         if (buf[0] != '2') {
625                 display_error(&buf[4]);
626                 return;
627         }
628         extract(er_name, &buf[4], 0);
629         extract(er_password, &buf[4], 1);
630         extract(er_dirname, &buf[4], 2);
631         er_flags = extract_int(&buf[4], 3);
632         er_floor = extract_int(&buf[4], 4);
633
634         output_headers(1);
635
636         /* print the tabbed dialog */
637         wprintf("<TABLE border=0 width=100%%><TR BGCOLOR=FFFFFF><TD> </TD>");
638
639         if (!strcmp(tab, "admin")) {
640                 wprintf("<TD BGCOLOR=000077><FONT SIZE=+1 COLOR=\"FFFFFF\"><B>");
641         }
642         else {
643                 wprintf("<TD><A HREF=\"/display_editroom&tab=admin\">");
644         }
645         wprintf("Room administration");
646         if (!strcmp(tab, "admin")) {
647                 wprintf("</B></FONT></TD>\n");
648         }
649         else {
650                 wprintf("</A></TD>\n");
651         }
652
653         wprintf("<TD> </TD>\n");
654
655         if (!strcmp(tab, "config")) {
656                 wprintf("<TD BGCOLOR=000077><FONT SIZE=+1 COLOR=\"FFFFFF\"><B>");
657         }
658         else {
659                 wprintf("<TD><A HREF=\"/display_editroom&tab=config\">");
660         }
661         wprintf("Room configuration");
662         if (!strcmp(tab, "config")) {
663                 wprintf("</B></FONT></TD>\n");
664         }
665         else {
666                 wprintf("</A></TD>\n");
667         }
668
669         wprintf("<TD> </TD>\n");
670
671         if (!strcmp(tab, "sharing")) {
672                 wprintf("<TD BGCOLOR=000077><FONT SIZE=+1 COLOR=\"FFFFFF\"><B>");
673         }
674         else {
675                 wprintf("<TD><A HREF=\"/display_editroom&tab=sharing\">");
676         }
677         wprintf("Sharing");
678         if (!strcmp(tab, "sharing")) {
679                 wprintf("</B></FONT></TD>\n");
680         }
681         else {
682                 wprintf("</A></TD>\n");
683         }
684
685         wprintf("<TD> </TD>\n");
686
687         if (!strcmp(tab, "listserv")) {
688                 wprintf("<TD BGCOLOR=000077><FONT SIZE=+1 COLOR=\"FFFFFF\"><B>");
689         }
690         else {
691                 wprintf("<TD><A HREF=\"/display_editroom&tab=listserv\">");
692         }
693         wprintf("Mailing list service");
694         if (!strcmp(tab, "listserv")) {
695                 wprintf("</B></FONT></TD>\n");
696         }
697         else {
698                 wprintf("</A></TD>\n");
699         }
700
701         wprintf("<TD> </TD></TR></TABLE>\n");
702
703         /* end tabbed dialog */ 
704
705
706         if (!strcmp(tab, "admin")) {
707                 wprintf("<UL>"
708                         "<LI><A HREF=\"/confirm_delete_room\">\n"
709                         "Delete this room</A>\n"
710                         "<LI><A HREF=\"/display_editroompic\">\n"
711                         "Set or change the graphic for this room's banner</A>\n"
712                         "<LI><A HREF=\"/display_editinfo\">\n"
713                         "Edit this room's Info file</A>\n"
714                         "</UL>");
715         }
716
717         if (!strcmp(tab, "config")) {
718                 wprintf("<FORM METHOD=\"POST\" ACTION=\"/editroom\">\n");
719         
720                 wprintf("<UL><LI>Name of room: ");
721                 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\"19\">\n", er_name);
722         
723                 wprintf("<LI>Resides on floor: ");
724                 load_floorlist();
725                 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
726                 for (i = 0; i < 128; ++i)
727                         if (strlen(floorlist[i]) > 0) {
728                                 wprintf("<OPTION ");
729                                 if (i == er_floor)
730                                         wprintf("SELECTED ");
731                                 wprintf("VALUE=\"%d\">", i);
732                                 escputs(floorlist[i]);
733                                 wprintf("</OPTION>\n");
734                         }
735                 wprintf("</SELECT>\n");
736         
737                 wprintf("<LI>Type of room:<UL>\n");
738
739                 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
740                 if ((er_flags & QR_PRIVATE) == 0)
741                 wprintf("CHECKED ");
742                 wprintf("> Public room\n");
743
744                 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"guessname\" ");
745                 if ((er_flags & QR_PRIVATE) &&
746                     (er_flags & QR_GUESSNAME))
747                         wprintf("CHECKED ");
748                 wprintf("> Private - guess name\n");
749         
750                 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
751                 if ((er_flags & QR_PRIVATE) &&
752                     (er_flags & QR_PASSWORDED))
753                         wprintf("CHECKED ");
754                 wprintf("> Private - require password:\n");
755                 wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n", er_password);
756         
757                 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
758                 if ((er_flags & QR_PRIVATE)
759                     && ((er_flags & QR_GUESSNAME) == 0)
760                     && ((er_flags & QR_PASSWORDED) == 0))
761                         wprintf("CHECKED ");
762                 wprintf("> Private - invitation only\n");
763         
764                 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
765                 wprintf("> If private, cause current users to forget room\n");
766         
767                 wprintf("</UL>\n");
768         
769                 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
770                 if (er_flags & QR_PREFONLY)
771                         wprintf("CHECKED ");
772                 wprintf("> Preferred users only\n");
773         
774                 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
775                 if (er_flags & QR_READONLY)
776                         wprintf("CHECKED ");
777                 wprintf("> Read-only room\n");
778         
779         /* directory stuff */
780                 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
781                 if (er_flags & QR_DIRECTORY)
782                         wprintf("CHECKED ");
783                 wprintf("> File directory room\n");
784
785                 wprintf("<UL><LI>Directory name: ");
786                 wprintf("<INPUT TYPE=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n", er_dirname);
787
788                 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
789                 if (er_flags & QR_UPLOAD)
790                         wprintf("CHECKED ");
791                 wprintf("> Uploading allowed\n");
792         
793                 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
794                 if (er_flags & QR_DOWNLOAD)
795                         wprintf("CHECKED ");
796                 wprintf("> Downloading allowed\n");
797         
798                 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
799                 if (er_flags & QR_VISDIR)
800                         wprintf("CHECKED ");
801                 wprintf("> Visible directory</UL>\n");
802         
803         /* end of directory stuff */
804         
805                 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
806                 if (er_flags & QR_NETWORK)
807                         wprintf("CHECKED ");
808                 wprintf("> Network shared room\n");
809
810         /* start of anon options */
811         
812                 wprintf("<LI>Anonymous messages<UL>\n");
813         
814                 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
815                 if (((er_flags & QR_ANONONLY) == 0)
816                     && ((er_flags & QR_ANONOPT) == 0))
817                         wprintf("CHECKED ");
818                 wprintf("> No anonymous messages\n");
819         
820                 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
821                 if (er_flags & QR_ANONONLY)
822                         wprintf("CHECKED ");
823                 wprintf("> All messages are anonymous\n");
824         
825                 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
826                 if (er_flags & QR_ANONOPT)
827                         wprintf("CHECKED ");
828                 wprintf("> Prompt user when entering messages</UL>\n");
829         
830         /* end of anon options */
831         
832                 wprintf("<LI>Room aide: \n");
833                 serv_puts("GETA");
834                 serv_gets(buf);
835                 if (buf[0] != '2') {
836                         wprintf("<EM>%s</EM>\n", &buf[4]);
837                 } else {
838                         extract(er_roomaide, &buf[4], 0);
839                         wprintf("<INPUT TYPE=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n", er_roomaide);
840                 }
841         
842                 wprintf("</UL><CENTER>\n");
843                 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
844                 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
845                 wprintf("</CENTER>\n");
846         }
847
848
849         /* Sharing the room with other Citadel nodes... */
850         if (!strcmp(tab, "sharing")) {
851
852                 shared_with = strdup("");
853                 not_shared_with = strdup("");
854
855                 /* Learn the current configuration */
856                 serv_puts("CONF getsys|application/x-citadel-ignet-config");
857                 serv_gets(buf);
858                 if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
859                         extract(node, buf, 0);
860                         not_shared_with = realloc(not_shared_with,
861                                         strlen(not_shared_with) + 32);
862                         strcat(not_shared_with, node);
863                         strcat(not_shared_with, "|");
864                 }
865
866                 serv_puts("GNET");
867                 serv_gets(buf);
868                 if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
869                         extract(cmd, buf, 0);
870                         extract(node, buf, 1);
871                         if (!strcasecmp(cmd, "ignet_push_share")) {
872                                 shared_with = realloc(shared_with,
873                                                 strlen(shared_with) + 32);
874                                 strcat(shared_with, node);
875                                 strcat(shared_with, "|");
876                         }
877                 }
878
879                 for (i=0; i<num_tokens(shared_with, '|'); ++i) {
880                         extract(node, shared_with, i);
881                         for (j=0; j<num_tokens(not_shared_with, '|'); ++j) {
882                                 extract(cmd, not_shared_with, j);
883                                 if (!strcasecmp(node, cmd)) {
884                                         remove_token(not_shared_with, j, '|');
885                                 }
886                         }
887                 }
888
889                 /* Display the stuff */
890                 wprintf("<CENTER><BR>"
891                         "<TABLE border=1 cellpadding=5><TR>"
892                         "<TD><B><I>Shared with</I></B></TD>"
893                         "<TD><B><I>Not shared with</I></B></TD></TR>\n"
894                         "<TR><TD>\n");
895
896                 for (i=0; i<num_tokens(shared_with, '|'); ++i) {
897                         extract(node, shared_with, i);
898                         if (strlen(node) > 0) {
899                                 wprintf("%s ", node);
900                                 wprintf("<A HREF=\"/netedit&cmd=remove&line="
901                                         "ignet_push_share|");
902                                 urlescputs(node);
903                                 wprintf("&tab=sharing\">(unshare)</A><BR>");
904                         }
905                 }
906
907                 wprintf("</TD><TD>\n");
908
909                 for (i=0; i<num_tokens(not_shared_with, '|'); ++i) {
910                         extract(node, not_shared_with, i);
911                         if (strlen(node) > 0) {
912                                 wprintf("%s ", node);
913                                 wprintf("<A HREF=\"/netedit&cmd=add&line="
914                                         "ignet_push_share|");
915                                 urlescputs(node);
916                                 wprintf("&tab=sharing\">(share)</A><BR>");
917                         }
918                 }
919
920                 wprintf("</TD></TR></TABLE><BR>\n"
921                         "<I><B>Reminder:</B> When sharing a room, "
922                         "it must be shared from both ends.  Adding a node to "
923                         "the 'shared' list sends messages out, but in order to"
924                         " receive messages, the other nodes must be configured"
925                         " to send messages out to your system as well.</I><BR>"
926                         "</CENTER>\n");
927
928         }
929
930         /* Mailing list management */
931         if (!strcmp(tab, "listserv")) {
932
933                 wprintf("<BR><center><i>The contents of this room are being "
934                         "mailed to the following list recipients:"
935                         "</i><br><br>\n");
936
937                 serv_puts("GNET");
938                 serv_gets(buf);
939                 if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
940                         extract(cmd, buf, 0);
941                         if (!strcasecmp(cmd, "listrecp")) {
942                                 extract(recp, buf, 1);
943                         
944                                 escputs(recp);
945                                 wprintf(" <A HREF=\"/netedit&cmd=remove&line="
946                                         "listrecp|");
947                                 urlescputs(recp);
948                                 wprintf("&tab=listserv\">(remove)</A><BR>");
949
950                         }
951                 }
952                 wprintf("<BR><FORM METHOD=\"POST\" ACTION=\"/netedit\">\n"
953                         "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
954                         "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"listrecp|\">\n");
955                 wprintf("<INPUT TYPE=\"text\" NAME=\"line\">\n");
956                 wprintf("<INPUT TYPE=\"submit\" NAME=\"cmd\" VALUE=\"Add\">");
957                 wprintf("</FORM><BR></CENTER>\n");
958         }
959
960         wDumpContent(1);
961 }
962
963
964 /*
965  * save new parameters for a room
966  */
967 void editroom(void)
968 {
969         char buf[SIZ];
970         char er_name[20];
971         char er_password[10];
972         char er_dirname[15];
973         char er_roomaide[26];
974         int er_floor;
975         unsigned er_flags;
976         int bump;
977
978
979         if (strcmp(bstr("sc"), "OK")) {
980                 display_error("Cancelled.  Changes were not saved.");
981                 return;
982         }
983         serv_puts("GETR");
984         serv_gets(buf);
985
986         if (buf[0] != '2') {
987                 display_error(&buf[4]);
988                 return;
989         }
990         extract(er_name, &buf[4], 0);
991         extract(er_password, &buf[4], 1);
992         extract(er_dirname, &buf[4], 2);
993         er_flags = extract_int(&buf[4], 3);
994
995         strcpy(er_roomaide, bstr("er_roomaide"));
996         if (strlen(er_roomaide) == 0) {
997                 serv_puts("GETA");
998                 serv_gets(buf);
999                 if (buf[0] != '2') {
1000                         strcpy(er_roomaide, "");
1001                 } else {
1002                         extract(er_roomaide, &buf[4], 0);
1003                 }
1004         }
1005         strcpy(buf, bstr("er_name"));
1006         buf[20] = 0;
1007         if (strlen(buf) > 0)
1008                 strcpy(er_name, buf);
1009
1010         strcpy(buf, bstr("er_password"));
1011         buf[10] = 0;
1012         if (strlen(buf) > 0)
1013                 strcpy(er_password, buf);
1014
1015         strcpy(buf, bstr("er_dirname"));
1016         buf[15] = 0;
1017         if (strlen(buf) > 0)
1018                 strcpy(er_dirname, buf);
1019
1020         strcpy(buf, bstr("type"));
1021         er_flags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME);
1022
1023         if (!strcmp(buf, "invonly")) {
1024                 er_flags |= (QR_PRIVATE);
1025         }
1026         if (!strcmp(buf, "guessname")) {
1027                 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
1028         }
1029         if (!strcmp(buf, "passworded")) {
1030                 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
1031         }
1032         if (!strcmp(bstr("prefonly"), "yes")) {
1033                 er_flags |= QR_PREFONLY;
1034         } else {
1035                 er_flags &= ~QR_PREFONLY;
1036         }
1037
1038         if (!strcmp(bstr("readonly"), "yes")) {
1039                 er_flags |= QR_READONLY;
1040         } else {
1041                 er_flags &= ~QR_READONLY;
1042         }
1043
1044         if (!strcmp(bstr("network"), "yes")) {
1045                 er_flags |= QR_NETWORK;
1046         } else {
1047                 er_flags &= ~QR_NETWORK;
1048         }
1049
1050         if (!strcmp(bstr("directory"), "yes")) {
1051                 er_flags |= QR_DIRECTORY;
1052         } else {
1053                 er_flags &= ~QR_DIRECTORY;
1054         }
1055
1056         if (!strcmp(bstr("ulallowed"), "yes")) {
1057                 er_flags |= QR_UPLOAD;
1058         } else {
1059                 er_flags &= ~QR_UPLOAD;
1060         }
1061
1062         if (!strcmp(bstr("dlallowed"), "yes")) {
1063                 er_flags |= QR_DOWNLOAD;
1064         } else {
1065                 er_flags &= ~QR_DOWNLOAD;
1066         }
1067
1068         if (!strcmp(bstr("visdir"), "yes")) {
1069                 er_flags |= QR_VISDIR;
1070         } else {
1071                 er_flags &= ~QR_VISDIR;
1072         }
1073
1074         strcpy(buf, bstr("anon"));
1075
1076         er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
1077         if (!strcmp(buf, "anononly"))
1078                 er_flags |= QR_ANONONLY;
1079         if (!strcmp(buf, "anon2"))
1080                 er_flags |= QR_ANONOPT;
1081
1082         bump = 0;
1083         if (!strcmp(bstr("bump"), "yes"))
1084                 bump = 1;
1085
1086         er_floor = atoi(bstr("er_floor"));
1087
1088         sprintf(buf, "SETR %s|%s|%s|%u|%d|%d",
1089              er_name, er_password, er_dirname, er_flags, bump, er_floor);
1090         serv_puts(buf);
1091         serv_gets(buf);
1092         if (buf[0] != '2') {
1093                 display_error(&buf[4]);
1094                 return;
1095         }
1096         gotoroom(er_name, 0);
1097
1098         if (strlen(er_roomaide) > 0) {
1099                 sprintf(buf, "SETA %s", er_roomaide);
1100                 serv_puts(buf);
1101                 serv_gets(buf);
1102                 if (buf[0] != '2') {
1103                         display_error(&buf[4]);
1104                         return;
1105                 }
1106         }
1107         smart_goto(er_name);
1108 }
1109
1110 /*
1111  * Invite, Kick, and show Who Knows a room
1112  */
1113 void display_whok(void)
1114 {
1115         char buf[SIZ], room[SIZ], username[SIZ];
1116
1117         serv_puts("GETR");
1118         serv_gets(buf);
1119
1120         if (buf[0] != '2') {
1121                 display_error(&buf[4]);
1122                 return;
1123         }
1124         extract(room, &buf[4], 0);
1125
1126         strcpy(username, bstr("username"));
1127
1128         output_headers(1);
1129
1130         wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=007700><TR><TD>");
1131         wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"<B>Access control list for ");
1132         escputs(WC->wc_roomname);
1133         wprintf("</B></FONT></TD></TR></TABLE>\n");
1134
1135         if(!strcmp(bstr("sc"), "Kick")) {
1136                 sprintf(buf, "KICK %s", username);
1137                 serv_puts(buf);
1138                 serv_gets(buf);
1139
1140                 if (buf[0] != '2') {
1141                         display_error(&buf[4]);
1142                         return;
1143                 } else {
1144                         wprintf("<B><I>User %s kicked out of room %s.</I></B>\n", 
1145                                 username, room);
1146                 }
1147         } else if(!strcmp(bstr("sc"), "Invite")) {
1148                 sprintf(buf, "INVT %s", username);
1149                 serv_puts(buf);
1150                 serv_gets(buf);
1151
1152                 if (buf[0] != '2') {
1153                         display_error(&buf[4]);
1154                         return;
1155                 } else {
1156                         wprintf("<B><I>User %s invited to room %s.</I></B>\n", 
1157                                 username, room);
1158                 }
1159         }
1160         
1161
1162
1163         wprintf("<TABLE border=0 CELLSPACING=10><TR VALIGN=TOP>"
1164                 "<TD>The users listed below have access to this room.  "
1165                 "To remove a user from the access list, select the user "
1166                 "name from the list and click 'Kick'.<BR><BR>");
1167         
1168         wprintf("<CENTER><FORM METHOD=\"POST\" ACTION=\"/display_whok\">\n");
1169         wprintf("<SELECT NAME=\"username\" SIZE=10>\n");
1170         serv_puts("WHOK");
1171         serv_gets(buf);
1172         if (buf[0] == '1') {
1173                 while (serv_gets(buf), strcmp(buf, "000")) {
1174                         extract(username, buf, 0);
1175                         wprintf("<OPTION>");
1176                         escputs(username);
1177                         wprintf("\n");
1178                 }
1179         }
1180         wprintf("</SELECT><BR>\n");
1181
1182         wprintf("<input type=submit name=sc value=\"Kick\">");
1183         wprintf("</FORM></CENTER>\n");
1184
1185         wprintf("</TD><TD>"
1186                 "To grant another user access to this room, enter the "
1187                 "user name in the box below and click 'Invite'.<BR><BR>");
1188
1189         wprintf("<CENTER><FORM METHOD=\"POST\" ACTION=\"/display_whok\">\n");
1190         wprintf("Invite: ");
1191         wprintf("<input type=text name=username><BR>\n"
1192                 "<input type=hidden name=sc value=\"Invite\">"
1193                 "<input type=submit value=\"Invite\">"
1194                 "</FORM></CENTER>\n");
1195
1196         wprintf("</TD></TR></TABLE>\n");
1197         wDumpContent(1);
1198 }
1199
1200
1201
1202 /*
1203  * display the form for entering a new room
1204  */
1205 void display_entroom(void)
1206 {
1207         int i;
1208         char buf[SIZ];
1209
1210         serv_puts("CRE8 0");
1211         serv_gets(buf);
1212
1213         if (buf[0] != '2') {
1214                 display_error(&buf[4]);
1215                 return;
1216         }
1217         output_headers(1);
1218
1219         wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=000077><TR><TD>");
1220         wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
1221         wprintf("<B>Enter (create) a new room</B>\n");
1222         wprintf("</FONT></TD></TR></TABLE>\n");
1223
1224         wprintf("<FORM METHOD=\"POST\" ACTION=\"/entroom\">\n");
1225
1226         wprintf("<UL><LI>Name of room: ");
1227         wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" MAXLENGTH=\"19\">\n");
1228
1229         wprintf("<LI>Type of room:<UL>\n");
1230
1231         wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1232         wprintf("CHECKED > Public room\n");
1233
1234         wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"guessname\" ");
1235         wprintf("> Private - guess name\n");
1236
1237         wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
1238         wprintf("> Private - require password:\n");
1239         wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
1240
1241         wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
1242         wprintf("> Private - invitation only\n");
1243         wprintf("</UL>\n");
1244
1245         wprintf("<LI>Resides on floor: ");
1246         load_floorlist(); 
1247         wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
1248         for (i = 0; i < 128; ++i)
1249                 if (strlen(floorlist[i]) > 0) {
1250                         wprintf("<OPTION ");
1251                         wprintf("VALUE=\"%d\">", i);
1252                         escputs(floorlist[i]);
1253                         wprintf("</OPTION>\n");
1254                 }
1255         wprintf("</SELECT>\n");                
1256         wprintf("</UL>\n");
1257
1258
1259         wprintf("<CENTER>\n");
1260         wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
1261         wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1262         wprintf("</CENTER>\n");
1263         wprintf("</FORM>\n<HR>");
1264         serv_printf("MESG roomaccess");
1265         serv_gets(buf);
1266         if (buf[0] == '1') {
1267                 fmout(NULL);
1268         }
1269         wDumpContent(1);
1270 }
1271
1272
1273
1274 /*
1275  * enter a new room
1276  */
1277 void entroom(void)
1278 {
1279         char buf[SIZ];
1280         char er_name[20];
1281         char er_type[20];
1282         char er_password[10];
1283         int er_floor;
1284         int er_num_type;
1285
1286         if (strcmp(bstr("sc"), "OK")) {
1287                 display_error("Cancelled.  No new room was created.");
1288                 return;
1289         }
1290         strcpy(er_name, bstr("er_name"));
1291         strcpy(er_type, bstr("type"));
1292         strcpy(er_password, bstr("er_password"));
1293         er_floor = atoi(bstr("er_floor"));
1294
1295         er_num_type = 0;
1296         if (!strcmp(er_type, "guessname"))
1297                 er_num_type = 1;
1298         if (!strcmp(er_type, "passworded"))
1299                 er_num_type = 2;
1300         if (!strcmp(er_type, "invonly"))
1301                 er_num_type = 3;
1302
1303         sprintf(buf, "CRE8 1|%s|%d|%s|%d", 
1304                 er_name, er_num_type, er_password, er_floor);
1305         serv_puts(buf);
1306         serv_gets(buf);
1307         if (buf[0] != '2') {
1308                 display_error(&buf[4]);
1309                 return;
1310         }
1311         smart_goto(er_name);
1312 }
1313
1314
1315 /*
1316  * display the screen to enter a private room
1317  */
1318 void display_private(char *rname, int req_pass)
1319 {
1320
1321         output_headers(1);
1322
1323         wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=770000><TR><TD>");
1324         wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
1325         wprintf("<B>Goto a private room</B>\n");
1326         wprintf("</FONT></TD></TR></TABLE>\n");
1327
1328         wprintf("<CENTER>\n");
1329         wprintf("If you know the name of a hidden (guess-name) or\n");
1330         wprintf("passworded room, you can enter that room by typing\n");
1331         wprintf("its name below.  Once you gain access to a private\n");
1332         wprintf("room, it will appear in your regular room listings\n");
1333         wprintf("so you don't have to keep returning here.\n");
1334         wprintf("<BR><BR>");
1335
1336         wprintf("<FORM METHOD=\"POST\" ACTION=\"/goto_private\">\n");
1337
1338         wprintf("<TABLE border><TR><TD>");
1339         wprintf("Enter room name:</TD><TD>");
1340         wprintf("<INPUT TYPE=\"text\" NAME=\"gr_name\" VALUE=\"%s\" MAXLENGTH=\"19\">\n", rname);
1341
1342         if (req_pass) {
1343                 wprintf("</TD></TR><TR><TD>");
1344                 wprintf("Enter room password:</TD><TD>");
1345                 wprintf("<INPUT TYPE=\"password\" NAME=\"gr_pass\" MAXLENGTH=\"9\">\n");
1346         }
1347         wprintf("</TD></TR></TABLE>\n");
1348
1349         wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
1350         wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1351         wprintf("</FORM>\n");
1352         wDumpContent(1);
1353 }
1354
1355 /* 
1356  * goto a private room
1357  */
1358 void goto_private(void)
1359 {
1360         char hold_rm[32];
1361         char buf[SIZ];
1362
1363         if (strcasecmp(bstr("sc"), "OK")) {
1364                 display_main_menu();
1365                 return;
1366         }
1367         strcpy(hold_rm, WC->wc_roomname);
1368         strcpy(buf, "GOTO ");
1369         strcat(buf, bstr("gr_name"));
1370         strcat(buf, "|");
1371         strcat(buf, bstr("gr_pass"));
1372         serv_puts(buf);
1373         serv_gets(buf);
1374
1375         if (buf[0] == '2') {
1376                 smart_goto(bstr("gr_name"));
1377                 return;
1378         }
1379         if (!strncmp(buf, "540", 3)) {
1380                 display_private(bstr("gr_name"), 1);
1381                 return;
1382         }
1383         output_headers(1);
1384         wprintf("%s\n", &buf[4]);
1385         wDumpContent(1);
1386         return;
1387 }
1388
1389
1390 /*
1391  * display the screen to zap a room
1392  */
1393 void display_zap(void)
1394 {
1395         output_headers(1);
1396
1397         wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=770000><TR><TD>");
1398         wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
1399         wprintf("<B>Zap (forget) the current room</B>\n");
1400         wprintf("</FONT></TD></TR></TABLE>\n");
1401
1402         wprintf("If you select this option, <em>%s</em> will ", WC->wc_roomname);
1403         wprintf("disappear from your room list.  Is this what you wish ");
1404         wprintf("to do?<BR>\n");
1405
1406         wprintf("<FORM METHOD=\"POST\" ACTION=\"/zap\">\n");
1407         wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
1408         wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1409         wprintf("</FORM>\n");
1410         wDumpContent(1);
1411 }
1412
1413
1414 /* 
1415  * zap a room
1416  */
1417 void zap(void)
1418 {
1419         char buf[SIZ];
1420         char final_destination[SIZ];
1421
1422         /* If the forget-room routine fails for any reason, we fall back
1423          * to the current room; otherwise, we go to the Lobby
1424          */
1425         strcpy(final_destination, WC->wc_roomname);
1426
1427         if (!strcasecmp(bstr("sc"), "OK")) {
1428                 serv_printf("GOTO %s", WC->wc_roomname);
1429                 serv_gets(buf);
1430                 if (buf[0] != '2') {
1431                         /* ExpressMessageCat(&buf[4]); */
1432                 } else {
1433                         serv_puts("FORG");
1434                         serv_gets(buf);
1435                         if (buf[0] != '2') {
1436                                 /* ExpressMessageCat(&buf[4]); */
1437                         } else {
1438                                 strcpy(final_destination, "_BASEROOM_");
1439                         }
1440                 }
1441         }
1442         smart_goto(final_destination);
1443 }
1444
1445
1446
1447
1448 /*
1449  * Confirm deletion of the current room
1450  */
1451 void confirm_delete_room(void)
1452 {
1453         char buf[SIZ];
1454
1455         serv_puts("KILL 0");
1456         serv_gets(buf);
1457         if (buf[0] != '2') {
1458                 display_error(&buf[4]);
1459                 return;
1460         }
1461         output_headers(1);
1462         wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=770000><TR><TD>");
1463         wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
1464         wprintf("<B>Confirm deletion of room</B>\n");
1465         wprintf("</FONT></TD></TR></TABLE>\n");
1466
1467         wprintf("<CENTER>");
1468         wprintf("<FORM METHOD=\"POST\" ACTION=\"/delete_room\">\n");
1469
1470         wprintf("Are you sure you want to delete <FONT SIZE=+1>");
1471         escputs(WC->wc_roomname);
1472         wprintf("</FONT>?<BR>\n");
1473
1474         wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Delete\">");
1475         wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1476
1477         wprintf("</FORM></CENTER>\n");
1478         wDumpContent(1);
1479 }
1480
1481
1482 /*
1483  * Delete the current room
1484  */
1485 void delete_room(void)
1486 {
1487         char buf[SIZ];
1488         char sc[SIZ];
1489
1490         strcpy(sc, bstr("sc"));
1491
1492         if (strcasecmp(sc, "Delete")) {
1493                 display_error("Cancelled.  This room was not deleted.");
1494                 return;
1495         }
1496         serv_puts("KILL 1");
1497         serv_gets(buf);
1498         if (buf[0] != '2') {
1499                 display_error(&buf[4]);
1500         } else {
1501                 smart_goto("_BASEROOM_");
1502         }
1503 }
1504
1505
1506
1507 /*
1508  * Perform changes to a room's network configuration
1509  */
1510 void netedit(void) {
1511         FILE *fp;
1512         char buf[SIZ];
1513         char line[SIZ];
1514
1515         if (strlen(bstr("line"))==0) {
1516                 display_editroom();
1517                 return;
1518         }
1519
1520         strcpy(line, bstr("prefix"));
1521         strcat(line, bstr("line"));
1522         strcat(line, bstr("suffix"));
1523
1524         fp = tmpfile();
1525         if (fp == NULL) {
1526                 display_editroom();
1527                 return;
1528         }
1529
1530         serv_puts("GNET");
1531         serv_gets(buf);
1532         if (buf[0] != '1') {
1533                 fclose(fp);
1534                 display_editroom();
1535                 return;
1536         }
1537
1538         /* This loop works for add *or* remove.  Spiffy, eh? */
1539         while (serv_gets(buf), strcmp(buf, "000")) {
1540                 if (strcasecmp(buf, line)) {
1541                         fprintf(fp, "%s\n", buf);
1542                 }
1543         }
1544
1545         rewind(fp);
1546         serv_puts("SNET");
1547         serv_gets(buf);
1548         if (buf[0] != '4') {
1549                 fclose(fp);
1550                 display_editroom();
1551                 return;
1552         }
1553
1554         while (fgets(buf, sizeof buf, fp) != NULL) {
1555                 buf[strlen(buf)-1] = 0;
1556                 serv_puts(buf);
1557         }
1558
1559         if (!strcasecmp(bstr("cmd"), "add")) {
1560                 serv_puts(line);
1561         }
1562
1563         serv_puts("000");
1564         fclose(fp);
1565         display_editroom();
1566 }