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 "<SELECT NAME=\"newview\" SIZE=\"1\" "
304 "OnChange=\"location.href=viewomatic.newview.options"
305 "[selectedIndex].value\">\n");
307 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
309 * Only offer the views that make sense, given the default
310 * view for the room. For example, don't offer a Calendar
311 * view in a non-Calendar room.
315 || (i == WC->wc_default_view)
316 || ( (i == 0) && (WC->wc_default_view == 1) )
317 || ( (i == 1) && (WC->wc_default_view == 0) )
320 wprintf("<OPTION %s VALUE=\"/changeview?view=%d\">",
321 ((i == WC->wc_view) ? "SELECTED" : ""),
323 escputs(viewdefs[i]);
324 wprintf("</OPTION>\n");
327 wprintf("</SELECT></FORM>\n");
332 void embed_room_banner(char *got, int navbar_style) {
335 /* We need to have the information returned by a GOTO server command.
336 * If it isn't supplied, we fake it by issuing our own GOTO.
339 serv_printf("GOTO %s", WC->wc_roomname);
344 /* If the user happens to select the "make this my start page" link,
345 * we want it to remember the URL as a "/dotskip" one instead of
346 * a "skip" or "gotonext" or something like that.
348 snprintf(WC->this_page, sizeof(WC->this_page), "/dotskip&room=%s",
351 /* Check for new mail. */
352 WC->new_mail = extract_int(&got[4], 9);
353 WC->wc_view = extract_int(&got[4], 11);
355 svprintf("ROOMNAME", WCS_STRING, "%s", WC->wc_roomname);
356 svprintf("NEWMSGS", WCS_STRING, "%d", extract_int(&got[4], 1));
357 svprintf("TOTALMSGS", WCS_STRING, "%d", extract_int(&got[4], 2));
358 svcallback("ROOMPIC", embed_room_graphic);
359 svcallback("ROOMINFO", readinfo);
360 svcallback("YOUHAVEMAIL", embed_newmail_button);
361 svcallback("VIEWOMATIC", embed_view_o_matic);
362 svcallback("START", offer_start_page);
364 do_template("roombanner");
365 if (navbar_style != navbar_none) {
367 wprintf("<div style=\"position:absolute; bottom:0px; left:0px\">\n"
368 "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"100%%\"><tr>\n");
371 if (navbar_style == navbar_default) wprintf(
373 "<a href=\"/ungoto\">"
374 "<img align=\"middle\" src=\"/static/back.gif\" border=\"0\">"
375 "<span class=\"navbar_link\">Ungoto</span></A>"
379 if ( (navbar_style == navbar_default)
380 && (WC->wc_view != VIEW_CALENDAR)
381 && (WC->wc_view != VIEW_ADDRESSBOOK)
382 && (WC->wc_view != VIEW_NOTES)
383 && (WC->wc_view != VIEW_TASKS)
387 "<A HREF=\"/readnew\">"
388 "<img align=\"middle\" src=\"/static/readmsgs.gif\" border=\"0\">"
389 "<span class=\"navbar_link\">Read new messages</span></A>"
394 if (navbar_style == navbar_default) {
395 switch(WC->wc_view) {
396 case VIEW_ADDRESSBOOK:
399 "<A HREF=\"/readfwd\">"
400 "<img align=\"middle\" src=\"/static/readmsgs.gif\" "
402 "<span class=\"navbar_link\">"
410 "<A HREF=\"/readfwd?calview=day\">"
411 "<img align=\"middle\" src=\"/static/day_view.gif\" "
413 "<span class=\"navbar_link\">"
419 "<A HREF=\"/readfwd?calview=month\">"
420 "<img align=\"middle\" src=\"/static/month_view.gif\" "
422 "<span class=\"navbar_link\">"
430 "<A HREF=\"/readfwd\">"
431 "<img align=\"middle\" src=\"/static/readmsgs.gif\" "
433 "<span class=\"navbar_link\">"
441 "<A HREF=\"/readfwd\">"
442 "<img align=\"middle\" src=\"/static/readmsgs.gif\" "
444 "<span class=\"navbar_link\">"
452 "<A HREF=\"/readfwd\">"
453 "<img align=\"middle\" src=\"/static/readmsgs.gif\" "
455 "<span class=\"navbar_link\">"
463 if (navbar_style == navbar_default) {
466 "<A HREF=\"/display_enter\">"
467 "<img align=\"middle\" src=\"/static/enter.gif\" border=\"0\">"
468 "<span class=\"navbar_link\">"
470 switch(WC->wc_view) {
471 case VIEW_ADDRESSBOOK:
472 wprintf("Add new contact");
475 wprintf("Add new event");
478 wprintf("Add new task");
481 wprintf("Add new note");
484 wprintf("Enter a message");
487 wprintf("</span></a></td>\n");
490 if (navbar_style == navbar_default) wprintf(
493 "TITLE=\"Leave all messages marked as unread, go to next room with unread messages\">"
494 "<span class=\"navbar_link\">Skip this room</span>"
495 "<img align=\"middle\" src=\"/static/forward.gif\" border=\"0\"></A>"
499 if (navbar_style == navbar_default) wprintf(
501 "<A HREF=\"/gotonext\" "
502 "TITLE=\"Mark all messages as read, go to next room with unread messages\">"
503 "<span class=\"navbar_link\">Goto next room</span>"
504 "<img align=\"middle\" src=\"/static/forward.gif\" border=\"0\"></A>"
508 wprintf("</tr></table></div>\n");
518 * back end routine to take the session to a new room
521 void gotoroom(char *gname)
524 static long ls = (-1L);
526 /* store ungoto information */
527 strcpy(WC->ugname, WC->wc_roomname);
530 /* move to the new room */
531 serv_printf("GOTO %s", gname);
534 serv_puts("GOTO _BASEROOM_");
540 extract(WC->wc_roomname, &buf[4], 0);
541 WC->room_flags = extract_int(&buf[4], 4);
542 /* highest_msg_read = extract_int(&buf[4],6);
543 maxmsgnum = extract_int(&buf[4],5);
544 is_mail = (char) extract_int(&buf[4],7); */
545 ls = extract_long(&buf[4], 6);
546 WC->wc_floor = extract_int(&buf[4], 10);
547 WC->wc_view = extract_int(&buf[4], 11);
548 WC->wc_default_view = extract_int(&buf[4], 12);
551 WC->is_room_aide = WC->is_aide;
553 WC->is_room_aide = (char) extract_int(&buf[4], 8);
555 remove_march(WC->wc_roomname);
556 if (!strcasecmp(gname, "_BASEROOM_"))
562 * Locate the room on the march list which we most want to go to. Each room
563 * is measured given a "weight" of preference based on various factors.
565 char *pop_march(int desired_floor)
567 static char TheRoom[128];
569 int TheOrder = 32767;
572 struct march *mptr = NULL;
574 strcpy(TheRoom, "_BASEROOM_");
575 if (WC->march == NULL)
578 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
580 if ((strcasecmp(mptr->march_name, "_BASEROOM_")))
581 weight = weight + 10000;
582 if (mptr->march_floor == desired_floor)
583 weight = weight + 5000;
585 weight = weight + ((128 - (mptr->march_floor)) * 128);
586 weight = weight + (128 - (mptr->march_order));
588 if (weight > TheWeight) {
590 strcpy(TheRoom, mptr->march_name);
591 TheFloor = mptr->march_floor;
592 TheOrder = mptr->march_order;
600 /* Goto next room having unread messages.
601 * We want to skip over rooms that the user has already been to, and take the
602 * user back to the lobby when done. The room we end up in is placed in
603 * newroom - which is set to 0 (the lobby) initially.
604 * We start the search in the current room rather than the beginning to prevent
605 * two or more concurrent users from dragging each other back to the same room.
610 struct march *mptr, *mptr2;
613 /* First check to see if the march-mode list is already allocated.
614 * If it is, pop the first room off the list and go there.
617 if (WC->march == NULL) {
621 while (serv_gets(buf), strcmp(buf, "000")) {
622 mptr = (struct march *) malloc(sizeof(struct march));
624 extract(mptr->march_name, buf, 0);
625 mptr->march_floor = extract_int(buf, 2);
626 mptr->march_order = extract_int(buf, 3);
627 if (WC->march == NULL) {
631 while (mptr2->next != NULL)
636 /* add _BASEROOM_ to the end of the march list, so the user will end up
637 * in the system base room (usually the Lobby>) at the end of the loop
639 mptr = (struct march *) malloc(sizeof(struct march));
641 strcpy(mptr->march_name, "_BASEROOM_");
642 if (WC->march == NULL) {
646 while (mptr2->next != NULL)
651 * ...and remove the room we're currently in, so a <G>oto doesn't make us
652 * walk around in circles
654 remove_march(WC->wc_roomname);
656 if (WC->march != NULL) {
657 strcpy(next_room, pop_march(-1));
659 strcpy(next_room, "_BASEROOM_");
663 smart_goto(next_room);
667 void smart_goto(char *next_room) {
675 * mark all messages in current room as having been read
677 void slrp_highest(void)
682 serv_puts("SLRP HIGHEST");
685 wprintf("<EM>%s</EM><br />\n", &buf[4]);
692 * un-goto the previous room
698 if (!strcmp(WC->ugname, "")) {
699 smart_goto(WC->wc_roomname);
702 serv_printf("GOTO %s", WC->ugname);
705 smart_goto(WC->wc_roomname);
708 if (WC->uglsn >= 0L) {
709 serv_printf("SLRP %ld", WC->uglsn);
712 strcpy(buf, WC->ugname);
713 strcpy(WC->ugname, "");
722 * Set/clear/read the "self-service list subscribe" flag for a room
724 * Set 'newval' to 0 to clear, 1 to set, any other value to leave unchanged.
725 * Always returns the new value.
728 int self_service(int newval) {
729 int current_value = 0;
735 int flags, floor, order, view, flags2;
739 if (buf[0] != '2') return(0);
741 extract(name, &buf[4], 0);
742 extract(password, &buf[4], 1);
743 extract(dirname, &buf[4], 2);
744 flags = extract_int(&buf[4], 3);
745 floor = extract_int(&buf[4], 4);
746 order = extract_int(&buf[4], 5);
747 view = extract_int(&buf[4], 6);
748 flags2 = extract_int(&buf[4], 7);
750 if (flags2 & QR2_SELFLIST) {
758 flags2 = flags2 | QR2_SELFLIST;
760 else if (newval == 0) {
761 flags2 = flags2 & ~QR2_SELFLIST;
764 return(current_value);
767 if (newval != current_value) {
768 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
769 name, password, dirname, flags,
770 floor, order, view, flags2);
784 * display the form for editing a room
786 void display_editroom(void)
791 char remote_room[SIZ];
794 char er_password[10];
796 char er_roomaide[26];
802 char *not_shared_with;
809 if (strlen(tab) == 0) tab = "admin";
816 strcpy(WC->ImportantMessage, &buf[4]);
820 extract(er_name, &buf[4], 0);
821 extract(er_password, &buf[4], 1);
822 extract(er_dirname, &buf[4], 2);
823 er_flags = extract_int(&buf[4], 3);
824 er_floor = extract_int(&buf[4], 4);
826 output_headers(1, 1, 1, 0, 0, 0, 0);
828 /* print the tabbed dialog */
829 wprintf("<br /><center><TABLE border=0 cellspacing=0 cellpadding=0 width=99%%>"
831 "<TD> </TD>\n");
833 if (!strcmp(tab, "admin")) {
834 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
837 wprintf("<TD BGCOLOR=\"#CCCCCC\"><A HREF=\"/display_editroom&tab=admin\">");
839 wprintf("Administration");
840 if (!strcmp(tab, "admin")) {
841 wprintf("</SPAN></TD>\n");
844 wprintf("</A></TD>\n");
847 wprintf("<TD> </TD>\n");
849 if (!strcmp(tab, "config")) {
850 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
853 wprintf("<TD BGCOLOR=\"#CCCCCC\"><A HREF=\"/display_editroom&tab=config\">");
855 wprintf("Configuration");
856 if (!strcmp(tab, "config")) {
857 wprintf("</SPAN></TD>\n");
860 wprintf("</A></TD>\n");
863 wprintf("<TD> </TD>\n");
865 if (!strcmp(tab, "expire")) {
866 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
869 wprintf("<TD BGCOLOR=\"#CCCCCC\"><A HREF=\"/display_editroom&tab=expire\">");
871 wprintf("Message expire policy");
872 if (!strcmp(tab, "expire")) {
873 wprintf("</SPAN></TD>\n");
876 wprintf("</A></TD>\n");
879 wprintf("<TD> </TD>\n");
881 if (!strcmp(tab, "access")) {
882 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
885 wprintf("<TD BGCOLOR=\"#CCCCCC\"><A HREF=\"/display_editroom&tab=access\">");
887 wprintf("Access controls");
888 if (!strcmp(tab, "access")) {
889 wprintf("</SPAN></TD>\n");
892 wprintf("</A></TD>\n");
895 wprintf("<TD> </TD>\n");
897 if (!strcmp(tab, "sharing")) {
898 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
901 wprintf("<TD BGCOLOR=\"#CCCCCC\"><A HREF=\"/display_editroom&tab=sharing\">");
904 if (!strcmp(tab, "sharing")) {
905 wprintf("</SPAN></TD>\n");
908 wprintf("</A></TD>\n");
911 wprintf("<TD> </TD>\n");
913 if (!strcmp(tab, "listserv")) {
914 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
917 wprintf("<TD BGCOLOR=\"#CCCCCC\"><A HREF=\"/display_editroom&tab=listserv\">");
919 wprintf("Mailing list service");
920 if (!strcmp(tab, "listserv")) {
921 wprintf("</SPAN></TD>\n");
924 wprintf("</A></TD>\n");
927 wprintf("<TD> </TD>\n");
929 wprintf("</TR></TABLE>\n");
930 /* end tabbed dialog */
932 /* begin content of whatever tab is open now */
933 wprintf("<TABLE border=0 width=99%% bgcolor=\"#FFFFFF\">\n"
936 if (!strcmp(tab, "admin")) {
938 "<LI><A HREF=\"/confirm_delete_room\">\n"
939 "Delete this room</A>\n"
940 "<LI><A HREF=\"/display_editroompic\">\n"
941 "Set or change the graphic for this room's banner</A>\n"
942 "<LI><A HREF=\"/display_editinfo\">\n"
943 "Edit this room's Info file</A>\n"
947 if (!strcmp(tab, "config")) {
948 wprintf("<FORM METHOD=\"POST\" ACTION=\"/editroom\">\n");
950 wprintf("<UL><LI>Name of room: ");
951 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\"19\">\n", er_name);
953 wprintf("<LI>Resides on floor: ");
954 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
955 for (i = 0; i < 128; ++i)
956 if (strlen(floorlist[i]) > 0) {
959 wprintf("SELECTED ");
960 wprintf("VALUE=\"%d\">", i);
961 escputs(floorlist[i]);
962 wprintf("</OPTION>\n");
964 wprintf("</SELECT>\n");
966 wprintf("<LI>Type of room:<UL>\n");
968 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
969 if ((er_flags & QR_PRIVATE) == 0)
971 wprintf("> Public room\n");
973 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"guessname\" ");
974 if ((er_flags & QR_PRIVATE) &&
975 (er_flags & QR_GUESSNAME))
977 wprintf("> Private - guess name\n");
979 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
980 if ((er_flags & QR_PRIVATE) &&
981 (er_flags & QR_PASSWORDED))
983 wprintf("> Private - require password:\n");
984 wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n", er_password);
986 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
987 if ((er_flags & QR_PRIVATE)
988 && ((er_flags & QR_GUESSNAME) == 0)
989 && ((er_flags & QR_PASSWORDED) == 0))
991 wprintf("> Private - invitation only\n");
993 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
994 wprintf("> If private, cause current users to forget room\n");
998 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
999 if (er_flags & QR_PREFONLY)
1000 wprintf("CHECKED ");
1001 wprintf("> Preferred users only\n");
1003 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
1004 if (er_flags & QR_READONLY)
1005 wprintf("CHECKED ");
1006 wprintf("> Read-only room\n");
1008 /* directory stuff */
1009 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
1010 if (er_flags & QR_DIRECTORY)
1011 wprintf("CHECKED ");
1012 wprintf("> File directory room\n");
1014 wprintf("<UL><LI>Directory name: ");
1015 wprintf("<INPUT TYPE=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n", er_dirname);
1017 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
1018 if (er_flags & QR_UPLOAD)
1019 wprintf("CHECKED ");
1020 wprintf("> Uploading allowed\n");
1022 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
1023 if (er_flags & QR_DOWNLOAD)
1024 wprintf("CHECKED ");
1025 wprintf("> Downloading allowed\n");
1027 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
1028 if (er_flags & QR_VISDIR)
1029 wprintf("CHECKED ");
1030 wprintf("> Visible directory</UL>\n");
1032 /* end of directory stuff */
1034 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
1035 if (er_flags & QR_NETWORK)
1036 wprintf("CHECKED ");
1037 wprintf("> Network shared room\n");
1039 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"permanent\" VALUE=\"yes\" ");
1040 if (er_flags & QR_PERMANENT)
1041 wprintf("CHECKED ");
1042 wprintf("> Permanent (does not auto-purge)\n");
1044 /* start of anon options */
1046 wprintf("<LI>Anonymous messages<UL>\n");
1048 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
1049 if (((er_flags & QR_ANONONLY) == 0)
1050 && ((er_flags & QR_ANONOPT) == 0))
1051 wprintf("CHECKED ");
1052 wprintf("> No anonymous messages\n");
1054 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
1055 if (er_flags & QR_ANONONLY)
1056 wprintf("CHECKED ");
1057 wprintf("> All messages are anonymous\n");
1059 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
1060 if (er_flags & QR_ANONOPT)
1061 wprintf("CHECKED ");
1062 wprintf("> Prompt user when entering messages</UL>\n");
1064 /* end of anon options */
1066 wprintf("<LI>Room aide: \n");
1069 if (buf[0] != '2') {
1070 wprintf("<EM>%s</EM>\n", &buf[4]);
1072 extract(er_roomaide, &buf[4], 0);
1073 wprintf("<INPUT TYPE=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n", er_roomaide);
1076 wprintf("</UL><CENTER>\n");
1077 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"config\">\n"
1078 "<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">"
1080 "<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">"
1086 /* Sharing the room with other Citadel nodes... */
1087 if (!strcmp(tab, "sharing")) {
1089 shared_with = strdup("");
1090 not_shared_with = strdup("");
1092 /* Learn the current configuration */
1093 serv_puts("CONF getsys|application/x-citadel-ignet-config");
1095 if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
1096 extract(node, buf, 0);
1097 not_shared_with = realloc(not_shared_with,
1098 strlen(not_shared_with) + 32);
1099 strcat(not_shared_with, node);
1100 strcat(not_shared_with, "\n");
1105 if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
1106 extract(cmd, buf, 0);
1107 extract(node, buf, 1);
1108 extract(remote_room, buf, 2);
1109 if (!strcasecmp(cmd, "ignet_push_share")) {
1110 shared_with = realloc(shared_with,
1111 strlen(shared_with) + 32);
1112 strcat(shared_with, node);
1113 if (strlen(remote_room) > 0) {
1114 strcat(shared_with, "|");
1115 strcat(shared_with, remote_room);
1117 strcat(shared_with, "\n");
1121 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1122 extract_token(buf, shared_with, i, '\n');
1123 extract_token(node, buf, 0, '|');
1124 for (j=0; j<num_tokens(not_shared_with, '\n'); ++j) {
1125 extract_token(cmd, not_shared_with, j, '\n');
1126 if (!strcasecmp(node, cmd)) {
1127 remove_token(not_shared_with, j, '\n');
1132 /* Display the stuff */
1133 wprintf("<CENTER><br />"
1134 "<TABLE border=1 cellpadding=5><TR>"
1135 "<TD><B><I>Shared with</I></B></TD>"
1136 "<TD><B><I>Not shared with</I></B></TD></TR>\n"
1137 "<TR><TD VALIGN=TOP>\n");
1139 wprintf("<TABLE border=0 cellpadding=5><TR BGCOLOR=\"#CCCCCC\">"
1140 "<TD>Remote node name</TD>"
1141 "<TD>Remote room name</TD>"
1146 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1147 extract_token(buf, shared_with, i, '\n');
1148 extract_token(node, buf, 0, '|');
1149 extract_token(remote_room, buf, 1, '|');
1150 if (strlen(node) > 0) {
1151 wprintf("<FORM METHOD=\"POST\" "
1152 "ACTION=\"/netedit\">"
1153 "<TR><TD>%s</TD>\n", node);
1156 if (strlen(remote_room) > 0) {
1157 escputs(remote_room);
1163 wprintf("<INPUT TYPE=\"hidden\" NAME=\"line\" "
1164 "VALUE=\"ignet_push_share|");
1166 if (strlen(remote_room) > 0) {
1168 urlescputs(remote_room);
1171 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" "
1172 "VALUE=\"sharing\">\n");
1173 wprintf("<INPUT TYPE=\"hidden\" NAME=\"cmd\" "
1174 "VALUE=\"remove\">\n");
1175 wprintf("<INPUT TYPE=\"submit\" "
1176 "NAME=\"sc\" VALUE=\"Unshare\">");
1177 wprintf("</TD></TR></FORM>\n");
1181 wprintf("</TABLE>\n");
1182 wprintf("</TD><TD VALIGN=TOP>\n");
1183 wprintf("<TABLE border=0 cellpadding=5><TR BGCOLOR=\"#CCCCCC\">"
1184 "<TD>Remote node name</TD>"
1185 "<TD>Remote room name</TD>"
1190 for (i=0; i<num_tokens(not_shared_with, '\n'); ++i) {
1191 extract_token(node, not_shared_with, i, '\n');
1192 if (strlen(node) > 0) {
1193 wprintf("<FORM METHOD=\"POST\" "
1194 "ACTION=\"/netedit\">"
1198 "<INPUT TYPE=\"INPUT\" "
1202 wprintf("<INPUT TYPE=\"hidden\" "
1204 "VALUE=\"ignet_push_share|");
1207 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" "
1208 "VALUE=\"sharing\">\n");
1209 wprintf("<INPUT TYPE=\"hidden\" NAME=\"cmd\" "
1210 "VALUE=\"add\">\n");
1211 wprintf("<INPUT TYPE=\"submit\" "
1212 "NAME=\"sc\" VALUE=\"Share\">");
1213 wprintf("</TD></TR></FORM>\n");
1217 wprintf("</TABLE>\n");
1218 wprintf("</TD></TR>"
1219 "</TABLE></CENTER><br />\n"
1220 "<I><B>Notes:</B><UL><LI>When sharing a room, "
1221 "it must be shared from both ends. Adding a node to "
1222 "the 'shared' list sends messages out, but in order to"
1223 " receive messages, the other nodes must be configured"
1224 " to send messages out to your system as well.\n"
1225 "<LI>If the remote room name is blank, it is assumed "
1226 "that the room name is identical on the remote node."
1227 "<LI>If the remote room name is different, the remote "
1228 "node must also configure the name of the room here."
1234 /* Mailing list management */
1235 if (!strcmp(tab, "listserv")) {
1237 wprintf("<br /><center>"
1238 "<TABLE BORDER=0 WIDTH=100%% CELLPADDING=5>"
1239 "<TR><TD VALIGN=TOP>");
1241 wprintf("<i>The contents of this room are being "
1242 "mailed <b>as individual messages</b> "
1243 "to the following list recipients:"
1244 "</i><br /><br />\n");
1248 if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
1249 extract(cmd, buf, 0);
1250 if (!strcasecmp(cmd, "listrecp")) {
1251 extract(recp, buf, 1);
1254 wprintf(" <A HREF=\"/netedit&cmd=remove&line="
1257 wprintf("&tab=listserv\">(remove)</A><br />");
1261 wprintf("<br /><FORM METHOD=\"POST\" ACTION=\"/netedit\">\n"
1262 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1263 "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"listrecp|\">\n");
1264 wprintf("<INPUT TYPE=\"text\" NAME=\"line\">\n");
1265 wprintf("<INPUT TYPE=\"submit\" NAME=\"cmd\" VALUE=\"Add\">");
1266 wprintf("</FORM>\n");
1268 wprintf("</TD><TD VALIGN=TOP>\n");
1270 wprintf("<i>The contents of this room are being "
1271 "mailed <b>in digest form</b> "
1272 "to the following list recipients:"
1273 "</i><br /><br />\n");
1277 if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
1278 extract(cmd, buf, 0);
1279 if (!strcasecmp(cmd, "digestrecp")) {
1280 extract(recp, buf, 1);
1283 wprintf(" <A HREF=\"/netedit&cmd=remove&line="
1286 wprintf("&tab=listserv\">(remove)</A><br />");
1290 wprintf("<br /><FORM METHOD=\"POST\" ACTION=\"/netedit\">\n"
1291 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1292 "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"digestrecp|\">\n");
1293 wprintf("<INPUT TYPE=\"text\" NAME=\"line\">\n");
1294 wprintf("<INPUT TYPE=\"submit\" NAME=\"cmd\" VALUE=\"Add\">");
1295 wprintf("</FORM>\n");
1297 wprintf("</TD></TR></TABLE><hr />\n");
1299 if (self_service(999) == 1) {
1300 wprintf("This room is configured to allow "
1301 "self-service subscribe/unsubscribe requests."
1302 " <A HREF=\"/toggle_self_service?newval=0&"
1304 "Click to disable.</A><br />\n"
1305 "The URL for subscribe/unsubscribe is: "
1306 "<TT>http://%s/listsub</TT><br />\n",
1311 wprintf("This room is <i>not</i> configured to allow "
1312 "self-service subscribe/unsubscribe requests."
1313 " <A HREF=\"/toggle_self_service?newval=1&"
1315 "Click to enable.</A><br />\n"
1320 wprintf("</CENTER>\n");
1324 /* Mailing list management */
1325 if (!strcmp(tab, "expire")) {
1327 serv_puts("GPEX room");
1329 if (buf[0] == '2') {
1330 roompolicy = extract_int(&buf[4], 0);
1331 roomvalue = extract_int(&buf[4], 1);
1334 serv_puts("GPEX floor");
1336 if (buf[0] == '2') {
1337 floorpolicy = extract_int(&buf[4], 0);
1338 floorvalue = extract_int(&buf[4], 1);
1341 wprintf("<br /><FORM METHOD=\"POST\" ACTION=\"/set_room_policy\">\n");
1342 wprintf("<TABLE border=0 cellspacing=5>\n");
1343 wprintf("<TR><TD>Message expire policy for this room<br />(");
1344 escputs(WC->wc_roomname);
1345 wprintf(")</TD><TD>");
1346 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"0\" %s>",
1347 ((roompolicy == 0) ? "CHECKED" : "") );
1348 wprintf("Use the default policy for this floor<br />\n");
1349 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"1\" %s>",
1350 ((roompolicy == 1) ? "CHECKED" : "") );
1351 wprintf("Never automatically expire messages<br />\n");
1352 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"2\" %s>",
1353 ((roompolicy == 2) ? "CHECKED" : "") );
1354 wprintf("Expire by message count<br />\n");
1355 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"3\" %s>",
1356 ((roompolicy == 3) ? "CHECKED" : "") );
1357 wprintf("Expire by message age<br />");
1358 wprintf("Number of messages or days: ");
1359 wprintf("<INPUT TYPE=\"text\" NAME=\"roomvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">", roomvalue);
1360 wprintf("</TD></TR>\n");
1362 if (WC->axlevel >= 6) {
1363 wprintf("<TR><TD COLSPAN=2><hr /></TD></TR>\n");
1364 wprintf("<TR><TD>Message expire policy for this floor<br />(");
1365 escputs(floorlist[WC->wc_floor]);
1366 wprintf(")</TD><TD>");
1367 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"0\" %s>",
1368 ((floorpolicy == 0) ? "CHECKED" : "") );
1369 wprintf("Use the system default<br />\n");
1370 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"1\" %s>",
1371 ((floorpolicy == 1) ? "CHECKED" : "") );
1372 wprintf("Never automatically expire messages<br />\n");
1373 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"2\" %s>",
1374 ((floorpolicy == 2) ? "CHECKED" : "") );
1375 wprintf("Expire by message count<br />\n");
1376 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"3\" %s>",
1377 ((floorpolicy == 3) ? "CHECKED" : "") );
1378 wprintf("Expire by message age<br />");
1379 wprintf("Number of messages or days: ");
1380 wprintf("<INPUT TYPE=\"text\" NAME=\"floorvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">",
1384 wprintf("<CENTER>\n");
1385 wprintf("<TR><TD COLSPAN=2><hr /><CENTER>\n");
1386 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
1388 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1389 wprintf("</CENTER></TD><TR>\n");
1391 wprintf("</TABLE>\n"
1392 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"expire\">\n"
1398 /* Mailing list management */
1399 if (!strcmp(tab, "access")) {
1403 /* end content of whatever tab is open now */
1404 wprintf("</TD></TR></TABLE>\n");
1411 * Toggle self-service list subscription
1413 void toggle_self_service(void) {
1416 newval = atoi(bstr("newval"));
1417 self_service(newval);
1424 * save new parameters for a room
1430 char er_password[10];
1431 char er_dirname[15];
1432 char er_roomaide[26];
1438 if (strcmp(bstr("sc"), "OK")) {
1439 strcpy(WC->ImportantMessage,
1440 "Cancelled. Changes were not saved.");
1447 if (buf[0] != '2') {
1448 strcpy(WC->ImportantMessage, &buf[4]);
1452 extract(er_name, &buf[4], 0);
1453 extract(er_password, &buf[4], 1);
1454 extract(er_dirname, &buf[4], 2);
1455 er_flags = extract_int(&buf[4], 3);
1457 strcpy(er_roomaide, bstr("er_roomaide"));
1458 if (strlen(er_roomaide) == 0) {
1461 if (buf[0] != '2') {
1462 strcpy(er_roomaide, "");
1464 extract(er_roomaide, &buf[4], 0);
1467 strcpy(buf, bstr("er_name"));
1469 if (strlen(buf) > 0)
1470 strcpy(er_name, buf);
1472 strcpy(buf, bstr("er_password"));
1474 if (strlen(buf) > 0)
1475 strcpy(er_password, buf);
1477 strcpy(buf, bstr("er_dirname"));
1479 if (strlen(buf) > 0)
1480 strcpy(er_dirname, buf);
1482 strcpy(buf, bstr("type"));
1483 er_flags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME);
1485 if (!strcmp(buf, "invonly")) {
1486 er_flags |= (QR_PRIVATE);
1488 if (!strcmp(buf, "guessname")) {
1489 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
1491 if (!strcmp(buf, "passworded")) {
1492 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
1494 if (!strcmp(bstr("prefonly"), "yes")) {
1495 er_flags |= QR_PREFONLY;
1497 er_flags &= ~QR_PREFONLY;
1500 if (!strcmp(bstr("readonly"), "yes")) {
1501 er_flags |= QR_READONLY;
1503 er_flags &= ~QR_READONLY;
1506 if (!strcmp(bstr("permanent"), "yes")) {
1507 er_flags |= QR_PERMANENT;
1509 er_flags &= ~QR_PERMANENT;
1512 if (!strcmp(bstr("network"), "yes")) {
1513 er_flags |= QR_NETWORK;
1515 er_flags &= ~QR_NETWORK;
1518 if (!strcmp(bstr("directory"), "yes")) {
1519 er_flags |= QR_DIRECTORY;
1521 er_flags &= ~QR_DIRECTORY;
1524 if (!strcmp(bstr("ulallowed"), "yes")) {
1525 er_flags |= QR_UPLOAD;
1527 er_flags &= ~QR_UPLOAD;
1530 if (!strcmp(bstr("dlallowed"), "yes")) {
1531 er_flags |= QR_DOWNLOAD;
1533 er_flags &= ~QR_DOWNLOAD;
1536 if (!strcmp(bstr("visdir"), "yes")) {
1537 er_flags |= QR_VISDIR;
1539 er_flags &= ~QR_VISDIR;
1542 strcpy(buf, bstr("anon"));
1544 er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
1545 if (!strcmp(buf, "anononly"))
1546 er_flags |= QR_ANONONLY;
1547 if (!strcmp(buf, "anon2"))
1548 er_flags |= QR_ANONOPT;
1551 if (!strcmp(bstr("bump"), "yes"))
1554 er_floor = atoi(bstr("er_floor"));
1556 sprintf(buf, "SETR %s|%s|%s|%u|%d|%d",
1557 er_name, er_password, er_dirname, er_flags, bump, er_floor);
1560 if (buf[0] != '2') {
1561 strcpy(WC->ImportantMessage, &buf[4]);
1567 if (strlen(er_roomaide) > 0) {
1568 sprintf(buf, "SETA %s", er_roomaide);
1571 if (buf[0] != '2') {
1572 strcpy(WC->ImportantMessage, &buf[4]);
1573 display_main_menu();
1578 strcpy(WC->ImportantMessage, "Your changes have been saved.");
1585 * Display form for Invite, Kick, and show Who Knows a room
1587 void do_invt_kick(void) {
1588 char buf[SIZ], room[SIZ], username[SIZ];
1593 if (buf[0] != '2') {
1597 extract(room, &buf[4], 0);
1599 strcpy(username, bstr("username"));
1601 if (!strcmp(bstr("sc"), "Kick")) {
1602 sprintf(buf, "KICK %s", username);
1606 if (buf[0] != '2') {
1607 strcpy(WC->ImportantMessage, &buf[4]);
1609 sprintf(WC->ImportantMessage,
1610 "<B><I>User %s kicked out of room %s.</I></B>\n",
1615 if (!strcmp(bstr("sc"), "Invite")) {
1616 sprintf(buf, "INVT %s", username);
1620 if (buf[0] != '2') {
1621 strcpy(WC->ImportantMessage, &buf[4]);
1623 sprintf(WC->ImportantMessage,
1624 "<B><I>User %s invited to room %s.</I></B>\n",
1635 * Display form for Invite, Kick, and show Who Knows a room
1637 void display_whok(void)
1639 char buf[SIZ], room[SIZ], username[SIZ];
1644 if (buf[0] != '2') {
1648 extract(room, &buf[4], 0);
1651 wprintf("<TABLE border=0 CELLSPACING=10><TR VALIGN=TOP>"
1652 "<TD>The users listed below have access to this room. "
1653 "To remove a user from the access list, select the user "
1654 "name from the list and click 'Kick'.<br /><br />");
1656 wprintf("<CENTER><FORM METHOD=\"POST\" ACTION=\"/do_invt_kick\">\n");
1657 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
1658 wprintf("<SELECT NAME=\"username\" SIZE=\"10\" style=\"width:100%%\">\n");
1661 if (buf[0] == '1') {
1662 while (serv_gets(buf), strcmp(buf, "000")) {
1663 extract(username, buf, 0);
1664 wprintf("<OPTION>");
1669 wprintf("</SELECT><br />\n");
1671 wprintf("<input type=submit name=sc value=\"Kick\">");
1672 wprintf("</FORM></CENTER>\n");
1675 "To grant another user access to this room, enter the "
1676 "user name in the box below and click 'Invite'.<br /><br />");
1678 wprintf("<CENTER><FORM METHOD=\"POST\" ACTION=\"/do_invt_kick\">\n");
1679 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
1680 wprintf("Invite: ");
1681 wprintf("<input type=\"text\" name=\"username\" style=\"width:100%%\"><br />\n"
1682 "<input type=\"hidden\" name=\"sc\" value=\"Invite\">"
1683 "<input type=\"submit\" value=\"Invite\">"
1684 "</FORM></CENTER>\n");
1686 wprintf("</TD></TR></TABLE>\n");
1693 * display the form for entering a new room
1695 void display_entroom(void)
1700 serv_puts("CRE8 0");
1703 if (buf[0] != '2') {
1704 strcpy(WC->ImportantMessage, &buf[4]);
1705 display_main_menu();
1709 output_headers(1, 1, 2, 0, 0, 0, 0);
1710 wprintf("<div id=\"banner\">\n"
1711 "<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>"
1712 "<SPAN CLASS=\"titlebar\">Create a new room</SPAN>"
1713 "</TD></TR></TABLE>\n"
1714 "</div>\n<div id=\"content\">\n"
1717 wprintf("<center><table border=0 width=99%% bgcolor=\"#ffffff\"><tr><td>\n");
1719 wprintf("<FORM METHOD=\"POST\" ACTION=\"/entroom\">\n");
1721 wprintf("<UL><LI>Name of room: ");
1722 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" MAXLENGTH=\"127\">\n");
1724 wprintf("<LI>Resides on floor: ");
1726 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
1727 for (i = 0; i < 128; ++i)
1728 if (strlen(floorlist[i]) > 0) {
1729 wprintf("<OPTION ");
1730 wprintf("VALUE=\"%d\">", i);
1731 escputs(floorlist[i]);
1732 wprintf("</OPTION>\n");
1734 wprintf("</SELECT>\n");
1736 wprintf("<LI>Default view for room: ");
1737 wprintf("<SELECT NAME=\"er_view\" SIZE=\"1\">\n");
1738 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
1739 wprintf("<OPTION %s VALUE=\"%d\">",
1740 ((i == 0) ? "SELECTED" : ""), i );
1741 escputs(viewdefs[i]);
1742 wprintf("</OPTION>\n");
1744 wprintf("</SELECT>\n");
1746 wprintf("<LI>Type of room:<UL>\n");
1748 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1749 wprintf("CHECKED > Public room\n");
1751 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"guessname\" ");
1752 wprintf("> Private - guess name\n");
1754 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
1755 wprintf("> Private - require password:\n");
1756 wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
1758 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
1759 wprintf("> Private - invitation only\n");
1761 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"personal\" ");
1762 wprintf("> Personal (mailbox for you only)\n");
1765 wprintf("<CENTER>\n");
1766 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
1768 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1769 wprintf("</CENTER>\n");
1770 wprintf("</FORM>\n<hr />");
1771 serv_printf("MESG roomaccess");
1773 if (buf[0] == '1') {
1774 fmout(NULL, "CENTER");
1776 wprintf("</td></tr></table></center>\n");
1784 * support function for entroom() -- sets the default view
1786 void er_set_default_view(int newview) {
1800 if (buf[0] != '2') return;
1802 extract(rm_name, &buf[4], 0);
1803 extract(rm_pass, &buf[4], 1);
1804 extract(rm_dir, &buf[4], 2);
1805 rm_bits1 = extract_int(&buf[4], 3);
1806 rm_floor = extract_int(&buf[4], 4);
1807 rm_listorder = extract_int(&buf[4], 5);
1808 rm_bits2 = extract_int(&buf[4], 7);
1810 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
1811 rm_name, rm_pass, rm_dir, rm_bits1, rm_floor,
1812 rm_listorder, newview, rm_bits2
1827 char er_password[SIZ];
1832 if (strcmp(bstr("sc"), "OK")) {
1833 strcpy(WC->ImportantMessage,
1834 "Cancelled. No new room was created.");
1835 display_main_menu();
1838 strcpy(er_name, bstr("er_name"));
1839 strcpy(er_type, bstr("type"));
1840 strcpy(er_password, bstr("er_password"));
1841 er_floor = atoi(bstr("er_floor"));
1842 er_view = atoi(bstr("er_view"));
1845 if (!strcmp(er_type, "guessname"))
1847 if (!strcmp(er_type, "passworded"))
1849 if (!strcmp(er_type, "invonly"))
1851 if (!strcmp(er_type, "personal"))
1854 sprintf(buf, "CRE8 1|%s|%d|%s|%d|%d|%d",
1855 er_name, er_num_type, er_password, er_floor, 0, er_view);
1858 if (buf[0] != '2') {
1859 strcpy(WC->ImportantMessage, &buf[4]);
1860 display_main_menu();
1864 do_change_view(er_view); /* Now go there */
1869 * display the screen to enter a private room
1871 void display_private(char *rname, int req_pass)
1874 output_headers(1, 1, 0, 0, 0, 0, 0);
1876 svprintf("BOXTITLE", WCS_STRING, "Go to a hidden room");
1877 do_template("beginbox");
1879 wprintf("<CENTER>\n");
1880 wprintf("<br />If you know the name of a hidden (guess-name) or\n");
1881 wprintf("passworded room, you can enter that room by typing\n");
1882 wprintf("its name below. Once you gain access to a private\n");
1883 wprintf("room, it will appear in your regular room listings\n");
1884 wprintf("so you don't have to keep returning here.\n");
1885 wprintf("<br /><br />");
1887 wprintf("<FORM METHOD=\"GET\" ACTION=\"/goto_private\">\n");
1889 wprintf("<table border=\"0\" cellspacing=\"5\" "
1890 "cellpadding=\"5\" BGCOLOR=\"#EEEEEE\">\n"
1892 "Enter room name:</TD><TD>"
1893 "<INPUT TYPE=\"text\" NAME=\"gr_name\" "
1894 "VALUE=\"%s\" MAXLENGTH=\"19\">\n", rname);
1897 wprintf("</TD></TR><TR><TD>");
1898 wprintf("Enter room password:</TD><TD>");
1899 wprintf("<INPUT TYPE=\"password\" NAME=\"gr_pass\" MAXLENGTH=\"9\">\n");
1901 wprintf("</TD></TR></TABLE><br />\n");
1903 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">"
1905 "<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1906 wprintf("</FORM>\n");
1907 do_template("endbox");
1912 * goto a private room
1914 void goto_private(void)
1919 if (strcasecmp(bstr("sc"), "OK")) {
1920 display_main_menu();
1923 strcpy(hold_rm, WC->wc_roomname);
1924 strcpy(buf, "GOTO ");
1925 strcat(buf, bstr("gr_name"));
1927 strcat(buf, bstr("gr_pass"));
1931 if (buf[0] == '2') {
1932 smart_goto(bstr("gr_name"));
1935 if (!strncmp(buf, "540", 3)) {
1936 display_private(bstr("gr_name"), 1);
1939 output_headers(1, 1, 1, 0, 0, 0, 0);
1940 wprintf("%s\n", &buf[4]);
1947 * display the screen to zap a room
1949 void display_zap(void)
1951 output_headers(1, 1, 2, 0, 0, 0, 0);
1953 wprintf("<div id=\"banner\">\n");
1954 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#770000\"><TR><TD>");
1955 wprintf("<SPAN CLASS=\"titlebar\">Zap (forget/unsubscribe) the current room</SPAN>\n");
1956 wprintf("</TD></TR></TABLE>\n");
1957 wprintf("</div>\n<div id=\"content\">\n");
1959 wprintf("If you select this option, <em>%s</em> will ", WC->wc_roomname);
1960 wprintf("disappear from your room list. Is this what you wish ");
1961 wprintf("to do?<br />\n");
1963 wprintf("<FORM METHOD=\"GET\" ACTION=\"/zap\">\n");
1964 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
1966 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1967 wprintf("</FORM>\n");
1978 char final_destination[SIZ];
1980 /* If the forget-room routine fails for any reason, we fall back
1981 * to the current room; otherwise, we go to the Lobby
1983 strcpy(final_destination, WC->wc_roomname);
1985 if (!strcasecmp(bstr("sc"), "OK")) {
1986 serv_printf("GOTO %s", WC->wc_roomname);
1988 if (buf[0] == '2') {
1991 if (buf[0] == '2') {
1992 strcpy(final_destination, "_BASEROOM_");
1996 smart_goto(final_destination);
2003 * Confirm deletion of the current room
2005 void confirm_delete_room(void)
2009 serv_puts("KILL 0");
2011 if (buf[0] != '2') {
2012 strcpy(WC->ImportantMessage, &buf[4]);
2013 display_main_menu();
2016 output_headers(1, 1, 2, 0, 0, 0, 0);
2017 wprintf("<div id=\"banner\">\n");
2018 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#770000\"><TR><TD>");
2019 wprintf("<SPAN CLASS=\"titlebar\">Confirm deletion of room</SPAN>\n");
2020 wprintf("</TD></TR></TABLE>\n");
2021 wprintf("</div>\n<div id=\"content\">\n");
2023 wprintf("<CENTER>");
2024 wprintf("<FORM METHOD=\"GET\" ACTION=\"/delete_room\">\n");
2026 wprintf("Are you sure you want to delete <FONT SIZE=+1>");
2027 escputs(WC->wc_roomname);
2028 wprintf("</FONT>?<br />\n");
2030 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Delete\">");
2031 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
2033 wprintf("</FORM></CENTER>\n");
2039 * Delete the current room
2041 void delete_room(void)
2046 strcpy(sc, bstr("sc"));
2048 if (strcasecmp(sc, "Delete")) {
2049 strcpy(WC->ImportantMessage,
2050 "Cancelled. This room was not deleted.");
2051 display_main_menu();
2054 serv_puts("KILL 1");
2056 if (buf[0] != '2') {
2057 strcpy(WC->ImportantMessage, &buf[4]);
2058 display_main_menu();
2061 smart_goto("_BASEROOM_");
2068 * Perform changes to a room's network configuration
2070 void netedit(void) {
2079 if (strlen(bstr("line"))==0) {
2084 strcpy(line, bstr("prefix"));
2085 strcat(line, bstr("line"));
2086 strcat(line, bstr("suffix"));
2096 if (buf[0] != '1') {
2102 /* This loop works for add *or* remove. Spiffy, eh? */
2103 while (serv_gets(buf), strcmp(buf, "000")) {
2104 extract(cmpa0, buf, 0);
2105 extract(cmpa1, buf, 1);
2106 extract(cmpb0, line, 0);
2107 extract(cmpb1, line, 1);
2108 if ( (strcasecmp(cmpa0, cmpb0))
2109 || (strcasecmp(cmpa1, cmpb1)) ) {
2110 fprintf(fp, "%s\n", buf);
2117 if (buf[0] != '4') {
2123 while (fgets(buf, sizeof buf, fp) != NULL) {
2124 buf[strlen(buf)-1] = 0;
2128 if (!strcasecmp(bstr("cmd"), "add")) {
2140 * Convert a room name to a folder-ish-looking name.
2142 void room_to_folder(char *folder, char *room, int floor, int is_mailbox)
2147 * For mailboxes, just do it straight...
2150 sprintf(folder, "My folders|%s", room);
2154 * Otherwise, prefix the floor name as a "public folders" moniker
2157 sprintf(folder, "%s|%s", floorlist[floor], room);
2161 * Replace "\" characters with "|" for pseudo-folder-delimiting
2163 for (i=0; i<strlen(folder); ++i) {
2164 if (folder[i] == '\\') folder[i] = '|';
2172 * Back end for change_view()
2174 void do_change_view(int newview) {
2177 serv_printf("VIEW %d", newview);
2179 WC->wc_view = newview;
2180 smart_goto(WC->wc_roomname);
2186 * Change the view for this room
2188 void change_view(void) {
2191 view = atol(bstr("view"));
2192 do_change_view(view);
2197 * One big expanded tree list view --- like a folder list
2199 void do_folder_view(struct folder *fold, int max_folders, int num_floors) {
2201 int levels, oldlevels;
2204 int has_subfolders = 0;
2206 /* Include the menu expanding/collapsing code */
2207 wprintf("<script type=\"text/javascript\" src=\"/static/menuExpandable3.js\"></script>\n");
2209 /* BEGIN TREE MENU */
2210 wprintf("<div style=\"background: white\">\n");
2211 wprintf("<div id=\"mainMenu\">\n");
2212 wprintf("<UL id=\"menuList\">\n");
2216 for (i=0; i<max_folders; ++i) {
2219 if ((i+1) < max_folders) {
2220 if ( (!strncasecmp(fold[i].name, fold[i+1].name, strlen(fold[i].name)))
2221 && (fold[i+1].name[strlen(fold[i].name)] == '|') ) {
2226 levels = num_tokens(fold[i].name, '|');
2228 if ( (levels < oldlevels) || ((levels==1)&&(i!=0)) ) {
2229 for (t=0; t<(oldlevels-levels); ++t) {
2234 if (has_subfolders) {
2236 if (levels == 1) wprintf(" class=\"menubar\"");
2238 wprintf("<A href=\"#\" id=\"actuator%d\" class=\"actuator\"></a>\n", actnum);
2244 if (fold[i].selectable) {
2245 wprintf("<A HREF=\"/dotgoto?room=");
2246 urlescputs(fold[i].room);
2251 wprintf("<SPAN CLASS=\"roomlist_floor\">");
2253 else if (fold[i].hasnewmsgs) {
2254 wprintf("<SPAN CLASS=\"roomlist_new\">");
2257 wprintf("<SPAN CLASS=\"roomlist_old\">");
2259 extract(buf, fold[i].name, levels-1);
2263 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
2264 wprintf(" (INBOX)");
2267 if (fold[i].selectable) {
2272 if (has_subfolders) {
2273 wprintf("<UL id=\"menu%d\" class=\"%s\">\n",
2275 ( (levels == 1) ? "menu" : "submenu")
2281 wprintf("</UL></UL>\n");
2282 wprintf("<img src=\"/static/blank.gif\" onLoad = ' \n");
2283 for (i=0; i<actnum; ++i) {
2284 wprintf(" initializeMenu(\"menu%d\", \"actuator%d\");\n", i, i);
2287 wprintf("</DIV>\n");
2292 * Boxes and rooms and lists ... oh my!
2294 void do_rooms_view(struct folder *fold, int max_folders, int num_floors) {
2297 int levels, oldlevels;
2300 static int columns = 3;
2301 int boxes_per_column = 0;
2302 int current_column = 0;
2306 while (nf % columns != 0) ++nf;
2307 boxes_per_column = (nf / columns);
2308 if (boxes_per_column < 1) boxes_per_column = 1;
2310 /* Outer table (for columnization) */
2311 wprintf("<TABLE BORDER=0 WIDTH=96%% CELLPADDING=5>"
2312 "<tr><td valign=top>");
2316 for (i=0; i<max_folders; ++i) {
2318 levels = num_tokens(fold[i].name, '|');
2320 if ((levels == 1) && (oldlevels > 1)) {
2323 do_template("endbox");
2326 if ((num_boxes % boxes_per_column) == 0) {
2328 if (current_column < columns) {
2329 wprintf("</td><td valign=top>\n");
2336 /* Begin inner box */
2337 extract(buf, fold[i].name, levels-1);
2338 stresc(boxtitle, buf, 1, 0);
2339 svprintf("BOXTITLE", WCS_STRING, boxtitle);
2340 do_template("beginbox");
2348 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
2349 if (fold[i].selectable) {
2350 wprintf("<A HREF=\"/dotgoto?room=");
2351 urlescputs(fold[i].room);
2357 if (fold[i].hasnewmsgs) {
2358 wprintf("<SPAN CLASS=\"roomlist_new\">");
2361 wprintf("<SPAN CLASS=\"roomlist_old\">");
2363 extract(buf, fold[i].name, levels-1);
2366 if (fold[i].selectable) {
2372 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
2373 wprintf(" (INBOX)");
2375 wprintf("<br />\n");
2378 /* End the final inner box */
2379 do_template("endbox");
2381 wprintf("</TD></TR></TABLE>\n");
2386 * Show the room list. (only should get called by
2387 * knrooms() because that's where output_headers() is called from)
2390 void list_all_rooms_by_floor(char *viewpref) {
2393 struct folder *fold = NULL;
2395 int max_folders = 0;
2396 int alloc_folders = 0;
2400 int num_floors = 1; /* add an extra one for private folders */
2402 /* Start with the mailboxes */
2405 fold = malloc(sizeof(struct folder));
2406 memset(fold, 0, sizeof(struct folder));
2407 strcpy(fold[0].name, "My folders");
2408 fold[0].is_mailbox = 1;
2410 /* Then add floors */
2413 if (buf[0]=='1') while(serv_gets(buf), strcmp(buf, "000")) {
2414 if (max_folders >= alloc_folders) {
2415 alloc_folders = max_folders + 100;
2416 fold = realloc(fold,
2417 alloc_folders * sizeof(struct folder));
2419 memset(&fold[max_folders], 0, sizeof(struct folder));
2420 extract(fold[max_folders].name, buf, 1);
2428 if (buf[0]=='1') while(serv_gets(buf), strcmp(buf, "000")) {
2429 if (max_folders >= alloc_folders) {
2430 alloc_folders = max_folders + 100;
2431 fold = realloc(fold,
2432 alloc_folders * sizeof(struct folder));
2434 memset(&fold[max_folders], 0, sizeof(struct folder));
2435 extract(fold[max_folders].room, buf, 0);
2436 ra_flags = extract_int(buf, 5);
2437 flags = extract_int(buf, 1);
2438 fold[max_folders].floor = extract_int(buf, 2);
2439 fold[max_folders].hasnewmsgs =
2440 ((ra_flags & UA_HASNEWMSGS) ? 1 : 0 );
2441 if (flags & QR_MAILBOX) {
2442 fold[max_folders].is_mailbox = 1;
2444 room_to_folder(fold[max_folders].name,
2445 fold[max_folders].room,
2446 fold[max_folders].floor,
2447 fold[max_folders].is_mailbox);
2448 fold[max_folders].selectable = 1;
2452 /* Bubble-sort the folder list */
2453 for (i=0; i<max_folders; ++i) {
2454 for (j=0; j<(max_folders-1)-i; ++j) {
2455 if (fold[j].is_mailbox == fold[j+1].is_mailbox) {
2456 swap = strcasecmp(fold[j].name, fold[j+1].name);
2459 if ( (fold[j+1].is_mailbox)
2460 && (!fold[j].is_mailbox)) {
2468 memcpy(&ftmp, &fold[j], sizeof(struct folder));
2469 memcpy(&fold[j], &fold[j+1],
2470 sizeof(struct folder));
2471 memcpy(&fold[j+1], &ftmp,
2472 sizeof(struct folder));
2477 /* test only hackish view
2478 wprintf("<table><TR><TD>A Table</TD></TR></table>\n");
2479 for (i=0; i<max_folders; ++i) {
2480 escputs(fold[i].name);
2481 wprintf("<br />\n");
2485 if (!strcasecmp(viewpref, "folders")) {
2486 do_folder_view(fold, max_folders, num_floors);
2489 do_rooms_view(fold, max_folders, num_floors);
2497 /* Do either a known rooms list or a folders list, depending on the
2501 char listviewpref[SIZ];
2503 output_headers(1, 1, 2, 0, 0, 0, 0);
2506 /* Determine whether the user is trying to change views */
2507 if (bstr("view") != NULL) {
2508 if (strlen(bstr("view")) > 0) {
2509 set_preference("roomlistview", bstr("view"));
2513 get_preference("roomlistview", listviewpref);
2515 if ( (strcasecmp(listviewpref, "folders"))
2516 && (strcasecmp(listviewpref, "table")) ) {
2517 strcpy(listviewpref, "rooms");
2521 wprintf("<div id=\"banner\">\n"
2522 "<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>"
2523 "<SPAN CLASS=\"titlebar\">"
2525 if (!strcasecmp(listviewpref, "rooms")) {
2526 wprintf("Room list");
2528 if (!strcasecmp(listviewpref, "folders")) {
2529 wprintf("Folder list");
2531 if (!strcasecmp(listviewpref, "table")) {
2532 wprintf("Room list");
2534 wprintf("</SPAN></TD>\n");
2536 /* offer the ability to switch views */
2537 wprintf("<TD ALIGN=RIGHT><FORM NAME=\"roomlistomatic\">\n"
2538 "<SELECT NAME=\"newview\" SIZE=\"1\" "
2539 "OnChange=\"location.href=roomlistomatic.newview.options"
2540 "[selectedIndex].value\">\n");
2542 wprintf("<OPTION %s VALUE=\"/knrooms&view=rooms\">"
2545 ( !strcasecmp(listviewpref, "rooms") ? "SELECTED" : "" )
2548 wprintf("<OPTION %s VALUE=\"/knrooms&view=folders\">"
2549 "View as folder list"
2551 ( !strcasecmp(listviewpref, "folders") ? "SELECTED" : "" )
2554 wprintf("</SELECT><br />");
2556 wprintf("</FORM></TD></TR></TABLE>\n");
2559 "<div id=\"content\">\n");
2561 /* Display the room list in the user's preferred format */
2562 list_all_rooms_by_floor(listviewpref);
2568 * Set the message expire policy for this room and/or floor
2570 void set_room_policy(void) {
2573 if (strcmp(bstr("sc"), "OK")) {
2574 strcpy(WC->ImportantMessage,
2575 "Cancelled. Changes were not saved.");
2580 serv_printf("SPEX room|%d|%d", atoi(bstr("roompolicy")), atoi(bstr("roomvalue")));
2582 strcpy(WC->ImportantMessage, &buf[4]);
2584 if (WC->axlevel >= 6) {
2585 strcat(WC->ImportantMessage, "<br />\n");
2586 serv_printf("SPEX floor|%d|%d", atoi(bstr("floorpolicy")), atoi(bstr("floorvalue")));
2588 strcat(WC->ImportantMessage, &buf[4]);