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)
295 wprintf("<FONT SIZE=-1>");
304 /* Display room graphic. The server doesn't actually
305 * need the room name, but we supply it in order to
306 * keep the browser from using a cached graphic from
309 void embed_room_graphic(void) {
312 serv_puts("OIMG _roompic_");
316 wprintf("<IMG SRC=\"/image&name=_roompic_&room=");
317 urlescputs(WC->wc_roomname);
326 /* Let the user know if new mail has arrived
328 void embed_newmail_button(void) {
329 if ( (WC->new_mail > WC->remember_new_mail) && (WC->new_mail>0) ) {
330 wprintf("<TD VALIGN=TOP>"
331 "<A HREF=\"/dotgoto?room=_MAIL_\">"
332 "<IMG SRC=\"/static/mail.gif\" border=0 "
333 "ALT=\"You have new mail\">"
334 "<BR><BLINK>%d</BLINK>", WC->new_mail);
335 wprintf("<FONT SIZE=-2> new mail messages</FONT></A></TD>");
336 WC->remember_new_mail = WC->new_mail;
343 * Display the current view and offer an option to change it
345 void embed_view_o_matic(void) {
348 wprintf("<FORM NAME=\"viewomatic\">\n"
349 "<SELECT NAME=\"newview\" SIZE=\"1\" "
350 "OnChange=\"location.href=viewomatic.newview.options"
351 "[selectedIndex].value\">\n");
353 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
354 wprintf("<OPTION %s VALUE=\"/changeview?view=%d\">",
355 ((i == WC->wc_view) ? "SELECTED" : ""),
357 escputs(viewdefs[i]);
358 wprintf("</OPTION>\n");
360 wprintf("</SELECT></FORM>\n");
365 void embed_room_banner(char *got) {
368 /* We need to have the information returned by a GOTO server command.
369 * If it isn't supplied, we fake it by issuing our own GOTO.
372 serv_printf("GOTO %s", WC->wc_roomname);
377 /* Check for new mail. */
378 WC->new_mail = extract_int(&got[4], 9);
379 WC->wc_view = extract_int(&got[4], 11);
381 svprintf("ROOMNAME", WCS_STRING, "%s", WC->wc_roomname);
382 svprintf("NEWMSGS", WCS_STRING, "%d", extract_int(&got[4], 1));
383 svprintf("TOTALMSGS", WCS_STRING, "%d", extract_int(&got[4], 2));
384 svcallback("ROOMPIC", embed_room_graphic);
385 svcallback("ROOMINFO", readinfo);
386 svcallback("YOUHAVEMAIL", embed_newmail_button);
387 svcallback("VIEWOMATIC", embed_view_o_matic);
389 do_template("roombanner.html");
390 clear_local_substs();
398 * generic routine to take the session to a new room
400 * display_name values: 0 = goto only
401 * 1 = goto and display
404 void gotoroom(char *gname, int display_name)
407 static long ls = (-1L);
412 wprintf("Pragma: no-cache\n");
413 wprintf("Cache-Control: no-store\n");
415 wprintf("<HTML><HEAD>\n"
416 "<META HTTP-EQUIV=\"refresh\" CONTENT=\"500363689;\">\n"
417 "<META HTTP-EQUIV=\"Pragma\" CONTENT=\"no-cache\">\n"
418 "<META HTTP-EQUIV=\"expired\" CONTENT=\"28-May-1971 18:10:00 GMT\">\n"
419 "<meta name=\"MSSmartTagsPreventParsing\" content=\"TRUE\">\n"
421 do_template("background.html");
423 if (display_name != 2) {
424 /* store ungoto information */
425 strcpy(WC->ugname, WC->wc_roomname);
428 /* move to the new room */
429 serv_printf("GOTO %s", gname);
432 serv_puts("GOTO _BASEROOM_");
437 wprintf("<EM>%s</EM><BR>\n", &buf[4]);
442 extract(WC->wc_roomname, &buf[4], 0);
443 WC->room_flags = extract_int(&buf[4], 4);
444 /* highest_msg_read = extract_int(&buf[4],6);
445 maxmsgnum = extract_int(&buf[4],5);
446 is_mail = (char) extract_int(&buf[4],7); */
447 ls = extract_long(&buf[4], 6);
450 WC->is_room_aide = WC->is_aide;
452 WC->is_room_aide = (char) extract_int(&buf[4], 8);
454 remove_march(WC->wc_roomname);
455 if (!strcasecmp(gname, "_BASEROOM_"))
458 /* Display the room banner */
460 embed_room_banner(buf);
463 strcpy(WC->wc_roomname, WC->wc_roomname);
464 WC->wc_view = extract_int(&buf[4], 11);
469 * Locate the room on the march list which we most want to go to. Each room
470 * is measured given a "weight" of preference based on various factors.
472 char *pop_march(int desired_floor)
474 static char TheRoom[64];
476 int TheOrder = 32767;
479 struct march *mptr = NULL;
481 strcpy(TheRoom, "_BASEROOM_");
482 if (WC->march == NULL)
485 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
487 if ((strcasecmp(mptr->march_name, "_BASEROOM_")))
488 weight = weight + 10000;
489 if (mptr->march_floor == desired_floor)
490 weight = weight + 5000;
492 weight = weight + ((128 - (mptr->march_floor)) * 128);
493 weight = weight + (128 - (mptr->march_order));
495 if (weight > TheWeight) {
497 strcpy(TheRoom, mptr->march_name);
498 TheFloor = mptr->march_floor;
499 TheOrder = mptr->march_order;
507 /* Goto next room having unread messages.
508 * We want to skip over rooms that the user has already been to, and take the
509 * user back to the lobby when done. The room we end up in is placed in
510 * newroom - which is set to 0 (the lobby) initially.
511 * We start the search in the current room rather than the beginning to prevent
512 * two or more concurrent users from dragging each other back to the same room.
517 struct march *mptr, *mptr2;
520 /* First check to see if the march-mode list is already allocated.
521 * If it is, pop the first room off the list and go there.
524 if (WC->march == NULL) {
528 while (serv_gets(buf), strcmp(buf, "000")) {
529 mptr = (struct march *) malloc(sizeof(struct march));
531 extract(mptr->march_name, buf, 0);
532 mptr->march_floor = extract_int(buf, 2);
533 mptr->march_order = extract_int(buf, 3);
534 if (WC->march == NULL) {
538 while (mptr2->next != NULL)
543 /* add _BASEROOM_ to the end of the march list, so the user will end up
544 * in the system base room (usually the Lobby>) at the end of the loop
546 mptr = (struct march *) malloc(sizeof(struct march));
548 strcpy(mptr->march_name, "_BASEROOM_");
549 if (WC->march == NULL) {
553 while (mptr2->next != NULL)
558 * ...and remove the room we're currently in, so a <G>oto doesn't make us
559 * walk around in circles
561 remove_march(WC->wc_roomname);
563 if (WC->march != NULL) {
564 strcpy(next_room, pop_march(-1));
566 strcpy(next_room, "_BASEROOM_");
570 smart_goto(next_room);
574 void smart_goto(char *next_room) {
575 gotoroom(next_room, 0);
582 * mark all messages in current room as having been read
584 void slrp_highest(void)
589 serv_puts("SLRP HIGHEST");
592 wprintf("<EM>%s</EM><BR>\n", &buf[4]);
599 * un-goto the previous room
605 if (!strcmp(WC->ugname, "")) {
606 smart_goto(WC->wc_roomname);
609 serv_printf("GOTO %s", WC->ugname);
612 smart_goto(WC->wc_roomname);
615 if (WC->uglsn >= 0L) {
616 serv_printf("SLRP %ld", WC->uglsn);
619 strcpy(buf, WC->ugname);
620 strcpy(WC->ugname, "");
625 * display the form for editing a room
627 void display_editroom(void)
634 char er_password[10];
636 char er_roomaide[26];
642 char *not_shared_with;
645 if (strlen(tab) == 0) tab = "admin";
651 display_error(&buf[4]);
654 extract(er_name, &buf[4], 0);
655 extract(er_password, &buf[4], 1);
656 extract(er_dirname, &buf[4], 2);
657 er_flags = extract_int(&buf[4], 3);
658 er_floor = extract_int(&buf[4], 4);
662 /* print the tabbed dialog */
663 wprintf("<TABLE border=0 width=100%%><TR BGCOLOR=FFFFFF><TD> </TD>");
665 if (!strcmp(tab, "admin")) {
666 wprintf("<TD BGCOLOR=000077><FONT SIZE=+1 COLOR=\"FFFFFF\"><B>");
669 wprintf("<TD><A HREF=\"/display_editroom&tab=admin\">");
671 wprintf("Room administration");
672 if (!strcmp(tab, "admin")) {
673 wprintf("</B></FONT></TD>\n");
676 wprintf("</A></TD>\n");
679 wprintf("<TD> </TD>\n");
681 if (!strcmp(tab, "config")) {
682 wprintf("<TD BGCOLOR=000077><FONT SIZE=+1 COLOR=\"FFFFFF\"><B>");
685 wprintf("<TD><A HREF=\"/display_editroom&tab=config\">");
687 wprintf("Room configuration");
688 if (!strcmp(tab, "config")) {
689 wprintf("</B></FONT></TD>\n");
692 wprintf("</A></TD>\n");
695 wprintf("<TD> </TD>\n");
697 if (!strcmp(tab, "sharing")) {
698 wprintf("<TD BGCOLOR=000077><FONT SIZE=+1 COLOR=\"FFFFFF\"><B>");
701 wprintf("<TD><A HREF=\"/display_editroom&tab=sharing\">");
704 if (!strcmp(tab, "sharing")) {
705 wprintf("</B></FONT></TD>\n");
708 wprintf("</A></TD>\n");
711 wprintf("<TD> </TD>\n");
713 if (!strcmp(tab, "listserv")) {
714 wprintf("<TD BGCOLOR=000077><FONT SIZE=+1 COLOR=\"FFFFFF\"><B>");
717 wprintf("<TD><A HREF=\"/display_editroom&tab=listserv\">");
719 wprintf("Mailing list service");
720 if (!strcmp(tab, "listserv")) {
721 wprintf("</B></FONT></TD>\n");
724 wprintf("</A></TD>\n");
727 wprintf("<TD> </TD></TR></TABLE>\n");
729 /* end tabbed dialog */
732 if (!strcmp(tab, "admin")) {
734 "<LI><A HREF=\"/confirm_delete_room\">\n"
735 "Delete this room</A>\n"
736 "<LI><A HREF=\"/display_editroompic\">\n"
737 "Set or change the graphic for this room's banner</A>\n"
738 "<LI><A HREF=\"/display_editinfo\">\n"
739 "Edit this room's Info file</A>\n"
743 if (!strcmp(tab, "config")) {
744 wprintf("<FORM METHOD=\"POST\" ACTION=\"/editroom\">\n");
746 wprintf("<UL><LI>Name of room: ");
747 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\"19\">\n", er_name);
749 wprintf("<LI>Resides on floor: ");
751 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
752 for (i = 0; i < 128; ++i)
753 if (strlen(floorlist[i]) > 0) {
756 wprintf("SELECTED ");
757 wprintf("VALUE=\"%d\">", i);
758 escputs(floorlist[i]);
759 wprintf("</OPTION>\n");
761 wprintf("</SELECT>\n");
763 wprintf("<LI>Type of room:<UL>\n");
765 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
766 if ((er_flags & QR_PRIVATE) == 0)
768 wprintf("> Public room\n");
770 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"guessname\" ");
771 if ((er_flags & QR_PRIVATE) &&
772 (er_flags & QR_GUESSNAME))
774 wprintf("> Private - guess name\n");
776 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
777 if ((er_flags & QR_PRIVATE) &&
778 (er_flags & QR_PASSWORDED))
780 wprintf("> Private - require password:\n");
781 wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n", er_password);
783 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
784 if ((er_flags & QR_PRIVATE)
785 && ((er_flags & QR_GUESSNAME) == 0)
786 && ((er_flags & QR_PASSWORDED) == 0))
788 wprintf("> Private - invitation only\n");
790 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
791 wprintf("> If private, cause current users to forget room\n");
795 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
796 if (er_flags & QR_PREFONLY)
798 wprintf("> Preferred users only\n");
800 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
801 if (er_flags & QR_READONLY)
803 wprintf("> Read-only room\n");
805 /* directory stuff */
806 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
807 if (er_flags & QR_DIRECTORY)
809 wprintf("> File directory room\n");
811 wprintf("<UL><LI>Directory name: ");
812 wprintf("<INPUT TYPE=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n", er_dirname);
814 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
815 if (er_flags & QR_UPLOAD)
817 wprintf("> Uploading allowed\n");
819 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
820 if (er_flags & QR_DOWNLOAD)
822 wprintf("> Downloading allowed\n");
824 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
825 if (er_flags & QR_VISDIR)
827 wprintf("> Visible directory</UL>\n");
829 /* end of directory stuff */
831 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
832 if (er_flags & QR_NETWORK)
834 wprintf("> Network shared room\n");
836 /* start of anon options */
838 wprintf("<LI>Anonymous messages<UL>\n");
840 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
841 if (((er_flags & QR_ANONONLY) == 0)
842 && ((er_flags & QR_ANONOPT) == 0))
844 wprintf("> No anonymous messages\n");
846 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
847 if (er_flags & QR_ANONONLY)
849 wprintf("> All messages are anonymous\n");
851 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
852 if (er_flags & QR_ANONOPT)
854 wprintf("> Prompt user when entering messages</UL>\n");
856 /* end of anon options */
858 wprintf("<LI>Room aide: \n");
862 wprintf("<EM>%s</EM>\n", &buf[4]);
864 extract(er_roomaide, &buf[4], 0);
865 wprintf("<INPUT TYPE=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n", er_roomaide);
868 wprintf("</UL><CENTER>\n");
869 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
870 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
871 wprintf("</CENTER>\n");
875 /* Sharing the room with other Citadel nodes... */
876 if (!strcmp(tab, "sharing")) {
878 shared_with = strdup("");
879 not_shared_with = strdup("");
881 /* Learn the current configuration */
882 serv_puts("CONF getsys|application/x-citadel-ignet-config");
884 if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
885 extract(node, buf, 0);
886 not_shared_with = realloc(not_shared_with,
887 strlen(not_shared_with) + 32);
888 strcat(not_shared_with, node);
889 strcat(not_shared_with, "|");
894 if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
895 extract(cmd, buf, 0);
896 extract(node, buf, 1);
897 if (!strcasecmp(cmd, "ignet_push_share")) {
898 shared_with = realloc(shared_with,
899 strlen(shared_with) + 32);
900 strcat(shared_with, node);
901 strcat(shared_with, "|");
905 for (i=0; i<num_tokens(shared_with, '|'); ++i) {
906 extract(node, shared_with, i);
907 for (j=0; j<num_tokens(not_shared_with, '|'); ++j) {
908 extract(cmd, not_shared_with, j);
909 if (!strcasecmp(node, cmd)) {
910 remove_token(not_shared_with, j, '|');
915 /* Display the stuff */
916 wprintf("<CENTER><BR>"
917 "<TABLE border=1 cellpadding=5><TR>"
918 "<TD><B><I>Shared with</I></B></TD>"
919 "<TD><B><I>Not shared with</I></B></TD></TR>\n"
922 for (i=0; i<num_tokens(shared_with, '|'); ++i) {
923 extract(node, shared_with, i);
924 if (strlen(node) > 0) {
925 wprintf("%s ", node);
926 wprintf("<A HREF=\"/netedit&cmd=remove&line="
927 "ignet_push_share|");
929 wprintf("&tab=sharing\">(unshare)</A><BR>");
933 wprintf("</TD><TD>\n");
935 for (i=0; i<num_tokens(not_shared_with, '|'); ++i) {
936 extract(node, not_shared_with, i);
937 if (strlen(node) > 0) {
938 wprintf("%s ", node);
939 wprintf("<A HREF=\"/netedit&cmd=add&line="
940 "ignet_push_share|");
942 wprintf("&tab=sharing\">(share)</A><BR>");
946 wprintf("</TD></TR></TABLE><BR>\n"
947 "<I><B>Reminder:</B> When sharing a room, "
948 "it must be shared from both ends. Adding a node to "
949 "the 'shared' list sends messages out, but in order to"
950 " receive messages, the other nodes must be configured"
951 " to send messages out to your system as well.</I><BR>"
956 /* Mailing list management */
957 if (!strcmp(tab, "listserv")) {
959 wprintf("<BR><center><i>The contents of this room are being "
960 "mailed to the following list recipients:"
965 if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
966 extract(cmd, buf, 0);
967 if (!strcasecmp(cmd, "listrecp")) {
968 extract(recp, buf, 1);
971 wprintf(" <A HREF=\"/netedit&cmd=remove&line="
974 wprintf("&tab=listserv\">(remove)</A><BR>");
978 wprintf("<BR><FORM METHOD=\"POST\" ACTION=\"/netedit\">\n"
979 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
980 "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"listrecp|\">\n");
981 wprintf("<INPUT TYPE=\"text\" NAME=\"line\">\n");
982 wprintf("<INPUT TYPE=\"submit\" NAME=\"cmd\" VALUE=\"Add\">");
983 wprintf("</FORM><BR></CENTER>\n");
991 * save new parameters for a room
997 char er_password[10];
999 char er_roomaide[26];
1005 if (strcmp(bstr("sc"), "OK")) {
1006 display_error("Cancelled. Changes were not saved.");
1012 if (buf[0] != '2') {
1013 display_error(&buf[4]);
1016 extract(er_name, &buf[4], 0);
1017 extract(er_password, &buf[4], 1);
1018 extract(er_dirname, &buf[4], 2);
1019 er_flags = extract_int(&buf[4], 3);
1021 strcpy(er_roomaide, bstr("er_roomaide"));
1022 if (strlen(er_roomaide) == 0) {
1025 if (buf[0] != '2') {
1026 strcpy(er_roomaide, "");
1028 extract(er_roomaide, &buf[4], 0);
1031 strcpy(buf, bstr("er_name"));
1033 if (strlen(buf) > 0)
1034 strcpy(er_name, buf);
1036 strcpy(buf, bstr("er_password"));
1038 if (strlen(buf) > 0)
1039 strcpy(er_password, buf);
1041 strcpy(buf, bstr("er_dirname"));
1043 if (strlen(buf) > 0)
1044 strcpy(er_dirname, buf);
1046 strcpy(buf, bstr("type"));
1047 er_flags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME);
1049 if (!strcmp(buf, "invonly")) {
1050 er_flags |= (QR_PRIVATE);
1052 if (!strcmp(buf, "guessname")) {
1053 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
1055 if (!strcmp(buf, "passworded")) {
1056 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
1058 if (!strcmp(bstr("prefonly"), "yes")) {
1059 er_flags |= QR_PREFONLY;
1061 er_flags &= ~QR_PREFONLY;
1064 if (!strcmp(bstr("readonly"), "yes")) {
1065 er_flags |= QR_READONLY;
1067 er_flags &= ~QR_READONLY;
1070 if (!strcmp(bstr("network"), "yes")) {
1071 er_flags |= QR_NETWORK;
1073 er_flags &= ~QR_NETWORK;
1076 if (!strcmp(bstr("directory"), "yes")) {
1077 er_flags |= QR_DIRECTORY;
1079 er_flags &= ~QR_DIRECTORY;
1082 if (!strcmp(bstr("ulallowed"), "yes")) {
1083 er_flags |= QR_UPLOAD;
1085 er_flags &= ~QR_UPLOAD;
1088 if (!strcmp(bstr("dlallowed"), "yes")) {
1089 er_flags |= QR_DOWNLOAD;
1091 er_flags &= ~QR_DOWNLOAD;
1094 if (!strcmp(bstr("visdir"), "yes")) {
1095 er_flags |= QR_VISDIR;
1097 er_flags &= ~QR_VISDIR;
1100 strcpy(buf, bstr("anon"));
1102 er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
1103 if (!strcmp(buf, "anononly"))
1104 er_flags |= QR_ANONONLY;
1105 if (!strcmp(buf, "anon2"))
1106 er_flags |= QR_ANONOPT;
1109 if (!strcmp(bstr("bump"), "yes"))
1112 er_floor = atoi(bstr("er_floor"));
1114 sprintf(buf, "SETR %s|%s|%s|%u|%d|%d",
1115 er_name, er_password, er_dirname, er_flags, bump, er_floor);
1118 if (buf[0] != '2') {
1119 display_error(&buf[4]);
1122 gotoroom(er_name, 0);
1124 if (strlen(er_roomaide) > 0) {
1125 sprintf(buf, "SETA %s", er_roomaide);
1128 if (buf[0] != '2') {
1129 display_error(&buf[4]);
1133 smart_goto(er_name);
1137 * Invite, Kick, and show Who Knows a room
1139 void display_whok(void)
1141 char buf[SIZ], room[SIZ], username[SIZ];
1146 if (buf[0] != '2') {
1147 display_error(&buf[4]);
1150 extract(room, &buf[4], 0);
1152 strcpy(username, bstr("username"));
1156 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=007700><TR><TD>");
1157 wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"<B>Access control list for ");
1158 escputs(WC->wc_roomname);
1159 wprintf("</B></FONT></TD></TR></TABLE>\n");
1161 if(!strcmp(bstr("sc"), "Kick")) {
1162 sprintf(buf, "KICK %s", username);
1166 if (buf[0] != '2') {
1167 display_error(&buf[4]);
1170 wprintf("<B><I>User %s kicked out of room %s.</I></B>\n",
1173 } else if(!strcmp(bstr("sc"), "Invite")) {
1174 sprintf(buf, "INVT %s", username);
1178 if (buf[0] != '2') {
1179 display_error(&buf[4]);
1182 wprintf("<B><I>User %s invited to room %s.</I></B>\n",
1189 wprintf("<TABLE border=0 CELLSPACING=10><TR VALIGN=TOP>"
1190 "<TD>The users listed below have access to this room. "
1191 "To remove a user from the access list, select the user "
1192 "name from the list and click 'Kick'.<BR><BR>");
1194 wprintf("<CENTER><FORM METHOD=\"POST\" ACTION=\"/display_whok\">\n");
1195 wprintf("<SELECT NAME=\"username\" SIZE=10>\n");
1198 if (buf[0] == '1') {
1199 while (serv_gets(buf), strcmp(buf, "000")) {
1200 extract(username, buf, 0);
1201 wprintf("<OPTION>");
1206 wprintf("</SELECT><BR>\n");
1208 wprintf("<input type=submit name=sc value=\"Kick\">");
1209 wprintf("</FORM></CENTER>\n");
1212 "To grant another user access to this room, enter the "
1213 "user name in the box below and click 'Invite'.<BR><BR>");
1215 wprintf("<CENTER><FORM METHOD=\"POST\" ACTION=\"/display_whok\">\n");
1216 wprintf("Invite: ");
1217 wprintf("<input type=text name=username><BR>\n"
1218 "<input type=hidden name=sc value=\"Invite\">"
1219 "<input type=submit value=\"Invite\">"
1220 "</FORM></CENTER>\n");
1222 wprintf("</TD></TR></TABLE>\n");
1229 * display the form for entering a new room
1231 void display_entroom(void)
1236 serv_puts("CRE8 0");
1239 if (buf[0] != '2') {
1240 display_error(&buf[4]);
1245 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=000077><TR><TD>");
1246 wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
1247 wprintf("<B>Enter (create) a new room</B>\n");
1248 wprintf("</FONT></TD></TR></TABLE>\n");
1250 wprintf("<FORM METHOD=\"POST\" ACTION=\"/entroom\">\n");
1252 wprintf("<UL><LI>Name of room: ");
1253 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" MAXLENGTH=\"19\">\n");
1255 wprintf("<LI>Type of room:<UL>\n");
1257 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1258 wprintf("CHECKED > Public room\n");
1260 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"guessname\" ");
1261 wprintf("> Private - guess name\n");
1263 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
1264 wprintf("> Private - require password:\n");
1265 wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
1267 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
1268 wprintf("> Private - invitation only\n");
1271 wprintf("<LI>Resides on floor: ");
1273 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
1274 for (i = 0; i < 128; ++i)
1275 if (strlen(floorlist[i]) > 0) {
1276 wprintf("<OPTION ");
1277 wprintf("VALUE=\"%d\">", i);
1278 escputs(floorlist[i]);
1279 wprintf("</OPTION>\n");
1281 wprintf("</SELECT>\n");
1285 wprintf("<CENTER>\n");
1286 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
1287 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1288 wprintf("</CENTER>\n");
1289 wprintf("</FORM>\n<HR>");
1290 serv_printf("MESG roomaccess");
1292 if (buf[0] == '1') {
1308 char er_password[10];
1312 if (strcmp(bstr("sc"), "OK")) {
1313 display_error("Cancelled. No new room was created.");
1316 strcpy(er_name, bstr("er_name"));
1317 strcpy(er_type, bstr("type"));
1318 strcpy(er_password, bstr("er_password"));
1319 er_floor = atoi(bstr("er_floor"));
1322 if (!strcmp(er_type, "guessname"))
1324 if (!strcmp(er_type, "passworded"))
1326 if (!strcmp(er_type, "invonly"))
1329 sprintf(buf, "CRE8 1|%s|%d|%s|%d",
1330 er_name, er_num_type, er_password, er_floor);
1333 if (buf[0] != '2') {
1334 display_error(&buf[4]);
1337 smart_goto(er_name);
1342 * display the screen to enter a private room
1344 void display_private(char *rname, int req_pass)
1349 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=770000><TR><TD>");
1350 wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
1351 wprintf("<B>Goto a private room</B>\n");
1352 wprintf("</FONT></TD></TR></TABLE>\n");
1354 wprintf("<CENTER>\n");
1355 wprintf("If you know the name of a hidden (guess-name) or\n");
1356 wprintf("passworded room, you can enter that room by typing\n");
1357 wprintf("its name below. Once you gain access to a private\n");
1358 wprintf("room, it will appear in your regular room listings\n");
1359 wprintf("so you don't have to keep returning here.\n");
1360 wprintf("<BR><BR>");
1362 wprintf("<FORM METHOD=\"POST\" ACTION=\"/goto_private\">\n");
1364 wprintf("<TABLE border><TR><TD>");
1365 wprintf("Enter room name:</TD><TD>");
1366 wprintf("<INPUT TYPE=\"text\" NAME=\"gr_name\" VALUE=\"%s\" MAXLENGTH=\"19\">\n", rname);
1369 wprintf("</TD></TR><TR><TD>");
1370 wprintf("Enter room password:</TD><TD>");
1371 wprintf("<INPUT TYPE=\"password\" NAME=\"gr_pass\" MAXLENGTH=\"9\">\n");
1373 wprintf("</TD></TR></TABLE>\n");
1375 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
1376 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1377 wprintf("</FORM>\n");
1382 * goto a private room
1384 void goto_private(void)
1389 if (strcasecmp(bstr("sc"), "OK")) {
1390 display_main_menu();
1393 strcpy(hold_rm, WC->wc_roomname);
1394 strcpy(buf, "GOTO ");
1395 strcat(buf, bstr("gr_name"));
1397 strcat(buf, bstr("gr_pass"));
1401 if (buf[0] == '2') {
1402 smart_goto(bstr("gr_name"));
1405 if (!strncmp(buf, "540", 3)) {
1406 display_private(bstr("gr_name"), 1);
1410 wprintf("%s\n", &buf[4]);
1417 * display the screen to zap a room
1419 void display_zap(void)
1423 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=770000><TR><TD>");
1424 wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
1425 wprintf("<B>Zap (forget) the current room</B>\n");
1426 wprintf("</FONT></TD></TR></TABLE>\n");
1428 wprintf("If you select this option, <em>%s</em> will ", WC->wc_roomname);
1429 wprintf("disappear from your room list. Is this what you wish ");
1430 wprintf("to do?<BR>\n");
1432 wprintf("<FORM METHOD=\"POST\" ACTION=\"/zap\">\n");
1433 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
1434 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1435 wprintf("</FORM>\n");
1446 char final_destination[SIZ];
1448 /* If the forget-room routine fails for any reason, we fall back
1449 * to the current room; otherwise, we go to the Lobby
1451 strcpy(final_destination, WC->wc_roomname);
1453 if (!strcasecmp(bstr("sc"), "OK")) {
1454 serv_printf("GOTO %s", WC->wc_roomname);
1456 if (buf[0] != '2') {
1457 /* ExpressMessageCat(&buf[4]); */
1461 if (buf[0] != '2') {
1462 /* ExpressMessageCat(&buf[4]); */
1464 strcpy(final_destination, "_BASEROOM_");
1468 smart_goto(final_destination);
1475 * Confirm deletion of the current room
1477 void confirm_delete_room(void)
1481 serv_puts("KILL 0");
1483 if (buf[0] != '2') {
1484 display_error(&buf[4]);
1488 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=770000><TR><TD>");
1489 wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
1490 wprintf("<B>Confirm deletion of room</B>\n");
1491 wprintf("</FONT></TD></TR></TABLE>\n");
1493 wprintf("<CENTER>");
1494 wprintf("<FORM METHOD=\"POST\" ACTION=\"/delete_room\">\n");
1496 wprintf("Are you sure you want to delete <FONT SIZE=+1>");
1497 escputs(WC->wc_roomname);
1498 wprintf("</FONT>?<BR>\n");
1500 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Delete\">");
1501 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1503 wprintf("</FORM></CENTER>\n");
1509 * Delete the current room
1511 void delete_room(void)
1516 strcpy(sc, bstr("sc"));
1518 if (strcasecmp(sc, "Delete")) {
1519 display_error("Cancelled. This room was not deleted.");
1522 serv_puts("KILL 1");
1524 if (buf[0] != '2') {
1525 display_error(&buf[4]);
1527 smart_goto("_BASEROOM_");
1534 * Perform changes to a room's network configuration
1536 void netedit(void) {
1541 if (strlen(bstr("line"))==0) {
1546 strcpy(line, bstr("prefix"));
1547 strcat(line, bstr("line"));
1548 strcat(line, bstr("suffix"));
1558 if (buf[0] != '1') {
1564 /* This loop works for add *or* remove. Spiffy, eh? */
1565 while (serv_gets(buf), strcmp(buf, "000")) {
1566 if (strcasecmp(buf, line)) {
1567 fprintf(fp, "%s\n", buf);
1574 if (buf[0] != '4') {
1580 while (fgets(buf, sizeof buf, fp) != NULL) {
1581 buf[strlen(buf)-1] = 0;
1585 if (!strcasecmp(bstr("cmd"), "add")) {
1597 * Change the view for this room
1599 void change_view(void) {
1603 view = atol(bstr("view"));
1605 serv_printf("VIEW %d", view);
1607 smart_goto(WC->wc_roomname);