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)
60 serv_getln(buf, sizeof buf);
62 strcpy(floorlist[0], "Main Floor");
65 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
66 extract_token(floorlist[extract_int(buf, 0)], buf, 1, '|', sizeof floorlist[0]);
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 */
175 serv_getln(buf, sizeof buf);
180 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
182 rp = malloc(sizeof(struct roomlisting));
183 extract_token(rp->rlname, buf, 0, '|', sizeof rp->rlname);
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)
249 serv_getln(buf, sizeof buf);
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_");
267 serv_getln(buf, sizeof buf);
269 wprintf("<TD BGCOLOR=\"#444455\">");
270 wprintf("<IMG HEIGHT=64 SRC=\"/image&name=_roompic_&room=");
271 urlescputs(WC->wc_roomname);
274 serv_getln(buf, sizeof buf);
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);
343 serv_getln(fakegot, sizeof fakegot);
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);
541 serv_getln(buf, sizeof buf);
543 serv_puts("GOTO _BASEROOM_");
544 serv_getln(buf, sizeof buf);
549 extract_token(WC->wc_roomname, &buf[4], 0, '|', sizeof WC->wc_roomname);
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) {
628 serv_getln(buf, sizeof buf);
630 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
631 mptr = (struct march *) malloc(sizeof(struct march));
633 extract_token(mptr->march_name, buf, 0, '|', sizeof mptr->march_name);
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");
692 serv_getln(buf, sizeof buf);
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);
712 serv_getln(buf, sizeof buf);
714 smart_goto(WC->wc_roomname);
717 if (WC->uglsn >= 0L) {
718 serv_printf("SLRP %ld", WC->uglsn);
719 serv_getln(buf, sizeof buf);
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;
747 serv_getln(buf, sizeof buf);
748 if (buf[0] != '2') return(0);
750 extract_token(name, &buf[4], 0, '|', sizeof name);
751 extract_token(password, &buf[4], 1, '|', sizeof password);
752 extract_token(dirname, &buf[4], 2, '|', sizeof dirname);
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);
780 serv_getln(buf, sizeof buf);
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";
822 serv_getln(buf, sizeof buf);
825 strcpy(WC->ImportantMessage, &buf[4]);
829 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
830 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
831 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
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=\"/delete_room\" "
951 "onClick=\"return confirm('Are you sure you want to delete this room?');\">\n"
952 "Delete this room</A>\n"
953 "<LI><A HREF=\"/display_editroompic\">\n"
954 "Set or change the graphic for this room's banner</A>\n"
955 "<LI><A HREF=\"/display_editinfo\">\n"
956 "Edit this room's Info file</A>\n"
960 if (!strcmp(tab, "config")) {
961 wprintf("<FORM METHOD=\"POST\" ACTION=\"/editroom\">\n");
963 wprintf("<UL><LI>Name of room: ");
964 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\"19\">\n", er_name);
966 wprintf("<LI>Resides on floor: ");
967 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
968 for (i = 0; i < 128; ++i)
969 if (strlen(floorlist[i]) > 0) {
972 wprintf("SELECTED ");
973 wprintf("VALUE=\"%d\">", i);
974 escputs(floorlist[i]);
975 wprintf("</OPTION>\n");
977 wprintf("</SELECT>\n");
979 wprintf("<LI>Type of room:<UL>\n");
981 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
982 if ((er_flags & QR_PRIVATE) == 0)
984 wprintf("> Public room\n");
986 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"hidden\" ");
987 if ((er_flags & QR_PRIVATE) &&
988 (er_flags & QR_GUESSNAME))
990 wprintf("> Private - guess name\n");
992 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
993 if ((er_flags & QR_PRIVATE) &&
994 (er_flags & QR_PASSWORDED))
996 wprintf("> Private - require password:\n");
997 wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n", er_password);
999 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
1000 if ((er_flags & QR_PRIVATE)
1001 && ((er_flags & QR_GUESSNAME) == 0)
1002 && ((er_flags & QR_PASSWORDED) == 0))
1003 wprintf("CHECKED ");
1004 wprintf("> Private - invitation only\n");
1006 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
1007 wprintf("> If private, cause current users to forget room\n");
1011 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
1012 if (er_flags & QR_PREFONLY)
1013 wprintf("CHECKED ");
1014 wprintf("> Preferred users only\n");
1016 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
1017 if (er_flags & QR_READONLY)
1018 wprintf("CHECKED ");
1019 wprintf("> Read-only room\n");
1021 /* directory stuff */
1022 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
1023 if (er_flags & QR_DIRECTORY)
1024 wprintf("CHECKED ");
1025 wprintf("> File directory room\n");
1027 wprintf("<UL><LI>Directory name: ");
1028 wprintf("<INPUT TYPE=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n", er_dirname);
1030 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
1031 if (er_flags & QR_UPLOAD)
1032 wprintf("CHECKED ");
1033 wprintf("> Uploading allowed\n");
1035 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
1036 if (er_flags & QR_DOWNLOAD)
1037 wprintf("CHECKED ");
1038 wprintf("> Downloading allowed\n");
1040 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
1041 if (er_flags & QR_VISDIR)
1042 wprintf("CHECKED ");
1043 wprintf("> Visible directory</UL>\n");
1045 /* end of directory stuff */
1047 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
1048 if (er_flags & QR_NETWORK)
1049 wprintf("CHECKED ");
1050 wprintf("> Network shared room\n");
1052 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"permanent\" VALUE=\"yes\" ");
1053 if (er_flags & QR_PERMANENT)
1054 wprintf("CHECKED ");
1055 wprintf("> Permanent (does not auto-purge)\n");
1057 /* start of anon options */
1059 wprintf("<LI>Anonymous messages<UL>\n");
1061 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
1062 if (((er_flags & QR_ANONONLY) == 0)
1063 && ((er_flags & QR_ANONOPT) == 0))
1064 wprintf("CHECKED ");
1065 wprintf("> No anonymous messages\n");
1067 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
1068 if (er_flags & QR_ANONONLY)
1069 wprintf("CHECKED ");
1070 wprintf("> All messages are anonymous\n");
1072 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
1073 if (er_flags & QR_ANONOPT)
1074 wprintf("CHECKED ");
1075 wprintf("> Prompt user when entering messages</UL>\n");
1077 /* end of anon options */
1079 wprintf("<LI>Room aide: \n");
1081 serv_getln(buf, sizeof buf);
1082 if (buf[0] != '2') {
1083 wprintf("<EM>%s</EM>\n", &buf[4]);
1085 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
1086 wprintf("<INPUT TYPE=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n", er_roomaide);
1089 wprintf("</UL><CENTER>\n");
1090 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"config\">\n"
1091 "<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">"
1093 "<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">"
1099 /* Sharing the room with other Citadel nodes... */
1100 if (!strcmp(tab, "sharing")) {
1102 shared_with = strdup("");
1103 not_shared_with = strdup("");
1105 /* Learn the current configuration */
1106 serv_puts("CONF getsys|application/x-citadel-ignet-config");
1107 serv_getln(buf, sizeof buf);
1108 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1109 extract_token(node, buf, 0, '|', sizeof node);
1110 not_shared_with = realloc(not_shared_with,
1111 strlen(not_shared_with) + 32);
1112 strcat(not_shared_with, node);
1113 strcat(not_shared_with, "\n");
1117 serv_getln(buf, sizeof buf);
1118 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1119 extract_token(cmd, buf, 0, '|', sizeof cmd);
1120 extract_token(node, buf, 1, '|', sizeof node);
1121 extract_token(remote_room, buf, 2, '|', sizeof remote_room);
1122 if (!strcasecmp(cmd, "ignet_push_share")) {
1123 shared_with = realloc(shared_with,
1124 strlen(shared_with) + 32);
1125 strcat(shared_with, node);
1126 if (strlen(remote_room) > 0) {
1127 strcat(shared_with, "|");
1128 strcat(shared_with, remote_room);
1130 strcat(shared_with, "\n");
1134 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1135 extract_token(buf, shared_with, i, '\n', sizeof buf);
1136 extract_token(node, buf, 0, '|', sizeof node);
1137 for (j=0; j<num_tokens(not_shared_with, '\n'); ++j) {
1138 extract_token(cmd, not_shared_with, j, '\n', sizeof cmd);
1139 if (!strcasecmp(node, cmd)) {
1140 remove_token(not_shared_with, j, '\n');
1145 /* Display the stuff */
1146 wprintf("<CENTER><br />"
1147 "<TABLE border=1 cellpadding=5><TR>"
1148 "<TD><B><I>Shared with</I></B></TD>"
1149 "<TD><B><I>Not shared with</I></B></TD></TR>\n"
1150 "<TR><TD VALIGN=TOP>\n");
1152 wprintf("<TABLE border=0 cellpadding=5><TR BGCOLOR=\"#CCCCCC\">"
1153 "<TD>Remote node name</TD>"
1154 "<TD>Remote room name</TD>"
1159 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1160 extract_token(buf, shared_with, i, '\n', sizeof buf);
1161 extract_token(node, buf, 0, '|', sizeof node);
1162 extract_token(remote_room, buf, 1, '|', sizeof remote_room);
1163 if (strlen(node) > 0) {
1164 wprintf("<FORM METHOD=\"POST\" "
1165 "ACTION=\"/netedit\">"
1166 "<TR><TD>%s</TD>\n", node);
1169 if (strlen(remote_room) > 0) {
1170 escputs(remote_room);
1176 wprintf("<INPUT TYPE=\"hidden\" NAME=\"line\" "
1177 "VALUE=\"ignet_push_share|");
1179 if (strlen(remote_room) > 0) {
1181 urlescputs(remote_room);
1184 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" "
1185 "VALUE=\"sharing\">\n");
1186 wprintf("<INPUT TYPE=\"hidden\" NAME=\"cmd\" "
1187 "VALUE=\"remove\">\n");
1188 wprintf("<INPUT TYPE=\"submit\" "
1189 "NAME=\"sc\" VALUE=\"Unshare\">");
1190 wprintf("</TD></TR></FORM>\n");
1194 wprintf("</TABLE>\n");
1195 wprintf("</TD><TD VALIGN=TOP>\n");
1196 wprintf("<TABLE border=0 cellpadding=5><TR BGCOLOR=\"#CCCCCC\">"
1197 "<TD>Remote node name</TD>"
1198 "<TD>Remote room name</TD>"
1203 for (i=0; i<num_tokens(not_shared_with, '\n'); ++i) {
1204 extract_token(node, not_shared_with, i, '\n', sizeof node);
1205 if (strlen(node) > 0) {
1206 wprintf("<FORM METHOD=\"POST\" "
1207 "ACTION=\"/netedit\">"
1211 "<INPUT TYPE=\"INPUT\" "
1215 wprintf("<INPUT TYPE=\"hidden\" "
1217 "VALUE=\"ignet_push_share|");
1220 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" "
1221 "VALUE=\"sharing\">\n");
1222 wprintf("<INPUT TYPE=\"hidden\" NAME=\"cmd\" "
1223 "VALUE=\"add\">\n");
1224 wprintf("<INPUT TYPE=\"submit\" "
1225 "NAME=\"sc\" VALUE=\"Share\">");
1226 wprintf("</TD></TR></FORM>\n");
1230 wprintf("</TABLE>\n");
1231 wprintf("</TD></TR>"
1232 "</TABLE></CENTER><br />\n"
1233 "<I><B>Notes:</B><UL><LI>When sharing a room, "
1234 "it must be shared from both ends. Adding a node to "
1235 "the 'shared' list sends messages out, but in order to"
1236 " receive messages, the other nodes must be configured"
1237 " to send messages out to your system as well.\n"
1238 "<LI>If the remote room name is blank, it is assumed "
1239 "that the room name is identical on the remote node."
1240 "<LI>If the remote room name is different, the remote "
1241 "node must also configure the name of the room here."
1247 /* Mailing list management */
1248 if (!strcmp(tab, "listserv")) {
1250 wprintf("<br /><center>"
1251 "<TABLE BORDER=0 WIDTH=100%% CELLPADDING=5>"
1252 "<TR><TD VALIGN=TOP>");
1254 wprintf("<i>The contents of this room are being "
1255 "mailed <b>as individual messages</b> "
1256 "to the following list recipients:"
1257 "</i><br /><br />\n");
1260 serv_getln(buf, sizeof buf);
1261 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1262 extract_token(cmd, buf, 0, '|', sizeof cmd);
1263 if (!strcasecmp(cmd, "listrecp")) {
1264 extract_token(recp, buf, 1, '|', sizeof recp);
1267 wprintf(" <A HREF=\"/netedit&cmd=remove&line="
1270 wprintf("&tab=listserv\">(remove)</A><br />");
1274 wprintf("<br /><FORM METHOD=\"POST\" ACTION=\"/netedit\">\n"
1275 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1276 "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"listrecp|\">\n");
1277 wprintf("<INPUT TYPE=\"text\" NAME=\"line\">\n");
1278 wprintf("<INPUT TYPE=\"submit\" NAME=\"cmd\" VALUE=\"Add\">");
1279 wprintf("</FORM>\n");
1281 wprintf("</TD><TD VALIGN=TOP>\n");
1283 wprintf("<i>The contents of this room are being "
1284 "mailed <b>in digest form</b> "
1285 "to the following list recipients:"
1286 "</i><br /><br />\n");
1289 serv_getln(buf, sizeof buf);
1290 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1291 extract_token(cmd, buf, 0, '|', sizeof cmd);
1292 if (!strcasecmp(cmd, "digestrecp")) {
1293 extract_token(recp, buf, 1, '|', sizeof recp);
1296 wprintf(" <A HREF=\"/netedit&cmd=remove&line="
1299 wprintf("&tab=listserv\">(remove)</A><br />");
1303 wprintf("<br /><FORM METHOD=\"POST\" ACTION=\"/netedit\">\n"
1304 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1305 "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"digestrecp|\">\n");
1306 wprintf("<INPUT TYPE=\"text\" NAME=\"line\">\n");
1307 wprintf("<INPUT TYPE=\"submit\" NAME=\"cmd\" VALUE=\"Add\">");
1308 wprintf("</FORM>\n");
1310 wprintf("</TD></TR></TABLE><hr />\n");
1312 if (self_service(999) == 1) {
1313 wprintf("This room is configured to allow "
1314 "self-service subscribe/unsubscribe requests."
1315 " <A HREF=\"/toggle_self_service?newval=0&"
1317 "Click to disable.</A><br />\n"
1318 "The URL for subscribe/unsubscribe is: "
1319 "<TT>http://%s/listsub</TT><br />\n",
1324 wprintf("This room is <i>not</i> configured to allow "
1325 "self-service subscribe/unsubscribe requests."
1326 " <A HREF=\"/toggle_self_service?newval=1&"
1328 "Click to enable.</A><br />\n"
1333 wprintf("</CENTER>\n");
1337 /* Mailing list management */
1338 if (!strcmp(tab, "expire")) {
1340 serv_puts("GPEX room");
1341 serv_getln(buf, sizeof buf);
1342 if (buf[0] == '2') {
1343 roompolicy = extract_int(&buf[4], 0);
1344 roomvalue = extract_int(&buf[4], 1);
1347 serv_puts("GPEX floor");
1348 serv_getln(buf, sizeof buf);
1349 if (buf[0] == '2') {
1350 floorpolicy = extract_int(&buf[4], 0);
1351 floorvalue = extract_int(&buf[4], 1);
1354 wprintf("<br /><FORM METHOD=\"POST\" ACTION=\"/set_room_policy\">\n");
1355 wprintf("<TABLE border=0 cellspacing=5>\n");
1356 wprintf("<TR><TD>Message expire policy for this room<br />(");
1357 escputs(WC->wc_roomname);
1358 wprintf(")</TD><TD>");
1359 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"0\" %s>",
1360 ((roompolicy == 0) ? "CHECKED" : "") );
1361 wprintf("Use the default policy for this floor<br />\n");
1362 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"1\" %s>",
1363 ((roompolicy == 1) ? "CHECKED" : "") );
1364 wprintf("Never automatically expire messages<br />\n");
1365 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"2\" %s>",
1366 ((roompolicy == 2) ? "CHECKED" : "") );
1367 wprintf("Expire by message count<br />\n");
1368 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"3\" %s>",
1369 ((roompolicy == 3) ? "CHECKED" : "") );
1370 wprintf("Expire by message age<br />");
1371 wprintf("Number of messages or days: ");
1372 wprintf("<INPUT TYPE=\"text\" NAME=\"roomvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">", roomvalue);
1373 wprintf("</TD></TR>\n");
1375 if (WC->axlevel >= 6) {
1376 wprintf("<TR><TD COLSPAN=2><hr /></TD></TR>\n");
1377 wprintf("<TR><TD>Message expire policy for this floor<br />(");
1378 escputs(floorlist[WC->wc_floor]);
1379 wprintf(")</TD><TD>");
1380 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"0\" %s>",
1381 ((floorpolicy == 0) ? "CHECKED" : "") );
1382 wprintf("Use the system default<br />\n");
1383 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"1\" %s>",
1384 ((floorpolicy == 1) ? "CHECKED" : "") );
1385 wprintf("Never automatically expire messages<br />\n");
1386 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"2\" %s>",
1387 ((floorpolicy == 2) ? "CHECKED" : "") );
1388 wprintf("Expire by message count<br />\n");
1389 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"3\" %s>",
1390 ((floorpolicy == 3) ? "CHECKED" : "") );
1391 wprintf("Expire by message age<br />");
1392 wprintf("Number of messages or days: ");
1393 wprintf("<INPUT TYPE=\"text\" NAME=\"floorvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">",
1397 wprintf("<CENTER>\n");
1398 wprintf("<TR><TD COLSPAN=2><hr /><CENTER>\n");
1399 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
1401 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1402 wprintf("</CENTER></TD><TR>\n");
1404 wprintf("</TABLE>\n"
1405 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"expire\">\n"
1411 /* Mailing list management */
1412 if (!strcmp(tab, "access")) {
1416 /* end content of whatever tab is open now */
1417 wprintf("</TD></TR></TABLE></div>\n");
1424 * Toggle self-service list subscription
1426 void toggle_self_service(void) {
1429 newval = atoi(bstr("newval"));
1430 self_service(newval);
1437 * save new parameters for a room
1443 char er_password[10];
1444 char er_dirname[15];
1445 char er_roomaide[26];
1451 if (strcmp(bstr("sc"), "OK")) {
1452 strcpy(WC->ImportantMessage,
1453 "Cancelled. Changes were not saved.");
1458 serv_getln(buf, sizeof buf);
1460 if (buf[0] != '2') {
1461 strcpy(WC->ImportantMessage, &buf[4]);
1465 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
1466 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
1467 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
1468 er_flags = extract_int(&buf[4], 3);
1470 strcpy(er_roomaide, bstr("er_roomaide"));
1471 if (strlen(er_roomaide) == 0) {
1473 serv_getln(buf, sizeof buf);
1474 if (buf[0] != '2') {
1475 strcpy(er_roomaide, "");
1477 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
1480 strcpy(buf, bstr("er_name"));
1482 if (strlen(buf) > 0)
1483 strcpy(er_name, buf);
1485 strcpy(buf, bstr("er_password"));
1487 if (strlen(buf) > 0)
1488 strcpy(er_password, buf);
1490 strcpy(buf, bstr("er_dirname"));
1492 if (strlen(buf) > 0)
1493 strcpy(er_dirname, buf);
1495 strcpy(buf, bstr("type"));
1496 er_flags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME);
1498 if (!strcmp(buf, "invonly")) {
1499 er_flags |= (QR_PRIVATE);
1501 if (!strcmp(buf, "hidden")) {
1502 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
1504 if (!strcmp(buf, "passworded")) {
1505 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
1507 if (!strcmp(bstr("prefonly"), "yes")) {
1508 er_flags |= QR_PREFONLY;
1510 er_flags &= ~QR_PREFONLY;
1513 if (!strcmp(bstr("readonly"), "yes")) {
1514 er_flags |= QR_READONLY;
1516 er_flags &= ~QR_READONLY;
1519 if (!strcmp(bstr("permanent"), "yes")) {
1520 er_flags |= QR_PERMANENT;
1522 er_flags &= ~QR_PERMANENT;
1525 if (!strcmp(bstr("network"), "yes")) {
1526 er_flags |= QR_NETWORK;
1528 er_flags &= ~QR_NETWORK;
1531 if (!strcmp(bstr("directory"), "yes")) {
1532 er_flags |= QR_DIRECTORY;
1534 er_flags &= ~QR_DIRECTORY;
1537 if (!strcmp(bstr("ulallowed"), "yes")) {
1538 er_flags |= QR_UPLOAD;
1540 er_flags &= ~QR_UPLOAD;
1543 if (!strcmp(bstr("dlallowed"), "yes")) {
1544 er_flags |= QR_DOWNLOAD;
1546 er_flags &= ~QR_DOWNLOAD;
1549 if (!strcmp(bstr("visdir"), "yes")) {
1550 er_flags |= QR_VISDIR;
1552 er_flags &= ~QR_VISDIR;
1555 strcpy(buf, bstr("anon"));
1557 er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
1558 if (!strcmp(buf, "anononly"))
1559 er_flags |= QR_ANONONLY;
1560 if (!strcmp(buf, "anon2"))
1561 er_flags |= QR_ANONOPT;
1564 if (!strcmp(bstr("bump"), "yes"))
1567 er_floor = atoi(bstr("er_floor"));
1569 sprintf(buf, "SETR %s|%s|%s|%u|%d|%d",
1570 er_name, er_password, er_dirname, er_flags, bump, er_floor);
1572 serv_getln(buf, sizeof buf);
1573 if (buf[0] != '2') {
1574 strcpy(WC->ImportantMessage, &buf[4]);
1580 if (strlen(er_roomaide) > 0) {
1581 sprintf(buf, "SETA %s", er_roomaide);
1583 serv_getln(buf, sizeof buf);
1584 if (buf[0] != '2') {
1585 strcpy(WC->ImportantMessage, &buf[4]);
1586 display_main_menu();
1591 strcpy(WC->ImportantMessage, "Your changes have been saved.");
1598 * Display form for Invite, Kick, and show Who Knows a room
1600 void do_invt_kick(void) {
1601 char buf[SIZ], room[SIZ], username[SIZ];
1604 serv_getln(buf, sizeof buf);
1606 if (buf[0] != '2') {
1610 extract_token(room, &buf[4], 0, '|', sizeof room);
1612 strcpy(username, bstr("username"));
1614 if (!strcmp(bstr("sc"), "Kick")) {
1615 sprintf(buf, "KICK %s", username);
1617 serv_getln(buf, sizeof buf);
1619 if (buf[0] != '2') {
1620 strcpy(WC->ImportantMessage, &buf[4]);
1622 sprintf(WC->ImportantMessage,
1623 "<B><I>User %s kicked out of room %s.</I></B>\n",
1628 if (!strcmp(bstr("sc"), "Invite")) {
1629 sprintf(buf, "INVT %s", username);
1631 serv_getln(buf, sizeof buf);
1633 if (buf[0] != '2') {
1634 strcpy(WC->ImportantMessage, &buf[4]);
1636 sprintf(WC->ImportantMessage,
1637 "<B><I>User %s invited to room %s.</I></B>\n",
1648 * Display form for Invite, Kick, and show Who Knows a room
1650 void display_whok(void)
1652 char buf[SIZ], room[SIZ], username[SIZ];
1655 serv_getln(buf, sizeof buf);
1657 if (buf[0] != '2') {
1661 extract_token(room, &buf[4], 0, '|', sizeof room);
1664 wprintf("<TABLE border=0 CELLSPACING=10><TR VALIGN=TOP>"
1665 "<TD>The users listed below have access to this room. "
1666 "To remove a user from the access list, select the user "
1667 "name from the list and click 'Kick'.<br /><br />");
1669 wprintf("<CENTER><FORM METHOD=\"POST\" ACTION=\"/do_invt_kick\">\n");
1670 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
1671 wprintf("<SELECT NAME=\"username\" SIZE=\"10\" style=\"width:100%%\">\n");
1673 serv_getln(buf, sizeof buf);
1674 if (buf[0] == '1') {
1675 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1676 extract_token(username, buf, 0, '|', sizeof username);
1677 wprintf("<OPTION>");
1682 wprintf("</SELECT><br />\n");
1684 wprintf("<input type=submit name=sc value=\"Kick\">");
1685 wprintf("</FORM></CENTER>\n");
1688 "To grant another user access to this room, enter the "
1689 "user name in the box below and click 'Invite'.<br /><br />");
1691 wprintf("<CENTER><FORM METHOD=\"POST\" ACTION=\"/do_invt_kick\">\n");
1692 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
1693 wprintf("Invite: ");
1694 wprintf("<input type=\"text\" name=\"username\" style=\"width:100%%\"><br />\n"
1695 "<input type=\"hidden\" name=\"sc\" value=\"Invite\">"
1696 "<input type=\"submit\" value=\"Invite\">"
1697 "</FORM></CENTER>\n");
1699 wprintf("</TD></TR></TABLE>\n");
1706 * display the form for entering a new room
1708 void display_entroom(void)
1713 serv_puts("CRE8 0");
1714 serv_getln(buf, sizeof buf);
1716 if (buf[0] != '2') {
1717 strcpy(WC->ImportantMessage, &buf[4]);
1718 display_main_menu();
1722 output_headers(1, 1, 2, 0, 0, 0, 0);
1723 wprintf("<div id=\"banner\">\n"
1724 "<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>"
1725 "<SPAN CLASS=\"titlebar\">Create a new room</SPAN>"
1726 "</TD></TR></TABLE>\n"
1727 "</div>\n<div id=\"content\">\n"
1730 wprintf("<div id=\"fix_scrollbar_bug\">"
1731 "<table border=0 width=100%% bgcolor=\"#ffffff\"><tr><td>\n");
1733 wprintf("<form name=\"create_room_form\" method=\"POST\" action=\"/entroom\">\n");
1735 wprintf("<UL><LI>Name of room: ");
1736 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" MAXLENGTH=\"127\">\n");
1738 wprintf("<LI>Resides on floor: ");
1740 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
1741 for (i = 0; i < 128; ++i)
1742 if (strlen(floorlist[i]) > 0) {
1743 wprintf("<OPTION ");
1744 wprintf("VALUE=\"%d\">", i);
1745 escputs(floorlist[i]);
1746 wprintf("</OPTION>\n");
1748 wprintf("</SELECT>\n");
1750 /* Our clever little snippet of JavaScript automatically selects
1751 * a public room if the view is set to Bulletin Board, and it
1752 * selects a mailbox room otherwise. The user can override this,
1755 wprintf("<LI>Default view for room: ");
1756 wprintf("<SELECT NAME=\"er_view\" SIZE=\"1\" OnChange=\""
1757 " if (this.form.er_view.value == 0) { "
1758 " this.form.type[0].checked=true; "
1759 " this.form.er_floor.disabled = false; "
1762 " this.form.type[4].checked=true; "
1763 " this.form.er_floor.disabled = true; "
1766 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
1767 wprintf("<OPTION %s VALUE=\"%d\">",
1768 ((i == 0) ? "SELECTED" : ""), i );
1769 escputs(viewdefs[i]);
1770 wprintf("</OPTION>\n");
1772 wprintf("</SELECT>\n");
1774 wprintf("<LI>Type of room:<UL>\n");
1776 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1777 wprintf("CHECKED OnChange=\""
1778 " if (this.form.type[0].checked == true) { "
1779 " this.form.er_floor.disabled = false; "
1781 "\"> Public (automatically appears to everyone)\n");
1783 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"hidden\" OnChange=\""
1784 " if (this.form.type[1].checked == true) { "
1785 " this.form.er_floor.disabled = false; "
1787 "\"> Private - hidden (accessible to anyone who knows its name)\n");
1789 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" OnChange=\""
1790 " if (this.form.type[2].checked == true) { "
1791 " this.form.er_floor.disabled = false; "
1793 "\"> Private - require password:\n");
1794 wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
1796 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" OnChange=\""
1797 " if (this.form.type[3].checked == true) { "
1798 " this.form.er_floor.disabled = false; "
1800 "\"> Private - invitation only\n");
1802 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"personal\" "
1804 " if (this.form.type[4].checked == true) { "
1805 " this.form.er_floor.disabled = true; "
1807 "\"> Personal (mailbox for you only)\n");
1811 wprintf("<CENTER>\n");
1812 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
1814 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1815 wprintf("</CENTER>\n");
1816 wprintf("</FORM>\n<hr />");
1817 serv_printf("MESG roomaccess");
1818 serv_getln(buf, sizeof buf);
1819 if (buf[0] == '1') {
1820 fmout(NULL, "CENTER");
1822 wprintf("</td></tr></table></div>\n");
1830 * support function for entroom() -- sets the default view
1832 void er_set_default_view(int newview) {
1845 serv_getln(buf, sizeof buf);
1846 if (buf[0] != '2') return;
1848 extract_token(rm_name, &buf[4], 0, '|', sizeof rm_name);
1849 extract_token(rm_pass, &buf[4], 1, '|', sizeof rm_pass);
1850 extract_token(rm_dir, &buf[4], 2, '|', sizeof rm_dir);
1851 rm_bits1 = extract_int(&buf[4], 3);
1852 rm_floor = extract_int(&buf[4], 4);
1853 rm_listorder = extract_int(&buf[4], 5);
1854 rm_bits2 = extract_int(&buf[4], 7);
1856 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
1857 rm_name, rm_pass, rm_dir, rm_bits1, rm_floor,
1858 rm_listorder, newview, rm_bits2
1860 serv_getln(buf, sizeof buf);
1873 char er_password[SIZ];
1878 if (strcmp(bstr("sc"), "OK")) {
1879 strcpy(WC->ImportantMessage,
1880 "Cancelled. No new room was created.");
1881 display_main_menu();
1884 strcpy(er_name, bstr("er_name"));
1885 strcpy(er_type, bstr("type"));
1886 strcpy(er_password, bstr("er_password"));
1887 er_floor = atoi(bstr("er_floor"));
1888 er_view = atoi(bstr("er_view"));
1891 if (!strcmp(er_type, "hidden"))
1893 if (!strcmp(er_type, "passworded"))
1895 if (!strcmp(er_type, "invonly"))
1897 if (!strcmp(er_type, "personal"))
1900 sprintf(buf, "CRE8 1|%s|%d|%s|%d|%d|%d",
1901 er_name, er_num_type, er_password, er_floor, 0, er_view);
1903 serv_getln(buf, sizeof buf);
1904 if (buf[0] != '2') {
1905 strcpy(WC->ImportantMessage, &buf[4]);
1906 display_main_menu();
1910 do_change_view(er_view); /* Now go there */
1915 * display the screen to enter a private room
1917 void display_private(char *rname, int req_pass)
1919 output_headers(1, 1, 2, 0, 0, 0, 0);
1920 wprintf("<div id=\"banner\">\n"
1921 "<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>"
1922 "<SPAN CLASS=\"titlebar\">Go to a hidden room</SPAN>"
1923 "</TD></TR></TABLE>\n"
1924 "</div>\n<div id=\"content\">\n"
1927 wprintf("<div id=\"fix_scrollbar_bug\">"
1928 "<table border=0 width=100%% bgcolor=\"#ffffff\"><tr><td>\n");
1930 wprintf("<CENTER>\n");
1931 wprintf("<br />If you know the name of a hidden (guess-name) or\n");
1932 wprintf("passworded room, you can enter that room by typing\n");
1933 wprintf("its name below. Once you gain access to a private\n");
1934 wprintf("room, it will appear in your regular room listings\n");
1935 wprintf("so you don't have to keep returning here.\n");
1936 wprintf("<br /><br />");
1938 wprintf("<FORM METHOD=\"GET\" ACTION=\"/goto_private\">\n");
1940 wprintf("<table border=\"0\" cellspacing=\"5\" "
1941 "cellpadding=\"5\" BGCOLOR=\"#EEEEEE\">\n"
1943 "Enter room name:</TD><TD>"
1944 "<INPUT TYPE=\"text\" NAME=\"gr_name\" "
1945 "VALUE=\"%s\" MAXLENGTH=\"19\">\n", rname);
1948 wprintf("</TD></TR><TR><TD>");
1949 wprintf("Enter room password:</TD><TD>");
1950 wprintf("<INPUT TYPE=\"password\" NAME=\"gr_pass\" MAXLENGTH=\"9\">\n");
1952 wprintf("</TD></TR></TABLE><br />\n");
1954 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">"
1956 "<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1957 wprintf("</FORM>\n");
1958 wprintf("</td></tr></table></div>\n");
1963 * goto a private room
1965 void goto_private(void)
1970 if (strcasecmp(bstr("sc"), "OK")) {
1971 display_main_menu();
1974 strcpy(hold_rm, WC->wc_roomname);
1975 strcpy(buf, "GOTO ");
1976 strcat(buf, bstr("gr_name"));
1978 strcat(buf, bstr("gr_pass"));
1980 serv_getln(buf, sizeof buf);
1982 if (buf[0] == '2') {
1983 smart_goto(bstr("gr_name"));
1986 if (!strncmp(buf, "540", 3)) {
1987 display_private(bstr("gr_name"), 1);
1990 output_headers(1, 1, 1, 0, 0, 0, 0);
1991 wprintf("%s\n", &buf[4]);
1998 * display the screen to zap a room
2000 void display_zap(void)
2002 output_headers(1, 1, 2, 0, 0, 0, 0);
2004 wprintf("<div id=\"banner\">\n");
2005 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#770000\"><TR><TD>");
2006 wprintf("<SPAN CLASS=\"titlebar\">Zap (forget/unsubscribe) the current room</SPAN>\n");
2007 wprintf("</TD></TR></TABLE>\n");
2008 wprintf("</div>\n<div id=\"content\">\n");
2010 wprintf("If you select this option, <em>%s</em> will ", WC->wc_roomname);
2011 wprintf("disappear from your room list. Is this what you wish ");
2012 wprintf("to do?<br />\n");
2014 wprintf("<FORM METHOD=\"GET\" ACTION=\"/zap\">\n");
2015 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
2017 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
2018 wprintf("</FORM>\n");
2029 char final_destination[SIZ];
2031 /* If the forget-room routine fails for any reason, we fall back
2032 * to the current room; otherwise, we go to the Lobby
2034 strcpy(final_destination, WC->wc_roomname);
2036 if (!strcasecmp(bstr("sc"), "OK")) {
2037 serv_printf("GOTO %s", WC->wc_roomname);
2038 serv_getln(buf, sizeof buf);
2039 if (buf[0] == '2') {
2041 serv_getln(buf, sizeof buf);
2042 if (buf[0] == '2') {
2043 strcpy(final_destination, "_BASEROOM_");
2047 smart_goto(final_destination);
2053 * Delete the current room
2055 void delete_room(void)
2059 serv_puts("KILL 1");
2060 serv_getln(buf, sizeof buf);
2061 if (buf[0] != '2') {
2062 strcpy(WC->ImportantMessage, &buf[4]);
2063 display_main_menu();
2066 smart_goto("_BASEROOM_");
2073 * Perform changes to a room's network configuration
2075 void netedit(void) {
2084 if (strlen(bstr("line"))==0) {
2089 strcpy(line, bstr("prefix"));
2090 strcat(line, bstr("line"));
2091 strcat(line, bstr("suffix"));
2100 serv_getln(buf, sizeof buf);
2101 if (buf[0] != '1') {
2107 /* This loop works for add *or* remove. Spiffy, eh? */
2108 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2109 extract_token(cmpa0, buf, 0, '|', sizeof cmpa0);
2110 extract_token(cmpa1, buf, 1, '|', sizeof cmpa1);
2111 extract_token(cmpb0, line, 0, '|', sizeof cmpb0);
2112 extract_token(cmpb1, line, 1, '|', sizeof cmpb1);
2113 if ( (strcasecmp(cmpa0, cmpb0))
2114 || (strcasecmp(cmpa1, cmpb1)) ) {
2115 fprintf(fp, "%s\n", buf);
2121 serv_getln(buf, sizeof buf);
2122 if (buf[0] != '4') {
2128 while (fgets(buf, sizeof buf, fp) != NULL) {
2129 buf[strlen(buf)-1] = 0;
2133 if (!strcasecmp(bstr("cmd"), "add")) {
2145 * Convert a room name to a folder-ish-looking name.
2147 void room_to_folder(char *folder, char *room, int floor, int is_mailbox)
2152 * For mailboxes, just do it straight...
2155 sprintf(folder, "My folders|%s", room);
2159 * Otherwise, prefix the floor name as a "public folders" moniker
2162 sprintf(folder, "%s|%s", floorlist[floor], room);
2166 * Replace "\" characters with "|" for pseudo-folder-delimiting
2168 for (i=0; i<strlen(folder); ++i) {
2169 if (folder[i] == '\\') folder[i] = '|';
2177 * Back end for change_view()
2179 void do_change_view(int newview) {
2182 serv_printf("VIEW %d", newview);
2183 serv_getln(buf, sizeof buf);
2184 WC->wc_view = newview;
2185 smart_goto(WC->wc_roomname);
2191 * Change the view for this room
2193 void change_view(void) {
2196 view = atol(bstr("view"));
2197 do_change_view(view);
2202 * One big expanded tree list view --- like a folder list
2204 void do_folder_view(struct folder *fold, int max_folders, int num_floors) {
2206 int levels, oldlevels;
2209 int has_subfolders = 0;
2211 /* Include the menu expanding/collapsing code */
2212 wprintf("<script type=\"text/javascript\" src=\"/static/menuExpandable3.js\"></script>\n");
2214 /* BEGIN TREE MENU */
2215 wprintf("<div style=\"background: white\">\n");
2216 wprintf("<div id=\"mainMenu\">\n");
2217 wprintf("<UL id=\"menuList\">\n");
2221 for (i=0; i<max_folders; ++i) {
2224 if ((i+1) < max_folders) {
2225 if ( (!strncasecmp(fold[i].name, fold[i+1].name, strlen(fold[i].name)))
2226 && (fold[i+1].name[strlen(fold[i].name)] == '|') ) {
2231 levels = num_tokens(fold[i].name, '|');
2233 if ( (levels < oldlevels) || ((levels==1)&&(i!=0)) ) {
2234 for (t=0; t<(oldlevels-levels); ++t) {
2239 if (has_subfolders) {
2241 if (levels == 1) wprintf(" class=\"menubar\"");
2243 wprintf("<A href=\"#\" id=\"actuator%d\" class=\"actuator\"></a>\n", actnum);
2249 if (fold[i].selectable) {
2250 wprintf("<A HREF=\"/dotgoto?room=");
2251 urlescputs(fold[i].room);
2256 wprintf("<SPAN CLASS=\"roomlist_floor\">");
2258 else if (fold[i].hasnewmsgs) {
2259 wprintf("<SPAN CLASS=\"roomlist_new\">");
2262 wprintf("<SPAN CLASS=\"roomlist_old\">");
2264 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
2268 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
2269 wprintf(" (INBOX)");
2272 if (fold[i].selectable) {
2277 if (has_subfolders) {
2278 wprintf("<UL id=\"menu%d\" class=\"%s\">\n",
2280 ( (levels == 1) ? "menu" : "submenu")
2286 wprintf("</UL></UL>\n");
2287 wprintf("<img src=\"/static/blank.gif\" onLoad = ' \n");
2288 for (i=0; i<actnum; ++i) {
2289 wprintf(" initializeMenu(\"menu%d\", \"actuator%d\");\n", i, i);
2292 wprintf("</DIV>\n");
2297 * Boxes and rooms and lists ... oh my!
2299 void do_rooms_view(struct folder *fold, int max_folders, int num_floors) {
2302 int levels, oldlevels;
2305 static int columns = 3;
2306 int boxes_per_column = 0;
2307 int current_column = 0;
2311 while (nf % columns != 0) ++nf;
2312 boxes_per_column = (nf / columns);
2313 if (boxes_per_column < 1) boxes_per_column = 1;
2315 /* Outer table (for columnization) */
2316 wprintf("<TABLE BORDER=0 WIDTH=96%% CELLPADDING=5>"
2317 "<tr><td valign=top>");
2321 for (i=0; i<max_folders; ++i) {
2323 levels = num_tokens(fold[i].name, '|');
2325 if ((levels == 1) && (oldlevels > 1)) {
2328 do_template("endbox");
2331 if ((num_boxes % boxes_per_column) == 0) {
2333 if (current_column < columns) {
2334 wprintf("</td><td valign=top>\n");
2341 /* Begin inner box */
2342 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
2343 stresc(boxtitle, buf, 1, 0);
2344 svprintf("BOXTITLE", WCS_STRING, boxtitle);
2345 do_template("beginbox");
2353 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
2354 if (fold[i].selectable) {
2355 wprintf("<A HREF=\"/dotgoto?room=");
2356 urlescputs(fold[i].room);
2362 if (fold[i].hasnewmsgs) {
2363 wprintf("<SPAN CLASS=\"roomlist_new\">");
2366 wprintf("<SPAN CLASS=\"roomlist_old\">");
2368 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
2371 if (fold[i].selectable) {
2377 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
2378 wprintf(" (INBOX)");
2380 wprintf("<br />\n");
2383 /* End the final inner box */
2384 do_template("endbox");
2386 wprintf("</TD></TR></TABLE>\n");
2391 * Show the room list. (only should get called by
2392 * knrooms() because that's where output_headers() is called from)
2395 void list_all_rooms_by_floor(char *viewpref) {
2398 struct folder *fold = NULL;
2400 int max_folders = 0;
2401 int alloc_folders = 0;
2405 int num_floors = 1; /* add an extra one for private folders */
2407 /* Start with the mailboxes */
2410 fold = malloc(sizeof(struct folder));
2411 memset(fold, 0, sizeof(struct folder));
2412 strcpy(fold[0].name, "My folders");
2413 fold[0].is_mailbox = 1;
2415 /* Then add floors */
2417 serv_getln(buf, sizeof buf);
2418 if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2419 if (max_folders >= alloc_folders) {
2420 alloc_folders = max_folders + 100;
2421 fold = realloc(fold,
2422 alloc_folders * sizeof(struct folder));
2424 memset(&fold[max_folders], 0, sizeof(struct folder));
2425 extract_token(fold[max_folders].name, buf, 1, '|', sizeof fold[max_folders].name);
2432 serv_getln(buf, sizeof buf);
2433 if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2434 if (max_folders >= alloc_folders) {
2435 alloc_folders = max_folders + 100;
2436 fold = realloc(fold,
2437 alloc_folders * sizeof(struct folder));
2439 memset(&fold[max_folders], 0, sizeof(struct folder));
2440 extract_token(fold[max_folders].room, buf, 0, '|', sizeof fold[max_folders].room);
2441 ra_flags = extract_int(buf, 5);
2442 flags = extract_int(buf, 1);
2443 fold[max_folders].floor = extract_int(buf, 2);
2444 fold[max_folders].hasnewmsgs =
2445 ((ra_flags & UA_HASNEWMSGS) ? 1 : 0 );
2446 if (flags & QR_MAILBOX) {
2447 fold[max_folders].is_mailbox = 1;
2449 room_to_folder(fold[max_folders].name,
2450 fold[max_folders].room,
2451 fold[max_folders].floor,
2452 fold[max_folders].is_mailbox);
2453 fold[max_folders].selectable = 1;
2457 /* Bubble-sort the folder list */
2458 for (i=0; i<max_folders; ++i) {
2459 for (j=0; j<(max_folders-1)-i; ++j) {
2460 if (fold[j].is_mailbox == fold[j+1].is_mailbox) {
2461 swap = strcasecmp(fold[j].name, fold[j+1].name);
2464 if ( (fold[j+1].is_mailbox)
2465 && (!fold[j].is_mailbox)) {
2473 memcpy(&ftmp, &fold[j], sizeof(struct folder));
2474 memcpy(&fold[j], &fold[j+1],
2475 sizeof(struct folder));
2476 memcpy(&fold[j+1], &ftmp,
2477 sizeof(struct folder));
2482 /* test only hackish view
2483 wprintf("<table><TR><TD>A Table</TD></TR></table>\n");
2484 for (i=0; i<max_folders; ++i) {
2485 escputs(fold[i].name);
2486 wprintf("<br />\n");
2490 if (!strcasecmp(viewpref, "folders")) {
2491 do_folder_view(fold, max_folders, num_floors);
2494 do_rooms_view(fold, max_folders, num_floors);
2502 /* Do either a known rooms list or a folders list, depending on the
2506 char listviewpref[SIZ];
2508 output_headers(1, 1, 2, 0, 0, 0, 0);
2511 /* Determine whether the user is trying to change views */
2512 if (bstr("view") != NULL) {
2513 if (strlen(bstr("view")) > 0) {
2514 set_preference("roomlistview", bstr("view"));
2518 get_preference("roomlistview", listviewpref, sizeof listviewpref);
2520 if ( (strcasecmp(listviewpref, "folders"))
2521 && (strcasecmp(listviewpref, "table")) ) {
2522 strcpy(listviewpref, "rooms");
2526 wprintf("<div id=\"banner\">\n"
2527 "<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>"
2528 "<SPAN CLASS=\"titlebar\">"
2530 if (!strcasecmp(listviewpref, "rooms")) {
2531 wprintf("Room list");
2533 if (!strcasecmp(listviewpref, "folders")) {
2534 wprintf("Folder list");
2536 if (!strcasecmp(listviewpref, "table")) {
2537 wprintf("Room list");
2539 wprintf("</SPAN></TD>\n");
2541 /* offer the ability to switch views */
2542 wprintf("<TD ALIGN=RIGHT><FORM NAME=\"roomlistomatic\">\n"
2543 "<SELECT NAME=\"newview\" SIZE=\"1\" "
2544 "OnChange=\"location.href=roomlistomatic.newview.options"
2545 "[selectedIndex].value\">\n");
2547 wprintf("<OPTION %s VALUE=\"/knrooms&view=rooms\">"
2550 ( !strcasecmp(listviewpref, "rooms") ? "SELECTED" : "" )
2553 wprintf("<OPTION %s VALUE=\"/knrooms&view=folders\">"
2554 "View as folder list"
2556 ( !strcasecmp(listviewpref, "folders") ? "SELECTED" : "" )
2559 wprintf("</SELECT><br />");
2561 wprintf("</FORM></TD></TR></TABLE>\n");
2564 "<div id=\"content\">\n");
2566 /* Display the room list in the user's preferred format */
2567 list_all_rooms_by_floor(listviewpref);
2573 * Set the message expire policy for this room and/or floor
2575 void set_room_policy(void) {
2578 if (strcmp(bstr("sc"), "OK")) {
2579 strcpy(WC->ImportantMessage,
2580 "Cancelled. Changes were not saved.");
2585 serv_printf("SPEX room|%d|%d", atoi(bstr("roompolicy")), atoi(bstr("roomvalue")));
2586 serv_getln(buf, sizeof buf);
2587 strcpy(WC->ImportantMessage, &buf[4]);
2589 if (WC->axlevel >= 6) {
2590 strcat(WC->ImportantMessage, "<br />\n");
2591 serv_printf("SPEX floor|%d|%d", atoi(bstr("floorpolicy")), atoi(bstr("floorvalue")));
2592 serv_getln(buf, sizeof buf);
2593 strcat(WC->ImportantMessage, &buf[4]);