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 "<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;
342 void embed_room_banner(char *got) {
345 /* We need to have the information returned by a GOTO server command.
346 * If it isn't supplied, we fake it by issuing our own GOTO.
349 serv_printf("GOTO %s", WC->wc_roomname);
354 /* Check for new mail. */
355 WC->new_mail = extract_int(&got[4], 9);
357 svprintf("ROOMNAME", WCS_STRING, "%s", WC->wc_roomname);
358 svprintf("NEWMSGS", WCS_STRING, "%d", extract_int(&got[4], 1));
359 svprintf("TOTALMSGS", WCS_STRING, "%d", extract_int(&got[4], 2));
360 svcallback("ROOMPIC", embed_room_graphic);
361 svcallback("ROOMINFO", readinfo);
362 svcallback("YOUHAVEMAIL", embed_newmail_button);
364 do_template("roombanner.html");
365 clear_local_substs();
373 * generic routine to take the session to a new room
375 * display_name values: 0 = goto only
376 * 1 = goto and display
379 void gotoroom(char *gname, int display_name)
382 static long ls = (-1L);
387 wprintf("Pragma: no-cache\n");
388 wprintf("Cache-Control: no-store\n");
390 wprintf("<HTML><HEAD>\n"
391 "<META HTTP-EQUIV=\"refresh\" CONTENT=\"500363689;\">\n"
392 "<META HTTP-EQUIV=\"Pragma\" CONTENT=\"no-cache\">\n"
393 "<META HTTP-EQUIV=\"expired\" CONTENT=\"28-May-1971 18:10:00 GMT\">\n"
394 "<meta name=\"MSSmartTagsPreventParsing\" content=\"TRUE\">\n"
396 do_template("background.html");
398 if (display_name != 2) {
399 /* store ungoto information */
400 strcpy(WC->ugname, WC->wc_roomname);
403 /* move to the new room */
404 serv_printf("GOTO %s", gname);
407 serv_puts("GOTO _BASEROOM_");
412 wprintf("<EM>%s</EM><BR>\n", &buf[4]);
417 extract(WC->wc_roomname, &buf[4], 0);
418 WC->room_flags = extract_int(&buf[4], 4);
419 /* highest_msg_read = extract_int(&buf[4],6);
420 maxmsgnum = extract_int(&buf[4],5);
421 is_mail = (char) extract_int(&buf[4],7); */
422 ls = extract_long(&buf[4], 6);
425 WC->is_room_aide = WC->is_aide;
427 WC->is_room_aide = (char) extract_int(&buf[4], 8);
429 remove_march(WC->wc_roomname);
430 if (!strcasecmp(gname, "_BASEROOM_"))
433 /* Display the room banner */
435 embed_room_banner(buf);
438 strcpy(WC->wc_roomname, WC->wc_roomname);
443 * Locate the room on the march list which we most want to go to. Each room
444 * is measured given a "weight" of preference based on various factors.
446 char *pop_march(int desired_floor)
448 static char TheRoom[64];
450 int TheOrder = 32767;
453 struct march *mptr = NULL;
455 strcpy(TheRoom, "_BASEROOM_");
456 if (WC->march == NULL)
459 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
461 if ((strcasecmp(mptr->march_name, "_BASEROOM_")))
462 weight = weight + 10000;
463 if (mptr->march_floor == desired_floor)
464 weight = weight + 5000;
466 weight = weight + ((128 - (mptr->march_floor)) * 128);
467 weight = weight + (128 - (mptr->march_order));
469 if (weight > TheWeight) {
471 strcpy(TheRoom, mptr->march_name);
472 TheFloor = mptr->march_floor;
473 TheOrder = mptr->march_order;
481 /* Goto next room having unread messages.
482 * We want to skip over rooms that the user has already been to, and take the
483 * user back to the lobby when done. The room we end up in is placed in
484 * newroom - which is set to 0 (the lobby) initially.
485 * We start the search in the current room rather than the beginning to prevent
486 * two or more concurrent users from dragging each other back to the same room.
491 struct march *mptr, *mptr2;
494 /* First check to see if the march-mode list is already allocated.
495 * If it is, pop the first room off the list and go there.
498 if (WC->march == NULL) {
502 while (serv_gets(buf), strcmp(buf, "000")) {
503 mptr = (struct march *) malloc(sizeof(struct march));
505 extract(mptr->march_name, buf, 0);
506 mptr->march_floor = extract_int(buf, 2);
507 mptr->march_order = extract_int(buf, 3);
508 if (WC->march == NULL) {
512 while (mptr2->next != NULL)
517 /* add _BASEROOM_ to the end of the march list, so the user will end up
518 * in the system base room (usually the Lobby>) at the end of the loop
520 mptr = (struct march *) malloc(sizeof(struct march));
522 strcpy(mptr->march_name, "_BASEROOM_");
523 if (WC->march == NULL) {
527 while (mptr2->next != NULL)
532 * ...and remove the room we're currently in, so a <G>oto doesn't make us
533 * walk around in circles
535 remove_march(WC->wc_roomname);
537 if (WC->march != NULL) {
538 strcpy(next_room, pop_march(-1));
540 strcpy(next_room, "_BASEROOM_");
544 smart_goto(next_room);
548 void smart_goto(char *next_room) {
549 gotoroom(next_room, 0);
556 * mark all messages in current room as having been read
558 void slrp_highest(void)
563 serv_puts("SLRP HIGHEST");
566 wprintf("<EM>%s</EM><BR>\n", &buf[4]);
573 * un-goto the previous room
579 if (!strcmp(WC->ugname, "")) {
580 smart_goto(WC->wc_roomname);
583 serv_printf("GOTO %s", WC->ugname);
586 smart_goto(WC->wc_roomname);
589 if (WC->uglsn >= 0L) {
590 serv_printf("SLRP %ld", WC->uglsn);
593 strcpy(buf, WC->ugname);
594 strcpy(WC->ugname, "");
599 * display the form for editing a room
601 void display_editroom(void)
608 char er_password[10];
610 char er_roomaide[26];
616 char *not_shared_with;
619 if (strlen(tab) == 0) tab = "admin";
625 display_error(&buf[4]);
628 extract(er_name, &buf[4], 0);
629 extract(er_password, &buf[4], 1);
630 extract(er_dirname, &buf[4], 2);
631 er_flags = extract_int(&buf[4], 3);
632 er_floor = extract_int(&buf[4], 4);
636 /* print the tabbed dialog */
637 wprintf("<TABLE border=0 width=100%%><TR BGCOLOR=FFFFFF><TD> </TD>");
639 if (!strcmp(tab, "admin")) {
640 wprintf("<TD BGCOLOR=000077><FONT SIZE=+1 COLOR=\"FFFFFF\"><B>");
643 wprintf("<TD><A HREF=\"/display_editroom&tab=admin\">");
645 wprintf("Room administration");
646 if (!strcmp(tab, "admin")) {
647 wprintf("</B></FONT></TD>\n");
650 wprintf("</A></TD>\n");
653 wprintf("<TD> </TD>\n");
655 if (!strcmp(tab, "config")) {
656 wprintf("<TD BGCOLOR=000077><FONT SIZE=+1 COLOR=\"FFFFFF\"><B>");
659 wprintf("<TD><A HREF=\"/display_editroom&tab=config\">");
661 wprintf("Room configuration");
662 if (!strcmp(tab, "config")) {
663 wprintf("</B></FONT></TD>\n");
666 wprintf("</A></TD>\n");
669 wprintf("<TD> </TD>\n");
671 if (!strcmp(tab, "sharing")) {
672 wprintf("<TD BGCOLOR=000077><FONT SIZE=+1 COLOR=\"FFFFFF\"><B>");
675 wprintf("<TD><A HREF=\"/display_editroom&tab=sharing\">");
678 if (!strcmp(tab, "sharing")) {
679 wprintf("</B></FONT></TD>\n");
682 wprintf("</A></TD>\n");
685 wprintf("<TD> </TD>\n");
687 if (!strcmp(tab, "listserv")) {
688 wprintf("<TD BGCOLOR=000077><FONT SIZE=+1 COLOR=\"FFFFFF\"><B>");
691 wprintf("<TD><A HREF=\"/display_editroom&tab=listserv\">");
693 wprintf("Mailing list service");
694 if (!strcmp(tab, "listserv")) {
695 wprintf("</B></FONT></TD>\n");
698 wprintf("</A></TD>\n");
701 wprintf("<TD> </TD></TR></TABLE>\n");
703 /* end tabbed dialog */
706 if (!strcmp(tab, "admin")) {
708 "<LI><A HREF=\"/confirm_delete_room\">\n"
709 "Delete this room</A>\n"
710 "<LI><A HREF=\"/display_editroompic\">\n"
711 "Set or change the graphic for this room's banner</A>\n"
712 "<LI><A HREF=\"/display_editinfo\">\n"
713 "Edit this room's Info file</A>\n"
717 if (!strcmp(tab, "config")) {
718 wprintf("<FORM METHOD=\"POST\" ACTION=\"/editroom\">\n");
720 wprintf("<UL><LI>Name of room: ");
721 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\"19\">\n", er_name);
723 wprintf("<LI>Resides on floor: ");
725 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
726 for (i = 0; i < 128; ++i)
727 if (strlen(floorlist[i]) > 0) {
730 wprintf("SELECTED ");
731 wprintf("VALUE=\"%d\">", i);
732 escputs(floorlist[i]);
733 wprintf("</OPTION>\n");
735 wprintf("</SELECT>\n");
737 wprintf("<LI>Type of room:<UL>\n");
739 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
740 if ((er_flags & QR_PRIVATE) == 0)
742 wprintf("> Public room\n");
744 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"guessname\" ");
745 if ((er_flags & QR_PRIVATE) &&
746 (er_flags & QR_GUESSNAME))
748 wprintf("> Private - guess name\n");
750 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
751 if ((er_flags & QR_PRIVATE) &&
752 (er_flags & QR_PASSWORDED))
754 wprintf("> Private - require password:\n");
755 wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n", er_password);
757 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
758 if ((er_flags & QR_PRIVATE)
759 && ((er_flags & QR_GUESSNAME) == 0)
760 && ((er_flags & QR_PASSWORDED) == 0))
762 wprintf("> Private - invitation only\n");
764 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
765 wprintf("> If private, cause current users to forget room\n");
769 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
770 if (er_flags & QR_PREFONLY)
772 wprintf("> Preferred users only\n");
774 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
775 if (er_flags & QR_READONLY)
777 wprintf("> Read-only room\n");
779 /* directory stuff */
780 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
781 if (er_flags & QR_DIRECTORY)
783 wprintf("> File directory room\n");
785 wprintf("<UL><LI>Directory name: ");
786 wprintf("<INPUT TYPE=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n", er_dirname);
788 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
789 if (er_flags & QR_UPLOAD)
791 wprintf("> Uploading allowed\n");
793 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
794 if (er_flags & QR_DOWNLOAD)
796 wprintf("> Downloading allowed\n");
798 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
799 if (er_flags & QR_VISDIR)
801 wprintf("> Visible directory</UL>\n");
803 /* end of directory stuff */
805 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
806 if (er_flags & QR_NETWORK)
808 wprintf("> Network shared room\n");
810 /* start of anon options */
812 wprintf("<LI>Anonymous messages<UL>\n");
814 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
815 if (((er_flags & QR_ANONONLY) == 0)
816 && ((er_flags & QR_ANONOPT) == 0))
818 wprintf("> No anonymous messages\n");
820 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
821 if (er_flags & QR_ANONONLY)
823 wprintf("> All messages are anonymous\n");
825 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
826 if (er_flags & QR_ANONOPT)
828 wprintf("> Prompt user when entering messages</UL>\n");
830 /* end of anon options */
832 wprintf("<LI>Room aide: \n");
836 wprintf("<EM>%s</EM>\n", &buf[4]);
838 extract(er_roomaide, &buf[4], 0);
839 wprintf("<INPUT TYPE=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n", er_roomaide);
842 wprintf("</UL><CENTER>\n");
843 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
844 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
845 wprintf("</CENTER>\n");
849 /* Sharing the room with other Citadel nodes... */
850 if (!strcmp(tab, "sharing")) {
852 shared_with = strdup("");
853 not_shared_with = strdup("");
855 /* Learn the current configuration */
856 serv_puts("CONF getsys|application/x-citadel-ignet-config");
858 if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
859 extract(node, buf, 0);
860 not_shared_with = realloc(not_shared_with,
861 strlen(not_shared_with) + 32);
862 strcat(not_shared_with, node);
863 strcat(not_shared_with, "|");
868 if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
869 extract(cmd, buf, 0);
870 extract(node, buf, 1);
871 if (!strcasecmp(cmd, "ignet_push_share")) {
872 shared_with = realloc(shared_with,
873 strlen(shared_with) + 32);
874 strcat(shared_with, node);
875 strcat(shared_with, "|");
879 for (i=0; i<num_tokens(shared_with, '|'); ++i) {
880 extract(node, shared_with, i);
881 for (j=0; j<num_tokens(not_shared_with, '|'); ++j) {
882 extract(cmd, not_shared_with, j);
883 if (!strcasecmp(node, cmd)) {
884 remove_token(not_shared_with, j, '|');
889 /* Display the stuff */
890 wprintf("<CENTER><BR>"
891 "<TABLE border=1 cellpadding=5><TR>"
892 "<TD><B><I>Shared with</I></B></TD>"
893 "<TD><B><I>Not shared with</I></B></TD></TR>\n"
896 for (i=0; i<num_tokens(shared_with, '|'); ++i) {
897 extract(node, shared_with, i);
898 if (strlen(node) > 0) {
899 wprintf("%s ", node);
900 wprintf("<A HREF=\"/netedit&cmd=remove&line="
901 "ignet_push_share|");
903 wprintf("&tab=sharing\">(unshare)</A><BR>");
907 wprintf("</TD><TD>\n");
909 for (i=0; i<num_tokens(not_shared_with, '|'); ++i) {
910 extract(node, not_shared_with, i);
911 if (strlen(node) > 0) {
912 wprintf("%s ", node);
913 wprintf("<A HREF=\"/netedit&cmd=add&line="
914 "ignet_push_share|");
916 wprintf("&tab=sharing\">(share)</A><BR>");
920 wprintf("</TD></TR></TABLE><BR>\n"
921 "<I><B>Reminder:</B> When sharing a room, "
922 "it must be shared from both ends. Adding a node to "
923 "the 'shared' list sends messages out, but in order to"
924 " receive messages, the other nodes must be configured"
925 " to send messages out to your system as well.</I><BR>"
930 /* Mailing list management */
931 if (!strcmp(tab, "listserv")) {
933 wprintf("<BR><center><i>The contents of this room are being "
934 "mailed to the following list recipients:"
939 if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
940 extract(cmd, buf, 0);
941 if (!strcasecmp(cmd, "listrecp")) {
942 extract(recp, buf, 1);
945 wprintf(" <A HREF=\"/netedit&cmd=remove&line="
948 wprintf("&tab=listserv\">(remove)</A><BR>");
952 wprintf("<BR><FORM METHOD=\"POST\" ACTION=\"/netedit\">\n"
953 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
954 "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"listrecp|\">\n");
955 wprintf("<INPUT TYPE=\"text\" NAME=\"line\">\n");
956 wprintf("<INPUT TYPE=\"submit\" NAME=\"cmd\" VALUE=\"Add\">");
957 wprintf("</FORM><BR></CENTER>\n");
965 * save new parameters for a room
971 char er_password[10];
973 char er_roomaide[26];
979 if (strcmp(bstr("sc"), "OK")) {
980 display_error("Cancelled. Changes were not saved.");
987 display_error(&buf[4]);
990 extract(er_name, &buf[4], 0);
991 extract(er_password, &buf[4], 1);
992 extract(er_dirname, &buf[4], 2);
993 er_flags = extract_int(&buf[4], 3);
995 strcpy(er_roomaide, bstr("er_roomaide"));
996 if (strlen(er_roomaide) == 0) {
1000 strcpy(er_roomaide, "");
1002 extract(er_roomaide, &buf[4], 0);
1005 strcpy(buf, bstr("er_name"));
1007 if (strlen(buf) > 0)
1008 strcpy(er_name, buf);
1010 strcpy(buf, bstr("er_password"));
1012 if (strlen(buf) > 0)
1013 strcpy(er_password, buf);
1015 strcpy(buf, bstr("er_dirname"));
1017 if (strlen(buf) > 0)
1018 strcpy(er_dirname, buf);
1020 strcpy(buf, bstr("type"));
1021 er_flags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME);
1023 if (!strcmp(buf, "invonly")) {
1024 er_flags |= (QR_PRIVATE);
1026 if (!strcmp(buf, "guessname")) {
1027 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
1029 if (!strcmp(buf, "passworded")) {
1030 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
1032 if (!strcmp(bstr("prefonly"), "yes")) {
1033 er_flags |= QR_PREFONLY;
1035 er_flags &= ~QR_PREFONLY;
1038 if (!strcmp(bstr("readonly"), "yes")) {
1039 er_flags |= QR_READONLY;
1041 er_flags &= ~QR_READONLY;
1044 if (!strcmp(bstr("network"), "yes")) {
1045 er_flags |= QR_NETWORK;
1047 er_flags &= ~QR_NETWORK;
1050 if (!strcmp(bstr("directory"), "yes")) {
1051 er_flags |= QR_DIRECTORY;
1053 er_flags &= ~QR_DIRECTORY;
1056 if (!strcmp(bstr("ulallowed"), "yes")) {
1057 er_flags |= QR_UPLOAD;
1059 er_flags &= ~QR_UPLOAD;
1062 if (!strcmp(bstr("dlallowed"), "yes")) {
1063 er_flags |= QR_DOWNLOAD;
1065 er_flags &= ~QR_DOWNLOAD;
1068 if (!strcmp(bstr("visdir"), "yes")) {
1069 er_flags |= QR_VISDIR;
1071 er_flags &= ~QR_VISDIR;
1074 strcpy(buf, bstr("anon"));
1076 er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
1077 if (!strcmp(buf, "anononly"))
1078 er_flags |= QR_ANONONLY;
1079 if (!strcmp(buf, "anon2"))
1080 er_flags |= QR_ANONOPT;
1083 if (!strcmp(bstr("bump"), "yes"))
1086 er_floor = atoi(bstr("er_floor"));
1088 sprintf(buf, "SETR %s|%s|%s|%u|%d|%d",
1089 er_name, er_password, er_dirname, er_flags, bump, er_floor);
1092 if (buf[0] != '2') {
1093 display_error(&buf[4]);
1096 gotoroom(er_name, 0);
1098 if (strlen(er_roomaide) > 0) {
1099 sprintf(buf, "SETA %s", er_roomaide);
1102 if (buf[0] != '2') {
1103 display_error(&buf[4]);
1107 smart_goto(er_name);
1111 * Invite, Kick, and show Who Knows a room
1113 void display_whok(void)
1115 char buf[SIZ], room[SIZ], username[SIZ];
1120 if (buf[0] != '2') {
1121 display_error(&buf[4]);
1124 extract(room, &buf[4], 0);
1126 strcpy(username, bstr("username"));
1130 if(!strcmp(bstr("sc"), "Kick")) {
1131 sprintf(buf, "KICK %s", username);
1135 if (buf[0] != '2') {
1136 display_error(&buf[4]);
1139 wprintf("User %s kicked out of room %s.\n",
1142 } else if(!strcmp(bstr("sc"), "Invite")) {
1143 sprintf(buf, "INVT %s", username);
1147 if (buf[0] != '2') {
1148 display_error(&buf[4]);
1151 wprintf("User %s invited to room %s.\n",
1157 wprintf("<FORM METHOD=\"POST\" ACTION=\"/display_whok\">\n");
1158 wprintf("<SELECT NAME=\"username\" SIZE=10>\n");
1161 if (buf[0] == '1') {
1162 while (serv_gets(buf), strcmp(buf, "000")) {
1163 extract(username, buf, 0);
1164 wprintf("<OPTION>");
1169 wprintf("</SELECT>\n");
1171 wprintf("<CENTER>\n");
1172 wprintf("<input type=submit name=sc value=\"Kick\">");
1173 wprintf("</CENTER>\n");
1174 wprintf("</FORM>\n");
1175 wprintf("<FORM METHOD=\"POST\" ACTION=\"/display_whok\">\n");
1176 wprintf("Invite: ");
1177 wprintf("<input type=text name=username>\n");
1178 wprintf("<input type=hidden name=sc value=\"Invite\">");
1179 wprintf("<input type=submit value=\"Invite\">");
1186 * display the form for entering a new room
1188 void display_entroom(void)
1193 serv_puts("CRE8 0");
1196 if (buf[0] != '2') {
1197 display_error(&buf[4]);
1202 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=000077><TR><TD>");
1203 wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
1204 wprintf("<B>Enter (create) a new room</B>\n");
1205 wprintf("</FONT></TD></TR></TABLE>\n");
1207 wprintf("<FORM METHOD=\"POST\" ACTION=\"/entroom\">\n");
1209 wprintf("<UL><LI>Name of room: ");
1210 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" MAXLENGTH=\"19\">\n");
1212 wprintf("<LI>Type of room:<UL>\n");
1214 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1215 wprintf("CHECKED > Public room\n");
1217 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"guessname\" ");
1218 wprintf("> Private - guess name\n");
1220 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
1221 wprintf("> Private - require password:\n");
1222 wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
1224 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
1225 wprintf("> Private - invitation only\n");
1228 wprintf("<LI>Resides on floor: ");
1230 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
1231 for (i = 0; i < 128; ++i)
1232 if (strlen(floorlist[i]) > 0) {
1233 wprintf("<OPTION ");
1234 wprintf("VALUE=\"%d\">", i);
1235 escputs(floorlist[i]);
1236 wprintf("</OPTION>\n");
1238 wprintf("</SELECT>\n");
1242 wprintf("<CENTER>\n");
1243 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
1244 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1245 wprintf("</CENTER>\n");
1246 wprintf("</FORM>\n<HR>");
1247 serv_printf("MESG roomaccess");
1249 if (buf[0] == '1') {
1265 char er_password[10];
1269 if (strcmp(bstr("sc"), "OK")) {
1270 display_error("Cancelled. No new room was created.");
1273 strcpy(er_name, bstr("er_name"));
1274 strcpy(er_type, bstr("type"));
1275 strcpy(er_password, bstr("er_password"));
1276 er_floor = atoi(bstr("er_floor"));
1279 if (!strcmp(er_type, "guessname"))
1281 if (!strcmp(er_type, "passworded"))
1283 if (!strcmp(er_type, "invonly"))
1286 sprintf(buf, "CRE8 1|%s|%d|%s|%d",
1287 er_name, er_num_type, er_password, er_floor);
1290 if (buf[0] != '2') {
1291 display_error(&buf[4]);
1294 smart_goto(er_name);
1299 * display the screen to enter a private room
1301 void display_private(char *rname, int req_pass)
1306 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=770000><TR><TD>");
1307 wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
1308 wprintf("<B>Goto a private room</B>\n");
1309 wprintf("</FONT></TD></TR></TABLE>\n");
1311 wprintf("<CENTER>\n");
1312 wprintf("If you know the name of a hidden (guess-name) or\n");
1313 wprintf("passworded room, you can enter that room by typing\n");
1314 wprintf("its name below. Once you gain access to a private\n");
1315 wprintf("room, it will appear in your regular room listings\n");
1316 wprintf("so you don't have to keep returning here.\n");
1317 wprintf("<BR><BR>");
1319 wprintf("<FORM METHOD=\"POST\" ACTION=\"/goto_private\">\n");
1321 wprintf("<TABLE border><TR><TD>");
1322 wprintf("Enter room name:</TD><TD>");
1323 wprintf("<INPUT TYPE=\"text\" NAME=\"gr_name\" VALUE=\"%s\" MAXLENGTH=\"19\">\n", rname);
1326 wprintf("</TD></TR><TR><TD>");
1327 wprintf("Enter room password:</TD><TD>");
1328 wprintf("<INPUT TYPE=\"password\" NAME=\"gr_pass\" MAXLENGTH=\"9\">\n");
1330 wprintf("</TD></TR></TABLE>\n");
1332 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
1333 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1334 wprintf("</FORM>\n");
1339 * goto a private room
1341 void goto_private(void)
1346 if (strcasecmp(bstr("sc"), "OK")) {
1347 display_main_menu();
1350 strcpy(hold_rm, WC->wc_roomname);
1351 strcpy(buf, "GOTO ");
1352 strcat(buf, bstr("gr_name"));
1354 strcat(buf, bstr("gr_pass"));
1358 if (buf[0] == '2') {
1359 smart_goto(bstr("gr_name"));
1362 if (!strncmp(buf, "540", 3)) {
1363 display_private(bstr("gr_name"), 1);
1367 wprintf("%s\n", &buf[4]);
1374 * display the screen to zap a room
1376 void display_zap(void)
1380 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=770000><TR><TD>");
1381 wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
1382 wprintf("<B>Zap (forget) the current room</B>\n");
1383 wprintf("</FONT></TD></TR></TABLE>\n");
1385 wprintf("If you select this option, <em>%s</em> will ", WC->wc_roomname);
1386 wprintf("disappear from your room list. Is this what you wish ");
1387 wprintf("to do?<BR>\n");
1389 wprintf("<FORM METHOD=\"POST\" ACTION=\"/zap\">\n");
1390 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
1391 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1392 wprintf("</FORM>\n");
1403 char final_destination[SIZ];
1405 /* If the forget-room routine fails for any reason, we fall back
1406 * to the current room; otherwise, we go to the Lobby
1408 strcpy(final_destination, WC->wc_roomname);
1410 if (!strcasecmp(bstr("sc"), "OK")) {
1411 serv_printf("GOTO %s", WC->wc_roomname);
1413 if (buf[0] != '2') {
1414 /* ExpressMessageCat(&buf[4]); */
1418 if (buf[0] != '2') {
1419 /* ExpressMessageCat(&buf[4]); */
1421 strcpy(final_destination, "_BASEROOM_");
1425 smart_goto(final_destination);
1432 * Confirm deletion of the current room
1434 void confirm_delete_room(void)
1438 serv_puts("KILL 0");
1440 if (buf[0] != '2') {
1441 display_error(&buf[4]);
1445 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=770000><TR><TD>");
1446 wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
1447 wprintf("<B>Confirm deletion of room</B>\n");
1448 wprintf("</FONT></TD></TR></TABLE>\n");
1450 wprintf("<CENTER>");
1451 wprintf("<FORM METHOD=\"POST\" ACTION=\"/delete_room\">\n");
1453 wprintf("Are you sure you want to delete <FONT SIZE=+1>");
1454 escputs(WC->wc_roomname);
1455 wprintf("</FONT>?<BR>\n");
1457 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Delete\">");
1458 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1460 wprintf("</FORM></CENTER>\n");
1466 * Delete the current room
1468 void delete_room(void)
1473 strcpy(sc, bstr("sc"));
1475 if (strcasecmp(sc, "Delete")) {
1476 display_error("Cancelled. This room was not deleted.");
1479 serv_puts("KILL 1");
1481 if (buf[0] != '2') {
1482 display_error(&buf[4]);
1484 smart_goto("_BASEROOM_");
1491 * Perform changes to a room's network configuration
1493 void netedit(void) {
1498 if (strlen(bstr("line"))==0) {
1503 strcpy(line, bstr("prefix"));
1504 strcat(line, bstr("line"));
1505 strcat(line, bstr("suffix"));
1515 if (buf[0] != '1') {
1521 /* This loop works for add *or* remove. Spiffy, eh? */
1522 while (serv_gets(buf), strcmp(buf, "000")) {
1523 if (strcasecmp(buf, line)) {
1524 fprintf(fp, "%s\n", buf);
1531 if (buf[0] != '4') {
1537 while (fgets(buf, sizeof buf, fp) != NULL) {
1538 buf[strlen(buf)-1] = 0;
1542 if (!strcasecmp(bstr("cmd"), "add")) {