13 char floorlist[128][256];
20 struct march *march = NULL;
23 * load the list of floors
25 void load_floorlist() {
29 for (a=0; a<128; ++a) floorlist[a][0] = 0;
34 strcpy(floorlist[0],"Main Floor");
37 while (serv_gets(buf), strcmp(buf,"000")) {
38 extract(floorlist[extract_int(buf,0)],buf,1);
45 * remove a room from the march list
47 void remove_march(aaa)
49 struct march *mptr,*mptr2;
51 if (march==NULL) return;
53 if (!strcasecmp(march->march_name,aaa)) {
61 for (mptr=march; mptr!=NULL; mptr=mptr->next) {
62 if (!strcasecmp(mptr->march_name,aaa)) {
63 mptr2->next = mptr->next;
80 fprintf(stderr, "doing listrms(%s)\n", variety);
83 if (buf[0]!='1') return;
84 while (serv_gets(buf), strcmp(buf,"000")) {
85 extract(rmname,buf,0);
86 wprintf("<A HREF=\"/dotgoto&room=");
90 f = extract_int(buf,1);
91 if ((f & QR_DIRECTORY) && (f & QR_NETWORK)) wprintf("}");
92 else if (f & QR_DIRECTORY) wprintf("]");
93 else if (f & QR_NETWORK) wprintf(")");
96 wprintf("</A><TT> </TT>\n");
104 * list all rooms by floor
106 void list_all_rooms_by_floor() {
113 printf("HTTP/1.0 200 OK\n");
115 wprintf("<HTML><HEAD><TITLE>List known rooms</TITLE></HEAD><BODY>\n");
117 wprintf("<TABLE width=100% border><TR><TH>Floor</TH>");
118 wprintf("<TH>Rooms with new messages</TH>");
119 wprintf("<TH>Rooms with no new messages</TH></TR>\n");
121 for (a=0; a<128; ++a) if (floorlist[a][0]!=0) {
123 /* Floor name column */
127 wprintf("<IMG SRC=\"/dynamic/_floorpic_/%d\" ALT=\"%s\">",
130 escputs(&floorlist[a][0]);
134 /* Rooms with new messages column */
136 sprintf(buf,"LKRN %d",a);
138 wprintf("</TD><TD>\n");
140 /* Rooms with old messages column */
141 sprintf(buf,"LKRO %d",a);
143 wprintf("</TD></TR>\n");
145 wprintf("</TABLE>\n");
146 wprintf("</BODY></HTML>\n");
152 * list all forgotten rooms
157 wprintf("<CENTER><H1>Forgotten rooms</H1>\n");
159 wprintf("</CENTER><HR>\n");
164 * read this room's info file (set v to 1 for verbose mode)
172 if (buf[0]=='1') fmout(NULL);
174 if (v==1) wprintf("<EM>%s</EM><BR>\n",&buf[4]);
180 * generic routine to take the session to a new room
182 * display_name values: 0 = goto only
183 * 1 = goto and display
186 void gotoroom(gname,display_name)
193 if (display_name != 2) {
194 /* store ungoto information */
195 strcpy(ugname,wc_roomname);
199 /* move to the new room */
200 sprintf(buf,"GOTO %s",gname);
204 serv_puts("GOTO _BASEROOM_");
208 wprintf("<EM>%s</EM><BR>\n",&buf[4]);
212 extract(wc_roomname,&buf[4],0);
213 room_flags = extract_int(&buf[4],4);
215 remove_march(wc_roomname);
216 if (!strcasecmp(gname,"_BASEROOM_")) remove_march(gname);
218 /* Display the room banner */
221 wprintf("<CENTER><TABLE><TR>");
223 if ( (strlen(ugname)>0) && (strcasecmp(ugname,wc_roomname)) ) {
224 wprintf("<TD><A HREF=\"/ungoto\">");
225 wprintf("<IMG SRC=\"/static/back.gif\" border=0></A></TD>");
228 wprintf("<TD><TABLE border><TR>");
229 wprintf("<TD><H1>%s</H1>",wc_roomname);
230 wprintf("%d new of %d messages</TD>\n",
231 extract_int(&buf[4],1),
232 extract_int(&buf[4],2));
237 wprintf("</TR></TABLE></TD>\n");
239 wprintf("<TD><A HREF=\"/gotonext\">");
240 wprintf("<IMG SRC=\"/dynamic/_roompic_\" border=0></A></TD>");
242 wprintf("</TR></TABLE></CENTER>\n");
245 /* highest_msg_read = extract_int(&buf[4],6);
246 maxmsgnum = extract_int(&buf[4],5);
247 is_mail = (char) extract_int(&buf[4],7); */
248 is_room_aide = (char) extract_int(&buf[4],8);
249 ls = extract_long(&buf[4],6);
251 strcpy(wc_roomname, wc_roomname);
256 * operation to goto a room
259 gotoroom(bstr("room"),1);
263 /* Goto next room having unread messages.
264 * We want to skip over rooms that the user has already been to, and take the
265 * user back to the lobby when done. The room we end up in is placed in
266 * newroom - which is set to 0 (the lobby) initially.
267 * We start the search in the current room rather than the beginning to prevent
268 * two or more concurrent users from dragging each other back to the same room.
274 struct march *mptr,*mptr2;
277 /* First check to see if the march-mode list is already allocated.
278 * If it is, pop the first room off the list and go there.
285 while (serv_gets(buf), strcmp(buf,"000")) {
286 mptr = (struct march *) malloc(sizeof(struct march));
288 extract(mptr->march_name,buf,0);
294 while (mptr2->next != NULL)
300 /* add _BASEROOM_ to the end of the march list, so the user will end up
301 * in the system base room (usually the Lobby>) at the end of the loop
303 mptr = (struct march *) malloc(sizeof(struct march));
305 strcpy(mptr->march_name,"_BASEROOM_");
311 while (mptr2->next != NULL)
316 * ...and remove the room we're currently in, so a <G>oto doesn't make us
317 * walk around in circles
319 remove_march(wc_roomname);
324 strcpy(next_room,march->march_name);
327 strcpy(next_room,"_BASEROOM_");
329 gotoroom(next_room,1);
335 * mark all messages in current room as having been read
337 void slrp_highest() {
341 serv_puts("SLRP HIGHEST");
344 wprintf("<EM>%s</EM><BR>\n",&buf[4]);
351 * un-goto the previous room
356 if (!strcmp(ugname,"")) return;
357 sprintf(buf,"GOTO %s",ugname);
361 wprintf("%s\n",&buf[4]);
364 sprintf(buf,"SLRP %ld",uglsn);
367 if (buf[0]!='2') wprintf("%s\n",&buf[4]);
374 * display the form for editing a room
376 int display_editroom() {
379 char er_password[10];
381 char er_roomaide[26];
388 wprintf("<EM>%s</EM><BR>\n",&buf[4]);
392 extract(er_name,&buf[4],0);
393 extract(er_password,&buf[4],1);
394 extract(er_dirname,&buf[4],2);
395 er_flags=extract_int(&buf[4],3);
398 wprintf("<TABLE WIDTH=100% BORDER=0 BGCOLOR=000077><TR><TD>");
399 wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
400 wprintf("<B>Edit this room</B>\n");
401 wprintf("</FONT></TD></TR></TABLE>\n");
403 wprintf("<FORM METHOD=\"POST\" ACTION=\"/editroom\">\n");
405 wprintf("<UL><LI>Name of room: ");
406 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\"19\">\n",er_name);
408 wprintf("<LI>Type of room:<UL>\n");
410 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
411 if ((er_flags & QR_PRIVATE) == 0) wprintf("CHECKED ");
412 wprintf("> Public room\n");
414 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"guessname\" ");
415 if ((er_flags & QR_PRIVATE)&&
416 (er_flags & QR_GUESSNAME)) wprintf("CHECKED ");
417 wprintf("> Private - guess name\n");
419 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
420 if ((er_flags & QR_PRIVATE)&&
421 (er_flags & QR_PASSWORDED)) wprintf("CHECKED ");
422 wprintf("> Private - require password:\n");
423 wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n",er_password);
425 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
426 if ( (er_flags & QR_PRIVATE)
427 && ((er_flags & QR_GUESSNAME) == 0)
428 && ((er_flags & QR_PASSWORDED) == 0) )
430 wprintf("> Private - invitation only\n");
432 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
433 wprintf("> If private, cause current users to forget room\n");
437 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
438 if (er_flags & QR_PREFONLY) wprintf("CHECKED ");
439 wprintf("> Preferred users only\n");
441 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
442 if (er_flags & QR_READONLY) wprintf("CHECKED ");
443 wprintf("> Read-only room\n");
445 /* directory stuff */
446 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
447 if (er_flags & QR_DIRECTORY) wprintf("CHECKED ");
448 wprintf("> File directory room\n");
450 wprintf("<UL><LI>Directory name: ");
451 wprintf("<INPUT TYPE=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n",er_dirname);
453 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
454 if (er_flags & QR_UPLOAD) wprintf("CHECKED ");
455 wprintf("> Uploading allowed\n");
457 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
458 if (er_flags & QR_DOWNLOAD) wprintf("CHECKED ");
459 wprintf("> Downloading allowed\n");
461 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
462 if (er_flags & QR_VISDIR) wprintf("CHECKED ");
463 wprintf("> Visible directory</UL>\n");
465 /* end of directory stuff */
467 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
468 if (er_flags & QR_NETWORK) wprintf("CHECKED ");
469 wprintf("> Network shared room\n");
471 /* start of anon options */
473 wprintf("<LI>Anonymous messages<UL>\n");
475 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
476 if ( ((er_flags & QR_ANONONLY)==0)
477 && ((er_flags & QR_ANONOPT)==0)) wprintf("CHECKED ");
478 wprintf("> No anonymous messages\n");
480 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
481 if (er_flags & QR_ANONONLY) wprintf("CHECKED ");
482 wprintf("> All messages are anonymous\n");
484 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
485 if (er_flags & QR_ANONOPT) wprintf("CHECKED ");
486 wprintf("> Prompt user when entering messages</UL>\n");
488 /* end of anon options */
490 wprintf("<LI>Room aide: \n");
494 wprintf("<EM>%s</EM>\n",&buf[4]);
497 extract(er_roomaide,&buf[4],0);
498 wprintf("<INPUT TYPE=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n",er_roomaide);
501 wprintf("</UL><CENTER>\n");
502 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
503 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
504 wprintf("</CENTER>\n");
506 wprintf("</FORM>\n");
512 * save new parameters for a room
517 char er_password[10];
519 char er_roomaide[26];
524 if (strcmp(bstr("sc"),"OK")) {
525 wprintf("<EM>Changes have <STRONG>not</STRONG> been saved.</EM><BR>");
533 wprintf("<EM>%s</EM><BR>\n",&buf[4]);
537 extract(er_name,&buf[4],0);
538 extract(er_password,&buf[4],1);
539 extract(er_dirname,&buf[4],2);
540 er_flags=extract_int(&buf[4],3);
542 strcpy(er_roomaide,bstr("er_roomaide"));
543 if (strlen(er_roomaide)==0) {
547 strcpy(er_roomaide,"");
550 extract(er_roomaide,&buf[4],0);
554 strcpy(buf,bstr("er_name")); buf[20] = 0;
555 if (strlen(buf)>0) strcpy(er_name,buf);
557 strcpy(buf,bstr("er_password")); buf[10] = 0;
558 if (strlen(buf)>0) strcpy(er_password,buf);
560 strcpy(buf,bstr("er_dirname")); buf[15] = 0;
561 if (strlen(buf)>0) strcpy(er_dirname,buf);
563 strcpy(buf,bstr("type"));
564 er_flags &= !(QR_PRIVATE|QR_PASSWORDED|QR_GUESSNAME);
566 if (!strcmp(buf,"invonly")) {
567 er_flags |= (QR_PRIVATE);
569 if (!strcmp(buf,"guessname")) {
570 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
572 if (!strcmp(buf,"passworded")) {
573 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
576 if (!strcmp(bstr("prefonly"),"yes")) {
577 er_flags |= QR_PREFONLY;
580 er_flags &= ~QR_PREFONLY;
583 if (!strcmp(bstr("readonly"),"yes")) {
584 er_flags |= QR_READONLY;
587 er_flags &= ~QR_READONLY;
590 if (!strcmp(bstr("network"),"yes")) {
591 er_flags |= QR_NETWORK;
594 er_flags &= ~QR_NETWORK;
597 if (!strcmp(bstr("directory"),"yes")) {
598 er_flags |= QR_DIRECTORY;
601 er_flags &= ~QR_DIRECTORY;
604 if (!strcmp(bstr("ulallowed"),"yes")) {
605 er_flags |= QR_UPLOAD;
608 er_flags &= ~QR_UPLOAD;
611 if (!strcmp(bstr("dlallowed"),"yes")) {
612 er_flags |= QR_DOWNLOAD;
615 er_flags &= ~QR_DOWNLOAD;
618 if (!strcmp(bstr("visdir"),"yes")) {
619 er_flags |= QR_VISDIR;
622 er_flags &= ~QR_VISDIR;
625 strcpy(buf,bstr("anon"));
627 er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
628 if (!strcmp(buf,"anononly")) er_flags |= QR_ANONONLY;
629 if (!strcmp(buf,"anon2")) er_flags |= QR_ANONOPT;
632 if (!strcmp(bstr("bump"),"yes")) bump = 1;
634 sprintf(buf,"SETR %s|%s|%s|%u|%d",
635 er_name,er_password,er_dirname,er_flags,bump);
639 wprintf("<EM>%s</EM><HR>\n",&buf[4]);
640 return(display_editroom());
644 if (strlen(er_roomaide)>0) {
645 sprintf(buf,"SETA %s",er_roomaide);
649 wprintf("<EM>%s</EM><HR>\n",&buf[4]);
650 return(display_editroom());
654 wprintf("<EM>Changes have been saved.</EM><BR>");
661 * display the form for entering a new room
663 int display_entroom() {
670 wprintf("<EM>%s</EM><HR>\n",&buf[4]);
674 wprintf("<TABLE WIDTH=100% BORDER=0 BGCOLOR=000077><TR><TD>");
675 wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
676 wprintf("<B>Enter (create) a new room</B>\n");
677 wprintf("</FONT></TD></TR></TABLE>\n");
679 wprintf("<FORM METHOD=\"POST\" ACTION=\"/entroom\">\n");
681 wprintf("<UL><LI>Name of room: ");
682 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" MAXLENGTH=\"19\">\n");
684 wprintf("<LI>Type of room:<UL>\n");
686 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
687 wprintf("CHECKED > Public room\n");
689 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"guessname\" ");
690 wprintf("> Private - guess name\n");
692 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
693 wprintf("> Private - require password:\n");
694 wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
696 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
697 wprintf("> Private - invitation only\n");
699 wprintf("<CENTER>\n");
700 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
701 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
702 wprintf("</CENTER>\n");
703 wprintf("</FORM>\n");
716 char er_password[10];
719 if (strcmp(bstr("sc"),"OK")) {
720 wprintf("<EM>Changes have <STRONG>not</STRONG> been saved.</EM><BR>");
724 strcpy(er_name,bstr("er_name"));
725 strcpy(er_type,bstr("type"));
726 strcpy(er_password,bstr("er_password"));
729 if (!strcmp(er_type,"guessname")) er_num_type = 1;
730 if (!strcmp(er_type,"passworded")) er_num_type = 2;
731 if (!strcmp(er_type,"invonly")) er_num_type = 3;
733 sprintf(buf,"CRE8 1|%s|%d|%s",er_name,er_num_type,er_password);
737 wprintf("<EM>%s</EM><HR>\n",&buf[4]);
738 return(display_editroom());
746 * display the screen to enter a private room
748 void display_private(rname,req_pass)
753 wprintf("<TABLE WIDTH=100% BORDER=0 BGCOLOR=770000><TR><TD>");
754 wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
755 wprintf("<B>Enter a private room</B>\n");
756 wprintf("</FONT></TD></TR></TABLE>\n");
758 wprintf("<CENTER>\n");
759 wprintf("If you know the name of a hidden (guess-name) or\n");
760 wprintf("passworded room, you can enter that room by typing\n");
761 wprintf("its name below. Once you gain access to a private\n");
762 wprintf("room, it will appear in your regular room listings\n");
763 wprintf("so you don't have to keep returning here.\n");
766 wprintf("<FORM METHOD=\"POST\" ACTION=\"/goto_private\">\n");
768 wprintf("<TABLE border><TR><TD>");
769 wprintf("Enter room name:</TD><TD>");
770 wprintf("<INPUT TYPE=\"text\" NAME=\"gr_name\" VALUE=\"%s\" MAXLENGTH=\"19\">\n",rname);
773 wprintf("</TD></TR><TR><TD>");
774 wprintf("Enter room password:</TD><TD>");
775 wprintf("<INPUT TYPE=\"password\" NAME=\"gr_pass\" MAXLENGTH=\"9\">\n");
778 wprintf("</TD></TR></TABLE>\n");
780 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
781 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
786 * goto a private room
792 if (strcmp(bstr("sc"),"OK")) {
796 strcpy(hold_rm,wc_roomname);
798 strcat(buf,bstr("gr_name"));
800 strcat(buf,bstr("gr_pass"));
805 gotoroom(bstr("gr_name"),1);
809 if (!strncmp(buf,"540",3)) {
810 display_private(bstr("gr_name"),1);
814 wprintf("<EM>%s</EM>\n",&buf[4]);
820 * display the screen to zap a room
825 strcpy(zaproom, bstr("room"));
827 wprintf("<TABLE WIDTH=100% BORDER=0 BGCOLOR=770000><TR><TD>");
828 wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
829 wprintf("<B>Zap (forget) the current room</B>\n");
830 wprintf("</FONT></TD></TR></TABLE>\n");
832 wprintf("If you select this option, <em>%s</em> will ", zaproom);
833 wprintf("disappear from your room list. Is this what you wish ");
834 wprintf("to do?<BR>\n");
836 wprintf("<FORM METHOD=\"POST\" ACTION=\"/zap\">\n");
837 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
838 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
850 if (strcmp(bstr("sc"),"OK")) {
854 strcpy(zaproom, bstr("room"));
855 sprintf(buf, "GOTO %s", zaproom);
859 wprintf("<EM>%s</EM>\n",&buf[4]);
866 wprintf("<EM>%s</EM>\n",&buf[4]);
870 gotoroom(bstr("_BASEROOM_"),1);