4 * Lots of different room-related operations.
13 #include <sys/types.h>
15 #include <sys/socket.h>
18 #include <netinet/in.h>
46 char floorlist[128][SIZ];
49 * load the list of floors
51 void load_floorlist(void)
56 for (a = 0; a < 128; ++a)
62 strcpy(floorlist[0], "Main Floor");
65 while (serv_gets(buf), strcmp(buf, "000")) {
66 extract(floorlist[extract_int(buf, 0)], buf, 1);
72 * remove a room from the march list
74 void remove_march(char *aaa)
76 struct march *mptr, *mptr2;
78 if (WC->march == NULL)
81 if (!strcasecmp(WC->march->march_name, aaa)) {
82 mptr = WC->march->next;
88 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
89 if (!strcasecmp(mptr->march_name, aaa)) {
90 mptr2->next = mptr->next;
103 void room_tree_list(struct roomlisting *rp)
112 room_tree_list(rp->lnext);
114 strcpy(rmname, rp->rlname);
117 wprintf("<A HREF=\"/dotgoto&room=");
121 escputs1(rmname, 1, 1);
122 if ((f & QR_DIRECTORY) && (f & QR_NETWORK))
124 else if (f & QR_DIRECTORY)
126 else if (f & QR_NETWORK)
130 wprintf("</A><TT> </TT>\n");
132 room_tree_list(rp->rnext);
138 * Room ordering stuff (compare first by floor, then by order)
140 int rordercmp(struct roomlisting *r1, struct roomlisting *r2)
142 if ((r1 == NULL) && (r2 == NULL))
148 if (r1->rlfloor < r2->rlfloor)
150 if (r1->rlfloor > r2->rlfloor)
152 if (r1->rlorder < r2->rlorder)
154 if (r1->rlorder > r2->rlorder)
161 * Common code for all room listings
163 void listrms(char *variety)
168 struct roomlisting *rl = NULL;
169 struct roomlisting *rp;
170 struct roomlisting *rs;
173 /* Ask the server for a room list */
180 while (serv_gets(buf), strcmp(buf, "000")) {
182 rp = malloc(sizeof(struct roomlisting));
183 extract(rp->rlname, buf, 0);
184 rp->rlflags = extract_int(buf, 1);
185 rp->rlfloor = extract_int(buf, 2);
186 rp->rlorder = extract_int(buf, 3);
195 if (rordercmp(rp, rs) < 0) {
196 if (rs->lnext == NULL) {
203 if (rs->rnext == NULL) {
215 /* If no rooms were listed, print an nbsp to make the cell
216 * borders show up anyway.
218 if (num_rooms == 0) wprintf(" ");
223 * list all forgotten rooms
225 void zapped_list(void)
227 output_headers(1, 1, 0, 0, 0, 0, 0);
229 svprintf("BOXTITLE", WCS_STRING, "Zapped (forgotten) rooms");
230 do_template("beginbox");
234 wprintf("<br /><br />\n");
235 wprintf("Click on any room to un-zap it and goto that room.\n");
236 do_template("endbox");
242 * read this room's info file (set v to 1 for verbose mode)
251 fmout(NULL, "CENTER");
258 /* Display room graphic. The server doesn't actually
259 * need the room name, but we supply it in order to
260 * keep the browser from using a cached graphic from
263 void embed_room_graphic(void) {
266 serv_puts("OIMG _roompic_");
269 wprintf("<TD BGCOLOR=\"#444455\">");
270 wprintf("<IMG HEIGHT=64 SRC=\"/image&name=_roompic_&room=");
271 urlescputs(WC->wc_roomname);
280 /* Let the user know if new mail has arrived
282 void embed_newmail_button(void) {
283 if ( (WC->new_mail > WC->remember_new_mail) && (WC->new_mail>0) ) {
285 "<A HREF=\"/dotgoto?room=_MAIL_\">"
286 "<IMG SRC=\"/static/mail.gif\" border=0 "
287 "ALT=\"You have new mail\">"
288 "<br /><SPAN CLASS=\"youhavemail\">"
289 "%d new mail</SPAN></A>", WC->new_mail);
290 WC->remember_new_mail = WC->new_mail;
297 * Display the current view and offer an option to change it
299 void embed_view_o_matic(void) {
302 wprintf("<FORM NAME=\"viewomatic\">\n"
303 "<span class=\"room_banner_new_messages\">View as: "
304 "<SELECT NAME=\"newview\" SIZE=\"1\" "
305 "STYLE=\"font-family: Bitstream Vera Sans,Arial,Helvetica,sans-serif;"
306 " font-size: 7pt; background: #444455; color: #ddddcc;\" "
307 "OnChange=\"location.href=viewomatic.newview.options"
308 "[selectedIndex].value\">\n");
310 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
312 * Only offer the views that make sense, given the default
313 * view for the room. For example, don't offer a Calendar
314 * view in a non-Calendar room.
318 || (i == WC->wc_default_view)
319 || ( (i == 0) && (WC->wc_default_view == 1) )
320 || ( (i == 1) && (WC->wc_default_view == 0) )
323 wprintf("<OPTION %s VALUE=\"/changeview?view=%d\">",
324 ((i == WC->wc_view) ? "SELECTED" : ""),
326 escputs(viewdefs[i]);
327 wprintf("</OPTION>\n");
330 wprintf("</select></span></form>\n");
335 void embed_room_banner(char *got, int navbar_style) {
338 /* We need to have the information returned by a GOTO server command.
339 * If it isn't supplied, we fake it by issuing our own GOTO.
342 serv_printf("GOTO %s", WC->wc_roomname);
347 /* If the user happens to select the "make this my start page" link,
348 * we want it to remember the URL as a "/dotskip" one instead of
349 * a "skip" or "gotonext" or something like that.
351 snprintf(WC->this_page, sizeof(WC->this_page), "/dotskip&room=%s",
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);
364 svcallback("VIEWOMATIC", embed_view_o_matic);
365 svcallback("START", offer_start_page);
367 do_template("roombanner");
368 if (navbar_style != navbar_none) {
370 wprintf("<div style=\"position:absolute; bottom:0px; left:0px\">\n"
371 "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"100%%\"><tr>\n");
374 if (navbar_style == navbar_default) wprintf(
376 "<a href=\"/ungoto\">"
377 "<img align=\"middle\" src=\"/static/back.gif\" border=\"0\">"
378 "<span class=\"navbar_link\">Ungoto</span></A>"
382 if ( (navbar_style == navbar_default) && (WC->wc_view == VIEW_BBS) ) {
385 "<A HREF=\"/readnew\">"
386 "<img align=\"middle\" src=\"/static/readmsgs.gif\" border=\"0\">"
387 "<span class=\"navbar_link\">Read new messages</span></A>"
392 if (navbar_style == navbar_default) {
393 switch(WC->wc_view) {
394 case VIEW_ADDRESSBOOK:
397 "<A HREF=\"/readfwd\">"
398 "<img align=\"middle\" src=\"/static/readmsgs.gif\" "
400 "<span class=\"navbar_link\">"
408 "<A HREF=\"/readfwd?calview=day\">"
409 "<img align=\"middle\" src=\"/static/day_view.gif\" "
411 "<span class=\"navbar_link\">"
417 "<A HREF=\"/readfwd?calview=month\">"
418 "<img align=\"middle\" src=\"/static/month_view.gif\" "
420 "<span class=\"navbar_link\">"
428 "<A HREF=\"/readfwd\">"
429 "<img align=\"middle\" src=\"/static/readmsgs.gif\" "
431 "<span class=\"navbar_link\">"
439 "<A HREF=\"/readfwd\">"
440 "<img align=\"middle\" src=\"/static/readmsgs.gif\" "
442 "<span class=\"navbar_link\">"
450 "<A HREF=\"/readfwd\">"
451 "<img align=\"middle\" src=\"/static/readmsgs.gif\" "
453 "<span class=\"navbar_link\">"
461 "<A HREF=\"/readfwd\">"
462 "<img align=\"middle\" src=\"/static/readmsgs.gif\" "
464 "<span class=\"navbar_link\">"
472 if (navbar_style == navbar_default) {
475 "<A HREF=\"/display_enter\">"
476 "<img align=\"middle\" src=\"/static/enter.gif\" border=\"0\">"
477 "<span class=\"navbar_link\">"
479 switch(WC->wc_view) {
480 case VIEW_ADDRESSBOOK:
481 wprintf("Add new contact");
484 wprintf("Add new event");
487 wprintf("Add new task");
490 wprintf("Add new note");
493 wprintf("Enter a message");
496 wprintf("</span></a></td>\n");
499 if (navbar_style == navbar_default) wprintf(
502 "TITLE=\"Leave all messages marked as unread, go to next room with unread messages\">"
503 "<span class=\"navbar_link\">Skip this room</span>"
504 "<img align=\"middle\" src=\"/static/forward.gif\" border=\"0\"></A>"
508 if (navbar_style == navbar_default) wprintf(
510 "<A HREF=\"/gotonext\" "
511 "TITLE=\"Mark all messages as read, go to next room with unread messages\">"
512 "<span class=\"navbar_link\">Goto next room</span>"
513 "<img align=\"middle\" src=\"/static/forward.gif\" border=\"0\"></A>"
517 wprintf("</tr></table></div>\n");
527 * back end routine to take the session to a new room
530 void gotoroom(char *gname)
533 static long ls = (-1L);
535 /* store ungoto information */
536 strcpy(WC->ugname, WC->wc_roomname);
539 /* move to the new room */
540 serv_printf("GOTO %s", gname);
543 serv_puts("GOTO _BASEROOM_");
549 extract(WC->wc_roomname, &buf[4], 0);
550 WC->room_flags = extract_int(&buf[4], 4);
551 /* highest_msg_read = extract_int(&buf[4],6);
552 maxmsgnum = extract_int(&buf[4],5);
553 is_mail = (char) extract_int(&buf[4],7); */
554 ls = extract_long(&buf[4], 6);
555 WC->wc_floor = extract_int(&buf[4], 10);
556 WC->wc_view = extract_int(&buf[4], 11);
557 WC->wc_default_view = extract_int(&buf[4], 12);
560 WC->is_room_aide = WC->is_aide;
562 WC->is_room_aide = (char) extract_int(&buf[4], 8);
564 remove_march(WC->wc_roomname);
565 if (!strcasecmp(gname, "_BASEROOM_"))
571 * Locate the room on the march list which we most want to go to. Each room
572 * is measured given a "weight" of preference based on various factors.
574 char *pop_march(int desired_floor)
576 static char TheRoom[128];
578 int TheOrder = 32767;
581 struct march *mptr = NULL;
583 strcpy(TheRoom, "_BASEROOM_");
584 if (WC->march == NULL)
587 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
589 if ((strcasecmp(mptr->march_name, "_BASEROOM_")))
590 weight = weight + 10000;
591 if (mptr->march_floor == desired_floor)
592 weight = weight + 5000;
594 weight = weight + ((128 - (mptr->march_floor)) * 128);
595 weight = weight + (128 - (mptr->march_order));
597 if (weight > TheWeight) {
599 strcpy(TheRoom, mptr->march_name);
600 TheFloor = mptr->march_floor;
601 TheOrder = mptr->march_order;
609 /* Goto next room having unread messages.
610 * We want to skip over rooms that the user has already been to, and take the
611 * user back to the lobby when done. The room we end up in is placed in
612 * newroom - which is set to 0 (the lobby) initially.
613 * We start the search in the current room rather than the beginning to prevent
614 * two or more concurrent users from dragging each other back to the same room.
619 struct march *mptr, *mptr2;
622 /* First check to see if the march-mode list is already allocated.
623 * If it is, pop the first room off the list and go there.
626 if (WC->march == NULL) {
630 while (serv_gets(buf), strcmp(buf, "000")) {
631 mptr = (struct march *) malloc(sizeof(struct march));
633 extract(mptr->march_name, buf, 0);
634 mptr->march_floor = extract_int(buf, 2);
635 mptr->march_order = extract_int(buf, 3);
636 if (WC->march == NULL) {
640 while (mptr2->next != NULL)
645 /* add _BASEROOM_ to the end of the march list, so the user will end up
646 * in the system base room (usually the Lobby>) at the end of the loop
648 mptr = (struct march *) malloc(sizeof(struct march));
650 strcpy(mptr->march_name, "_BASEROOM_");
651 if (WC->march == NULL) {
655 while (mptr2->next != NULL)
660 * ...and remove the room we're currently in, so a <G>oto doesn't make us
661 * walk around in circles
663 remove_march(WC->wc_roomname);
665 if (WC->march != NULL) {
666 strcpy(next_room, pop_march(-1));
668 strcpy(next_room, "_BASEROOM_");
672 smart_goto(next_room);
676 void smart_goto(char *next_room) {
684 * mark all messages in current room as having been read
686 void slrp_highest(void)
691 serv_puts("SLRP HIGHEST");
694 wprintf("<EM>%s</EM><br />\n", &buf[4]);
701 * un-goto the previous room
707 if (!strcmp(WC->ugname, "")) {
708 smart_goto(WC->wc_roomname);
711 serv_printf("GOTO %s", WC->ugname);
714 smart_goto(WC->wc_roomname);
717 if (WC->uglsn >= 0L) {
718 serv_printf("SLRP %ld", WC->uglsn);
721 strcpy(buf, WC->ugname);
722 strcpy(WC->ugname, "");
731 * Set/clear/read the "self-service list subscribe" flag for a room
733 * Set 'newval' to 0 to clear, 1 to set, any other value to leave unchanged.
734 * Always returns the new value.
737 int self_service(int newval) {
738 int current_value = 0;
744 int flags, floor, order, view, flags2;
748 if (buf[0] != '2') return(0);
750 extract(name, &buf[4], 0);
751 extract(password, &buf[4], 1);
752 extract(dirname, &buf[4], 2);
753 flags = extract_int(&buf[4], 3);
754 floor = extract_int(&buf[4], 4);
755 order = extract_int(&buf[4], 5);
756 view = extract_int(&buf[4], 6);
757 flags2 = extract_int(&buf[4], 7);
759 if (flags2 & QR2_SELFLIST) {
767 flags2 = flags2 | QR2_SELFLIST;
769 else if (newval == 0) {
770 flags2 = flags2 & ~QR2_SELFLIST;
773 return(current_value);
776 if (newval != current_value) {
777 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
778 name, password, dirname, flags,
779 floor, order, view, flags2);
793 * display the form for editing a room
795 void display_editroom(void)
800 char remote_room[SIZ];
803 char er_password[10];
805 char er_roomaide[26];
811 char *not_shared_with;
818 if (strlen(tab) == 0) tab = "admin";
825 strcpy(WC->ImportantMessage, &buf[4]);
829 extract(er_name, &buf[4], 0);
830 extract(er_password, &buf[4], 1);
831 extract(er_dirname, &buf[4], 2);
832 er_flags = extract_int(&buf[4], 3);
833 er_floor = extract_int(&buf[4], 4);
835 output_headers(1, 1, 1, 0, 0, 0, 0);
837 /* print the tabbed dialog */
839 "<div id=\"fix_scrollbar_bug\">"
840 "<TABLE border=0 cellspacing=0 cellpadding=0 width=100%%>"
842 "<TD> </TD>\n");
844 if (!strcmp(tab, "admin")) {
845 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
848 wprintf("<TD BGCOLOR=\"#CCCCCC\"><A HREF=\"/display_editroom&tab=admin\">");
850 wprintf("Administration");
851 if (!strcmp(tab, "admin")) {
852 wprintf("</SPAN></TD>\n");
855 wprintf("</A></TD>\n");
858 wprintf("<TD> </TD>\n");
860 if (!strcmp(tab, "config")) {
861 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
864 wprintf("<TD BGCOLOR=\"#CCCCCC\"><A HREF=\"/display_editroom&tab=config\">");
866 wprintf("Configuration");
867 if (!strcmp(tab, "config")) {
868 wprintf("</SPAN></TD>\n");
871 wprintf("</A></TD>\n");
874 wprintf("<TD> </TD>\n");
876 if (!strcmp(tab, "expire")) {
877 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
880 wprintf("<TD BGCOLOR=\"#CCCCCC\"><A HREF=\"/display_editroom&tab=expire\">");
882 wprintf("Message expire policy");
883 if (!strcmp(tab, "expire")) {
884 wprintf("</SPAN></TD>\n");
887 wprintf("</A></TD>\n");
890 wprintf("<TD> </TD>\n");
892 if (!strcmp(tab, "access")) {
893 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
896 wprintf("<TD BGCOLOR=\"#CCCCCC\"><A HREF=\"/display_editroom&tab=access\">");
898 wprintf("Access controls");
899 if (!strcmp(tab, "access")) {
900 wprintf("</SPAN></TD>\n");
903 wprintf("</A></TD>\n");
906 wprintf("<TD> </TD>\n");
908 if (!strcmp(tab, "sharing")) {
909 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
912 wprintf("<TD BGCOLOR=\"#CCCCCC\"><A HREF=\"/display_editroom&tab=sharing\">");
915 if (!strcmp(tab, "sharing")) {
916 wprintf("</SPAN></TD>\n");
919 wprintf("</A></TD>\n");
922 wprintf("<TD> </TD>\n");
924 if (!strcmp(tab, "listserv")) {
925 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
928 wprintf("<TD BGCOLOR=\"#CCCCCC\"><A HREF=\"/display_editroom&tab=listserv\">");
930 wprintf("Mailing list service");
931 if (!strcmp(tab, "listserv")) {
932 wprintf("</SPAN></TD>\n");
935 wprintf("</A></TD>\n");
938 wprintf("<TD> </TD>\n");
940 wprintf("</TR></TABLE></div>\n");
941 /* end tabbed dialog */
943 /* begin content of whatever tab is open now */
944 wprintf("<div id=\"fix_scrollbar_bug\">"
945 "<TABLE border=0 width=100%% bgcolor=\"#FFFFFF\">\n"
948 if (!strcmp(tab, "admin")) {
950 "<LI><A HREF=\"/confirm_delete_room\">\n"
951 "Delete this room</A>\n"
952 "<LI><A HREF=\"/display_editroompic\">\n"
953 "Set or change the graphic for this room's banner</A>\n"
954 "<LI><A HREF=\"/display_editinfo\">\n"
955 "Edit this room's Info file</A>\n"
959 if (!strcmp(tab, "config")) {
960 wprintf("<FORM METHOD=\"POST\" ACTION=\"/editroom\">\n");
962 wprintf("<UL><LI>Name of room: ");
963 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\"19\">\n", er_name);
965 wprintf("<LI>Resides on floor: ");
966 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
967 for (i = 0; i < 128; ++i)
968 if (strlen(floorlist[i]) > 0) {
971 wprintf("SELECTED ");
972 wprintf("VALUE=\"%d\">", i);
973 escputs(floorlist[i]);
974 wprintf("</OPTION>\n");
976 wprintf("</SELECT>\n");
978 wprintf("<LI>Type of room:<UL>\n");
980 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
981 if ((er_flags & QR_PRIVATE) == 0)
983 wprintf("> Public room\n");
985 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"hidden\" ");
986 if ((er_flags & QR_PRIVATE) &&
987 (er_flags & QR_GUESSNAME))
989 wprintf("> Private - guess name\n");
991 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
992 if ((er_flags & QR_PRIVATE) &&
993 (er_flags & QR_PASSWORDED))
995 wprintf("> Private - require password:\n");
996 wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n", er_password);
998 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
999 if ((er_flags & QR_PRIVATE)
1000 && ((er_flags & QR_GUESSNAME) == 0)
1001 && ((er_flags & QR_PASSWORDED) == 0))
1002 wprintf("CHECKED ");
1003 wprintf("> Private - invitation only\n");
1005 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
1006 wprintf("> If private, cause current users to forget room\n");
1010 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
1011 if (er_flags & QR_PREFONLY)
1012 wprintf("CHECKED ");
1013 wprintf("> Preferred users only\n");
1015 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
1016 if (er_flags & QR_READONLY)
1017 wprintf("CHECKED ");
1018 wprintf("> Read-only room\n");
1020 /* directory stuff */
1021 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
1022 if (er_flags & QR_DIRECTORY)
1023 wprintf("CHECKED ");
1024 wprintf("> File directory room\n");
1026 wprintf("<UL><LI>Directory name: ");
1027 wprintf("<INPUT TYPE=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n", er_dirname);
1029 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
1030 if (er_flags & QR_UPLOAD)
1031 wprintf("CHECKED ");
1032 wprintf("> Uploading allowed\n");
1034 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
1035 if (er_flags & QR_DOWNLOAD)
1036 wprintf("CHECKED ");
1037 wprintf("> Downloading allowed\n");
1039 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
1040 if (er_flags & QR_VISDIR)
1041 wprintf("CHECKED ");
1042 wprintf("> Visible directory</UL>\n");
1044 /* end of directory stuff */
1046 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
1047 if (er_flags & QR_NETWORK)
1048 wprintf("CHECKED ");
1049 wprintf("> Network shared room\n");
1051 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"permanent\" VALUE=\"yes\" ");
1052 if (er_flags & QR_PERMANENT)
1053 wprintf("CHECKED ");
1054 wprintf("> Permanent (does not auto-purge)\n");
1056 /* start of anon options */
1058 wprintf("<LI>Anonymous messages<UL>\n");
1060 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
1061 if (((er_flags & QR_ANONONLY) == 0)
1062 && ((er_flags & QR_ANONOPT) == 0))
1063 wprintf("CHECKED ");
1064 wprintf("> No anonymous messages\n");
1066 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
1067 if (er_flags & QR_ANONONLY)
1068 wprintf("CHECKED ");
1069 wprintf("> All messages are anonymous\n");
1071 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
1072 if (er_flags & QR_ANONOPT)
1073 wprintf("CHECKED ");
1074 wprintf("> Prompt user when entering messages</UL>\n");
1076 /* end of anon options */
1078 wprintf("<LI>Room aide: \n");
1081 if (buf[0] != '2') {
1082 wprintf("<EM>%s</EM>\n", &buf[4]);
1084 extract(er_roomaide, &buf[4], 0);
1085 wprintf("<INPUT TYPE=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n", er_roomaide);
1088 wprintf("</UL><CENTER>\n");
1089 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"config\">\n"
1090 "<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">"
1092 "<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">"
1098 /* Sharing the room with other Citadel nodes... */
1099 if (!strcmp(tab, "sharing")) {
1101 shared_with = strdup("");
1102 not_shared_with = strdup("");
1104 /* Learn the current configuration */
1105 serv_puts("CONF getsys|application/x-citadel-ignet-config");
1107 if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
1108 extract(node, buf, 0);
1109 not_shared_with = realloc(not_shared_with,
1110 strlen(not_shared_with) + 32);
1111 strcat(not_shared_with, node);
1112 strcat(not_shared_with, "\n");
1117 if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
1118 extract(cmd, buf, 0);
1119 extract(node, buf, 1);
1120 extract(remote_room, buf, 2);
1121 if (!strcasecmp(cmd, "ignet_push_share")) {
1122 shared_with = realloc(shared_with,
1123 strlen(shared_with) + 32);
1124 strcat(shared_with, node);
1125 if (strlen(remote_room) > 0) {
1126 strcat(shared_with, "|");
1127 strcat(shared_with, remote_room);
1129 strcat(shared_with, "\n");
1133 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1134 extract_token(buf, shared_with, i, '\n');
1135 extract_token(node, buf, 0, '|');
1136 for (j=0; j<num_tokens(not_shared_with, '\n'); ++j) {
1137 extract_token(cmd, not_shared_with, j, '\n');
1138 if (!strcasecmp(node, cmd)) {
1139 remove_token(not_shared_with, j, '\n');
1144 /* Display the stuff */
1145 wprintf("<CENTER><br />"
1146 "<TABLE border=1 cellpadding=5><TR>"
1147 "<TD><B><I>Shared with</I></B></TD>"
1148 "<TD><B><I>Not shared with</I></B></TD></TR>\n"
1149 "<TR><TD VALIGN=TOP>\n");
1151 wprintf("<TABLE border=0 cellpadding=5><TR BGCOLOR=\"#CCCCCC\">"
1152 "<TD>Remote node name</TD>"
1153 "<TD>Remote room name</TD>"
1158 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1159 extract_token(buf, shared_with, i, '\n');
1160 extract_token(node, buf, 0, '|');
1161 extract_token(remote_room, buf, 1, '|');
1162 if (strlen(node) > 0) {
1163 wprintf("<FORM METHOD=\"POST\" "
1164 "ACTION=\"/netedit\">"
1165 "<TR><TD>%s</TD>\n", node);
1168 if (strlen(remote_room) > 0) {
1169 escputs(remote_room);
1175 wprintf("<INPUT TYPE=\"hidden\" NAME=\"line\" "
1176 "VALUE=\"ignet_push_share|");
1178 if (strlen(remote_room) > 0) {
1180 urlescputs(remote_room);
1183 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" "
1184 "VALUE=\"sharing\">\n");
1185 wprintf("<INPUT TYPE=\"hidden\" NAME=\"cmd\" "
1186 "VALUE=\"remove\">\n");
1187 wprintf("<INPUT TYPE=\"submit\" "
1188 "NAME=\"sc\" VALUE=\"Unshare\">");
1189 wprintf("</TD></TR></FORM>\n");
1193 wprintf("</TABLE>\n");
1194 wprintf("</TD><TD VALIGN=TOP>\n");
1195 wprintf("<TABLE border=0 cellpadding=5><TR BGCOLOR=\"#CCCCCC\">"
1196 "<TD>Remote node name</TD>"
1197 "<TD>Remote room name</TD>"
1202 for (i=0; i<num_tokens(not_shared_with, '\n'); ++i) {
1203 extract_token(node, not_shared_with, i, '\n');
1204 if (strlen(node) > 0) {
1205 wprintf("<FORM METHOD=\"POST\" "
1206 "ACTION=\"/netedit\">"
1210 "<INPUT TYPE=\"INPUT\" "
1214 wprintf("<INPUT TYPE=\"hidden\" "
1216 "VALUE=\"ignet_push_share|");
1219 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" "
1220 "VALUE=\"sharing\">\n");
1221 wprintf("<INPUT TYPE=\"hidden\" NAME=\"cmd\" "
1222 "VALUE=\"add\">\n");
1223 wprintf("<INPUT TYPE=\"submit\" "
1224 "NAME=\"sc\" VALUE=\"Share\">");
1225 wprintf("</TD></TR></FORM>\n");
1229 wprintf("</TABLE>\n");
1230 wprintf("</TD></TR>"
1231 "</TABLE></CENTER><br />\n"
1232 "<I><B>Notes:</B><UL><LI>When sharing a room, "
1233 "it must be shared from both ends. Adding a node to "
1234 "the 'shared' list sends messages out, but in order to"
1235 " receive messages, the other nodes must be configured"
1236 " to send messages out to your system as well.\n"
1237 "<LI>If the remote room name is blank, it is assumed "
1238 "that the room name is identical on the remote node."
1239 "<LI>If the remote room name is different, the remote "
1240 "node must also configure the name of the room here."
1246 /* Mailing list management */
1247 if (!strcmp(tab, "listserv")) {
1249 wprintf("<br /><center>"
1250 "<TABLE BORDER=0 WIDTH=100%% CELLPADDING=5>"
1251 "<TR><TD VALIGN=TOP>");
1253 wprintf("<i>The contents of this room are being "
1254 "mailed <b>as individual messages</b> "
1255 "to the following list recipients:"
1256 "</i><br /><br />\n");
1260 if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
1261 extract(cmd, buf, 0);
1262 if (!strcasecmp(cmd, "listrecp")) {
1263 extract(recp, buf, 1);
1266 wprintf(" <A HREF=\"/netedit&cmd=remove&line="
1269 wprintf("&tab=listserv\">(remove)</A><br />");
1273 wprintf("<br /><FORM METHOD=\"POST\" ACTION=\"/netedit\">\n"
1274 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1275 "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"listrecp|\">\n");
1276 wprintf("<INPUT TYPE=\"text\" NAME=\"line\">\n");
1277 wprintf("<INPUT TYPE=\"submit\" NAME=\"cmd\" VALUE=\"Add\">");
1278 wprintf("</FORM>\n");
1280 wprintf("</TD><TD VALIGN=TOP>\n");
1282 wprintf("<i>The contents of this room are being "
1283 "mailed <b>in digest form</b> "
1284 "to the following list recipients:"
1285 "</i><br /><br />\n");
1289 if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
1290 extract(cmd, buf, 0);
1291 if (!strcasecmp(cmd, "digestrecp")) {
1292 extract(recp, buf, 1);
1295 wprintf(" <A HREF=\"/netedit&cmd=remove&line="
1298 wprintf("&tab=listserv\">(remove)</A><br />");
1302 wprintf("<br /><FORM METHOD=\"POST\" ACTION=\"/netedit\">\n"
1303 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1304 "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"digestrecp|\">\n");
1305 wprintf("<INPUT TYPE=\"text\" NAME=\"line\">\n");
1306 wprintf("<INPUT TYPE=\"submit\" NAME=\"cmd\" VALUE=\"Add\">");
1307 wprintf("</FORM>\n");
1309 wprintf("</TD></TR></TABLE><hr />\n");
1311 if (self_service(999) == 1) {
1312 wprintf("This room is configured to allow "
1313 "self-service subscribe/unsubscribe requests."
1314 " <A HREF=\"/toggle_self_service?newval=0&"
1316 "Click to disable.</A><br />\n"
1317 "The URL for subscribe/unsubscribe is: "
1318 "<TT>http://%s/listsub</TT><br />\n",
1323 wprintf("This room is <i>not</i> configured to allow "
1324 "self-service subscribe/unsubscribe requests."
1325 " <A HREF=\"/toggle_self_service?newval=1&"
1327 "Click to enable.</A><br />\n"
1332 wprintf("</CENTER>\n");
1336 /* Mailing list management */
1337 if (!strcmp(tab, "expire")) {
1339 serv_puts("GPEX room");
1341 if (buf[0] == '2') {
1342 roompolicy = extract_int(&buf[4], 0);
1343 roomvalue = extract_int(&buf[4], 1);
1346 serv_puts("GPEX floor");
1348 if (buf[0] == '2') {
1349 floorpolicy = extract_int(&buf[4], 0);
1350 floorvalue = extract_int(&buf[4], 1);
1353 wprintf("<br /><FORM METHOD=\"POST\" ACTION=\"/set_room_policy\">\n");
1354 wprintf("<TABLE border=0 cellspacing=5>\n");
1355 wprintf("<TR><TD>Message expire policy for this room<br />(");
1356 escputs(WC->wc_roomname);
1357 wprintf(")</TD><TD>");
1358 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"0\" %s>",
1359 ((roompolicy == 0) ? "CHECKED" : "") );
1360 wprintf("Use the default policy for this floor<br />\n");
1361 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"1\" %s>",
1362 ((roompolicy == 1) ? "CHECKED" : "") );
1363 wprintf("Never automatically expire messages<br />\n");
1364 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"2\" %s>",
1365 ((roompolicy == 2) ? "CHECKED" : "") );
1366 wprintf("Expire by message count<br />\n");
1367 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"3\" %s>",
1368 ((roompolicy == 3) ? "CHECKED" : "") );
1369 wprintf("Expire by message age<br />");
1370 wprintf("Number of messages or days: ");
1371 wprintf("<INPUT TYPE=\"text\" NAME=\"roomvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">", roomvalue);
1372 wprintf("</TD></TR>\n");
1374 if (WC->axlevel >= 6) {
1375 wprintf("<TR><TD COLSPAN=2><hr /></TD></TR>\n");
1376 wprintf("<TR><TD>Message expire policy for this floor<br />(");
1377 escputs(floorlist[WC->wc_floor]);
1378 wprintf(")</TD><TD>");
1379 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"0\" %s>",
1380 ((floorpolicy == 0) ? "CHECKED" : "") );
1381 wprintf("Use the system default<br />\n");
1382 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"1\" %s>",
1383 ((floorpolicy == 1) ? "CHECKED" : "") );
1384 wprintf("Never automatically expire messages<br />\n");
1385 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"2\" %s>",
1386 ((floorpolicy == 2) ? "CHECKED" : "") );
1387 wprintf("Expire by message count<br />\n");
1388 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"3\" %s>",
1389 ((floorpolicy == 3) ? "CHECKED" : "") );
1390 wprintf("Expire by message age<br />");
1391 wprintf("Number of messages or days: ");
1392 wprintf("<INPUT TYPE=\"text\" NAME=\"floorvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">",
1396 wprintf("<CENTER>\n");
1397 wprintf("<TR><TD COLSPAN=2><hr /><CENTER>\n");
1398 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
1400 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1401 wprintf("</CENTER></TD><TR>\n");
1403 wprintf("</TABLE>\n"
1404 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"expire\">\n"
1410 /* Mailing list management */
1411 if (!strcmp(tab, "access")) {
1415 /* end content of whatever tab is open now */
1416 wprintf("</TD></TR></TABLE></div>\n");
1423 * Toggle self-service list subscription
1425 void toggle_self_service(void) {
1428 newval = atoi(bstr("newval"));
1429 self_service(newval);
1436 * save new parameters for a room
1442 char er_password[10];
1443 char er_dirname[15];
1444 char er_roomaide[26];
1450 if (strcmp(bstr("sc"), "OK")) {
1451 strcpy(WC->ImportantMessage,
1452 "Cancelled. Changes were not saved.");
1459 if (buf[0] != '2') {
1460 strcpy(WC->ImportantMessage, &buf[4]);
1464 extract(er_name, &buf[4], 0);
1465 extract(er_password, &buf[4], 1);
1466 extract(er_dirname, &buf[4], 2);
1467 er_flags = extract_int(&buf[4], 3);
1469 strcpy(er_roomaide, bstr("er_roomaide"));
1470 if (strlen(er_roomaide) == 0) {
1473 if (buf[0] != '2') {
1474 strcpy(er_roomaide, "");
1476 extract(er_roomaide, &buf[4], 0);
1479 strcpy(buf, bstr("er_name"));
1481 if (strlen(buf) > 0)
1482 strcpy(er_name, buf);
1484 strcpy(buf, bstr("er_password"));
1486 if (strlen(buf) > 0)
1487 strcpy(er_password, buf);
1489 strcpy(buf, bstr("er_dirname"));
1491 if (strlen(buf) > 0)
1492 strcpy(er_dirname, buf);
1494 strcpy(buf, bstr("type"));
1495 er_flags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME);
1497 if (!strcmp(buf, "invonly")) {
1498 er_flags |= (QR_PRIVATE);
1500 if (!strcmp(buf, "hidden")) {
1501 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
1503 if (!strcmp(buf, "passworded")) {
1504 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
1506 if (!strcmp(bstr("prefonly"), "yes")) {
1507 er_flags |= QR_PREFONLY;
1509 er_flags &= ~QR_PREFONLY;
1512 if (!strcmp(bstr("readonly"), "yes")) {
1513 er_flags |= QR_READONLY;
1515 er_flags &= ~QR_READONLY;
1518 if (!strcmp(bstr("permanent"), "yes")) {
1519 er_flags |= QR_PERMANENT;
1521 er_flags &= ~QR_PERMANENT;
1524 if (!strcmp(bstr("network"), "yes")) {
1525 er_flags |= QR_NETWORK;
1527 er_flags &= ~QR_NETWORK;
1530 if (!strcmp(bstr("directory"), "yes")) {
1531 er_flags |= QR_DIRECTORY;
1533 er_flags &= ~QR_DIRECTORY;
1536 if (!strcmp(bstr("ulallowed"), "yes")) {
1537 er_flags |= QR_UPLOAD;
1539 er_flags &= ~QR_UPLOAD;
1542 if (!strcmp(bstr("dlallowed"), "yes")) {
1543 er_flags |= QR_DOWNLOAD;
1545 er_flags &= ~QR_DOWNLOAD;
1548 if (!strcmp(bstr("visdir"), "yes")) {
1549 er_flags |= QR_VISDIR;
1551 er_flags &= ~QR_VISDIR;
1554 strcpy(buf, bstr("anon"));
1556 er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
1557 if (!strcmp(buf, "anononly"))
1558 er_flags |= QR_ANONONLY;
1559 if (!strcmp(buf, "anon2"))
1560 er_flags |= QR_ANONOPT;
1563 if (!strcmp(bstr("bump"), "yes"))
1566 er_floor = atoi(bstr("er_floor"));
1568 sprintf(buf, "SETR %s|%s|%s|%u|%d|%d",
1569 er_name, er_password, er_dirname, er_flags, bump, er_floor);
1572 if (buf[0] != '2') {
1573 strcpy(WC->ImportantMessage, &buf[4]);
1579 if (strlen(er_roomaide) > 0) {
1580 sprintf(buf, "SETA %s", er_roomaide);
1583 if (buf[0] != '2') {
1584 strcpy(WC->ImportantMessage, &buf[4]);
1585 display_main_menu();
1590 strcpy(WC->ImportantMessage, "Your changes have been saved.");
1597 * Display form for Invite, Kick, and show Who Knows a room
1599 void do_invt_kick(void) {
1600 char buf[SIZ], room[SIZ], username[SIZ];
1605 if (buf[0] != '2') {
1609 extract(room, &buf[4], 0);
1611 strcpy(username, bstr("username"));
1613 if (!strcmp(bstr("sc"), "Kick")) {
1614 sprintf(buf, "KICK %s", username);
1618 if (buf[0] != '2') {
1619 strcpy(WC->ImportantMessage, &buf[4]);
1621 sprintf(WC->ImportantMessage,
1622 "<B><I>User %s kicked out of room %s.</I></B>\n",
1627 if (!strcmp(bstr("sc"), "Invite")) {
1628 sprintf(buf, "INVT %s", username);
1632 if (buf[0] != '2') {
1633 strcpy(WC->ImportantMessage, &buf[4]);
1635 sprintf(WC->ImportantMessage,
1636 "<B><I>User %s invited to room %s.</I></B>\n",
1647 * Display form for Invite, Kick, and show Who Knows a room
1649 void display_whok(void)
1651 char buf[SIZ], room[SIZ], username[SIZ];
1656 if (buf[0] != '2') {
1660 extract(room, &buf[4], 0);
1663 wprintf("<TABLE border=0 CELLSPACING=10><TR VALIGN=TOP>"
1664 "<TD>The users listed below have access to this room. "
1665 "To remove a user from the access list, select the user "
1666 "name from the list and click 'Kick'.<br /><br />");
1668 wprintf("<CENTER><FORM METHOD=\"POST\" ACTION=\"/do_invt_kick\">\n");
1669 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
1670 wprintf("<SELECT NAME=\"username\" SIZE=\"10\" style=\"width:100%%\">\n");
1673 if (buf[0] == '1') {
1674 while (serv_gets(buf), strcmp(buf, "000")) {
1675 extract(username, buf, 0);
1676 wprintf("<OPTION>");
1681 wprintf("</SELECT><br />\n");
1683 wprintf("<input type=submit name=sc value=\"Kick\">");
1684 wprintf("</FORM></CENTER>\n");
1687 "To grant another user access to this room, enter the "
1688 "user name in the box below and click 'Invite'.<br /><br />");
1690 wprintf("<CENTER><FORM METHOD=\"POST\" ACTION=\"/do_invt_kick\">\n");
1691 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
1692 wprintf("Invite: ");
1693 wprintf("<input type=\"text\" name=\"username\" style=\"width:100%%\"><br />\n"
1694 "<input type=\"hidden\" name=\"sc\" value=\"Invite\">"
1695 "<input type=\"submit\" value=\"Invite\">"
1696 "</FORM></CENTER>\n");
1698 wprintf("</TD></TR></TABLE>\n");
1705 * display the form for entering a new room
1707 void display_entroom(void)
1712 serv_puts("CRE8 0");
1715 if (buf[0] != '2') {
1716 strcpy(WC->ImportantMessage, &buf[4]);
1717 display_main_menu();
1721 output_headers(1, 1, 2, 0, 0, 0, 0);
1722 wprintf("<div id=\"banner\">\n"
1723 "<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>"
1724 "<SPAN CLASS=\"titlebar\">Create a new room</SPAN>"
1725 "</TD></TR></TABLE>\n"
1726 "</div>\n<div id=\"content\">\n"
1729 wprintf("<div id=\"fix_scrollbar_bug\">"
1730 "<table border=0 width=100%% bgcolor=\"#ffffff\"><tr><td>\n");
1732 wprintf("<form name=\"create_room_form\" method=\"POST\" action=\"/entroom\">\n");
1734 wprintf("<UL><LI>Name of room: ");
1735 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" MAXLENGTH=\"127\">\n");
1737 wprintf("<LI>Resides on floor: ");
1739 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
1740 for (i = 0; i < 128; ++i)
1741 if (strlen(floorlist[i]) > 0) {
1742 wprintf("<OPTION ");
1743 wprintf("VALUE=\"%d\">", i);
1744 escputs(floorlist[i]);
1745 wprintf("</OPTION>\n");
1747 wprintf("</SELECT>\n");
1749 /* Our clever little snippet of JavaScript automatically selects
1750 * a public room if the view is set to Bulletin Board, and it
1751 * selects a mailbox room otherwise. The user can override this,
1754 wprintf("<LI>Default view for room: ");
1755 wprintf("<SELECT NAME=\"er_view\" SIZE=\"1\" OnChange=\""
1756 " if (this.form.er_view.value == 0) { "
1757 " this.form.type[0].checked=true; "
1758 " this.form.er_floor.disabled = false; "
1761 " this.form.type[4].checked=true; "
1762 " this.form.er_floor.disabled = true; "
1765 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
1766 wprintf("<OPTION %s VALUE=\"%d\">",
1767 ((i == 0) ? "SELECTED" : ""), i );
1768 escputs(viewdefs[i]);
1769 wprintf("</OPTION>\n");
1771 wprintf("</SELECT>\n");
1773 wprintf("<LI>Type of room:<UL>\n");
1775 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1776 wprintf("CHECKED OnChange=\""
1777 " if (this.form.type[0].checked == true) { "
1778 " this.form.er_floor.disabled = false; "
1780 "\"> Public (automatically appears to everyone)\n");
1782 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"hidden\" OnChange=\""
1783 " if (this.form.type[1].checked == true) { "
1784 " this.form.er_floor.disabled = false; "
1786 "\"> Private - hidden (accessible to anyone who knows its name)\n");
1788 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" OnChange=\""
1789 " if (this.form.type[2].checked == true) { "
1790 " this.form.er_floor.disabled = false; "
1792 "\"> Private - require password:\n");
1793 wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
1795 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" OnChange=\""
1796 " if (this.form.type[3].checked == true) { "
1797 " this.form.er_floor.disabled = false; "
1799 "\"> Private - invitation only\n");
1801 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"personal\" "
1803 " if (this.form.type[4].checked == true) { "
1804 " this.form.er_floor.disabled = true; "
1806 "\"> Personal (mailbox for you only)\n");
1810 wprintf("<CENTER>\n");
1811 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
1813 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1814 wprintf("</CENTER>\n");
1815 wprintf("</FORM>\n<hr />");
1816 serv_printf("MESG roomaccess");
1818 if (buf[0] == '1') {
1819 fmout(NULL, "CENTER");
1821 wprintf("</td></tr></table></div>\n");
1829 * support function for entroom() -- sets the default view
1831 void er_set_default_view(int newview) {
1845 if (buf[0] != '2') return;
1847 extract(rm_name, &buf[4], 0);
1848 extract(rm_pass, &buf[4], 1);
1849 extract(rm_dir, &buf[4], 2);
1850 rm_bits1 = extract_int(&buf[4], 3);
1851 rm_floor = extract_int(&buf[4], 4);
1852 rm_listorder = extract_int(&buf[4], 5);
1853 rm_bits2 = extract_int(&buf[4], 7);
1855 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
1856 rm_name, rm_pass, rm_dir, rm_bits1, rm_floor,
1857 rm_listorder, newview, rm_bits2
1872 char er_password[SIZ];
1877 if (strcmp(bstr("sc"), "OK")) {
1878 strcpy(WC->ImportantMessage,
1879 "Cancelled. No new room was created.");
1880 display_main_menu();
1883 strcpy(er_name, bstr("er_name"));
1884 strcpy(er_type, bstr("type"));
1885 strcpy(er_password, bstr("er_password"));
1886 er_floor = atoi(bstr("er_floor"));
1887 er_view = atoi(bstr("er_view"));
1890 if (!strcmp(er_type, "hidden"))
1892 if (!strcmp(er_type, "passworded"))
1894 if (!strcmp(er_type, "invonly"))
1896 if (!strcmp(er_type, "personal"))
1899 sprintf(buf, "CRE8 1|%s|%d|%s|%d|%d|%d",
1900 er_name, er_num_type, er_password, er_floor, 0, er_view);
1903 if (buf[0] != '2') {
1904 strcpy(WC->ImportantMessage, &buf[4]);
1905 display_main_menu();
1909 do_change_view(er_view); /* Now go there */
1914 * display the screen to enter a private room
1916 void display_private(char *rname, int req_pass)
1918 output_headers(1, 1, 2, 0, 0, 0, 0);
1919 wprintf("<div id=\"banner\">\n"
1920 "<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>"
1921 "<SPAN CLASS=\"titlebar\">Go to a hidden room</SPAN>"
1922 "</TD></TR></TABLE>\n"
1923 "</div>\n<div id=\"content\">\n"
1926 wprintf("<div id=\"fix_scrollbar_bug\">"
1927 "<table border=0 width=100%% bgcolor=\"#ffffff\"><tr><td>\n");
1929 wprintf("<CENTER>\n");
1930 wprintf("<br />If you know the name of a hidden (guess-name) or\n");
1931 wprintf("passworded room, you can enter that room by typing\n");
1932 wprintf("its name below. Once you gain access to a private\n");
1933 wprintf("room, it will appear in your regular room listings\n");
1934 wprintf("so you don't have to keep returning here.\n");
1935 wprintf("<br /><br />");
1937 wprintf("<FORM METHOD=\"GET\" ACTION=\"/goto_private\">\n");
1939 wprintf("<table border=\"0\" cellspacing=\"5\" "
1940 "cellpadding=\"5\" BGCOLOR=\"#EEEEEE\">\n"
1942 "Enter room name:</TD><TD>"
1943 "<INPUT TYPE=\"text\" NAME=\"gr_name\" "
1944 "VALUE=\"%s\" MAXLENGTH=\"19\">\n", rname);
1947 wprintf("</TD></TR><TR><TD>");
1948 wprintf("Enter room password:</TD><TD>");
1949 wprintf("<INPUT TYPE=\"password\" NAME=\"gr_pass\" MAXLENGTH=\"9\">\n");
1951 wprintf("</TD></TR></TABLE><br />\n");
1953 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">"
1955 "<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1956 wprintf("</FORM>\n");
1957 wprintf("</td></tr></table></div>\n");
1962 * goto a private room
1964 void goto_private(void)
1969 if (strcasecmp(bstr("sc"), "OK")) {
1970 display_main_menu();
1973 strcpy(hold_rm, WC->wc_roomname);
1974 strcpy(buf, "GOTO ");
1975 strcat(buf, bstr("gr_name"));
1977 strcat(buf, bstr("gr_pass"));
1981 if (buf[0] == '2') {
1982 smart_goto(bstr("gr_name"));
1985 if (!strncmp(buf, "540", 3)) {
1986 display_private(bstr("gr_name"), 1);
1989 output_headers(1, 1, 1, 0, 0, 0, 0);
1990 wprintf("%s\n", &buf[4]);
1997 * display the screen to zap a room
1999 void display_zap(void)
2001 output_headers(1, 1, 2, 0, 0, 0, 0);
2003 wprintf("<div id=\"banner\">\n");
2004 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#770000\"><TR><TD>");
2005 wprintf("<SPAN CLASS=\"titlebar\">Zap (forget/unsubscribe) the current room</SPAN>\n");
2006 wprintf("</TD></TR></TABLE>\n");
2007 wprintf("</div>\n<div id=\"content\">\n");
2009 wprintf("If you select this option, <em>%s</em> will ", WC->wc_roomname);
2010 wprintf("disappear from your room list. Is this what you wish ");
2011 wprintf("to do?<br />\n");
2013 wprintf("<FORM METHOD=\"GET\" ACTION=\"/zap\">\n");
2014 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
2016 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
2017 wprintf("</FORM>\n");
2028 char final_destination[SIZ];
2030 /* If the forget-room routine fails for any reason, we fall back
2031 * to the current room; otherwise, we go to the Lobby
2033 strcpy(final_destination, WC->wc_roomname);
2035 if (!strcasecmp(bstr("sc"), "OK")) {
2036 serv_printf("GOTO %s", WC->wc_roomname);
2038 if (buf[0] == '2') {
2041 if (buf[0] == '2') {
2042 strcpy(final_destination, "_BASEROOM_");
2046 smart_goto(final_destination);
2053 * Confirm deletion of the current room
2055 void confirm_delete_room(void)
2059 serv_puts("KILL 0");
2061 if (buf[0] != '2') {
2062 strcpy(WC->ImportantMessage, &buf[4]);
2063 display_main_menu();
2066 output_headers(1, 1, 2, 0, 0, 0, 0);
2067 wprintf("<div id=\"banner\">\n");
2068 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#770000\"><TR><TD>");
2069 wprintf("<SPAN CLASS=\"titlebar\">Confirm deletion of room</SPAN>\n");
2070 wprintf("</TD></TR></TABLE>\n");
2071 wprintf("</div>\n<div id=\"content\">\n");
2073 wprintf("<CENTER>");
2074 wprintf("<FORM METHOD=\"GET\" ACTION=\"/delete_room\">\n");
2076 wprintf("Are you sure you want to delete <FONT SIZE=+1>");
2077 escputs(WC->wc_roomname);
2078 wprintf("</FONT>?<br />\n");
2080 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Delete\">");
2081 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
2083 wprintf("</FORM></CENTER>\n");
2089 * Delete the current room
2091 void delete_room(void)
2096 strcpy(sc, bstr("sc"));
2098 if (strcasecmp(sc, "Delete")) {
2099 strcpy(WC->ImportantMessage,
2100 "Cancelled. This room was not deleted.");
2101 display_main_menu();
2104 serv_puts("KILL 1");
2106 if (buf[0] != '2') {
2107 strcpy(WC->ImportantMessage, &buf[4]);
2108 display_main_menu();
2111 smart_goto("_BASEROOM_");
2118 * Perform changes to a room's network configuration
2120 void netedit(void) {
2129 if (strlen(bstr("line"))==0) {
2134 strcpy(line, bstr("prefix"));
2135 strcat(line, bstr("line"));
2136 strcat(line, bstr("suffix"));
2146 if (buf[0] != '1') {
2152 /* This loop works for add *or* remove. Spiffy, eh? */
2153 while (serv_gets(buf), strcmp(buf, "000")) {
2154 extract(cmpa0, buf, 0);
2155 extract(cmpa1, buf, 1);
2156 extract(cmpb0, line, 0);
2157 extract(cmpb1, line, 1);
2158 if ( (strcasecmp(cmpa0, cmpb0))
2159 || (strcasecmp(cmpa1, cmpb1)) ) {
2160 fprintf(fp, "%s\n", buf);
2167 if (buf[0] != '4') {
2173 while (fgets(buf, sizeof buf, fp) != NULL) {
2174 buf[strlen(buf)-1] = 0;
2178 if (!strcasecmp(bstr("cmd"), "add")) {
2190 * Convert a room name to a folder-ish-looking name.
2192 void room_to_folder(char *folder, char *room, int floor, int is_mailbox)
2197 * For mailboxes, just do it straight...
2200 sprintf(folder, "My folders|%s", room);
2204 * Otherwise, prefix the floor name as a "public folders" moniker
2207 sprintf(folder, "%s|%s", floorlist[floor], room);
2211 * Replace "\" characters with "|" for pseudo-folder-delimiting
2213 for (i=0; i<strlen(folder); ++i) {
2214 if (folder[i] == '\\') folder[i] = '|';
2222 * Back end for change_view()
2224 void do_change_view(int newview) {
2227 serv_printf("VIEW %d", newview);
2229 WC->wc_view = newview;
2230 smart_goto(WC->wc_roomname);
2236 * Change the view for this room
2238 void change_view(void) {
2241 view = atol(bstr("view"));
2242 do_change_view(view);
2247 * One big expanded tree list view --- like a folder list
2249 void do_folder_view(struct folder *fold, int max_folders, int num_floors) {
2251 int levels, oldlevels;
2254 int has_subfolders = 0;
2256 /* Include the menu expanding/collapsing code */
2257 wprintf("<script type=\"text/javascript\" src=\"/static/menuExpandable3.js\"></script>\n");
2259 /* BEGIN TREE MENU */
2260 wprintf("<div style=\"background: white\">\n");
2261 wprintf("<div id=\"mainMenu\">\n");
2262 wprintf("<UL id=\"menuList\">\n");
2266 for (i=0; i<max_folders; ++i) {
2269 if ((i+1) < max_folders) {
2270 if ( (!strncasecmp(fold[i].name, fold[i+1].name, strlen(fold[i].name)))
2271 && (fold[i+1].name[strlen(fold[i].name)] == '|') ) {
2276 levels = num_tokens(fold[i].name, '|');
2278 if ( (levels < oldlevels) || ((levels==1)&&(i!=0)) ) {
2279 for (t=0; t<(oldlevels-levels); ++t) {
2284 if (has_subfolders) {
2286 if (levels == 1) wprintf(" class=\"menubar\"");
2288 wprintf("<A href=\"#\" id=\"actuator%d\" class=\"actuator\"></a>\n", actnum);
2294 if (fold[i].selectable) {
2295 wprintf("<A HREF=\"/dotgoto?room=");
2296 urlescputs(fold[i].room);
2301 wprintf("<SPAN CLASS=\"roomlist_floor\">");
2303 else if (fold[i].hasnewmsgs) {
2304 wprintf("<SPAN CLASS=\"roomlist_new\">");
2307 wprintf("<SPAN CLASS=\"roomlist_old\">");
2309 extract(buf, fold[i].name, levels-1);
2313 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
2314 wprintf(" (INBOX)");
2317 if (fold[i].selectable) {
2322 if (has_subfolders) {
2323 wprintf("<UL id=\"menu%d\" class=\"%s\">\n",
2325 ( (levels == 1) ? "menu" : "submenu")
2331 wprintf("</UL></UL>\n");
2332 wprintf("<img src=\"/static/blank.gif\" onLoad = ' \n");
2333 for (i=0; i<actnum; ++i) {
2334 wprintf(" initializeMenu(\"menu%d\", \"actuator%d\");\n", i, i);
2337 wprintf("</DIV>\n");
2342 * Boxes and rooms and lists ... oh my!
2344 void do_rooms_view(struct folder *fold, int max_folders, int num_floors) {
2347 int levels, oldlevels;
2350 static int columns = 3;
2351 int boxes_per_column = 0;
2352 int current_column = 0;
2356 while (nf % columns != 0) ++nf;
2357 boxes_per_column = (nf / columns);
2358 if (boxes_per_column < 1) boxes_per_column = 1;
2360 /* Outer table (for columnization) */
2361 wprintf("<TABLE BORDER=0 WIDTH=96%% CELLPADDING=5>"
2362 "<tr><td valign=top>");
2366 for (i=0; i<max_folders; ++i) {
2368 levels = num_tokens(fold[i].name, '|');
2370 if ((levels == 1) && (oldlevels > 1)) {
2373 do_template("endbox");
2376 if ((num_boxes % boxes_per_column) == 0) {
2378 if (current_column < columns) {
2379 wprintf("</td><td valign=top>\n");
2386 /* Begin inner box */
2387 extract(buf, fold[i].name, levels-1);
2388 stresc(boxtitle, buf, 1, 0);
2389 svprintf("BOXTITLE", WCS_STRING, boxtitle);
2390 do_template("beginbox");
2398 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
2399 if (fold[i].selectable) {
2400 wprintf("<A HREF=\"/dotgoto?room=");
2401 urlescputs(fold[i].room);
2407 if (fold[i].hasnewmsgs) {
2408 wprintf("<SPAN CLASS=\"roomlist_new\">");
2411 wprintf("<SPAN CLASS=\"roomlist_old\">");
2413 extract(buf, fold[i].name, levels-1);
2416 if (fold[i].selectable) {
2422 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
2423 wprintf(" (INBOX)");
2425 wprintf("<br />\n");
2428 /* End the final inner box */
2429 do_template("endbox");
2431 wprintf("</TD></TR></TABLE>\n");
2436 * Show the room list. (only should get called by
2437 * knrooms() because that's where output_headers() is called from)
2440 void list_all_rooms_by_floor(char *viewpref) {
2443 struct folder *fold = NULL;
2445 int max_folders = 0;
2446 int alloc_folders = 0;
2450 int num_floors = 1; /* add an extra one for private folders */
2452 /* Start with the mailboxes */
2455 fold = malloc(sizeof(struct folder));
2456 memset(fold, 0, sizeof(struct folder));
2457 strcpy(fold[0].name, "My folders");
2458 fold[0].is_mailbox = 1;
2460 /* Then add floors */
2463 if (buf[0]=='1') while(serv_gets(buf), strcmp(buf, "000")) {
2464 if (max_folders >= alloc_folders) {
2465 alloc_folders = max_folders + 100;
2466 fold = realloc(fold,
2467 alloc_folders * sizeof(struct folder));
2469 memset(&fold[max_folders], 0, sizeof(struct folder));
2470 extract(fold[max_folders].name, buf, 1);
2478 if (buf[0]=='1') while(serv_gets(buf), strcmp(buf, "000")) {
2479 if (max_folders >= alloc_folders) {
2480 alloc_folders = max_folders + 100;
2481 fold = realloc(fold,
2482 alloc_folders * sizeof(struct folder));
2484 memset(&fold[max_folders], 0, sizeof(struct folder));
2485 extract(fold[max_folders].room, buf, 0);
2486 ra_flags = extract_int(buf, 5);
2487 flags = extract_int(buf, 1);
2488 fold[max_folders].floor = extract_int(buf, 2);
2489 fold[max_folders].hasnewmsgs =
2490 ((ra_flags & UA_HASNEWMSGS) ? 1 : 0 );
2491 if (flags & QR_MAILBOX) {
2492 fold[max_folders].is_mailbox = 1;
2494 room_to_folder(fold[max_folders].name,
2495 fold[max_folders].room,
2496 fold[max_folders].floor,
2497 fold[max_folders].is_mailbox);
2498 fold[max_folders].selectable = 1;
2502 /* Bubble-sort the folder list */
2503 for (i=0; i<max_folders; ++i) {
2504 for (j=0; j<(max_folders-1)-i; ++j) {
2505 if (fold[j].is_mailbox == fold[j+1].is_mailbox) {
2506 swap = strcasecmp(fold[j].name, fold[j+1].name);
2509 if ( (fold[j+1].is_mailbox)
2510 && (!fold[j].is_mailbox)) {
2518 memcpy(&ftmp, &fold[j], sizeof(struct folder));
2519 memcpy(&fold[j], &fold[j+1],
2520 sizeof(struct folder));
2521 memcpy(&fold[j+1], &ftmp,
2522 sizeof(struct folder));
2527 /* test only hackish view
2528 wprintf("<table><TR><TD>A Table</TD></TR></table>\n");
2529 for (i=0; i<max_folders; ++i) {
2530 escputs(fold[i].name);
2531 wprintf("<br />\n");
2535 if (!strcasecmp(viewpref, "folders")) {
2536 do_folder_view(fold, max_folders, num_floors);
2539 do_rooms_view(fold, max_folders, num_floors);
2547 /* Do either a known rooms list or a folders list, depending on the
2551 char listviewpref[SIZ];
2553 output_headers(1, 1, 2, 0, 0, 0, 0);
2556 /* Determine whether the user is trying to change views */
2557 if (bstr("view") != NULL) {
2558 if (strlen(bstr("view")) > 0) {
2559 set_preference("roomlistview", bstr("view"));
2563 get_preference("roomlistview", listviewpref);
2565 if ( (strcasecmp(listviewpref, "folders"))
2566 && (strcasecmp(listviewpref, "table")) ) {
2567 strcpy(listviewpref, "rooms");
2571 wprintf("<div id=\"banner\">\n"
2572 "<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>"
2573 "<SPAN CLASS=\"titlebar\">"
2575 if (!strcasecmp(listviewpref, "rooms")) {
2576 wprintf("Room list");
2578 if (!strcasecmp(listviewpref, "folders")) {
2579 wprintf("Folder list");
2581 if (!strcasecmp(listviewpref, "table")) {
2582 wprintf("Room list");
2584 wprintf("</SPAN></TD>\n");
2586 /* offer the ability to switch views */
2587 wprintf("<TD ALIGN=RIGHT><FORM NAME=\"roomlistomatic\">\n"
2588 "<SELECT NAME=\"newview\" SIZE=\"1\" "
2589 "OnChange=\"location.href=roomlistomatic.newview.options"
2590 "[selectedIndex].value\">\n");
2592 wprintf("<OPTION %s VALUE=\"/knrooms&view=rooms\">"
2595 ( !strcasecmp(listviewpref, "rooms") ? "SELECTED" : "" )
2598 wprintf("<OPTION %s VALUE=\"/knrooms&view=folders\">"
2599 "View as folder list"
2601 ( !strcasecmp(listviewpref, "folders") ? "SELECTED" : "" )
2604 wprintf("</SELECT><br />");
2606 wprintf("</FORM></TD></TR></TABLE>\n");
2609 "<div id=\"content\">\n");
2611 /* Display the room list in the user's preferred format */
2612 list_all_rooms_by_floor(listviewpref);
2618 * Set the message expire policy for this room and/or floor
2620 void set_room_policy(void) {
2623 if (strcmp(bstr("sc"), "OK")) {
2624 strcpy(WC->ImportantMessage,
2625 "Cancelled. Changes were not saved.");
2630 serv_printf("SPEX room|%d|%d", atoi(bstr("roompolicy")), atoi(bstr("roomvalue")));
2632 strcpy(WC->ImportantMessage, &buf[4]);
2634 if (WC->axlevel >= 6) {
2635 strcat(WC->ImportantMessage, "<br />\n");
2636 serv_printf("SPEX floor|%d|%d", atoi(bstr("floorpolicy")), atoi(bstr("floorvalue")));
2638 strcat(WC->ImportantMessage, &buf[4]);