10 #include <sys/types.h>
12 #include <sys/socket.h>
15 #include <netinet/in.h>
43 char floorlist[128][SIZ];
46 * load the list of floors
48 void load_floorlist(void)
53 for (a = 0; a < 128; ++a)
59 strcpy(floorlist[0], "Main Floor");
62 while (serv_gets(buf), strcmp(buf, "000")) {
63 extract(floorlist[extract_int(buf, 0)], buf, 1);
69 * remove a room from the march list
71 void remove_march(char *aaa)
73 struct march *mptr, *mptr2;
75 if (WC->march == NULL)
78 if (!strcasecmp(WC->march->march_name, aaa)) {
79 mptr = WC->march->next;
85 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
86 if (!strcasecmp(mptr->march_name, aaa)) {
87 mptr2->next = mptr->next;
100 void room_tree_list(struct roomlisting *rp)
109 room_tree_list(rp->lnext);
111 strcpy(rmname, rp->rlname);
114 wprintf("<A HREF=\"/dotgoto&room=");
118 escputs1(rmname, 1, 1);
119 if ((f & QR_DIRECTORY) && (f & QR_NETWORK))
121 else if (f & QR_DIRECTORY)
123 else if (f & QR_NETWORK)
127 wprintf("</A><TT> </TT>\n");
129 room_tree_list(rp->rnext);
135 * Room ordering stuff (compare first by floor, then by order)
137 int rordercmp(struct roomlisting *r1, struct roomlisting *r2)
139 if ((r1 == NULL) && (r2 == NULL))
145 if (r1->rlfloor < r2->rlfloor)
147 if (r1->rlfloor > r2->rlfloor)
149 if (r1->rlorder < r2->rlorder)
151 if (r1->rlorder > r2->rlorder)
158 * Common code for all room listings
160 void listrms(char *variety)
165 struct roomlisting *rl = NULL;
166 struct roomlisting *rp;
167 struct roomlisting *rs;
170 /* Ask the server for a room list */
177 while (serv_gets(buf), strcmp(buf, "000")) {
179 rp = malloc(sizeof(struct roomlisting));
180 extract(rp->rlname, buf, 0);
181 rp->rlflags = extract_int(buf, 1);
182 rp->rlfloor = extract_int(buf, 2);
183 rp->rlorder = extract_int(buf, 3);
192 if (rordercmp(rp, rs) < 0) {
193 if (rs->lnext == NULL) {
200 if (rs->rnext == NULL) {
212 /* If no rooms were listed, print an nbsp to make the cell
213 * borders show up anyway.
215 if (num_rooms == 0) wprintf(" ");
220 * list all forgotten rooms
222 void zapped_list(void)
226 svprintf("BOXTITLE", WCS_STRING, "Zapped (forgotten) rooms");
227 do_template("beginbox");
231 wprintf("<BR><BR>\n");
232 wprintf("Click on any room to un-zap it and goto that room.\n");
233 do_template("endbox");
239 * read this room's info file (set v to 1 for verbose mode)
248 fmout(NULL, "CENTER");
255 /* Display room graphic. The server doesn't actually
256 * need the room name, but we supply it in order to
257 * keep the browser from using a cached graphic from
260 void embed_room_graphic(void) {
263 serv_puts("OIMG _roompic_");
266 wprintf("<TD BGCOLOR=\"#444455\">");
267 wprintf("<IMG HEIGHT=64 SRC=\"/image&name=_roompic_&room=");
268 urlescputs(WC->wc_roomname);
277 /* Let the user know if new mail has arrived
279 void embed_newmail_button(void) {
280 if ( (WC->new_mail > WC->remember_new_mail) && (WC->new_mail>0) ) {
282 "<A HREF=\"/dotgoto?room=_MAIL_\">"
283 "<IMG SRC=\"/static/mail.gif\" border=0 "
284 "ALT=\"You have new mail\">"
285 "<BR><SPAN CLASS=\"youhavemail\">"
286 "%d new mail</SPAN></A>", WC->new_mail);
287 WC->remember_new_mail = WC->new_mail;
294 * Display the current view and offer an option to change it
296 void embed_view_o_matic(void) {
299 wprintf("<FORM NAME=\"viewomatic\">\n"
300 "<SELECT NAME=\"newview\" SIZE=\"1\" "
301 "OnChange=\"location.href=viewomatic.newview.options"
302 "[selectedIndex].value\">\n");
304 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
306 * Only offer the views that make sense, given the default
307 * view for the room. For example, don't offer a Calendar
308 * view in a non-Calendar room.
312 || (i == WC->wc_default_view)
313 || ( (i == 0) && (WC->wc_default_view == 1) )
314 || ( (i == 1) && (WC->wc_default_view == 0) )
317 wprintf("<OPTION %s VALUE=\"/changeview?view=%d\">",
318 ((i == WC->wc_view) ? "SELECTED" : ""),
320 escputs(viewdefs[i]);
321 wprintf("</OPTION>\n");
324 wprintf("</SELECT></FORM>\n");
329 void embed_room_banner(char *got) {
332 /* We need to have the information returned by a GOTO server command.
333 * If it isn't supplied, we fake it by issuing our own GOTO.
336 serv_printf("GOTO %s", WC->wc_roomname);
341 /* If the user happens to select the "make this my start page" link,
342 * we want it to remember the URL as a "/dotskip" one instead of
343 * a "skip" or "gotonext" or something like that.
345 snprintf(WC->this_page, sizeof(WC->this_page), "/dotskip&room=%s",
348 /* Check for new mail. */
349 WC->new_mail = extract_int(&got[4], 9);
350 WC->wc_view = extract_int(&got[4], 11);
352 svprintf("ROOMNAME", WCS_STRING, "%s", WC->wc_roomname);
353 svprintf("NEWMSGS", WCS_STRING, "%d", extract_int(&got[4], 1));
354 svprintf("TOTALMSGS", WCS_STRING, "%d", extract_int(&got[4], 2));
355 svcallback("ROOMPIC", embed_room_graphic);
356 svcallback("ROOMINFO", readinfo);
357 svcallback("YOUHAVEMAIL", embed_newmail_button);
358 svcallback("VIEWOMATIC", embed_view_o_matic);
359 svcallback("START", offer_start_page);
361 do_template("roombanner");
369 * back end routine to take the session to a new room
372 void gotoroom(char *gname)
375 static long ls = (-1L);
377 /* store ungoto information */
378 strcpy(WC->ugname, WC->wc_roomname);
381 /* move to the new room */
382 serv_printf("GOTO %s", gname);
385 serv_puts("GOTO _BASEROOM_");
391 extract(WC->wc_roomname, &buf[4], 0);
392 WC->room_flags = extract_int(&buf[4], 4);
393 /* highest_msg_read = extract_int(&buf[4],6);
394 maxmsgnum = extract_int(&buf[4],5);
395 is_mail = (char) extract_int(&buf[4],7); */
396 ls = extract_long(&buf[4], 6);
397 WC->wc_floor = extract_int(&buf[4], 10);
398 WC->wc_view = extract_int(&buf[4], 11);
399 WC->wc_default_view = extract_int(&buf[4], 12);
402 WC->is_room_aide = WC->is_aide;
404 WC->is_room_aide = (char) extract_int(&buf[4], 8);
406 remove_march(WC->wc_roomname);
407 if (!strcasecmp(gname, "_BASEROOM_"))
413 * Locate the room on the march list which we most want to go to. Each room
414 * is measured given a "weight" of preference based on various factors.
416 char *pop_march(int desired_floor)
418 static char TheRoom[128];
420 int TheOrder = 32767;
423 struct march *mptr = NULL;
425 strcpy(TheRoom, "_BASEROOM_");
426 if (WC->march == NULL)
429 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
431 if ((strcasecmp(mptr->march_name, "_BASEROOM_")))
432 weight = weight + 10000;
433 if (mptr->march_floor == desired_floor)
434 weight = weight + 5000;
436 weight = weight + ((128 - (mptr->march_floor)) * 128);
437 weight = weight + (128 - (mptr->march_order));
439 if (weight > TheWeight) {
441 strcpy(TheRoom, mptr->march_name);
442 TheFloor = mptr->march_floor;
443 TheOrder = mptr->march_order;
451 /* Goto next room having unread messages.
452 * We want to skip over rooms that the user has already been to, and take the
453 * user back to the lobby when done. The room we end up in is placed in
454 * newroom - which is set to 0 (the lobby) initially.
455 * We start the search in the current room rather than the beginning to prevent
456 * two or more concurrent users from dragging each other back to the same room.
461 struct march *mptr, *mptr2;
464 /* First check to see if the march-mode list is already allocated.
465 * If it is, pop the first room off the list and go there.
468 if (WC->march == NULL) {
472 while (serv_gets(buf), strcmp(buf, "000")) {
473 mptr = (struct march *) malloc(sizeof(struct march));
475 extract(mptr->march_name, buf, 0);
476 mptr->march_floor = extract_int(buf, 2);
477 mptr->march_order = extract_int(buf, 3);
478 if (WC->march == NULL) {
482 while (mptr2->next != NULL)
487 /* add _BASEROOM_ to the end of the march list, so the user will end up
488 * in the system base room (usually the Lobby>) at the end of the loop
490 mptr = (struct march *) malloc(sizeof(struct march));
492 strcpy(mptr->march_name, "_BASEROOM_");
493 if (WC->march == NULL) {
497 while (mptr2->next != NULL)
502 * ...and remove the room we're currently in, so a <G>oto doesn't make us
503 * walk around in circles
505 remove_march(WC->wc_roomname);
507 if (WC->march != NULL) {
508 strcpy(next_room, pop_march(-1));
510 strcpy(next_room, "_BASEROOM_");
514 smart_goto(next_room);
518 void smart_goto(char *next_room) {
526 * mark all messages in current room as having been read
528 void slrp_highest(void)
533 serv_puts("SLRP HIGHEST");
536 wprintf("<EM>%s</EM><BR>\n", &buf[4]);
543 * un-goto the previous room
549 if (!strcmp(WC->ugname, "")) {
550 smart_goto(WC->wc_roomname);
553 serv_printf("GOTO %s", WC->ugname);
556 smart_goto(WC->wc_roomname);
559 if (WC->uglsn >= 0L) {
560 serv_printf("SLRP %ld", WC->uglsn);
563 strcpy(buf, WC->ugname);
564 strcpy(WC->ugname, "");
573 * Set/clear/read the "self-service list subscribe" flag for a room
575 * Set 'newval' to 0 to clear, 1 to set, any other value to leave unchanged.
576 * Always returns the new value.
579 int self_service(int newval) {
580 int current_value = 0;
586 int flags, floor, order, view, flags2;
590 if (buf[0] != '2') return(0);
592 extract(name, &buf[4], 0);
593 extract(password, &buf[4], 1);
594 extract(dirname, &buf[4], 2);
595 flags = extract_int(&buf[4], 3);
596 floor = extract_int(&buf[4], 4);
597 order = extract_int(&buf[4], 5);
598 view = extract_int(&buf[4], 6);
599 flags2 = extract_int(&buf[4], 7);
601 if (flags2 & QR2_SELFLIST) {
609 flags2 = flags2 | QR2_SELFLIST;
611 else if (newval == 0) {
612 flags2 = flags2 & ~QR2_SELFLIST;
615 return(current_value);
618 if (newval != current_value) {
619 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
620 name, password, dirname, flags,
621 floor, order, view, flags2);
635 * display the form for editing a room
637 void display_editroom(void)
642 char remote_room[SIZ];
645 char er_password[10];
647 char er_roomaide[26];
653 char *not_shared_with;
660 if (strlen(tab) == 0) tab = "admin";
667 strcpy(WC->ImportantMessage, &buf[4]);
671 extract(er_name, &buf[4], 0);
672 extract(er_password, &buf[4], 1);
673 extract(er_dirname, &buf[4], 2);
674 er_flags = extract_int(&buf[4], 3);
675 er_floor = extract_int(&buf[4], 4);
679 /* print the tabbed dialog */
680 wprintf("<BR><TABLE border=0 cellspacing=0 cellpadding=0 width=100%%>"
682 "<TD> </TD>\n");
684 if (!strcmp(tab, "admin")) {
685 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
688 wprintf("<TD BGCOLOR=\"#CCCCCC\"><A HREF=\"/display_editroom&tab=admin\">");
690 wprintf("Administration");
691 if (!strcmp(tab, "admin")) {
692 wprintf("</SPAN></TD>\n");
695 wprintf("</A></TD>\n");
698 wprintf("<TD> </TD>\n");
700 if (!strcmp(tab, "config")) {
701 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
704 wprintf("<TD BGCOLOR=\"#CCCCCC\"><A HREF=\"/display_editroom&tab=config\">");
706 wprintf("Configuration");
707 if (!strcmp(tab, "config")) {
708 wprintf("</SPAN></TD>\n");
711 wprintf("</A></TD>\n");
714 wprintf("<TD> </TD>\n");
716 if (!strcmp(tab, "expire")) {
717 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
720 wprintf("<TD BGCOLOR=\"#CCCCCC\"><A HREF=\"/display_editroom&tab=expire\">");
722 wprintf("Message expire policy");
723 if (!strcmp(tab, "expire")) {
724 wprintf("</SPAN></TD>\n");
727 wprintf("</A></TD>\n");
730 wprintf("<TD> </TD>\n");
732 if (!strcmp(tab, "sharing")) {
733 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
736 wprintf("<TD BGCOLOR=\"#CCCCCC\"><A HREF=\"/display_editroom&tab=sharing\">");
739 if (!strcmp(tab, "sharing")) {
740 wprintf("</SPAN></TD>\n");
743 wprintf("</A></TD>\n");
746 wprintf("<TD> </TD>\n");
748 if (!strcmp(tab, "listserv")) {
749 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
752 wprintf("<TD BGCOLOR=\"#CCCCCC\"><A HREF=\"/display_editroom&tab=listserv\">");
754 wprintf("Mailing list service");
755 if (!strcmp(tab, "listserv")) {
756 wprintf("</SPAN></TD>\n");
759 wprintf("</A></TD>\n");
762 wprintf("<TD> </TD>\n");
764 wprintf("</TR></TABLE>\n");
765 /* end tabbed dialog */
767 /* begin content of whatever tab is open now */
768 wprintf("<TABLE border=0 width=100%% bgcolor=\"#FFFFFF\">\n"
771 if (!strcmp(tab, "admin")) {
773 "<LI><A HREF=\"/confirm_delete_room\">\n"
774 "Delete this room</A>\n"
775 "<LI><A HREF=\"/display_editroompic\">\n"
776 "Set or change the graphic for this room's banner</A>\n"
777 "<LI><A HREF=\"/display_editinfo\">\n"
778 "Edit this room's Info file</A>\n"
782 if (!strcmp(tab, "config")) {
783 wprintf("<FORM METHOD=\"POST\" ACTION=\"/editroom\">\n");
785 wprintf("<UL><LI>Name of room: ");
786 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\"19\">\n", er_name);
788 wprintf("<LI>Resides on floor: ");
789 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
790 for (i = 0; i < 128; ++i)
791 if (strlen(floorlist[i]) > 0) {
794 wprintf("SELECTED ");
795 wprintf("VALUE=\"%d\">", i);
796 escputs(floorlist[i]);
797 wprintf("</OPTION>\n");
799 wprintf("</SELECT>\n");
801 wprintf("<LI>Type of room:<UL>\n");
803 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
804 if ((er_flags & QR_PRIVATE) == 0)
806 wprintf("> Public room\n");
808 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"guessname\" ");
809 if ((er_flags & QR_PRIVATE) &&
810 (er_flags & QR_GUESSNAME))
812 wprintf("> Private - guess name\n");
814 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
815 if ((er_flags & QR_PRIVATE) &&
816 (er_flags & QR_PASSWORDED))
818 wprintf("> Private - require password:\n");
819 wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n", er_password);
821 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
822 if ((er_flags & QR_PRIVATE)
823 && ((er_flags & QR_GUESSNAME) == 0)
824 && ((er_flags & QR_PASSWORDED) == 0))
826 wprintf("> Private - invitation only\n");
828 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
829 wprintf("> If private, cause current users to forget room\n");
833 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
834 if (er_flags & QR_PREFONLY)
836 wprintf("> Preferred users only\n");
838 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
839 if (er_flags & QR_READONLY)
841 wprintf("> Read-only room\n");
843 /* directory stuff */
844 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
845 if (er_flags & QR_DIRECTORY)
847 wprintf("> File directory room\n");
849 wprintf("<UL><LI>Directory name: ");
850 wprintf("<INPUT TYPE=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n", er_dirname);
852 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
853 if (er_flags & QR_UPLOAD)
855 wprintf("> Uploading allowed\n");
857 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
858 if (er_flags & QR_DOWNLOAD)
860 wprintf("> Downloading allowed\n");
862 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
863 if (er_flags & QR_VISDIR)
865 wprintf("> Visible directory</UL>\n");
867 /* end of directory stuff */
869 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
870 if (er_flags & QR_NETWORK)
872 wprintf("> Network shared room\n");
874 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"permanent\" VALUE=\"yes\" ");
875 if (er_flags & QR_PERMANENT)
877 wprintf("> Permanent (does not auto-purge)\n");
879 /* start of anon options */
881 wprintf("<LI>Anonymous messages<UL>\n");
883 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
884 if (((er_flags & QR_ANONONLY) == 0)
885 && ((er_flags & QR_ANONOPT) == 0))
887 wprintf("> No anonymous messages\n");
889 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
890 if (er_flags & QR_ANONONLY)
892 wprintf("> All messages are anonymous\n");
894 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
895 if (er_flags & QR_ANONOPT)
897 wprintf("> Prompt user when entering messages</UL>\n");
899 /* end of anon options */
901 wprintf("<LI>Room aide: \n");
905 wprintf("<EM>%s</EM>\n", &buf[4]);
907 extract(er_roomaide, &buf[4], 0);
908 wprintf("<INPUT TYPE=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n", er_roomaide);
911 wprintf("</UL><CENTER>\n");
912 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"config\">\n"
913 "<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">"
915 "<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">"
921 /* Sharing the room with other Citadel nodes... */
922 if (!strcmp(tab, "sharing")) {
924 shared_with = strdup("");
925 not_shared_with = strdup("");
927 /* Learn the current configuration */
928 serv_puts("CONF getsys|application/x-citadel-ignet-config");
930 if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
931 extract(node, buf, 0);
932 not_shared_with = realloc(not_shared_with,
933 strlen(not_shared_with) + 32);
934 strcat(not_shared_with, node);
935 strcat(not_shared_with, "\n");
940 if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
941 extract(cmd, buf, 0);
942 extract(node, buf, 1);
943 extract(remote_room, buf, 2);
944 if (!strcasecmp(cmd, "ignet_push_share")) {
945 shared_with = realloc(shared_with,
946 strlen(shared_with) + 32);
947 strcat(shared_with, node);
948 if (strlen(remote_room) > 0) {
949 strcat(shared_with, "|");
950 strcat(shared_with, remote_room);
952 strcat(shared_with, "\n");
956 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
957 extract_token(buf, shared_with, i, '\n');
958 extract_token(node, buf, 0, '|');
959 for (j=0; j<num_tokens(not_shared_with, '\n'); ++j) {
960 extract_token(cmd, not_shared_with, j, '\n');
961 if (!strcasecmp(node, cmd)) {
962 remove_token(not_shared_with, j, '\n');
967 /* Display the stuff */
968 wprintf("<CENTER><BR>"
969 "<TABLE border=1 cellpadding=5><TR>"
970 "<TD><B><I>Shared with</I></B></TD>"
971 "<TD><B><I>Not shared with</I></B></TD></TR>\n"
974 wprintf("<TABLE border=1><TR>"
975 "<TD>Remote node name</TD>"
976 "<TD>Remote room name</TD>"
981 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
982 extract_token(buf, shared_with, i, '\n');
983 extract_token(node, buf, 0, '|');
984 extract_token(remote_room, buf, 1, '|');
985 if (strlen(node) > 0) {
986 wprintf("<TR><TD>%s</TD>\n", node);
989 if (strlen(remote_room) > 0) {
990 escputs(remote_room);
995 wprintf("<A HREF=\"/netedit&cmd=remove&line="
996 "ignet_push_share|");
998 if (strlen(remote_room) > 0) {
1000 urlescputs(remote_room);
1002 wprintf("&tab=sharing\">unshare</A>");
1003 wprintf("</TD></TR>\n");
1007 wprintf("</TABLE>\n");
1008 wprintf("</TD><TD>\n");
1010 for (i=0; i<num_tokens(not_shared_with, '\n'); ++i) {
1011 extract_token(node, not_shared_with, i, '\n');
1012 if (strlen(node) > 0) {
1013 wprintf("%s ", node);
1014 wprintf("<A HREF=\"/netedit&cmd=add&line="
1015 "ignet_push_share|");
1017 wprintf("&tab=sharing\">(share)</A><BR>");
1021 wprintf("</TD></TR>"
1023 "<I><B>Reminder:</B> When sharing a room, "
1024 "it must be shared from both ends. Adding a node to "
1025 "the 'shared' list sends messages out, but in order to"
1026 " receive messages, the other nodes must be configured"
1027 " to send messages out to your system as well.</I><BR>"
1032 /* Mailing list management */
1033 if (!strcmp(tab, "listserv")) {
1035 wprintf("<BR><center>"
1036 "<TABLE BORDER=0 WIDTH=100%% CELLPADDING=5>"
1037 "<TR><TD VALIGN=TOP>");
1039 wprintf("<i>The contents of this room are being "
1040 "mailed <b>as individual messages</b> "
1041 "to the following list recipients:"
1046 if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
1047 extract(cmd, buf, 0);
1048 if (!strcasecmp(cmd, "listrecp")) {
1049 extract(recp, buf, 1);
1052 wprintf(" <A HREF=\"/netedit&cmd=remove&line="
1055 wprintf("&tab=listserv\">(remove)</A><BR>");
1059 wprintf("<BR><FORM METHOD=\"POST\" ACTION=\"/netedit\">\n"
1060 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1061 "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"listrecp|\">\n");
1062 wprintf("<INPUT TYPE=\"text\" NAME=\"line\">\n");
1063 wprintf("<INPUT TYPE=\"submit\" NAME=\"cmd\" VALUE=\"Add\">");
1064 wprintf("</FORM>\n");
1066 wprintf("</TD><TD VALIGN=TOP>\n");
1068 wprintf("<i>The contents of this room are being "
1069 "mailed <b>in digest form</b> "
1070 "to the following list recipients:"
1075 if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
1076 extract(cmd, buf, 0);
1077 if (!strcasecmp(cmd, "digestrecp")) {
1078 extract(recp, buf, 1);
1081 wprintf(" <A HREF=\"/netedit&cmd=remove&line="
1084 wprintf("&tab=listserv\">(remove)</A><BR>");
1088 wprintf("<BR><FORM METHOD=\"POST\" ACTION=\"/netedit\">\n"
1089 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1090 "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"digestrecp|\">\n");
1091 wprintf("<INPUT TYPE=\"text\" NAME=\"line\">\n");
1092 wprintf("<INPUT TYPE=\"submit\" NAME=\"cmd\" VALUE=\"Add\">");
1093 wprintf("</FORM>\n");
1095 wprintf("</TD></TR></TABLE><HR>\n");
1097 if (self_service(999) == 1) {
1098 wprintf("This room is configured to allow "
1099 "self-service subscribe/unsubscribe requests."
1100 " <A HREF=\"/toggle_self_service?newval=0&"
1102 "Click to disable.</A><BR>\n"
1103 "The URL for subscribe/unsubscribe is: "
1104 "<TT>http://%s/listsub</TT><BR>\n",
1109 wprintf("This room is <i>not</i> configured to allow "
1110 "self-service subscribe/unsubscribe requests."
1111 " <A HREF=\"/toggle_self_service?newval=1&"
1113 "Click to enable.</A><BR>\n"
1118 wprintf("</CENTER>\n");
1122 /* Mailing list management */
1123 if (!strcmp(tab, "expire")) {
1125 serv_puts("GPEX room");
1127 if (buf[0] == '2') {
1128 roompolicy = extract_int(&buf[4], 0);
1129 roomvalue = extract_int(&buf[4], 1);
1132 serv_puts("GPEX floor");
1134 if (buf[0] == '2') {
1135 floorpolicy = extract_int(&buf[4], 0);
1136 floorvalue = extract_int(&buf[4], 1);
1139 wprintf("<BR><FORM METHOD=\"POST\" ACTION=\"/set_room_policy\">\n");
1140 wprintf("<TABLE border=0 cellspacing=5>\n");
1141 wprintf("<TR><TD>Message expire policy for this room<BR>(");
1142 escputs(WC->wc_roomname);
1143 wprintf(")</TD><TD>");
1144 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"0\" %s>",
1145 ((roompolicy == 0) ? "CHECKED" : "") );
1146 wprintf("Use the default policy for this floor<BR>\n");
1147 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"1\" %s>",
1148 ((roompolicy == 1) ? "CHECKED" : "") );
1149 wprintf("Never automatically expire messages<BR>\n");
1150 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"2\" %s>",
1151 ((roompolicy == 2) ? "CHECKED" : "") );
1152 wprintf("Expire by message count<BR>\n");
1153 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"3\" %s>",
1154 ((roompolicy == 3) ? "CHECKED" : "") );
1155 wprintf("Expire by message age<BR>");
1156 wprintf("Number of messages or days: ");
1157 wprintf("<INPUT TYPE=\"text\" NAME=\"roomvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">", roomvalue);
1158 wprintf("</TD></TR>\n");
1160 if (WC->axlevel >= 6) {
1161 wprintf("<TR><TD COLSPAN=2><HR></TD></TR>\n");
1162 wprintf("<TR><TD>Message expire policy for this floor<BR>(");
1163 escputs(floorlist[WC->wc_floor]);
1164 wprintf(")</TD><TD>");
1165 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"0\" %s>",
1166 ((floorpolicy == 0) ? "CHECKED" : "") );
1167 wprintf("Use the system default<BR>\n");
1168 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"1\" %s>",
1169 ((floorpolicy == 1) ? "CHECKED" : "") );
1170 wprintf("Never automatically expire messages<BR>\n");
1171 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"2\" %s>",
1172 ((floorpolicy == 2) ? "CHECKED" : "") );
1173 wprintf("Expire by message count<BR>\n");
1174 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"3\" %s>",
1175 ((floorpolicy == 3) ? "CHECKED" : "") );
1176 wprintf("Expire by message age<BR>");
1177 wprintf("Number of messages or days: ");
1178 wprintf("<INPUT TYPE=\"text\" NAME=\"floorvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">",
1182 wprintf("<CENTER>\n");
1183 wprintf("<TR><TD COLSPAN=2><HR><CENTER>\n");
1184 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
1186 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1187 wprintf("</CENTER></TD><TR>\n");
1189 wprintf("</TABLE>\n"
1190 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"expire\">\n"
1197 /* end content of whatever tab is open now */
1198 wprintf("</TD></TR></TABLE>\n");
1205 * Toggle self-service list subscription
1207 void toggle_self_service(void) {
1210 newval = atoi(bstr("newval"));
1211 self_service(newval);
1218 * save new parameters for a room
1224 char er_password[10];
1225 char er_dirname[15];
1226 char er_roomaide[26];
1232 if (strcmp(bstr("sc"), "OK")) {
1233 strcpy(WC->ImportantMessage,
1234 "Cancelled. Changes were not saved.");
1241 if (buf[0] != '2') {
1242 strcpy(WC->ImportantMessage, &buf[4]);
1246 extract(er_name, &buf[4], 0);
1247 extract(er_password, &buf[4], 1);
1248 extract(er_dirname, &buf[4], 2);
1249 er_flags = extract_int(&buf[4], 3);
1251 strcpy(er_roomaide, bstr("er_roomaide"));
1252 if (strlen(er_roomaide) == 0) {
1255 if (buf[0] != '2') {
1256 strcpy(er_roomaide, "");
1258 extract(er_roomaide, &buf[4], 0);
1261 strcpy(buf, bstr("er_name"));
1263 if (strlen(buf) > 0)
1264 strcpy(er_name, buf);
1266 strcpy(buf, bstr("er_password"));
1268 if (strlen(buf) > 0)
1269 strcpy(er_password, buf);
1271 strcpy(buf, bstr("er_dirname"));
1273 if (strlen(buf) > 0)
1274 strcpy(er_dirname, buf);
1276 strcpy(buf, bstr("type"));
1277 er_flags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME);
1279 if (!strcmp(buf, "invonly")) {
1280 er_flags |= (QR_PRIVATE);
1282 if (!strcmp(buf, "guessname")) {
1283 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
1285 if (!strcmp(buf, "passworded")) {
1286 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
1288 if (!strcmp(bstr("prefonly"), "yes")) {
1289 er_flags |= QR_PREFONLY;
1291 er_flags &= ~QR_PREFONLY;
1294 if (!strcmp(bstr("readonly"), "yes")) {
1295 er_flags |= QR_READONLY;
1297 er_flags &= ~QR_READONLY;
1300 if (!strcmp(bstr("permanent"), "yes")) {
1301 er_flags |= QR_PERMANENT;
1303 er_flags &= ~QR_PERMANENT;
1306 if (!strcmp(bstr("network"), "yes")) {
1307 er_flags |= QR_NETWORK;
1309 er_flags &= ~QR_NETWORK;
1312 if (!strcmp(bstr("directory"), "yes")) {
1313 er_flags |= QR_DIRECTORY;
1315 er_flags &= ~QR_DIRECTORY;
1318 if (!strcmp(bstr("ulallowed"), "yes")) {
1319 er_flags |= QR_UPLOAD;
1321 er_flags &= ~QR_UPLOAD;
1324 if (!strcmp(bstr("dlallowed"), "yes")) {
1325 er_flags |= QR_DOWNLOAD;
1327 er_flags &= ~QR_DOWNLOAD;
1330 if (!strcmp(bstr("visdir"), "yes")) {
1331 er_flags |= QR_VISDIR;
1333 er_flags &= ~QR_VISDIR;
1336 strcpy(buf, bstr("anon"));
1338 er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
1339 if (!strcmp(buf, "anononly"))
1340 er_flags |= QR_ANONONLY;
1341 if (!strcmp(buf, "anon2"))
1342 er_flags |= QR_ANONOPT;
1345 if (!strcmp(bstr("bump"), "yes"))
1348 er_floor = atoi(bstr("er_floor"));
1350 sprintf(buf, "SETR %s|%s|%s|%u|%d|%d",
1351 er_name, er_password, er_dirname, er_flags, bump, er_floor);
1354 if (buf[0] != '2') {
1355 strcpy(WC->ImportantMessage, &buf[4]);
1361 if (strlen(er_roomaide) > 0) {
1362 sprintf(buf, "SETA %s", er_roomaide);
1365 if (buf[0] != '2') {
1366 strcpy(WC->ImportantMessage, &buf[4]);
1367 display_main_menu();
1372 strcpy(WC->ImportantMessage, "Your changes have been saved.");
1378 * Invite, Kick, and show Who Knows a room
1380 void display_whok(void)
1382 char buf[SIZ], room[SIZ], username[SIZ];
1387 if (buf[0] != '2') {
1388 strcpy(WC->ImportantMessage, &buf[4]);
1389 display_main_menu();
1392 extract(room, &buf[4], 0);
1394 strcpy(username, bstr("username"));
1396 if(!strcmp(bstr("sc"), "Kick")) {
1397 sprintf(buf, "KICK %s", username);
1401 if (buf[0] != '2') {
1402 strcpy(WC->ImportantMessage, &buf[4]);
1404 sprintf(WC->ImportantMessage,
1405 "<B><I>User %s kicked out of room %s.</I></B>\n",
1408 } else if(!strcmp(bstr("sc"), "Invite")) {
1409 sprintf(buf, "INVT %s", username);
1413 if (buf[0] != '2') {
1414 strcpy(WC->ImportantMessage, &buf[4]);
1416 sprintf(WC->ImportantMessage,
1417 "<B><I>User %s invited to room %s.</I></B>\n",
1423 stresc(buf, WC->wc_roomname, 1, 1);
1424 svprintf("BOXTITLE", WCS_STRING, "Access control list for %s", buf);
1425 do_template("beginbox");
1427 wprintf("<TABLE border=0 CELLSPACING=10><TR VALIGN=TOP>"
1428 "<TD>The users listed below have access to this room. "
1429 "To remove a user from the access list, select the user "
1430 "name from the list and click 'Kick'.<BR><BR>");
1432 wprintf("<CENTER><FORM METHOD=\"POST\" ACTION=\"/display_whok\">\n");
1433 wprintf("<SELECT NAME=\"username\" SIZE=10>\n");
1436 if (buf[0] == '1') {
1437 while (serv_gets(buf), strcmp(buf, "000")) {
1438 extract(username, buf, 0);
1439 wprintf("<OPTION>");
1444 wprintf("</SELECT><BR>\n");
1446 wprintf("<input type=submit name=sc value=\"Kick\">");
1447 wprintf("</FORM></CENTER>\n");
1450 "To grant another user access to this room, enter the "
1451 "user name in the box below and click 'Invite'.<BR><BR>");
1453 wprintf("<CENTER><FORM METHOD=\"POST\" ACTION=\"/display_whok\">\n");
1454 wprintf("Invite: ");
1455 wprintf("<input type=text name=username><BR>\n"
1456 "<input type=hidden name=sc value=\"Invite\">"
1457 "<input type=submit value=\"Invite\">"
1458 "</FORM></CENTER>\n");
1460 wprintf("</TD></TR></TABLE>\n");
1461 do_template("endbox");
1468 * display the form for entering a new room
1470 void display_entroom(void)
1475 serv_puts("CRE8 0");
1478 if (buf[0] != '2') {
1479 strcpy(WC->ImportantMessage, &buf[4]);
1480 display_main_menu();
1484 svprintf("BOXTITLE", WCS_STRING, "Create a new room");
1485 do_template("beginbox");
1487 wprintf("<FORM METHOD=\"POST\" ACTION=\"/entroom\">\n");
1489 wprintf("<UL><LI>Name of room: ");
1490 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" MAXLENGTH=\"127\">\n");
1492 wprintf("<LI>Resides on floor: ");
1494 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
1495 for (i = 0; i < 128; ++i)
1496 if (strlen(floorlist[i]) > 0) {
1497 wprintf("<OPTION ");
1498 wprintf("VALUE=\"%d\">", i);
1499 escputs(floorlist[i]);
1500 wprintf("</OPTION>\n");
1502 wprintf("</SELECT>\n");
1504 wprintf("<LI>Type of room:<UL>\n");
1506 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1507 wprintf("CHECKED > Public room\n");
1509 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"guessname\" ");
1510 wprintf("> Private - guess name\n");
1512 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
1513 wprintf("> Private - require password:\n");
1514 wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
1516 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
1517 wprintf("> Private - invitation only\n");
1519 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"personal\" ");
1520 wprintf("> Personal (mailbox for you only)\n");
1523 wprintf("<LI>Default view for room: "); /* FOO */
1524 wprintf("<SELECT NAME=\"er_view\" SIZE=\"1\">\n");
1525 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
1526 wprintf("<OPTION %s VALUE=\"%d\">",
1527 ((i == 0) ? "SELECTED" : ""), i );
1528 escputs(viewdefs[i]);
1529 wprintf("</OPTION>\n");
1531 wprintf("</SELECT>\n");
1533 wprintf("<CENTER>\n");
1534 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
1536 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1537 wprintf("</CENTER>\n");
1538 wprintf("</FORM>\n<HR>");
1539 serv_printf("MESG roomaccess");
1541 if (buf[0] == '1') {
1542 fmout(NULL, "CENTER");
1544 do_template("endbox");
1552 * support function for entroom() -- sets the default view
1554 void er_set_default_view(int newview) {
1568 if (buf[0] != '2') return;
1570 extract(rm_name, &buf[4], 0);
1571 extract(rm_pass, &buf[4], 1);
1572 extract(rm_dir, &buf[4], 2);
1573 rm_bits1 = extract_int(&buf[4], 3);
1574 rm_floor = extract_int(&buf[4], 4);
1575 rm_listorder = extract_int(&buf[4], 5);
1576 rm_bits2 = extract_int(&buf[4], 7);
1578 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
1579 rm_name, rm_pass, rm_dir, rm_bits1, rm_floor,
1580 rm_listorder, newview, rm_bits2
1595 char er_password[SIZ];
1600 if (strcmp(bstr("sc"), "OK")) {
1601 strcpy(WC->ImportantMessage,
1602 "Cancelled. No new room was created.");
1603 display_main_menu();
1606 strcpy(er_name, bstr("er_name"));
1607 strcpy(er_type, bstr("type"));
1608 strcpy(er_password, bstr("er_password"));
1609 er_floor = atoi(bstr("er_floor"));
1610 er_view = atoi(bstr("er_view"));
1613 if (!strcmp(er_type, "guessname"))
1615 if (!strcmp(er_type, "passworded"))
1617 if (!strcmp(er_type, "invonly"))
1619 if (!strcmp(er_type, "personal"))
1622 sprintf(buf, "CRE8 1|%s|%d|%s|%d|%d|%d",
1623 er_name, er_num_type, er_password, er_floor, 0, er_view);
1626 if (buf[0] != '2') {
1627 strcpy(WC->ImportantMessage, &buf[4]);
1628 display_main_menu();
1632 do_change_view(er_view); /* Now go there */
1637 * display the screen to enter a private room
1639 void display_private(char *rname, int req_pass)
1644 svprintf("BOXTITLE", WCS_STRING, "Go to a hidden room");
1645 do_template("beginbox");
1647 wprintf("<CENTER>\n");
1648 wprintf("<BR>If you know the name of a hidden (guess-name) or\n");
1649 wprintf("passworded room, you can enter that room by typing\n");
1650 wprintf("its name below. Once you gain access to a private\n");
1651 wprintf("room, it will appear in your regular room listings\n");
1652 wprintf("so you don't have to keep returning here.\n");
1653 wprintf("<BR><BR>");
1655 wprintf("<FORM METHOD=\"GET\" ACTION=\"/goto_private\">\n");
1657 wprintf("<table border=\"0\" cellspacing=\"5\" "
1658 "cellpadding=\"5\" BGCOLOR=\"#EEEEEE\">\n"
1660 "Enter room name:</TD><TD>"
1661 "<INPUT TYPE=\"text\" NAME=\"gr_name\" "
1662 "VALUE=\"%s\" MAXLENGTH=\"19\">\n", rname);
1665 wprintf("</TD></TR><TR><TD>");
1666 wprintf("Enter room password:</TD><TD>");
1667 wprintf("<INPUT TYPE=\"password\" NAME=\"gr_pass\" MAXLENGTH=\"9\">\n");
1669 wprintf("</TD></TR></TABLE><BR>\n");
1671 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">"
1673 "<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1674 wprintf("</FORM>\n");
1675 do_template("endbox");
1680 * goto a private room
1682 void goto_private(void)
1687 if (strcasecmp(bstr("sc"), "OK")) {
1688 display_main_menu();
1691 strcpy(hold_rm, WC->wc_roomname);
1692 strcpy(buf, "GOTO ");
1693 strcat(buf, bstr("gr_name"));
1695 strcat(buf, bstr("gr_pass"));
1699 if (buf[0] == '2') {
1700 smart_goto(bstr("gr_name"));
1703 if (!strncmp(buf, "540", 3)) {
1704 display_private(bstr("gr_name"), 1);
1708 wprintf("%s\n", &buf[4]);
1715 * display the screen to zap a room
1717 void display_zap(void)
1721 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#770000\"><TR><TD>");
1722 wprintf("<SPAN CLASS=\"titlebar\">Zap (forget) the current room</SPAN>\n");
1723 wprintf("</TD></TR></TABLE>\n");
1725 wprintf("If you select this option, <em>%s</em> will ", WC->wc_roomname);
1726 wprintf("disappear from your room list. Is this what you wish ");
1727 wprintf("to do?<BR>\n");
1729 wprintf("<FORM METHOD=\"GET\" ACTION=\"/zap\">\n");
1730 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
1732 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1733 wprintf("</FORM>\n");
1744 char final_destination[SIZ];
1746 /* If the forget-room routine fails for any reason, we fall back
1747 * to the current room; otherwise, we go to the Lobby
1749 strcpy(final_destination, WC->wc_roomname);
1751 if (!strcasecmp(bstr("sc"), "OK")) {
1752 serv_printf("GOTO %s", WC->wc_roomname);
1754 if (buf[0] != '2') {
1755 /* ExpressMessageCat(&buf[4]); */
1759 if (buf[0] != '2') {
1760 /* ExpressMessageCat(&buf[4]); */
1762 strcpy(final_destination, "_BASEROOM_");
1766 smart_goto(final_destination);
1773 * Confirm deletion of the current room
1775 void confirm_delete_room(void)
1779 serv_puts("KILL 0");
1781 if (buf[0] != '2') {
1782 strcpy(WC->ImportantMessage, &buf[4]);
1783 display_main_menu();
1787 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#770000\"><TR><TD>");
1788 wprintf("<SPAN CLASS=\"titlebar\">Confirm deletion of room</SPAN>\n");
1789 wprintf("</TD></TR></TABLE>\n");
1791 wprintf("<CENTER>");
1792 wprintf("<FORM METHOD=\"GET\" ACTION=\"/delete_room\">\n");
1794 wprintf("Are you sure you want to delete <FONT SIZE=+1>");
1795 escputs(WC->wc_roomname);
1796 wprintf("</FONT>?<BR>\n");
1798 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Delete\">");
1799 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1801 wprintf("</FORM></CENTER>\n");
1807 * Delete the current room
1809 void delete_room(void)
1814 strcpy(sc, bstr("sc"));
1816 if (strcasecmp(sc, "Delete")) {
1817 strcpy(WC->ImportantMessage,
1818 "Cancelled. This room was not deleted.");
1819 display_main_menu();
1822 serv_puts("KILL 1");
1824 if (buf[0] != '2') {
1825 strcpy(WC->ImportantMessage, &buf[4]);
1826 display_main_menu();
1829 smart_goto("_BASEROOM_");
1836 * Perform changes to a room's network configuration
1838 void netedit(void) {
1843 if (strlen(bstr("line"))==0) {
1848 strcpy(line, bstr("prefix"));
1849 strcat(line, bstr("line"));
1850 strcat(line, bstr("suffix"));
1860 if (buf[0] != '1') {
1866 /* This loop works for add *or* remove. Spiffy, eh? */
1867 while (serv_gets(buf), strcmp(buf, "000")) {
1868 if (strcasecmp(buf, line)) {
1869 fprintf(fp, "%s\n", buf);
1876 if (buf[0] != '4') {
1882 while (fgets(buf, sizeof buf, fp) != NULL) {
1883 buf[strlen(buf)-1] = 0;
1887 if (!strcasecmp(bstr("cmd"), "add")) {
1899 * Convert a room name to a folder-ish-looking name.
1901 void room_to_folder(char *folder, char *room, int floor, int is_mailbox)
1906 * For mailboxes, just do it straight...
1909 sprintf(folder, "My folders|%s", room);
1913 * Otherwise, prefix the floor name as a "public folders" moniker
1916 sprintf(folder, "%s|%s", floorlist[floor], room);
1920 * Replace "\" characters with "|" for pseudo-folder-delimiting
1922 for (i=0; i<strlen(folder); ++i) {
1923 if (folder[i] == '\\') folder[i] = '|';
1931 * Back end for change_view()
1933 void do_change_view(int newview) {
1936 serv_printf("VIEW %d", newview);
1938 WC->wc_view = newview;
1939 smart_goto(WC->wc_roomname);
1945 * Change the view for this room
1947 void change_view(void) {
1950 view = atol(bstr("view"));
1951 do_change_view(view);
1956 * One big expanded tree list view --- like a folder list
1958 void do_folder_view(struct folder *fold, int max_folders, int num_floors) {
1960 int levels, oldlevels;
1963 int has_subfolders = 0;
1965 /* Include the menu expanding/collapsing code */
1966 wprintf("<script type=\"text/javascript\" src=\"/static/menuExpandable3.js\"></script>\n");
1968 do_template("beginbox_nt");
1969 wprintf("<div id=\"mainMenu\">\n");
1970 wprintf("<UL id=\"menuList\">\n");
1974 for (i=0; i<max_folders; ++i) {
1977 if ((i+1) < max_folders) {
1978 if ( (!strncasecmp(fold[i].name, fold[i+1].name, strlen(fold[i].name)))
1979 && (fold[i+1].name[strlen(fold[i].name)] == '|') ) {
1984 levels = num_tokens(fold[i].name, '|');
1986 if ( (levels < oldlevels) || ((levels==1)&&(i!=0)) ) {
1987 for (t=0; t<(oldlevels-levels); ++t) {
1992 if (has_subfolders) {
1994 if (levels == 1) wprintf(" class=\"menubar\"");
1996 wprintf("<A href=\"#\" id=\"actuator%d\" class=\"actuator\"></a>\n", actnum);
2002 if (fold[i].selectable) {
2003 wprintf("<A HREF=\"/dotgoto?room=");
2004 urlescputs(fold[i].room);
2009 wprintf("<SPAN CLASS=\"roomlist_floor\">");
2011 else if (fold[i].hasnewmsgs) {
2012 wprintf("<SPAN CLASS=\"roomlist_new\">");
2015 wprintf("<SPAN CLASS=\"roomlist_old\">");
2017 extract(buf, fold[i].name, levels-1);
2021 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
2022 wprintf(" (INBOX)");
2025 if (fold[i].selectable) {
2030 if (has_subfolders) {
2031 wprintf("<UL id=\"menu%d\" class=\"%s\">\n",
2033 ( (levels == 1) ? "menu" : "submenu")
2039 wprintf("</UL></UL>\n");
2040 wprintf("<img src=\"/static/blank.gif\" onLoad = ' \n");
2041 for (i=0; i<actnum; ++i) {
2042 wprintf(" initializeMenu(\"menu%d\", \"actuator%d\");\n", i, i);
2045 wprintf("</DIV>\n");
2046 do_template("endbox");
2050 * Boxes and rooms and lists ... oh my!
2052 void do_rooms_view(struct folder *fold, int max_folders, int num_floors) {
2055 int levels, oldlevels;
2058 static int columns = 3;
2059 int boxes_per_column = 0;
2060 int current_column = 0;
2064 while (nf % columns != 0) ++nf;
2065 boxes_per_column = (nf / columns);
2066 if (boxes_per_column < 1) boxes_per_column = 1;
2068 /* Outer table (for columnization) */
2069 wprintf("<TABLE BORDER=0 WIDTH=100%% CELLPADDING=5>"
2070 "<TR><TD VALIGN=TOP>");
2074 for (i=0; i<max_folders; ++i) {
2076 levels = num_tokens(fold[i].name, '|');
2078 if ((levels == 1) && (oldlevels > 1)) {
2081 do_template("endbox");
2084 if ((num_boxes % boxes_per_column) == 0) {
2086 if (current_column < columns) {
2087 wprintf("</TD><TD VALIGN=TOP>\n");
2094 /* Begin inner box */
2095 extract(buf, fold[i].name, levels-1);
2096 stresc(boxtitle, buf, 1, 0);
2097 svprintf("BOXTITLE", WCS_STRING, boxtitle);
2098 do_template("beginbox");
2106 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
2107 if (fold[i].selectable) {
2108 wprintf("<A HREF=\"/dotgoto?room=");
2109 urlescputs(fold[i].room);
2115 if (fold[i].hasnewmsgs) {
2116 wprintf("<SPAN CLASS=\"roomlist_new\">");
2119 wprintf("<SPAN CLASS=\"roomlist_old\">");
2121 extract(buf, fold[i].name, levels-1);
2124 if (fold[i].selectable) {
2130 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
2131 wprintf(" (INBOX)");
2136 /* End the final inner box */
2137 do_template("endbox");
2139 wprintf("</TD></TR></TABLE>\n");
2144 * Show the room list. (only should get called by
2145 * knrooms() because that's where output_headers() is called from)
2148 void list_all_rooms_by_floor(char *viewpref) {
2151 struct folder *fold = NULL;
2153 int max_folders = 0;
2154 int alloc_folders = 0;
2158 int num_floors = 1; /* add an extra one for private folders */
2160 /* Start with the mailboxes */
2163 fold = malloc(sizeof(struct folder));
2164 memset(fold, 0, sizeof(struct folder));
2165 strcpy(fold[0].name, "My folders");
2166 fold[0].is_mailbox = 1;
2168 /* Then add floors */
2171 if (buf[0]=='1') while(serv_gets(buf), strcmp(buf, "000")) {
2172 if (max_folders >= alloc_folders) {
2173 alloc_folders = max_folders + 100;
2174 fold = realloc(fold,
2175 alloc_folders * sizeof(struct folder));
2177 memset(&fold[max_folders], 0, sizeof(struct folder));
2178 extract(fold[max_folders].name, buf, 1);
2186 if (buf[0]=='1') while(serv_gets(buf), strcmp(buf, "000")) {
2187 if (max_folders >= alloc_folders) {
2188 alloc_folders = max_folders + 100;
2189 fold = realloc(fold,
2190 alloc_folders * sizeof(struct folder));
2192 memset(&fold[max_folders], 0, sizeof(struct folder));
2193 extract(fold[max_folders].room, buf, 0);
2194 ra_flags = extract_int(buf, 5);
2195 flags = extract_int(buf, 1);
2196 fold[max_folders].floor = extract_int(buf, 2);
2197 fold[max_folders].hasnewmsgs =
2198 ((ra_flags & UA_HASNEWMSGS) ? 1 : 0 );
2199 if (flags & QR_MAILBOX) {
2200 fold[max_folders].is_mailbox = 1;
2202 room_to_folder(fold[max_folders].name,
2203 fold[max_folders].room,
2204 fold[max_folders].floor,
2205 fold[max_folders].is_mailbox);
2206 fold[max_folders].selectable = 1;
2210 /* Bubble-sort the folder list */
2211 for (i=0; i<max_folders; ++i) {
2212 for (j=0; j<(max_folders-1)-i; ++j) {
2213 if (fold[j].is_mailbox == fold[j+1].is_mailbox) {
2214 swap = strcasecmp(fold[j].name, fold[j+1].name);
2217 if ( (fold[j+1].is_mailbox)
2218 && (!fold[j].is_mailbox)) {
2226 memcpy(&ftmp, &fold[j], sizeof(struct folder));
2227 memcpy(&fold[j], &fold[j+1],
2228 sizeof(struct folder));
2229 memcpy(&fold[j+1], &ftmp,
2230 sizeof(struct folder));
2235 if (!strcasecmp(viewpref, "folders")) {
2236 do_folder_view(fold, max_folders, num_floors);
2239 do_rooms_view(fold, max_folders, num_floors);
2247 /* Do either a known rooms list or a folders list, depending on the
2251 char listviewpref[SIZ];
2256 /* Determine whether the user is trying to change views */
2257 if (bstr("view") != NULL) {
2258 if (strlen(bstr("view")) > 0) {
2259 set_preference("roomlistview", bstr("view"));
2263 get_preference("roomlistview", listviewpref);
2265 if ( (strcasecmp(listviewpref, "folders"))
2266 && (strcasecmp(listviewpref, "table")) ) {
2267 strcpy(listviewpref, "rooms");
2271 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>"
2272 "<SPAN CLASS=\"titlebar\">"
2274 if (!strcasecmp(listviewpref, "rooms")) {
2275 wprintf("Room list");
2277 if (!strcasecmp(listviewpref, "folders")) {
2278 wprintf("Folder list");
2280 if (!strcasecmp(listviewpref, "table")) {
2281 wprintf("Room list");
2283 wprintf("</SPAN></TD>\n");
2286 /* offer the ability to switch views */
2287 wprintf("<TD ALIGN=RIGHT><FORM NAME=\"roomlistomatic\">\n"
2288 "<SELECT NAME=\"newview\" SIZE=\"1\" "
2289 "OnChange=\"location.href=roomlistomatic.newview.options"
2290 "[selectedIndex].value\">\n");
2292 wprintf("<OPTION %s VALUE=\"/knrooms&view=rooms\">"
2295 ( !strcasecmp(listviewpref, "rooms") ? "SELECTED" : "" )
2298 wprintf("<OPTION %s VALUE=\"/knrooms&view=folders\">"
2299 "View as folder list"
2301 ( !strcasecmp(listviewpref, "folders") ? "SELECTED" : "" )
2304 wprintf("</SELECT><BR>");
2306 wprintf("</FORM></TD></TR></TABLE>\n");
2308 /* Display the room list in the user's preferred format */
2309 list_all_rooms_by_floor(listviewpref);
2315 * Set the message expire policy for this room and/or floor
2317 void set_room_policy(void) {
2320 if (strcmp(bstr("sc"), "OK")) {
2321 strcpy(WC->ImportantMessage,
2322 "Cancelled. Changes were not saved.");
2327 serv_printf("SPEX room|%d|%d", atoi(bstr("roompolicy")), atoi(bstr("roomvalue")));
2329 strcpy(WC->ImportantMessage, &buf[4]);
2331 if (WC->axlevel >= 6) {
2332 strcat(WC->ImportantMessage, "<BR>\n");
2333 serv_printf("SPEX floor|%d|%d", atoi(bstr("floorpolicy")), atoi(bstr("floorvalue")));
2335 strcat(WC->ImportantMessage, &buf[4]);