10 #include <sys/types.h>
12 #include <sys/socket.h>
15 #include <netinet/in.h>
31 char floorlist[128][SIZ];
35 * load the list of floors
37 void load_floorlist(void)
42 for (a = 0; a < 128; ++a)
48 strcpy(floorlist[0], "Main Floor");
51 while (serv_gets(buf), strcmp(buf, "000")) {
52 extract(floorlist[extract_int(buf, 0)], buf, 1);
58 * remove a room from the march list
60 void remove_march(char *aaa)
62 struct march *mptr, *mptr2;
64 if (WC->march == NULL)
67 if (!strcasecmp(WC->march->march_name, aaa)) {
68 mptr = WC->march->next;
74 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
75 if (!strcasecmp(mptr->march_name, aaa)) {
76 mptr2->next = mptr->next;
89 void room_tree_list(struct roomlisting *rp)
97 if (rp->lnext != NULL) {
98 room_tree_list(rp->lnext);
100 strcpy(rmname, rp->rlname);
103 wprintf("<A HREF=\"/dotgoto&room=");
108 if ((f & QR_DIRECTORY) && (f & QR_NETWORK))
110 else if (f & QR_DIRECTORY)
112 else if (f & QR_NETWORK)
116 wprintf("</A><TT> </TT>\n");
118 if (rp->rnext != NULL) {
119 room_tree_list(rp->rnext);
126 * Room ordering stuff (compare first by floor, then by order)
128 int rordercmp(struct roomlisting *r1, struct roomlisting *r2)
130 if ((r1 == NULL) && (r2 == NULL))
136 if (r1->rlfloor < r2->rlfloor)
138 if (r1->rlfloor > r2->rlfloor)
140 if (r1->rlorder < r2->rlorder)
142 if (r1->rlorder > r2->rlorder)
149 * Common code for all room listings
151 void listrms(char *variety)
156 struct roomlisting *rl = NULL;
157 struct roomlisting *rp;
158 struct roomlisting *rs;
161 /* Ask the server for a room list */
168 while (serv_gets(buf), strcmp(buf, "000")) {
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);
183 if (rordercmp(rp, rs) < 0) {
184 if (rs->lnext == NULL) {
191 if (rs->rnext == NULL) {
203 /* If no rooms were listed, print an nbsp to make the cell
204 * borders show up anyway.
206 if (num_rooms == 0) wprintf(" ");
218 * list all rooms by floor
220 void list_all_rooms_by_floor(void)
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");
233 for (a = 0; a < 128; ++a)
234 if (floorlist[a][0] != 0) {
236 /* Floor name column */
239 serv_printf("OIMG _floorpic_|%d", a);
244 wprintf("<IMG SRC=\"/image&name=_floorpic_&parm=%d\" ALT=\"%s\">",
245 a, &floorlist[a][0]);
247 escputs(&floorlist[a][0]);
252 /* Rooms with new messages column */
254 sprintf(buf, "LKRN %d", a);
256 wprintf("</TD>\n<TD>");
258 /* Rooms with old messages column */
259 sprintf(buf, "LKRO %d", a);
261 wprintf("</TD></TR>\n");
263 wprintf("</TABLE>\n");
269 * list all forgotten rooms
271 void zapped_list(void)
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");
279 wprintf("<BR><BR>\n");
280 wprintf("Click on any room to un-zap it and goto that room.\n");
286 * read this room's info file (set v to 1 for verbose mode)
295 wprintf("<FONT SIZE=-1>");
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
309 void embed_room_graphic(void) {
312 serv_puts("OIMG _roompic_");
316 wprintf("<IMG SRC=\"/image&name=_roompic_&room=");
317 urlescputs(WC->wc_roomname);
326 /* Let the user know if new mail has arrived
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;
342 void embed_room_banner(char *got) {
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.
349 serv_printf("GOTO %s", WC->wc_roomname);
354 /* Check for new mail. */
355 WC->new_mail = extract_int(&got[4], 9);
356 WC->wc_view = extract_int(&got[4], 11);
358 svprintf("ROOMNAME", WCS_STRING, "%s", WC->wc_roomname);
359 svprintf("NEWMSGS", WCS_STRING, "%d", extract_int(&got[4], 1));
360 svprintf("TOTALMSGS", WCS_STRING, "%d", extract_int(&got[4], 2));
361 svcallback("ROOMPIC", embed_room_graphic);
362 svcallback("ROOMINFO", readinfo);
363 svcallback("YOUHAVEMAIL", embed_newmail_button);
365 do_template("roombanner.html");
366 clear_local_substs();
374 * generic routine to take the session to a new room
376 * display_name values: 0 = goto only
377 * 1 = goto and display
380 void gotoroom(char *gname, int display_name)
383 static long ls = (-1L);
388 wprintf("Pragma: no-cache\n");
389 wprintf("Cache-Control: no-store\n");
391 wprintf("<HTML><HEAD>\n"
392 "<META HTTP-EQUIV=\"refresh\" CONTENT=\"500363689;\">\n"
393 "<META HTTP-EQUIV=\"Pragma\" CONTENT=\"no-cache\">\n"
394 "<META HTTP-EQUIV=\"expired\" CONTENT=\"28-May-1971 18:10:00 GMT\">\n"
395 "<meta name=\"MSSmartTagsPreventParsing\" content=\"TRUE\">\n"
397 do_template("background.html");
399 if (display_name != 2) {
400 /* store ungoto information */
401 strcpy(WC->ugname, WC->wc_roomname);
404 /* move to the new room */
405 serv_printf("GOTO %s", gname);
408 serv_puts("GOTO _BASEROOM_");
413 wprintf("<EM>%s</EM><BR>\n", &buf[4]);
418 extract(WC->wc_roomname, &buf[4], 0);
419 WC->room_flags = extract_int(&buf[4], 4);
420 /* highest_msg_read = extract_int(&buf[4],6);
421 maxmsgnum = extract_int(&buf[4],5);
422 is_mail = (char) extract_int(&buf[4],7); */
423 ls = extract_long(&buf[4], 6);
426 WC->is_room_aide = WC->is_aide;
428 WC->is_room_aide = (char) extract_int(&buf[4], 8);
430 remove_march(WC->wc_roomname);
431 if (!strcasecmp(gname, "_BASEROOM_"))
434 /* Display the room banner */
436 embed_room_banner(buf);
439 strcpy(WC->wc_roomname, WC->wc_roomname);
440 WC->wc_view = extract_int(&buf[4], 11);
445 * Locate the room on the march list which we most want to go to. Each room
446 * is measured given a "weight" of preference based on various factors.
448 char *pop_march(int desired_floor)
450 static char TheRoom[64];
452 int TheOrder = 32767;
455 struct march *mptr = NULL;
457 strcpy(TheRoom, "_BASEROOM_");
458 if (WC->march == NULL)
461 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
463 if ((strcasecmp(mptr->march_name, "_BASEROOM_")))
464 weight = weight + 10000;
465 if (mptr->march_floor == desired_floor)
466 weight = weight + 5000;
468 weight = weight + ((128 - (mptr->march_floor)) * 128);
469 weight = weight + (128 - (mptr->march_order));
471 if (weight > TheWeight) {
473 strcpy(TheRoom, mptr->march_name);
474 TheFloor = mptr->march_floor;
475 TheOrder = mptr->march_order;
483 /* Goto next room having unread messages.
484 * We want to skip over rooms that the user has already been to, and take the
485 * user back to the lobby when done. The room we end up in is placed in
486 * newroom - which is set to 0 (the lobby) initially.
487 * We start the search in the current room rather than the beginning to prevent
488 * two or more concurrent users from dragging each other back to the same room.
493 struct march *mptr, *mptr2;
496 /* First check to see if the march-mode list is already allocated.
497 * If it is, pop the first room off the list and go there.
500 if (WC->march == NULL) {
504 while (serv_gets(buf), strcmp(buf, "000")) {
505 mptr = (struct march *) malloc(sizeof(struct march));
507 extract(mptr->march_name, buf, 0);
508 mptr->march_floor = extract_int(buf, 2);
509 mptr->march_order = extract_int(buf, 3);
510 if (WC->march == NULL) {
514 while (mptr2->next != NULL)
519 /* add _BASEROOM_ to the end of the march list, so the user will end up
520 * in the system base room (usually the Lobby>) at the end of the loop
522 mptr = (struct march *) malloc(sizeof(struct march));
524 strcpy(mptr->march_name, "_BASEROOM_");
525 if (WC->march == NULL) {
529 while (mptr2->next != NULL)
534 * ...and remove the room we're currently in, so a <G>oto doesn't make us
535 * walk around in circles
537 remove_march(WC->wc_roomname);
539 if (WC->march != NULL) {
540 strcpy(next_room, pop_march(-1));
542 strcpy(next_room, "_BASEROOM_");
546 smart_goto(next_room);
550 void smart_goto(char *next_room) {
551 gotoroom(next_room, 0);
558 * mark all messages in current room as having been read
560 void slrp_highest(void)
565 serv_puts("SLRP HIGHEST");
568 wprintf("<EM>%s</EM><BR>\n", &buf[4]);
575 * un-goto the previous room
581 if (!strcmp(WC->ugname, "")) {
582 smart_goto(WC->wc_roomname);
585 serv_printf("GOTO %s", WC->ugname);
588 smart_goto(WC->wc_roomname);
591 if (WC->uglsn >= 0L) {
592 serv_printf("SLRP %ld", WC->uglsn);
595 strcpy(buf, WC->ugname);
596 strcpy(WC->ugname, "");
601 * display the form for editing a room
603 void display_editroom(void)
610 char er_password[10];
612 char er_roomaide[26];
618 char *not_shared_with;
621 if (strlen(tab) == 0) tab = "admin";
627 display_error(&buf[4]);
630 extract(er_name, &buf[4], 0);
631 extract(er_password, &buf[4], 1);
632 extract(er_dirname, &buf[4], 2);
633 er_flags = extract_int(&buf[4], 3);
634 er_floor = extract_int(&buf[4], 4);
638 /* print the tabbed dialog */
639 wprintf("<TABLE border=0 width=100%%><TR BGCOLOR=FFFFFF><TD> </TD>");
641 if (!strcmp(tab, "admin")) {
642 wprintf("<TD BGCOLOR=000077><FONT SIZE=+1 COLOR=\"FFFFFF\"><B>");
645 wprintf("<TD><A HREF=\"/display_editroom&tab=admin\">");
647 wprintf("Room administration");
648 if (!strcmp(tab, "admin")) {
649 wprintf("</B></FONT></TD>\n");
652 wprintf("</A></TD>\n");
655 wprintf("<TD> </TD>\n");
657 if (!strcmp(tab, "config")) {
658 wprintf("<TD BGCOLOR=000077><FONT SIZE=+1 COLOR=\"FFFFFF\"><B>");
661 wprintf("<TD><A HREF=\"/display_editroom&tab=config\">");
663 wprintf("Room configuration");
664 if (!strcmp(tab, "config")) {
665 wprintf("</B></FONT></TD>\n");
668 wprintf("</A></TD>\n");
671 wprintf("<TD> </TD>\n");
673 if (!strcmp(tab, "sharing")) {
674 wprintf("<TD BGCOLOR=000077><FONT SIZE=+1 COLOR=\"FFFFFF\"><B>");
677 wprintf("<TD><A HREF=\"/display_editroom&tab=sharing\">");
680 if (!strcmp(tab, "sharing")) {
681 wprintf("</B></FONT></TD>\n");
684 wprintf("</A></TD>\n");
687 wprintf("<TD> </TD>\n");
689 if (!strcmp(tab, "listserv")) {
690 wprintf("<TD BGCOLOR=000077><FONT SIZE=+1 COLOR=\"FFFFFF\"><B>");
693 wprintf("<TD><A HREF=\"/display_editroom&tab=listserv\">");
695 wprintf("Mailing list service");
696 if (!strcmp(tab, "listserv")) {
697 wprintf("</B></FONT></TD>\n");
700 wprintf("</A></TD>\n");
703 wprintf("<TD> </TD></TR></TABLE>\n");
705 /* end tabbed dialog */
708 if (!strcmp(tab, "admin")) {
710 "<LI><A HREF=\"/confirm_delete_room\">\n"
711 "Delete this room</A>\n"
712 "<LI><A HREF=\"/display_editroompic\">\n"
713 "Set or change the graphic for this room's banner</A>\n"
714 "<LI><A HREF=\"/display_editinfo\">\n"
715 "Edit this room's Info file</A>\n"
719 if (!strcmp(tab, "config")) {
720 wprintf("<FORM METHOD=\"POST\" ACTION=\"/editroom\">\n");
722 wprintf("<UL><LI>Name of room: ");
723 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\"19\">\n", er_name);
725 wprintf("<LI>Resides on floor: ");
727 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
728 for (i = 0; i < 128; ++i)
729 if (strlen(floorlist[i]) > 0) {
732 wprintf("SELECTED ");
733 wprintf("VALUE=\"%d\">", i);
734 escputs(floorlist[i]);
735 wprintf("</OPTION>\n");
737 wprintf("</SELECT>\n");
739 wprintf("<LI>Type of room:<UL>\n");
741 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
742 if ((er_flags & QR_PRIVATE) == 0)
744 wprintf("> Public room\n");
746 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"guessname\" ");
747 if ((er_flags & QR_PRIVATE) &&
748 (er_flags & QR_GUESSNAME))
750 wprintf("> Private - guess name\n");
752 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
753 if ((er_flags & QR_PRIVATE) &&
754 (er_flags & QR_PASSWORDED))
756 wprintf("> Private - require password:\n");
757 wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n", er_password);
759 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
760 if ((er_flags & QR_PRIVATE)
761 && ((er_flags & QR_GUESSNAME) == 0)
762 && ((er_flags & QR_PASSWORDED) == 0))
764 wprintf("> Private - invitation only\n");
766 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
767 wprintf("> If private, cause current users to forget room\n");
771 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
772 if (er_flags & QR_PREFONLY)
774 wprintf("> Preferred users only\n");
776 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
777 if (er_flags & QR_READONLY)
779 wprintf("> Read-only room\n");
781 /* directory stuff */
782 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
783 if (er_flags & QR_DIRECTORY)
785 wprintf("> File directory room\n");
787 wprintf("<UL><LI>Directory name: ");
788 wprintf("<INPUT TYPE=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n", er_dirname);
790 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
791 if (er_flags & QR_UPLOAD)
793 wprintf("> Uploading allowed\n");
795 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
796 if (er_flags & QR_DOWNLOAD)
798 wprintf("> Downloading allowed\n");
800 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
801 if (er_flags & QR_VISDIR)
803 wprintf("> Visible directory</UL>\n");
805 /* end of directory stuff */
807 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
808 if (er_flags & QR_NETWORK)
810 wprintf("> Network shared room\n");
812 /* start of anon options */
814 wprintf("<LI>Anonymous messages<UL>\n");
816 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
817 if (((er_flags & QR_ANONONLY) == 0)
818 && ((er_flags & QR_ANONOPT) == 0))
820 wprintf("> No anonymous messages\n");
822 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
823 if (er_flags & QR_ANONONLY)
825 wprintf("> All messages are anonymous\n");
827 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
828 if (er_flags & QR_ANONOPT)
830 wprintf("> Prompt user when entering messages</UL>\n");
832 /* end of anon options */
834 wprintf("<LI>Room aide: \n");
838 wprintf("<EM>%s</EM>\n", &buf[4]);
840 extract(er_roomaide, &buf[4], 0);
841 wprintf("<INPUT TYPE=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n", er_roomaide);
844 wprintf("</UL><CENTER>\n");
845 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
846 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
847 wprintf("</CENTER>\n");
851 /* Sharing the room with other Citadel nodes... */
852 if (!strcmp(tab, "sharing")) {
854 shared_with = strdup("");
855 not_shared_with = strdup("");
857 /* Learn the current configuration */
858 serv_puts("CONF getsys|application/x-citadel-ignet-config");
860 if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
861 extract(node, buf, 0);
862 not_shared_with = realloc(not_shared_with,
863 strlen(not_shared_with) + 32);
864 strcat(not_shared_with, node);
865 strcat(not_shared_with, "|");
870 if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
871 extract(cmd, buf, 0);
872 extract(node, buf, 1);
873 if (!strcasecmp(cmd, "ignet_push_share")) {
874 shared_with = realloc(shared_with,
875 strlen(shared_with) + 32);
876 strcat(shared_with, node);
877 strcat(shared_with, "|");
881 for (i=0; i<num_tokens(shared_with, '|'); ++i) {
882 extract(node, shared_with, i);
883 for (j=0; j<num_tokens(not_shared_with, '|'); ++j) {
884 extract(cmd, not_shared_with, j);
885 if (!strcasecmp(node, cmd)) {
886 remove_token(not_shared_with, j, '|');
891 /* Display the stuff */
892 wprintf("<CENTER><BR>"
893 "<TABLE border=1 cellpadding=5><TR>"
894 "<TD><B><I>Shared with</I></B></TD>"
895 "<TD><B><I>Not shared with</I></B></TD></TR>\n"
898 for (i=0; i<num_tokens(shared_with, '|'); ++i) {
899 extract(node, shared_with, i);
900 if (strlen(node) > 0) {
901 wprintf("%s ", node);
902 wprintf("<A HREF=\"/netedit&cmd=remove&line="
903 "ignet_push_share|");
905 wprintf("&tab=sharing\">(unshare)</A><BR>");
909 wprintf("</TD><TD>\n");
911 for (i=0; i<num_tokens(not_shared_with, '|'); ++i) {
912 extract(node, not_shared_with, i);
913 if (strlen(node) > 0) {
914 wprintf("%s ", node);
915 wprintf("<A HREF=\"/netedit&cmd=add&line="
916 "ignet_push_share|");
918 wprintf("&tab=sharing\">(share)</A><BR>");
922 wprintf("</TD></TR></TABLE><BR>\n"
923 "<I><B>Reminder:</B> When sharing a room, "
924 "it must be shared from both ends. Adding a node to "
925 "the 'shared' list sends messages out, but in order to"
926 " receive messages, the other nodes must be configured"
927 " to send messages out to your system as well.</I><BR>"
932 /* Mailing list management */
933 if (!strcmp(tab, "listserv")) {
935 wprintf("<BR><center><i>The contents of this room are being "
936 "mailed to the following list recipients:"
941 if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
942 extract(cmd, buf, 0);
943 if (!strcasecmp(cmd, "listrecp")) {
944 extract(recp, buf, 1);
947 wprintf(" <A HREF=\"/netedit&cmd=remove&line="
950 wprintf("&tab=listserv\">(remove)</A><BR>");
954 wprintf("<BR><FORM METHOD=\"POST\" ACTION=\"/netedit\">\n"
955 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
956 "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"listrecp|\">\n");
957 wprintf("<INPUT TYPE=\"text\" NAME=\"line\">\n");
958 wprintf("<INPUT TYPE=\"submit\" NAME=\"cmd\" VALUE=\"Add\">");
959 wprintf("</FORM><BR></CENTER>\n");
967 * save new parameters for a room
973 char er_password[10];
975 char er_roomaide[26];
981 if (strcmp(bstr("sc"), "OK")) {
982 display_error("Cancelled. Changes were not saved.");
989 display_error(&buf[4]);
992 extract(er_name, &buf[4], 0);
993 extract(er_password, &buf[4], 1);
994 extract(er_dirname, &buf[4], 2);
995 er_flags = extract_int(&buf[4], 3);
997 strcpy(er_roomaide, bstr("er_roomaide"));
998 if (strlen(er_roomaide) == 0) {
1001 if (buf[0] != '2') {
1002 strcpy(er_roomaide, "");
1004 extract(er_roomaide, &buf[4], 0);
1007 strcpy(buf, bstr("er_name"));
1009 if (strlen(buf) > 0)
1010 strcpy(er_name, buf);
1012 strcpy(buf, bstr("er_password"));
1014 if (strlen(buf) > 0)
1015 strcpy(er_password, buf);
1017 strcpy(buf, bstr("er_dirname"));
1019 if (strlen(buf) > 0)
1020 strcpy(er_dirname, buf);
1022 strcpy(buf, bstr("type"));
1023 er_flags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME);
1025 if (!strcmp(buf, "invonly")) {
1026 er_flags |= (QR_PRIVATE);
1028 if (!strcmp(buf, "guessname")) {
1029 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
1031 if (!strcmp(buf, "passworded")) {
1032 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
1034 if (!strcmp(bstr("prefonly"), "yes")) {
1035 er_flags |= QR_PREFONLY;
1037 er_flags &= ~QR_PREFONLY;
1040 if (!strcmp(bstr("readonly"), "yes")) {
1041 er_flags |= QR_READONLY;
1043 er_flags &= ~QR_READONLY;
1046 if (!strcmp(bstr("network"), "yes")) {
1047 er_flags |= QR_NETWORK;
1049 er_flags &= ~QR_NETWORK;
1052 if (!strcmp(bstr("directory"), "yes")) {
1053 er_flags |= QR_DIRECTORY;
1055 er_flags &= ~QR_DIRECTORY;
1058 if (!strcmp(bstr("ulallowed"), "yes")) {
1059 er_flags |= QR_UPLOAD;
1061 er_flags &= ~QR_UPLOAD;
1064 if (!strcmp(bstr("dlallowed"), "yes")) {
1065 er_flags |= QR_DOWNLOAD;
1067 er_flags &= ~QR_DOWNLOAD;
1070 if (!strcmp(bstr("visdir"), "yes")) {
1071 er_flags |= QR_VISDIR;
1073 er_flags &= ~QR_VISDIR;
1076 strcpy(buf, bstr("anon"));
1078 er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
1079 if (!strcmp(buf, "anononly"))
1080 er_flags |= QR_ANONONLY;
1081 if (!strcmp(buf, "anon2"))
1082 er_flags |= QR_ANONOPT;
1085 if (!strcmp(bstr("bump"), "yes"))
1088 er_floor = atoi(bstr("er_floor"));
1090 sprintf(buf, "SETR %s|%s|%s|%u|%d|%d",
1091 er_name, er_password, er_dirname, er_flags, bump, er_floor);
1094 if (buf[0] != '2') {
1095 display_error(&buf[4]);
1098 gotoroom(er_name, 0);
1100 if (strlen(er_roomaide) > 0) {
1101 sprintf(buf, "SETA %s", er_roomaide);
1104 if (buf[0] != '2') {
1105 display_error(&buf[4]);
1109 smart_goto(er_name);
1113 * Invite, Kick, and show Who Knows a room
1115 void display_whok(void)
1117 char buf[SIZ], room[SIZ], username[SIZ];
1122 if (buf[0] != '2') {
1123 display_error(&buf[4]);
1126 extract(room, &buf[4], 0);
1128 strcpy(username, bstr("username"));
1132 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=007700><TR><TD>");
1133 wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"<B>Access control list for ");
1134 escputs(WC->wc_roomname);
1135 wprintf("</B></FONT></TD></TR></TABLE>\n");
1137 if(!strcmp(bstr("sc"), "Kick")) {
1138 sprintf(buf, "KICK %s", username);
1142 if (buf[0] != '2') {
1143 display_error(&buf[4]);
1146 wprintf("<B><I>User %s kicked out of room %s.</I></B>\n",
1149 } else if(!strcmp(bstr("sc"), "Invite")) {
1150 sprintf(buf, "INVT %s", username);
1154 if (buf[0] != '2') {
1155 display_error(&buf[4]);
1158 wprintf("<B><I>User %s invited to room %s.</I></B>\n",
1165 wprintf("<TABLE border=0 CELLSPACING=10><TR VALIGN=TOP>"
1166 "<TD>The users listed below have access to this room. "
1167 "To remove a user from the access list, select the user "
1168 "name from the list and click 'Kick'.<BR><BR>");
1170 wprintf("<CENTER><FORM METHOD=\"POST\" ACTION=\"/display_whok\">\n");
1171 wprintf("<SELECT NAME=\"username\" SIZE=10>\n");
1174 if (buf[0] == '1') {
1175 while (serv_gets(buf), strcmp(buf, "000")) {
1176 extract(username, buf, 0);
1177 wprintf("<OPTION>");
1182 wprintf("</SELECT><BR>\n");
1184 wprintf("<input type=submit name=sc value=\"Kick\">");
1185 wprintf("</FORM></CENTER>\n");
1188 "To grant another user access to this room, enter the "
1189 "user name in the box below and click 'Invite'.<BR><BR>");
1191 wprintf("<CENTER><FORM METHOD=\"POST\" ACTION=\"/display_whok\">\n");
1192 wprintf("Invite: ");
1193 wprintf("<input type=text name=username><BR>\n"
1194 "<input type=hidden name=sc value=\"Invite\">"
1195 "<input type=submit value=\"Invite\">"
1196 "</FORM></CENTER>\n");
1198 wprintf("</TD></TR></TABLE>\n");
1205 * display the form for entering a new room
1207 void display_entroom(void)
1212 serv_puts("CRE8 0");
1215 if (buf[0] != '2') {
1216 display_error(&buf[4]);
1221 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=000077><TR><TD>");
1222 wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
1223 wprintf("<B>Enter (create) a new room</B>\n");
1224 wprintf("</FONT></TD></TR></TABLE>\n");
1226 wprintf("<FORM METHOD=\"POST\" ACTION=\"/entroom\">\n");
1228 wprintf("<UL><LI>Name of room: ");
1229 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" MAXLENGTH=\"19\">\n");
1231 wprintf("<LI>Type of room:<UL>\n");
1233 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1234 wprintf("CHECKED > Public room\n");
1236 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"guessname\" ");
1237 wprintf("> Private - guess name\n");
1239 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
1240 wprintf("> Private - require password:\n");
1241 wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
1243 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
1244 wprintf("> Private - invitation only\n");
1247 wprintf("<LI>Resides on floor: ");
1249 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
1250 for (i = 0; i < 128; ++i)
1251 if (strlen(floorlist[i]) > 0) {
1252 wprintf("<OPTION ");
1253 wprintf("VALUE=\"%d\">", i);
1254 escputs(floorlist[i]);
1255 wprintf("</OPTION>\n");
1257 wprintf("</SELECT>\n");
1261 wprintf("<CENTER>\n");
1262 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
1263 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1264 wprintf("</CENTER>\n");
1265 wprintf("</FORM>\n<HR>");
1266 serv_printf("MESG roomaccess");
1268 if (buf[0] == '1') {
1284 char er_password[10];
1288 if (strcmp(bstr("sc"), "OK")) {
1289 display_error("Cancelled. No new room was created.");
1292 strcpy(er_name, bstr("er_name"));
1293 strcpy(er_type, bstr("type"));
1294 strcpy(er_password, bstr("er_password"));
1295 er_floor = atoi(bstr("er_floor"));
1298 if (!strcmp(er_type, "guessname"))
1300 if (!strcmp(er_type, "passworded"))
1302 if (!strcmp(er_type, "invonly"))
1305 sprintf(buf, "CRE8 1|%s|%d|%s|%d",
1306 er_name, er_num_type, er_password, er_floor);
1309 if (buf[0] != '2') {
1310 display_error(&buf[4]);
1313 smart_goto(er_name);
1318 * display the screen to enter a private room
1320 void display_private(char *rname, int req_pass)
1325 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=770000><TR><TD>");
1326 wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
1327 wprintf("<B>Goto a private room</B>\n");
1328 wprintf("</FONT></TD></TR></TABLE>\n");
1330 wprintf("<CENTER>\n");
1331 wprintf("If you know the name of a hidden (guess-name) or\n");
1332 wprintf("passworded room, you can enter that room by typing\n");
1333 wprintf("its name below. Once you gain access to a private\n");
1334 wprintf("room, it will appear in your regular room listings\n");
1335 wprintf("so you don't have to keep returning here.\n");
1336 wprintf("<BR><BR>");
1338 wprintf("<FORM METHOD=\"POST\" ACTION=\"/goto_private\">\n");
1340 wprintf("<TABLE border><TR><TD>");
1341 wprintf("Enter room name:</TD><TD>");
1342 wprintf("<INPUT TYPE=\"text\" NAME=\"gr_name\" VALUE=\"%s\" MAXLENGTH=\"19\">\n", rname);
1345 wprintf("</TD></TR><TR><TD>");
1346 wprintf("Enter room password:</TD><TD>");
1347 wprintf("<INPUT TYPE=\"password\" NAME=\"gr_pass\" MAXLENGTH=\"9\">\n");
1349 wprintf("</TD></TR></TABLE>\n");
1351 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
1352 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1353 wprintf("</FORM>\n");
1358 * goto a private room
1360 void goto_private(void)
1365 if (strcasecmp(bstr("sc"), "OK")) {
1366 display_main_menu();
1369 strcpy(hold_rm, WC->wc_roomname);
1370 strcpy(buf, "GOTO ");
1371 strcat(buf, bstr("gr_name"));
1373 strcat(buf, bstr("gr_pass"));
1377 if (buf[0] == '2') {
1378 smart_goto(bstr("gr_name"));
1381 if (!strncmp(buf, "540", 3)) {
1382 display_private(bstr("gr_name"), 1);
1386 wprintf("%s\n", &buf[4]);
1393 * display the screen to zap a room
1395 void display_zap(void)
1399 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=770000><TR><TD>");
1400 wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
1401 wprintf("<B>Zap (forget) the current room</B>\n");
1402 wprintf("</FONT></TD></TR></TABLE>\n");
1404 wprintf("If you select this option, <em>%s</em> will ", WC->wc_roomname);
1405 wprintf("disappear from your room list. Is this what you wish ");
1406 wprintf("to do?<BR>\n");
1408 wprintf("<FORM METHOD=\"POST\" ACTION=\"/zap\">\n");
1409 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
1410 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1411 wprintf("</FORM>\n");
1422 char final_destination[SIZ];
1424 /* If the forget-room routine fails for any reason, we fall back
1425 * to the current room; otherwise, we go to the Lobby
1427 strcpy(final_destination, WC->wc_roomname);
1429 if (!strcasecmp(bstr("sc"), "OK")) {
1430 serv_printf("GOTO %s", WC->wc_roomname);
1432 if (buf[0] != '2') {
1433 /* ExpressMessageCat(&buf[4]); */
1437 if (buf[0] != '2') {
1438 /* ExpressMessageCat(&buf[4]); */
1440 strcpy(final_destination, "_BASEROOM_");
1444 smart_goto(final_destination);
1451 * Confirm deletion of the current room
1453 void confirm_delete_room(void)
1457 serv_puts("KILL 0");
1459 if (buf[0] != '2') {
1460 display_error(&buf[4]);
1464 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=770000><TR><TD>");
1465 wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
1466 wprintf("<B>Confirm deletion of room</B>\n");
1467 wprintf("</FONT></TD></TR></TABLE>\n");
1469 wprintf("<CENTER>");
1470 wprintf("<FORM METHOD=\"POST\" ACTION=\"/delete_room\">\n");
1472 wprintf("Are you sure you want to delete <FONT SIZE=+1>");
1473 escputs(WC->wc_roomname);
1474 wprintf("</FONT>?<BR>\n");
1476 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Delete\">");
1477 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1479 wprintf("</FORM></CENTER>\n");
1485 * Delete the current room
1487 void delete_room(void)
1492 strcpy(sc, bstr("sc"));
1494 if (strcasecmp(sc, "Delete")) {
1495 display_error("Cancelled. This room was not deleted.");
1498 serv_puts("KILL 1");
1500 if (buf[0] != '2') {
1501 display_error(&buf[4]);
1503 smart_goto("_BASEROOM_");
1510 * Perform changes to a room's network configuration
1512 void netedit(void) {
1517 if (strlen(bstr("line"))==0) {
1522 strcpy(line, bstr("prefix"));
1523 strcat(line, bstr("line"));
1524 strcat(line, bstr("suffix"));
1534 if (buf[0] != '1') {
1540 /* This loop works for add *or* remove. Spiffy, eh? */
1541 while (serv_gets(buf), strcmp(buf, "000")) {
1542 if (strcasecmp(buf, line)) {
1543 fprintf(fp, "%s\n", buf);
1550 if (buf[0] != '4') {
1556 while (fgets(buf, sizeof buf, fp) != NULL) {
1557 buf[strlen(buf)-1] = 0;
1561 if (!strcasecmp(bstr("cmd"), "add")) {