10 #include <sys/types.h>
12 #include <sys/socket.h>
15 #include <netinet/in.h>
31 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 "<IMG SRC=\"/static/mail.gif\" border=0 "
332 "ALT=\"You have new mail\">"
333 "<BR><BLINK>%d</BLINK>", WC->new_mail);
334 wprintf("<FONT SIZE=-2> new mail messages</FONT></TD>");
335 WC->remember_new_mail = WC->new_mail;
341 void embed_room_banner(char *got) {
344 /* We need to have the information returned by a GOTO server command.
345 * If it isn't supplied, we fake it by issuing our own GOTO.
348 serv_printf("GOTO %s", WC->wc_roomname);
353 /* Check for new mail. */
354 WC->new_mail = extract_int(&got[4], 9);
356 svprintf("ROOMNAME", WCS_STRING, "%s", WC->wc_roomname);
357 svprintf("NEWMSGS", WCS_STRING, "%d", extract_int(&got[4], 1));
358 svprintf("TOTALMSGS", WCS_STRING, "%d", extract_int(&got[4], 2));
359 svcallback("ROOMPIC", embed_room_graphic);
360 svcallback("ROOMINFO", readinfo);
361 svcallback("YOUHAVEMAIL", embed_newmail_button);
363 do_template("roombanner.html");
364 clear_local_substs();
372 * generic routine to take the session to a new room
374 * display_name values: 0 = goto only
375 * 1 = goto and display
378 void gotoroom(char *gname, int display_name)
381 static long ls = (-1L);
386 wprintf("Pragma: no-cache\n");
387 wprintf("Cache-Control: no-store\n");
389 wprintf("<HTML><HEAD>\n"
390 "<META HTTP-EQUIV=\"refresh\" CONTENT=\"500363689;\">\n"
391 "<META HTTP-EQUIV=\"Pragma\" CONTENT=\"no-cache\">\n"
392 "<META HTTP-EQUIV=\"expired\" CONTENT=\"28-May-1971 18:10:00 GMT\">\n"
393 "<meta name=\"MSSmartTagsPreventParsing\" content=\"TRUE\">\n"
395 do_template("background.html");
397 if (display_name != 2) {
398 /* store ungoto information */
399 strcpy(WC->ugname, WC->wc_roomname);
402 /* move to the new room */
403 serv_printf("GOTO %s", gname);
406 serv_puts("GOTO _BASEROOM_");
411 wprintf("<EM>%s</EM><BR>\n", &buf[4]);
416 extract(WC->wc_roomname, &buf[4], 0);
417 WC->room_flags = extract_int(&buf[4], 4);
418 /* highest_msg_read = extract_int(&buf[4],6);
419 maxmsgnum = extract_int(&buf[4],5);
420 is_mail = (char) extract_int(&buf[4],7); */
421 ls = extract_long(&buf[4], 6);
424 WC->is_room_aide = WC->is_aide;
426 WC->is_room_aide = (char) extract_int(&buf[4], 8);
428 remove_march(WC->wc_roomname);
429 if (!strcasecmp(gname, "_BASEROOM_"))
432 /* Display the room banner */
434 embed_room_banner(buf);
437 strcpy(WC->wc_roomname, WC->wc_roomname);
442 * Locate the room on the march list which we most want to go to. Each room
443 * is measured given a "weight" of preference based on various factors.
445 char *pop_march(int desired_floor)
447 static char TheRoom[64];
449 int TheOrder = 32767;
452 struct march *mptr = NULL;
454 strcpy(TheRoom, "_BASEROOM_");
455 if (WC->march == NULL)
458 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
460 if ((strcasecmp(mptr->march_name, "_BASEROOM_")))
461 weight = weight + 10000;
462 if (mptr->march_floor == desired_floor)
463 weight = weight + 5000;
465 weight = weight + ((128 - (mptr->march_floor)) * 128);
466 weight = weight + (128 - (mptr->march_order));
468 if (weight > TheWeight) {
470 strcpy(TheRoom, mptr->march_name);
471 TheFloor = mptr->march_floor;
472 TheOrder = mptr->march_order;
480 /* Goto next room having unread messages.
481 * We want to skip over rooms that the user has already been to, and take the
482 * user back to the lobby when done. The room we end up in is placed in
483 * newroom - which is set to 0 (the lobby) initially.
484 * We start the search in the current room rather than the beginning to prevent
485 * two or more concurrent users from dragging each other back to the same room.
490 struct march *mptr, *mptr2;
493 /* First check to see if the march-mode list is already allocated.
494 * If it is, pop the first room off the list and go there.
497 if (WC->march == NULL) {
501 while (serv_gets(buf), strcmp(buf, "000")) {
502 mptr = (struct march *) malloc(sizeof(struct march));
504 extract(mptr->march_name, buf, 0);
505 mptr->march_floor = extract_int(buf, 2);
506 mptr->march_order = extract_int(buf, 3);
507 if (WC->march == NULL) {
511 while (mptr2->next != NULL)
516 /* add _BASEROOM_ to the end of the march list, so the user will end up
517 * in the system base room (usually the Lobby>) at the end of the loop
519 mptr = (struct march *) malloc(sizeof(struct march));
521 strcpy(mptr->march_name, "_BASEROOM_");
522 if (WC->march == NULL) {
526 while (mptr2->next != NULL)
531 * ...and remove the room we're currently in, so a <G>oto doesn't make us
532 * walk around in circles
534 remove_march(WC->wc_roomname);
536 if (WC->march != NULL) {
537 strcpy(next_room, pop_march(-1));
539 strcpy(next_room, "_BASEROOM_");
543 smart_goto(next_room);
547 void smart_goto(char *next_room) {
548 gotoroom(next_room, 0);
555 * mark all messages in current room as having been read
557 void slrp_highest(void)
562 serv_puts("SLRP HIGHEST");
565 wprintf("<EM>%s</EM><BR>\n", &buf[4]);
572 * un-goto the previous room
578 if (!strcmp(WC->ugname, "")) {
579 smart_goto(WC->wc_roomname);
582 serv_printf("GOTO %s", WC->ugname);
585 smart_goto(WC->wc_roomname);
588 if (WC->uglsn >= 0L) {
589 serv_printf("SLRP %ld", WC->uglsn);
592 strcpy(buf, WC->ugname);
593 strcpy(WC->ugname, "");
598 * display the form for editing a room
600 void display_editroom(void)
607 char er_password[10];
609 char er_roomaide[26];
615 char *not_shared_with;
618 if (strlen(tab) == 0) tab = "admin";
624 display_error(&buf[4]);
627 extract(er_name, &buf[4], 0);
628 extract(er_password, &buf[4], 1);
629 extract(er_dirname, &buf[4], 2);
630 er_flags = extract_int(&buf[4], 3);
631 er_floor = extract_int(&buf[4], 4);
635 /* print the tabbed dialog */
636 wprintf("<TABLE border=0 width=100%%><TR BGCOLOR=FFFFFF><TD> </TD>");
638 if (!strcmp(tab, "admin")) {
639 wprintf("<TD BGCOLOR=000077><FONT SIZE=+1 COLOR=\"FFFFFF\"><B>");
642 wprintf("<TD><A HREF=\"/display_editroom&tab=admin\">");
644 wprintf("Room administration");
645 if (!strcmp(tab, "admin")) {
646 wprintf("</B></FONT></TD>\n");
649 wprintf("</A></TD>\n");
652 wprintf("<TD> </TD>\n");
654 if (!strcmp(tab, "config")) {
655 wprintf("<TD BGCOLOR=000077><FONT SIZE=+1 COLOR=\"FFFFFF\"><B>");
658 wprintf("<TD><A HREF=\"/display_editroom&tab=config\">");
660 wprintf("Room configuration");
661 if (!strcmp(tab, "config")) {
662 wprintf("</B></FONT></TD>\n");
665 wprintf("</A></TD>\n");
668 wprintf("<TD> </TD>\n");
670 if (!strcmp(tab, "sharing")) {
671 wprintf("<TD BGCOLOR=000077><FONT SIZE=+1 COLOR=\"FFFFFF\"><B>");
674 wprintf("<TD><A HREF=\"/display_editroom&tab=sharing\">");
677 if (!strcmp(tab, "sharing")) {
678 wprintf("</B></FONT></TD>\n");
681 wprintf("</A></TD>\n");
684 wprintf("<TD> </TD>\n");
686 if (!strcmp(tab, "listserv")) {
687 wprintf("<TD BGCOLOR=000077><FONT SIZE=+1 COLOR=\"FFFFFF\"><B>");
690 wprintf("<TD><A HREF=\"/display_editroom&tab=listserv\">");
692 wprintf("Mailing list service");
693 if (!strcmp(tab, "listserv")) {
694 wprintf("</B></FONT></TD>\n");
697 wprintf("</A></TD>\n");
700 wprintf("<TD> </TD></TR></TABLE>\n");
702 /* end tabbed dialog */
705 if (!strcmp(tab, "admin")) {
707 "<LI><A HREF=\"/confirm_delete_room\">\n"
708 "Delete this room</A>\n"
709 "<LI><A HREF=\"/display_editroompic\">\n"
710 "Set or change the graphic for this room's banner</A>\n"
711 "<LI><A HREF=\"/display_editinfo\">\n"
712 "Edit this room's Info file</A>\n"
716 if (!strcmp(tab, "config")) {
717 wprintf("<FORM METHOD=\"POST\" ACTION=\"/editroom\">\n");
719 wprintf("<UL><LI>Name of room: ");
720 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\"19\">\n", er_name);
722 wprintf("<LI>Resides on floor: ");
724 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
725 for (i = 0; i < 128; ++i)
726 if (strlen(floorlist[i]) > 0) {
729 wprintf("SELECTED ");
730 wprintf("VALUE=\"%d\">", i);
731 escputs(floorlist[i]);
732 wprintf("</OPTION>\n");
734 wprintf("</SELECT>\n");
736 wprintf("<LI>Type of room:<UL>\n");
738 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
739 if ((er_flags & QR_PRIVATE) == 0)
741 wprintf("> Public room\n");
743 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"guessname\" ");
744 if ((er_flags & QR_PRIVATE) &&
745 (er_flags & QR_GUESSNAME))
747 wprintf("> Private - guess name\n");
749 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
750 if ((er_flags & QR_PRIVATE) &&
751 (er_flags & QR_PASSWORDED))
753 wprintf("> Private - require password:\n");
754 wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n", er_password);
756 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
757 if ((er_flags & QR_PRIVATE)
758 && ((er_flags & QR_GUESSNAME) == 0)
759 && ((er_flags & QR_PASSWORDED) == 0))
761 wprintf("> Private - invitation only\n");
763 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
764 wprintf("> If private, cause current users to forget room\n");
768 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
769 if (er_flags & QR_PREFONLY)
771 wprintf("> Preferred users only\n");
773 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
774 if (er_flags & QR_READONLY)
776 wprintf("> Read-only room\n");
778 /* directory stuff */
779 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
780 if (er_flags & QR_DIRECTORY)
782 wprintf("> File directory room\n");
784 wprintf("<UL><LI>Directory name: ");
785 wprintf("<INPUT TYPE=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n", er_dirname);
787 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
788 if (er_flags & QR_UPLOAD)
790 wprintf("> Uploading allowed\n");
792 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
793 if (er_flags & QR_DOWNLOAD)
795 wprintf("> Downloading allowed\n");
797 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
798 if (er_flags & QR_VISDIR)
800 wprintf("> Visible directory</UL>\n");
802 /* end of directory stuff */
804 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
805 if (er_flags & QR_NETWORK)
807 wprintf("> Network shared room\n");
809 /* start of anon options */
811 wprintf("<LI>Anonymous messages<UL>\n");
813 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
814 if (((er_flags & QR_ANONONLY) == 0)
815 && ((er_flags & QR_ANONOPT) == 0))
817 wprintf("> No anonymous messages\n");
819 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
820 if (er_flags & QR_ANONONLY)
822 wprintf("> All messages are anonymous\n");
824 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
825 if (er_flags & QR_ANONOPT)
827 wprintf("> Prompt user when entering messages</UL>\n");
829 /* end of anon options */
831 wprintf("<LI>Room aide: \n");
835 wprintf("<EM>%s</EM>\n", &buf[4]);
837 extract(er_roomaide, &buf[4], 0);
838 wprintf("<INPUT TYPE=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n", er_roomaide);
841 wprintf("</UL><CENTER>\n");
842 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
843 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
844 wprintf("</CENTER>\n");
848 /* Sharing the room with other Citadel nodes... */
849 if (!strcmp(tab, "sharing")) {
851 shared_with = strdup("");
852 not_shared_with = strdup("");
854 /* Learn the current configuration */
855 serv_puts("CONF getsys|application/x-citadel-ignet-config");
857 if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
858 extract(node, buf, 0);
859 not_shared_with = realloc(not_shared_with,
860 strlen(not_shared_with) + 32);
861 strcat(not_shared_with, node);
862 strcat(not_shared_with, "|");
867 if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
868 extract(cmd, buf, 0);
869 extract(node, buf, 1);
870 if (!strcasecmp(cmd, "ignet_push_share")) {
871 shared_with = realloc(shared_with,
872 strlen(shared_with) + 32);
873 strcat(shared_with, node);
874 strcat(shared_with, "|");
878 for (i=0; i<num_tokens(shared_with, '|'); ++i) {
879 extract(node, shared_with, i);
880 for (j=0; j<num_tokens(not_shared_with, '|'); ++j) {
881 extract(cmd, not_shared_with, j);
882 if (!strcasecmp(node, cmd)) {
883 remove_token(not_shared_with, j, '|');
888 /* Display the stuff */
889 wprintf("<CENTER><BR>"
890 "<TABLE border=1 cellpadding=5><TR>"
891 "<TD><B><I>Shared with</I></B></TD>"
892 "<TD><B><I>Not shared with</I></B></TD></TR>\n"
895 for (i=0; i<num_tokens(shared_with, '|'); ++i) {
896 extract(node, shared_with, i);
897 if (strlen(node) > 0) {
898 wprintf("%s ", node);
899 wprintf("<A HREF=\"/netedit&cmd=remove&line="
900 "ignet_push_share|");
902 wprintf("&tab=sharing\">(unshare)</A><BR>");
906 wprintf("</TD><TD>\n");
908 for (i=0; i<num_tokens(not_shared_with, '|'); ++i) {
909 extract(node, not_shared_with, i);
910 if (strlen(node) > 0) {
911 wprintf("%s ", node);
912 wprintf("<A HREF=\"/netedit&cmd=add&line="
913 "ignet_push_share|");
915 wprintf("&tab=sharing\">(share)</A><BR>");
919 wprintf("</TD></TR></TABLE><BR>\n"
920 "<I><B>Reminder:</B> When sharing a room, "
921 "it must be shared from both ends. Adding a node to "
922 "the 'shared' list sends messages out, but in order to"
923 " receive messages, the other nodes must be configured"
924 " to send messages out to your system as well.</I><BR>"
929 /* Mailing list management */
930 if (!strcmp(tab, "listserv")) {
932 wprintf("<center><i>The contents of this room are being "
933 "mailed to the following list recipients:"
938 if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
939 extract(cmd, buf, 0);
940 if (!strcasecmp(cmd, "listrecp")) {
941 extract(recp, buf, 1);
944 wprintf(" <A HREF=\"/netedit&cmd=remove&line="
947 wprintf("&tab=listserv\">(remove)</A><BR>");
958 * save new parameters for a room
964 char er_password[10];
966 char er_roomaide[26];
972 if (strcmp(bstr("sc"), "OK")) {
973 display_error("Cancelled. Changes were not saved.");
980 display_error(&buf[4]);
983 extract(er_name, &buf[4], 0);
984 extract(er_password, &buf[4], 1);
985 extract(er_dirname, &buf[4], 2);
986 er_flags = extract_int(&buf[4], 3);
988 strcpy(er_roomaide, bstr("er_roomaide"));
989 if (strlen(er_roomaide) == 0) {
993 strcpy(er_roomaide, "");
995 extract(er_roomaide, &buf[4], 0);
998 strcpy(buf, bstr("er_name"));
1000 if (strlen(buf) > 0)
1001 strcpy(er_name, buf);
1003 strcpy(buf, bstr("er_password"));
1005 if (strlen(buf) > 0)
1006 strcpy(er_password, buf);
1008 strcpy(buf, bstr("er_dirname"));
1010 if (strlen(buf) > 0)
1011 strcpy(er_dirname, buf);
1013 strcpy(buf, bstr("type"));
1014 er_flags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME);
1016 if (!strcmp(buf, "invonly")) {
1017 er_flags |= (QR_PRIVATE);
1019 if (!strcmp(buf, "guessname")) {
1020 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
1022 if (!strcmp(buf, "passworded")) {
1023 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
1025 if (!strcmp(bstr("prefonly"), "yes")) {
1026 er_flags |= QR_PREFONLY;
1028 er_flags &= ~QR_PREFONLY;
1031 if (!strcmp(bstr("readonly"), "yes")) {
1032 er_flags |= QR_READONLY;
1034 er_flags &= ~QR_READONLY;
1037 if (!strcmp(bstr("network"), "yes")) {
1038 er_flags |= QR_NETWORK;
1040 er_flags &= ~QR_NETWORK;
1043 if (!strcmp(bstr("directory"), "yes")) {
1044 er_flags |= QR_DIRECTORY;
1046 er_flags &= ~QR_DIRECTORY;
1049 if (!strcmp(bstr("ulallowed"), "yes")) {
1050 er_flags |= QR_UPLOAD;
1052 er_flags &= ~QR_UPLOAD;
1055 if (!strcmp(bstr("dlallowed"), "yes")) {
1056 er_flags |= QR_DOWNLOAD;
1058 er_flags &= ~QR_DOWNLOAD;
1061 if (!strcmp(bstr("visdir"), "yes")) {
1062 er_flags |= QR_VISDIR;
1064 er_flags &= ~QR_VISDIR;
1067 strcpy(buf, bstr("anon"));
1069 er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
1070 if (!strcmp(buf, "anononly"))
1071 er_flags |= QR_ANONONLY;
1072 if (!strcmp(buf, "anon2"))
1073 er_flags |= QR_ANONOPT;
1076 if (!strcmp(bstr("bump"), "yes"))
1079 er_floor = atoi(bstr("er_floor"));
1081 sprintf(buf, "SETR %s|%s|%s|%u|%d|%d",
1082 er_name, er_password, er_dirname, er_flags, bump, er_floor);
1085 if (buf[0] != '2') {
1086 display_error(&buf[4]);
1089 gotoroom(er_name, 0);
1091 if (strlen(er_roomaide) > 0) {
1092 sprintf(buf, "SETA %s", er_roomaide);
1095 if (buf[0] != '2') {
1096 display_error(&buf[4]);
1100 smart_goto(er_name);
1104 * Invite, Kick, and show Who Knows a room
1106 void display_whok(void)
1108 char buf[SIZ], room[SIZ], username[SIZ];
1113 if (buf[0] != '2') {
1114 display_error(&buf[4]);
1117 extract(room, &buf[4], 0);
1119 strcpy(username, bstr("username"));
1123 if(!strcmp(bstr("sc"), "Kick")) {
1124 sprintf(buf, "KICK %s", username);
1128 if (buf[0] != '2') {
1129 display_error(&buf[4]);
1132 wprintf("User %s kicked out of room %s.\n",
1135 } else if(!strcmp(bstr("sc"), "Invite")) {
1136 sprintf(buf, "INVT %s", username);
1140 if (buf[0] != '2') {
1141 display_error(&buf[4]);
1144 wprintf("User %s invited to room %s.\n",
1150 wprintf("<FORM METHOD=\"POST\" ACTION=\"/display_whok\">\n");
1151 wprintf("<SELECT NAME=\"username\" SIZE=10>\n");
1154 if (buf[0] == '1') {
1155 while (serv_gets(buf), strcmp(buf, "000")) {
1156 extract(username, buf, 0);
1157 wprintf("<OPTION>");
1162 wprintf("</SELECT>\n");
1164 wprintf("<CENTER>\n");
1165 wprintf("<input type=submit name=sc value=\"Kick\">");
1166 wprintf("</CENTER>\n");
1167 wprintf("</FORM>\n");
1168 wprintf("<FORM METHOD=\"POST\" ACTION=\"/display_whok\">\n");
1169 wprintf("Invite: ");
1170 wprintf("<input type=text name=username>\n");
1171 wprintf("<input type=hidden name=sc value=\"Invite\">");
1172 wprintf("<input type=submit value=\"Invite\">");
1179 * display the form for entering a new room
1181 void display_entroom(void)
1186 serv_puts("CRE8 0");
1189 if (buf[0] != '2') {
1190 display_error(&buf[4]);
1195 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=000077><TR><TD>");
1196 wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
1197 wprintf("<B>Enter (create) a new room</B>\n");
1198 wprintf("</FONT></TD></TR></TABLE>\n");
1200 wprintf("<FORM METHOD=\"POST\" ACTION=\"/entroom\">\n");
1202 wprintf("<UL><LI>Name of room: ");
1203 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" MAXLENGTH=\"19\">\n");
1205 wprintf("<LI>Type of room:<UL>\n");
1207 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1208 wprintf("CHECKED > Public room\n");
1210 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"guessname\" ");
1211 wprintf("> Private - guess name\n");
1213 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
1214 wprintf("> Private - require password:\n");
1215 wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
1217 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
1218 wprintf("> Private - invitation only\n");
1221 wprintf("<LI>Resides on floor: ");
1223 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
1224 for (i = 0; i < 128; ++i)
1225 if (strlen(floorlist[i]) > 0) {
1226 wprintf("<OPTION ");
1227 wprintf("VALUE=\"%d\">", i);
1228 escputs(floorlist[i]);
1229 wprintf("</OPTION>\n");
1231 wprintf("</SELECT>\n");
1235 wprintf("<CENTER>\n");
1236 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
1237 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1238 wprintf("</CENTER>\n");
1239 wprintf("</FORM>\n<HR>");
1240 serv_printf("MESG roomaccess");
1242 if (buf[0] == '1') {
1258 char er_password[10];
1262 if (strcmp(bstr("sc"), "OK")) {
1263 display_error("Cancelled. No new room was created.");
1266 strcpy(er_name, bstr("er_name"));
1267 strcpy(er_type, bstr("type"));
1268 strcpy(er_password, bstr("er_password"));
1269 er_floor = atoi(bstr("er_floor"));
1272 if (!strcmp(er_type, "guessname"))
1274 if (!strcmp(er_type, "passworded"))
1276 if (!strcmp(er_type, "invonly"))
1279 sprintf(buf, "CRE8 1|%s|%d|%s|%d",
1280 er_name, er_num_type, er_password, er_floor);
1283 if (buf[0] != '2') {
1284 display_error(&buf[4]);
1287 smart_goto(er_name);
1292 * display the screen to enter a private room
1294 void display_private(char *rname, int req_pass)
1299 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=770000><TR><TD>");
1300 wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
1301 wprintf("<B>Goto a private room</B>\n");
1302 wprintf("</FONT></TD></TR></TABLE>\n");
1304 wprintf("<CENTER>\n");
1305 wprintf("If you know the name of a hidden (guess-name) or\n");
1306 wprintf("passworded room, you can enter that room by typing\n");
1307 wprintf("its name below. Once you gain access to a private\n");
1308 wprintf("room, it will appear in your regular room listings\n");
1309 wprintf("so you don't have to keep returning here.\n");
1310 wprintf("<BR><BR>");
1312 wprintf("<FORM METHOD=\"POST\" ACTION=\"/goto_private\">\n");
1314 wprintf("<TABLE border><TR><TD>");
1315 wprintf("Enter room name:</TD><TD>");
1316 wprintf("<INPUT TYPE=\"text\" NAME=\"gr_name\" VALUE=\"%s\" MAXLENGTH=\"19\">\n", rname);
1319 wprintf("</TD></TR><TR><TD>");
1320 wprintf("Enter room password:</TD><TD>");
1321 wprintf("<INPUT TYPE=\"password\" NAME=\"gr_pass\" MAXLENGTH=\"9\">\n");
1323 wprintf("</TD></TR></TABLE>\n");
1325 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
1326 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1327 wprintf("</FORM>\n");
1332 * goto a private room
1334 void goto_private(void)
1339 if (strcasecmp(bstr("sc"), "OK")) {
1340 display_main_menu();
1343 strcpy(hold_rm, WC->wc_roomname);
1344 strcpy(buf, "GOTO ");
1345 strcat(buf, bstr("gr_name"));
1347 strcat(buf, bstr("gr_pass"));
1351 if (buf[0] == '2') {
1352 smart_goto(bstr("gr_name"));
1355 if (!strncmp(buf, "540", 3)) {
1356 display_private(bstr("gr_name"), 1);
1360 wprintf("%s\n", &buf[4]);
1367 * display the screen to zap a room
1369 void display_zap(void)
1373 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=770000><TR><TD>");
1374 wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
1375 wprintf("<B>Zap (forget) the current room</B>\n");
1376 wprintf("</FONT></TD></TR></TABLE>\n");
1378 wprintf("If you select this option, <em>%s</em> will ", WC->wc_roomname);
1379 wprintf("disappear from your room list. Is this what you wish ");
1380 wprintf("to do?<BR>\n");
1382 wprintf("<FORM METHOD=\"POST\" ACTION=\"/zap\">\n");
1383 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
1384 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1385 wprintf("</FORM>\n");
1396 char final_destination[SIZ];
1398 /* If the forget-room routine fails for any reason, we fall back
1399 * to the current room; otherwise, we go to the Lobby
1401 strcpy(final_destination, WC->wc_roomname);
1403 if (!strcasecmp(bstr("sc"), "OK")) {
1404 serv_printf("GOTO %s", WC->wc_roomname);
1406 if (buf[0] != '2') {
1407 /* ExpressMessageCat(&buf[4]); FIXME */
1411 if (buf[0] != '2') {
1412 /* ExpressMessageCat(&buf[4]); FIXME */
1414 strcpy(final_destination, "_BASEROOM_");
1418 smart_goto(final_destination);
1425 * Confirm deletion of the current room
1427 void confirm_delete_room(void)
1431 serv_puts("KILL 0");
1433 if (buf[0] != '2') {
1434 display_error(&buf[4]);
1438 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=770000><TR><TD>");
1439 wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
1440 wprintf("<B>Confirm deletion of room</B>\n");
1441 wprintf("</FONT></TD></TR></TABLE>\n");
1443 wprintf("<CENTER>");
1444 wprintf("<FORM METHOD=\"POST\" ACTION=\"/delete_room\">\n");
1446 wprintf("Are you sure you want to delete <FONT SIZE=+1>");
1447 escputs(WC->wc_roomname);
1448 wprintf("</FONT>?<BR>\n");
1450 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Delete\">");
1451 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1453 wprintf("</FORM></CENTER>\n");
1459 * Delete the current room
1461 void delete_room(void)
1466 strcpy(sc, bstr("sc"));
1468 if (strcasecmp(sc, "Delete")) {
1469 display_error("Cancelled. This room was not deleted.");
1472 serv_puts("KILL 1");
1474 if (buf[0] != '2') {
1475 display_error(&buf[4]);
1477 smart_goto("_BASEROOM_");
1484 * Perform changes to a room's network configuration
1486 void netedit(void) {
1498 if (buf[0] != '1') {
1504 /* This loop works for add *or* remove. Spiffy, eh? */
1505 while (serv_gets(buf), strcmp(buf, "000")) {
1506 if (strcasecmp(buf, bstr("line"))) {
1507 fprintf(fp, "%s\n", buf);
1514 if (buf[0] != '4') {
1520 while (fgets(buf, sizeof buf, fp) != NULL) {
1521 buf[strlen(buf)-1] = 0;
1525 if (!strcasecmp(bstr("cmd"), "add")) {
1526 serv_puts(bstr("line"));