10 #include <sys/types.h>
12 #include <sys/socket.h>
15 #include <netinet/in.h>
32 char floorlist[128][SIZ];
35 * load the list of floors
37 void load_floorlist(void)
42 for (a = 0; a < 128; ++a)
48 strcpy(floorlist[0], "Main Floor");
51 while (serv_gets(buf), strcmp(buf, "000")) {
52 extract(floorlist[extract_int(buf, 0)], buf, 1);
58 * remove a room from the march list
60 void remove_march(char *aaa)
62 struct march *mptr, *mptr2;
64 if (WC->march == NULL)
67 if (!strcasecmp(WC->march->march_name, aaa)) {
68 mptr = WC->march->next;
74 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
75 if (!strcasecmp(mptr->march_name, aaa)) {
76 mptr2->next = mptr->next;
89 void room_tree_list(struct roomlisting *rp)
97 if (rp->lnext != NULL) {
98 room_tree_list(rp->lnext);
100 strcpy(rmname, rp->rlname);
103 wprintf("<A HREF=\"/dotgoto&room=");
108 if ((f & QR_DIRECTORY) && (f & QR_NETWORK))
110 else if (f & QR_DIRECTORY)
112 else if (f & QR_NETWORK)
116 wprintf("</A><TT> </TT>\n");
118 if (rp->rnext != NULL) {
119 room_tree_list(rp->rnext);
126 * Room ordering stuff (compare first by floor, then by order)
128 int rordercmp(struct roomlisting *r1, struct roomlisting *r2)
130 if ((r1 == NULL) && (r2 == NULL))
136 if (r1->rlfloor < r2->rlfloor)
138 if (r1->rlfloor > r2->rlfloor)
140 if (r1->rlorder < r2->rlorder)
142 if (r1->rlorder > r2->rlorder)
149 * Common code for all room listings
151 void listrms(char *variety)
156 struct roomlisting *rl = NULL;
157 struct roomlisting *rp;
158 struct roomlisting *rs;
161 /* Ask the server for a room list */
168 while (serv_gets(buf), strcmp(buf, "000")) {
170 rp = malloc(sizeof(struct roomlisting));
171 extract(rp->rlname, buf, 0);
172 rp->rlflags = extract_int(buf, 1);
173 rp->rlfloor = extract_int(buf, 2);
174 rp->rlorder = extract_int(buf, 3);
183 if (rordercmp(rp, rs) < 0) {
184 if (rs->lnext == NULL) {
191 if (rs->rnext == NULL) {
203 /* If no rooms were listed, print an nbsp to make the cell
204 * borders show up anyway.
206 if (num_rooms == 0) wprintf(" ");
218 * list all rooms by floor
220 void list_all_rooms_by_floor(void)
229 wprintf("<TABLE width=100%% border><TR><TH>Floor</TH>");
230 wprintf("<TH>Rooms with new messages</TH>");
231 wprintf("<TH>Rooms with no new messages</TH></TR>\n");
233 for (a = 0; a < 128; ++a)
234 if (floorlist[a][0] != 0) {
236 /* Floor name column */
239 serv_printf("OIMG _floorpic_|%d", a);
244 wprintf("<IMG SRC=\"/image&name=_floorpic_&parm=%d\" ALT=\"%s\">",
245 a, &floorlist[a][0]);
247 escputs(&floorlist[a][0]);
252 /* Rooms with new messages column */
254 sprintf(buf, "LKRN %d", a);
256 wprintf("</TD>\n<TD>");
258 /* Rooms with old messages column */
259 sprintf(buf, "LKRO %d", a);
261 wprintf("</TD></TR>\n");
263 wprintf("</TABLE>\n");
269 * list all forgotten rooms
271 void zapped_list(void)
274 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=770000><TR><TD>");
275 wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
276 wprintf("<B>Zapped (forgotten) rooms</B>\n");
277 wprintf("</TD></TR></TABLE><BR>\n");
279 wprintf("<BR><BR>\n");
280 wprintf("Click on any room to un-zap it and goto that room.\n");
286 * read this room's info file (set v to 1 for verbose mode)
302 /* Display room graphic. The server doesn't actually
303 * need the room name, but we supply it in order to
304 * keep the browser from using a cached graphic from
307 void embed_room_graphic(void) {
310 serv_puts("OIMG _roompic_");
313 wprintf("<TD BGCOLOR=444455>");
314 wprintf("<IMG SRC=\"/image&name=_roompic_&room=");
315 urlescputs(WC->wc_roomname);
324 /* Let the user know if new mail has arrived
326 void embed_newmail_button(void) {
327 if ( (WC->new_mail > WC->remember_new_mail) && (WC->new_mail>0) ) {
329 "<A HREF=\"/dotgoto?room=_MAIL_\">"
330 "<IMG SRC=\"/static/mail.gif\" border=0 "
331 "ALT=\"You have new mail\">"
332 "<BR><FONT SIZE=2 COLOR=FFFFFF>"
333 "%d new mail</FONT></A>", WC->new_mail);
334 WC->remember_new_mail = WC->new_mail;
341 * Display the current view and offer an option to change it
343 void embed_view_o_matic(void) {
346 wprintf("<FORM NAME=\"viewomatic\">\n"
347 "<SELECT NAME=\"newview\" SIZE=\"1\" "
348 "OnChange=\"location.href=viewomatic.newview.options"
349 "[selectedIndex].value\">\n");
351 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
352 wprintf("<OPTION %s VALUE=\"/changeview?view=%d\">",
353 ((i == WC->wc_view) ? "SELECTED" : ""),
355 escputs(viewdefs[i]);
356 wprintf("</OPTION>\n");
358 wprintf("</SELECT></FORM>\n");
363 void embed_room_banner(char *got) {
366 /* We need to have the information returned by a GOTO server command.
367 * If it isn't supplied, we fake it by issuing our own GOTO.
370 serv_printf("GOTO %s", WC->wc_roomname);
375 /* Check for new mail. */
376 WC->new_mail = extract_int(&got[4], 9);
377 WC->wc_view = extract_int(&got[4], 11);
379 svprintf("ROOMNAME", WCS_STRING, "%s", WC->wc_roomname);
380 svprintf("NEWMSGS", WCS_STRING, "%d", extract_int(&got[4], 1));
381 svprintf("TOTALMSGS", WCS_STRING, "%d", extract_int(&got[4], 2));
382 svcallback("ROOMPIC", embed_room_graphic);
383 svcallback("ROOMINFO", readinfo);
384 svcallback("YOUHAVEMAIL", embed_newmail_button);
385 svcallback("VIEWOMATIC", embed_view_o_matic);
387 do_template("roombanner");
388 clear_local_substs();
396 * generic routine to take the session to a new room
398 * display_name values: 0 = goto only
399 * 1 = goto and display
402 void gotoroom(char *gname, int display_name)
405 static long ls = (-1L);
410 wprintf("Pragma: no-cache\n");
411 wprintf("Cache-Control: no-store\n");
413 wprintf("<HTML><HEAD>\n"
414 "<META HTTP-EQUIV=\"refresh\" CONTENT=\"500363689;\">\n"
415 "<META HTTP-EQUIV=\"Pragma\" CONTENT=\"no-cache\">\n"
416 "<META HTTP-EQUIV=\"expired\" CONTENT=\"28-May-1971 18:10:00 GMT\">\n"
417 "<meta name=\"MSSmartTagsPreventParsing\" content=\"TRUE\">\n"
419 do_template("background");
421 if (display_name != 2) {
422 /* store ungoto information */
423 strcpy(WC->ugname, WC->wc_roomname);
426 /* move to the new room */
427 serv_printf("GOTO %s", gname);
430 serv_puts("GOTO _BASEROOM_");
435 wprintf("<EM>%s</EM><BR>\n", &buf[4]);
440 extract(WC->wc_roomname, &buf[4], 0);
441 WC->room_flags = extract_int(&buf[4], 4);
442 /* highest_msg_read = extract_int(&buf[4],6);
443 maxmsgnum = extract_int(&buf[4],5);
444 is_mail = (char) extract_int(&buf[4],7); */
445 ls = extract_long(&buf[4], 6);
448 WC->is_room_aide = WC->is_aide;
450 WC->is_room_aide = (char) extract_int(&buf[4], 8);
452 remove_march(WC->wc_roomname);
453 if (!strcasecmp(gname, "_BASEROOM_"))
456 /* Display the room banner */
458 embed_room_banner(buf);
461 strcpy(WC->wc_roomname, WC->wc_roomname);
462 WC->wc_view = extract_int(&buf[4], 11);
467 * Locate the room on the march list which we most want to go to. Each room
468 * is measured given a "weight" of preference based on various factors.
470 char *pop_march(int desired_floor)
472 static char TheRoom[64];
474 int TheOrder = 32767;
477 struct march *mptr = NULL;
479 strcpy(TheRoom, "_BASEROOM_");
480 if (WC->march == NULL)
483 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
485 if ((strcasecmp(mptr->march_name, "_BASEROOM_")))
486 weight = weight + 10000;
487 if (mptr->march_floor == desired_floor)
488 weight = weight + 5000;
490 weight = weight + ((128 - (mptr->march_floor)) * 128);
491 weight = weight + (128 - (mptr->march_order));
493 if (weight > TheWeight) {
495 strcpy(TheRoom, mptr->march_name);
496 TheFloor = mptr->march_floor;
497 TheOrder = mptr->march_order;
505 /* Goto next room having unread messages.
506 * We want to skip over rooms that the user has already been to, and take the
507 * user back to the lobby when done. The room we end up in is placed in
508 * newroom - which is set to 0 (the lobby) initially.
509 * We start the search in the current room rather than the beginning to prevent
510 * two or more concurrent users from dragging each other back to the same room.
515 struct march *mptr, *mptr2;
518 /* First check to see if the march-mode list is already allocated.
519 * If it is, pop the first room off the list and go there.
522 if (WC->march == NULL) {
526 while (serv_gets(buf), strcmp(buf, "000")) {
527 mptr = (struct march *) malloc(sizeof(struct march));
529 extract(mptr->march_name, buf, 0);
530 mptr->march_floor = extract_int(buf, 2);
531 mptr->march_order = extract_int(buf, 3);
532 if (WC->march == NULL) {
536 while (mptr2->next != NULL)
541 /* add _BASEROOM_ to the end of the march list, so the user will end up
542 * in the system base room (usually the Lobby>) at the end of the loop
544 mptr = (struct march *) malloc(sizeof(struct march));
546 strcpy(mptr->march_name, "_BASEROOM_");
547 if (WC->march == NULL) {
551 while (mptr2->next != NULL)
556 * ...and remove the room we're currently in, so a <G>oto doesn't make us
557 * walk around in circles
559 remove_march(WC->wc_roomname);
561 if (WC->march != NULL) {
562 strcpy(next_room, pop_march(-1));
564 strcpy(next_room, "_BASEROOM_");
568 smart_goto(next_room);
572 void smart_goto(char *next_room) {
573 gotoroom(next_room, 0);
580 * mark all messages in current room as having been read
582 void slrp_highest(void)
587 serv_puts("SLRP HIGHEST");
590 wprintf("<EM>%s</EM><BR>\n", &buf[4]);
597 * un-goto the previous room
603 if (!strcmp(WC->ugname, "")) {
604 smart_goto(WC->wc_roomname);
607 serv_printf("GOTO %s", WC->ugname);
610 smart_goto(WC->wc_roomname);
613 if (WC->uglsn >= 0L) {
614 serv_printf("SLRP %ld", WC->uglsn);
617 strcpy(buf, WC->ugname);
618 strcpy(WC->ugname, "");
623 * display the form for editing a room
625 void display_editroom(void)
632 char er_password[10];
634 char er_roomaide[26];
640 char *not_shared_with;
643 if (strlen(tab) == 0) tab = "admin";
649 display_error(&buf[4]);
652 extract(er_name, &buf[4], 0);
653 extract(er_password, &buf[4], 1);
654 extract(er_dirname, &buf[4], 2);
655 er_flags = extract_int(&buf[4], 3);
656 er_floor = extract_int(&buf[4], 4);
660 /* print the tabbed dialog */
661 wprintf("<TABLE border=0 width=100%%><TR BGCOLOR=FFFFFF><TD> </TD>");
663 if (!strcmp(tab, "admin")) {
664 wprintf("<TD BGCOLOR=000077><FONT SIZE=+1 COLOR=\"FFFFFF\"><B>");
667 wprintf("<TD><A HREF=\"/display_editroom&tab=admin\">");
669 wprintf("Room administration");
670 if (!strcmp(tab, "admin")) {
671 wprintf("</B></FONT></TD>\n");
674 wprintf("</A></TD>\n");
677 wprintf("<TD> </TD>\n");
679 if (!strcmp(tab, "config")) {
680 wprintf("<TD BGCOLOR=000077><FONT SIZE=+1 COLOR=\"FFFFFF\"><B>");
683 wprintf("<TD><A HREF=\"/display_editroom&tab=config\">");
685 wprintf("Room configuration");
686 if (!strcmp(tab, "config")) {
687 wprintf("</B></FONT></TD>\n");
690 wprintf("</A></TD>\n");
693 wprintf("<TD> </TD>\n");
695 if (!strcmp(tab, "sharing")) {
696 wprintf("<TD BGCOLOR=000077><FONT SIZE=+1 COLOR=\"FFFFFF\"><B>");
699 wprintf("<TD><A HREF=\"/display_editroom&tab=sharing\">");
702 if (!strcmp(tab, "sharing")) {
703 wprintf("</B></FONT></TD>\n");
706 wprintf("</A></TD>\n");
709 wprintf("<TD> </TD>\n");
711 if (!strcmp(tab, "listserv")) {
712 wprintf("<TD BGCOLOR=000077><FONT SIZE=+1 COLOR=\"FFFFFF\"><B>");
715 wprintf("<TD><A HREF=\"/display_editroom&tab=listserv\">");
717 wprintf("Mailing list service");
718 if (!strcmp(tab, "listserv")) {
719 wprintf("</B></FONT></TD>\n");
722 wprintf("</A></TD>\n");
725 wprintf("<TD> </TD></TR></TABLE>\n");
727 /* end tabbed dialog */
730 if (!strcmp(tab, "admin")) {
732 "<LI><A HREF=\"/confirm_delete_room\">\n"
733 "Delete this room</A>\n"
734 "<LI><A HREF=\"/display_editroompic\">\n"
735 "Set or change the graphic for this room's banner</A>\n"
736 "<LI><A HREF=\"/display_editinfo\">\n"
737 "Edit this room's Info file</A>\n"
741 if (!strcmp(tab, "config")) {
742 wprintf("<FORM METHOD=\"POST\" ACTION=\"/editroom\">\n");
744 wprintf("<UL><LI>Name of room: ");
745 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\"19\">\n", er_name);
747 wprintf("<LI>Resides on floor: ");
749 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
750 for (i = 0; i < 128; ++i)
751 if (strlen(floorlist[i]) > 0) {
754 wprintf("SELECTED ");
755 wprintf("VALUE=\"%d\">", i);
756 escputs(floorlist[i]);
757 wprintf("</OPTION>\n");
759 wprintf("</SELECT>\n");
761 wprintf("<LI>Type of room:<UL>\n");
763 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
764 if ((er_flags & QR_PRIVATE) == 0)
766 wprintf("> Public room\n");
768 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"guessname\" ");
769 if ((er_flags & QR_PRIVATE) &&
770 (er_flags & QR_GUESSNAME))
772 wprintf("> Private - guess name\n");
774 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
775 if ((er_flags & QR_PRIVATE) &&
776 (er_flags & QR_PASSWORDED))
778 wprintf("> Private - require password:\n");
779 wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n", er_password);
781 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
782 if ((er_flags & QR_PRIVATE)
783 && ((er_flags & QR_GUESSNAME) == 0)
784 && ((er_flags & QR_PASSWORDED) == 0))
786 wprintf("> Private - invitation only\n");
788 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
789 wprintf("> If private, cause current users to forget room\n");
793 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
794 if (er_flags & QR_PREFONLY)
796 wprintf("> Preferred users only\n");
798 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
799 if (er_flags & QR_READONLY)
801 wprintf("> Read-only room\n");
803 /* directory stuff */
804 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
805 if (er_flags & QR_DIRECTORY)
807 wprintf("> File directory room\n");
809 wprintf("<UL><LI>Directory name: ");
810 wprintf("<INPUT TYPE=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n", er_dirname);
812 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
813 if (er_flags & QR_UPLOAD)
815 wprintf("> Uploading allowed\n");
817 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
818 if (er_flags & QR_DOWNLOAD)
820 wprintf("> Downloading allowed\n");
822 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
823 if (er_flags & QR_VISDIR)
825 wprintf("> Visible directory</UL>\n");
827 /* end of directory stuff */
829 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
830 if (er_flags & QR_NETWORK)
832 wprintf("> Network shared room\n");
834 /* start of anon options */
836 wprintf("<LI>Anonymous messages<UL>\n");
838 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
839 if (((er_flags & QR_ANONONLY) == 0)
840 && ((er_flags & QR_ANONOPT) == 0))
842 wprintf("> No anonymous messages\n");
844 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
845 if (er_flags & QR_ANONONLY)
847 wprintf("> All messages are anonymous\n");
849 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
850 if (er_flags & QR_ANONOPT)
852 wprintf("> Prompt user when entering messages</UL>\n");
854 /* end of anon options */
856 wprintf("<LI>Room aide: \n");
860 wprintf("<EM>%s</EM>\n", &buf[4]);
862 extract(er_roomaide, &buf[4], 0);
863 wprintf("<INPUT TYPE=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n", er_roomaide);
866 wprintf("</UL><CENTER>\n");
867 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
868 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
869 wprintf("</CENTER>\n");
873 /* Sharing the room with other Citadel nodes... */
874 if (!strcmp(tab, "sharing")) {
876 shared_with = strdup("");
877 not_shared_with = strdup("");
879 /* Learn the current configuration */
880 serv_puts("CONF getsys|application/x-citadel-ignet-config");
882 if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
883 extract(node, buf, 0);
884 not_shared_with = realloc(not_shared_with,
885 strlen(not_shared_with) + 32);
886 strcat(not_shared_with, node);
887 strcat(not_shared_with, "|");
892 if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
893 extract(cmd, buf, 0);
894 extract(node, buf, 1);
895 if (!strcasecmp(cmd, "ignet_push_share")) {
896 shared_with = realloc(shared_with,
897 strlen(shared_with) + 32);
898 strcat(shared_with, node);
899 strcat(shared_with, "|");
903 for (i=0; i<num_tokens(shared_with, '|'); ++i) {
904 extract(node, shared_with, i);
905 for (j=0; j<num_tokens(not_shared_with, '|'); ++j) {
906 extract(cmd, not_shared_with, j);
907 if (!strcasecmp(node, cmd)) {
908 remove_token(not_shared_with, j, '|');
913 /* Display the stuff */
914 wprintf("<CENTER><BR>"
915 "<TABLE border=1 cellpadding=5><TR>"
916 "<TD><B><I>Shared with</I></B></TD>"
917 "<TD><B><I>Not shared with</I></B></TD></TR>\n"
920 for (i=0; i<num_tokens(shared_with, '|'); ++i) {
921 extract(node, shared_with, i);
922 if (strlen(node) > 0) {
923 wprintf("%s ", node);
924 wprintf("<A HREF=\"/netedit&cmd=remove&line="
925 "ignet_push_share|");
927 wprintf("&tab=sharing\">(unshare)</A><BR>");
931 wprintf("</TD><TD>\n");
933 for (i=0; i<num_tokens(not_shared_with, '|'); ++i) {
934 extract(node, not_shared_with, i);
935 if (strlen(node) > 0) {
936 wprintf("%s ", node);
937 wprintf("<A HREF=\"/netedit&cmd=add&line="
938 "ignet_push_share|");
940 wprintf("&tab=sharing\">(share)</A><BR>");
944 wprintf("</TD></TR></TABLE><BR>\n"
945 "<I><B>Reminder:</B> When sharing a room, "
946 "it must be shared from both ends. Adding a node to "
947 "the 'shared' list sends messages out, but in order to"
948 " receive messages, the other nodes must be configured"
949 " to send messages out to your system as well.</I><BR>"
954 /* Mailing list management */
955 if (!strcmp(tab, "listserv")) {
957 wprintf("<BR><center><i>The contents of this room are being "
958 "mailed to the following list recipients:"
963 if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
964 extract(cmd, buf, 0);
965 if (!strcasecmp(cmd, "listrecp")) {
966 extract(recp, buf, 1);
969 wprintf(" <A HREF=\"/netedit&cmd=remove&line="
972 wprintf("&tab=listserv\">(remove)</A><BR>");
976 wprintf("<BR><FORM METHOD=\"POST\" ACTION=\"/netedit\">\n"
977 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
978 "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"listrecp|\">\n");
979 wprintf("<INPUT TYPE=\"text\" NAME=\"line\">\n");
980 wprintf("<INPUT TYPE=\"submit\" NAME=\"cmd\" VALUE=\"Add\">");
981 wprintf("</FORM><BR></CENTER>\n");
989 * save new parameters for a room
995 char er_password[10];
997 char er_roomaide[26];
1003 if (strcmp(bstr("sc"), "OK")) {
1004 display_error("Cancelled. Changes were not saved.");
1010 if (buf[0] != '2') {
1011 display_error(&buf[4]);
1014 extract(er_name, &buf[4], 0);
1015 extract(er_password, &buf[4], 1);
1016 extract(er_dirname, &buf[4], 2);
1017 er_flags = extract_int(&buf[4], 3);
1019 strcpy(er_roomaide, bstr("er_roomaide"));
1020 if (strlen(er_roomaide) == 0) {
1023 if (buf[0] != '2') {
1024 strcpy(er_roomaide, "");
1026 extract(er_roomaide, &buf[4], 0);
1029 strcpy(buf, bstr("er_name"));
1031 if (strlen(buf) > 0)
1032 strcpy(er_name, buf);
1034 strcpy(buf, bstr("er_password"));
1036 if (strlen(buf) > 0)
1037 strcpy(er_password, buf);
1039 strcpy(buf, bstr("er_dirname"));
1041 if (strlen(buf) > 0)
1042 strcpy(er_dirname, buf);
1044 strcpy(buf, bstr("type"));
1045 er_flags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME);
1047 if (!strcmp(buf, "invonly")) {
1048 er_flags |= (QR_PRIVATE);
1050 if (!strcmp(buf, "guessname")) {
1051 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
1053 if (!strcmp(buf, "passworded")) {
1054 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
1056 if (!strcmp(bstr("prefonly"), "yes")) {
1057 er_flags |= QR_PREFONLY;
1059 er_flags &= ~QR_PREFONLY;
1062 if (!strcmp(bstr("readonly"), "yes")) {
1063 er_flags |= QR_READONLY;
1065 er_flags &= ~QR_READONLY;
1068 if (!strcmp(bstr("network"), "yes")) {
1069 er_flags |= QR_NETWORK;
1071 er_flags &= ~QR_NETWORK;
1074 if (!strcmp(bstr("directory"), "yes")) {
1075 er_flags |= QR_DIRECTORY;
1077 er_flags &= ~QR_DIRECTORY;
1080 if (!strcmp(bstr("ulallowed"), "yes")) {
1081 er_flags |= QR_UPLOAD;
1083 er_flags &= ~QR_UPLOAD;
1086 if (!strcmp(bstr("dlallowed"), "yes")) {
1087 er_flags |= QR_DOWNLOAD;
1089 er_flags &= ~QR_DOWNLOAD;
1092 if (!strcmp(bstr("visdir"), "yes")) {
1093 er_flags |= QR_VISDIR;
1095 er_flags &= ~QR_VISDIR;
1098 strcpy(buf, bstr("anon"));
1100 er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
1101 if (!strcmp(buf, "anononly"))
1102 er_flags |= QR_ANONONLY;
1103 if (!strcmp(buf, "anon2"))
1104 er_flags |= QR_ANONOPT;
1107 if (!strcmp(bstr("bump"), "yes"))
1110 er_floor = atoi(bstr("er_floor"));
1112 sprintf(buf, "SETR %s|%s|%s|%u|%d|%d",
1113 er_name, er_password, er_dirname, er_flags, bump, er_floor);
1116 if (buf[0] != '2') {
1117 display_error(&buf[4]);
1120 gotoroom(er_name, 0);
1122 if (strlen(er_roomaide) > 0) {
1123 sprintf(buf, "SETA %s", er_roomaide);
1126 if (buf[0] != '2') {
1127 display_error(&buf[4]);
1131 smart_goto(er_name);
1135 * Invite, Kick, and show Who Knows a room
1137 void display_whok(void)
1139 char buf[SIZ], room[SIZ], username[SIZ];
1144 if (buf[0] != '2') {
1145 display_error(&buf[4]);
1148 extract(room, &buf[4], 0);
1150 strcpy(username, bstr("username"));
1154 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=007700><TR><TD>");
1155 wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"<B>Access control list for ");
1156 escputs(WC->wc_roomname);
1157 wprintf("</B></FONT></TD></TR></TABLE>\n");
1159 if(!strcmp(bstr("sc"), "Kick")) {
1160 sprintf(buf, "KICK %s", username);
1164 if (buf[0] != '2') {
1165 display_error(&buf[4]);
1168 wprintf("<B><I>User %s kicked out of room %s.</I></B>\n",
1171 } else if(!strcmp(bstr("sc"), "Invite")) {
1172 sprintf(buf, "INVT %s", username);
1176 if (buf[0] != '2') {
1177 display_error(&buf[4]);
1180 wprintf("<B><I>User %s invited to room %s.</I></B>\n",
1187 wprintf("<TABLE border=0 CELLSPACING=10><TR VALIGN=TOP>"
1188 "<TD>The users listed below have access to this room. "
1189 "To remove a user from the access list, select the user "
1190 "name from the list and click 'Kick'.<BR><BR>");
1192 wprintf("<CENTER><FORM METHOD=\"POST\" ACTION=\"/display_whok\">\n");
1193 wprintf("<SELECT NAME=\"username\" SIZE=10>\n");
1196 if (buf[0] == '1') {
1197 while (serv_gets(buf), strcmp(buf, "000")) {
1198 extract(username, buf, 0);
1199 wprintf("<OPTION>");
1204 wprintf("</SELECT><BR>\n");
1206 wprintf("<input type=submit name=sc value=\"Kick\">");
1207 wprintf("</FORM></CENTER>\n");
1210 "To grant another user access to this room, enter the "
1211 "user name in the box below and click 'Invite'.<BR><BR>");
1213 wprintf("<CENTER><FORM METHOD=\"POST\" ACTION=\"/display_whok\">\n");
1214 wprintf("Invite: ");
1215 wprintf("<input type=text name=username><BR>\n"
1216 "<input type=hidden name=sc value=\"Invite\">"
1217 "<input type=submit value=\"Invite\">"
1218 "</FORM></CENTER>\n");
1220 wprintf("</TD></TR></TABLE>\n");
1227 * display the form for entering a new room
1229 void display_entroom(void)
1234 serv_puts("CRE8 0");
1237 if (buf[0] != '2') {
1238 display_error(&buf[4]);
1243 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=000077><TR><TD>");
1244 wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
1245 wprintf("<B>Enter (create) a new room</B>\n");
1246 wprintf("</FONT></TD></TR></TABLE>\n");
1248 wprintf("<FORM METHOD=\"POST\" ACTION=\"/entroom\">\n");
1250 wprintf("<UL><LI>Name of room: ");
1251 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" MAXLENGTH=\"19\">\n");
1253 wprintf("<LI>Type of room:<UL>\n");
1255 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1256 wprintf("CHECKED > Public room\n");
1258 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"guessname\" ");
1259 wprintf("> Private - guess name\n");
1261 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
1262 wprintf("> Private - require password:\n");
1263 wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
1265 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
1266 wprintf("> Private - invitation only\n");
1269 wprintf("<LI>Resides on floor: ");
1271 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
1272 for (i = 0; i < 128; ++i)
1273 if (strlen(floorlist[i]) > 0) {
1274 wprintf("<OPTION ");
1275 wprintf("VALUE=\"%d\">", i);
1276 escputs(floorlist[i]);
1277 wprintf("</OPTION>\n");
1279 wprintf("</SELECT>\n");
1283 wprintf("<CENTER>\n");
1284 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
1285 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1286 wprintf("</CENTER>\n");
1287 wprintf("</FORM>\n<HR>");
1288 serv_printf("MESG roomaccess");
1290 if (buf[0] == '1') {
1306 char er_password[10];
1310 if (strcmp(bstr("sc"), "OK")) {
1311 display_error("Cancelled. No new room was created.");
1314 strcpy(er_name, bstr("er_name"));
1315 strcpy(er_type, bstr("type"));
1316 strcpy(er_password, bstr("er_password"));
1317 er_floor = atoi(bstr("er_floor"));
1320 if (!strcmp(er_type, "guessname"))
1322 if (!strcmp(er_type, "passworded"))
1324 if (!strcmp(er_type, "invonly"))
1327 sprintf(buf, "CRE8 1|%s|%d|%s|%d",
1328 er_name, er_num_type, er_password, er_floor);
1331 if (buf[0] != '2') {
1332 display_error(&buf[4]);
1335 smart_goto(er_name);
1340 * display the screen to enter a private room
1342 void display_private(char *rname, int req_pass)
1347 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=770000><TR><TD>");
1348 wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
1349 wprintf("<B>Goto a private room</B>\n");
1350 wprintf("</FONT></TD></TR></TABLE>\n");
1352 wprintf("<CENTER>\n");
1353 wprintf("If you know the name of a hidden (guess-name) or\n");
1354 wprintf("passworded room, you can enter that room by typing\n");
1355 wprintf("its name below. Once you gain access to a private\n");
1356 wprintf("room, it will appear in your regular room listings\n");
1357 wprintf("so you don't have to keep returning here.\n");
1358 wprintf("<BR><BR>");
1360 wprintf("<FORM METHOD=\"POST\" ACTION=\"/goto_private\">\n");
1362 wprintf("<TABLE border><TR><TD>");
1363 wprintf("Enter room name:</TD><TD>");
1364 wprintf("<INPUT TYPE=\"text\" NAME=\"gr_name\" VALUE=\"%s\" MAXLENGTH=\"19\">\n", rname);
1367 wprintf("</TD></TR><TR><TD>");
1368 wprintf("Enter room password:</TD><TD>");
1369 wprintf("<INPUT TYPE=\"password\" NAME=\"gr_pass\" MAXLENGTH=\"9\">\n");
1371 wprintf("</TD></TR></TABLE>\n");
1373 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
1374 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1375 wprintf("</FORM>\n");
1380 * goto a private room
1382 void goto_private(void)
1387 if (strcasecmp(bstr("sc"), "OK")) {
1388 display_main_menu();
1391 strcpy(hold_rm, WC->wc_roomname);
1392 strcpy(buf, "GOTO ");
1393 strcat(buf, bstr("gr_name"));
1395 strcat(buf, bstr("gr_pass"));
1399 if (buf[0] == '2') {
1400 smart_goto(bstr("gr_name"));
1403 if (!strncmp(buf, "540", 3)) {
1404 display_private(bstr("gr_name"), 1);
1408 wprintf("%s\n", &buf[4]);
1415 * display the screen to zap a room
1417 void display_zap(void)
1421 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=770000><TR><TD>");
1422 wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
1423 wprintf("<B>Zap (forget) the current room</B>\n");
1424 wprintf("</FONT></TD></TR></TABLE>\n");
1426 wprintf("If you select this option, <em>%s</em> will ", WC->wc_roomname);
1427 wprintf("disappear from your room list. Is this what you wish ");
1428 wprintf("to do?<BR>\n");
1430 wprintf("<FORM METHOD=\"POST\" ACTION=\"/zap\">\n");
1431 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
1432 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1433 wprintf("</FORM>\n");
1444 char final_destination[SIZ];
1446 /* If the forget-room routine fails for any reason, we fall back
1447 * to the current room; otherwise, we go to the Lobby
1449 strcpy(final_destination, WC->wc_roomname);
1451 if (!strcasecmp(bstr("sc"), "OK")) {
1452 serv_printf("GOTO %s", WC->wc_roomname);
1454 if (buf[0] != '2') {
1455 /* ExpressMessageCat(&buf[4]); */
1459 if (buf[0] != '2') {
1460 /* ExpressMessageCat(&buf[4]); */
1462 strcpy(final_destination, "_BASEROOM_");
1466 smart_goto(final_destination);
1473 * Confirm deletion of the current room
1475 void confirm_delete_room(void)
1479 serv_puts("KILL 0");
1481 if (buf[0] != '2') {
1482 display_error(&buf[4]);
1486 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=770000><TR><TD>");
1487 wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
1488 wprintf("<B>Confirm deletion of room</B>\n");
1489 wprintf("</FONT></TD></TR></TABLE>\n");
1491 wprintf("<CENTER>");
1492 wprintf("<FORM METHOD=\"POST\" ACTION=\"/delete_room\">\n");
1494 wprintf("Are you sure you want to delete <FONT SIZE=+1>");
1495 escputs(WC->wc_roomname);
1496 wprintf("</FONT>?<BR>\n");
1498 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Delete\">");
1499 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1501 wprintf("</FORM></CENTER>\n");
1507 * Delete the current room
1509 void delete_room(void)
1514 strcpy(sc, bstr("sc"));
1516 if (strcasecmp(sc, "Delete")) {
1517 display_error("Cancelled. This room was not deleted.");
1520 serv_puts("KILL 1");
1522 if (buf[0] != '2') {
1523 display_error(&buf[4]);
1525 smart_goto("_BASEROOM_");
1532 * Perform changes to a room's network configuration
1534 void netedit(void) {
1539 if (strlen(bstr("line"))==0) {
1544 strcpy(line, bstr("prefix"));
1545 strcat(line, bstr("line"));
1546 strcat(line, bstr("suffix"));
1556 if (buf[0] != '1') {
1562 /* This loop works for add *or* remove. Spiffy, eh? */
1563 while (serv_gets(buf), strcmp(buf, "000")) {
1564 if (strcasecmp(buf, line)) {
1565 fprintf(fp, "%s\n", buf);
1572 if (buf[0] != '4') {
1578 while (fgets(buf, sizeof buf, fp) != NULL) {
1579 buf[strlen(buf)-1] = 0;
1583 if (!strcasecmp(bstr("cmd"), "add")) {
1595 * Convert a room name to a folder-ish-looking name.
1597 void room_to_folder(char *folder, char *room, int floor, int is_mailbox)
1602 * For mailboxes, just do it straight...
1605 sprintf(folder, "My folders|%s", room);
1609 * Otherwise, prefix the floor name as a "public folders" moniker
1612 sprintf(folder, "%s|%s", floorlist[floor], room);
1616 * Replace "/" characters with "|" for pseudo-folder-delimiting
1618 for (i=0; i<strlen(folder); ++i) {
1619 if (folder[i] == '/') folder[i] = '|';
1630 * Change the view for this room
1632 void change_view(void) {
1636 view = atol(bstr("view"));
1638 serv_printf("VIEW %d", view);
1640 smart_goto(WC->wc_roomname);
1645 * Show the room list in "folders" format
1647 void folders(void) {
1650 int levels, oldlevels;
1660 struct folder *fold = NULL;
1662 int max_folders = 0;
1663 int alloc_folders = 0;
1673 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=000077><TR><TD>"
1674 "<FONT SIZE=+1 COLOR=\"FFFFFF\""
1675 "<B>Folder list</B>\n"
1676 "</TD></TR></TABLE><BR>\n"
1679 /* Start with the mailboxes */
1682 fold = malloc(sizeof(struct folder));
1683 memset(fold, 0, sizeof(struct folder));
1684 strcpy(fold[0].name, "My folders");
1686 /* Then add floors */
1689 if (buf[0]=='1') while(serv_gets(buf), strcmp(buf, "000")) {
1690 if (max_folders >= alloc_folders) {
1691 alloc_folders = max_folders + 100;
1692 fold = realloc(fold,
1693 alloc_folders * sizeof(struct folder));
1695 memset(&fold[max_folders], 0, sizeof(struct folder));
1696 extract(fold[max_folders].name, buf, 1);
1701 for (p = 0; p < 2; ++p) {
1702 if (p == 0) serv_puts("LKRN");
1703 else if (p == 1) serv_puts("LKRO");
1705 if (buf[0]=='1') while(serv_gets(buf), strcmp(buf, "000")) {
1706 if (max_folders >= alloc_folders) {
1707 alloc_folders = max_folders + 100;
1708 fold = realloc(fold,
1709 alloc_folders * sizeof(struct folder));
1711 memset(&fold[max_folders], 0, sizeof(struct folder));
1712 extract(fold[max_folders].room, buf, 0);
1713 if (p == 0) fold[max_folders].hasnewmsgs = 1;
1714 flags = extract_int(buf, 1);
1715 floor = extract_int(buf, 2);
1716 if (flags & QR_MAILBOX) {
1717 fold[max_folders].is_mailbox = 1;
1719 room_to_folder(fold[max_folders].name,
1720 fold[max_folders].room,
1722 fold[max_folders].is_mailbox);
1723 fold[max_folders].selectable = 1;
1728 /* Bubble-sort the folder list */
1729 for (i=0; i<max_folders; ++i) {
1730 for (j=0; j<(max_folders-1)-i; ++j) {
1731 if (strcasecmp(fold[j].name, fold[j+1].name) > 0) {
1732 memcpy(&ftmp, &fold[j], sizeof(struct folder));
1733 memcpy(&fold[j], &fold[j+1],
1734 sizeof(struct folder));
1735 memcpy(&fold[j+1], &ftmp,
1736 sizeof(struct folder));
1745 for (i=0; i<max_folders; ++i) {
1747 levels = num_tokens(fold[i].name, '|');
1748 if (levels > oldlevels) {
1749 for (k=0; k<(levels-oldlevels); ++k) {
1754 if (levels < oldlevels) {
1755 for (k=0; k<(oldlevels-levels); ++k) {
1763 if (fold[i].selectable) {
1764 wprintf("<A HREF=\"/dotgoto?room=");
1765 urlescputs(fold[i].room);
1768 if (fold[i].hasnewmsgs) wprintf("<B>");
1769 extract(buf, fold[i].name, levels-1);
1771 if (fold[i].hasnewmsgs) wprintf("</B>");
1772 if (fold[i].selectable) wprintf("</A>\n");
1774 while (nests-- > 0) wprintf("</UL>\n");