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=");
88 wprintf("\" TARGET=\"top\">");
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)
194 printf("HTTP/1.0 200 OK\n");
196 wprintf("<HTML><BODY>\n");
198 if (display_name != 2) {
199 /* store ungoto information */
200 strcpy(ugname,wc_roomname);
204 /* move to the new room */
205 sprintf(buf,"GOTO %s",gname);
209 serv_puts("GOTO _BASEROOM_");
213 wprintf("<EM>%s</EM><BR>\n",&buf[4]);
218 extract(wc_roomname,&buf[4],0);
219 room_flags = extract_int(&buf[4],4);
221 remove_march(wc_roomname);
222 if (!strcasecmp(gname,"_BASEROOM_")) remove_march(gname);
224 /* Display the room banner */
227 wprintf("<CENTER><TABLE border=0><TR>");
229 if ( (strlen(ugname)>0) && (strcasecmp(ugname,wc_roomname)) ) {
230 wprintf("<TD><A HREF=\"/ungoto\">");
231 wprintf("<IMG SRC=\"/static/back.gif\" border=0></A></TD>");
234 wprintf("<TD><H1>%s</H1>",wc_roomname);
235 wprintf("<FONT SIZE=-1>%d new of %d messages</FONT></TD>\n",
236 extract_int(&buf[4],1),
237 extract_int(&buf[4],2));
239 /* FIX add room image here */
245 wprintf("<TD><A HREF=\"/gotonext\">");
246 wprintf("<IMG SRC=\"/static/forward.gif\" border=0></A></TD>");
248 wprintf("</TR></TABLE></CENTER>\n");
251 /* highest_msg_read = extract_int(&buf[4],6);
252 maxmsgnum = extract_int(&buf[4],5);
253 is_mail = (char) extract_int(&buf[4],7); */
254 is_room_aide = (char) extract_int(&buf[4],8);
255 ls = extract_long(&buf[4],6);
257 strcpy(wc_roomname, wc_roomname);
263 * operation to goto a room
266 gotoroom(bstr("room"),1);
270 /* Goto next room having unread messages.
271 * We want to skip over rooms that the user has already been to, and take the
272 * user back to the lobby when done. The room we end up in is placed in
273 * newroom - which is set to 0 (the lobby) initially.
274 * We start the search in the current room rather than the beginning to prevent
275 * two or more concurrent users from dragging each other back to the same room.
281 struct march *mptr,*mptr2;
284 /* First check to see if the march-mode list is already allocated.
285 * If it is, pop the first room off the list and go there.
292 while (serv_gets(buf), strcmp(buf,"000")) {
293 mptr = (struct march *) malloc(sizeof(struct march));
295 extract(mptr->march_name,buf,0);
301 while (mptr2->next != NULL)
307 /* add _BASEROOM_ to the end of the march list, so the user will end up
308 * in the system base room (usually the Lobby>) at the end of the loop
310 mptr = (struct march *) malloc(sizeof(struct march));
312 strcpy(mptr->march_name,"_BASEROOM_");
318 while (mptr2->next != NULL)
323 * ...and remove the room we're currently in, so a <G>oto doesn't make us
324 * walk around in circles
326 remove_march(wc_roomname);
331 strcpy(next_room,march->march_name);
334 strcpy(next_room,"_BASEROOM_");
336 gotoroom(next_room,1);
342 * mark all messages in current room as having been read
344 void slrp_highest() {
348 serv_puts("SLRP HIGHEST");
351 wprintf("<EM>%s</EM><BR>\n",&buf[4]);
358 * un-goto the previous room
363 if (!strcmp(ugname,"")) return;
364 sprintf(buf,"GOTO %s",ugname);
368 wprintf("%s\n",&buf[4]);
371 sprintf(buf,"SLRP %ld",uglsn);
374 if (buf[0]!='2') wprintf("%s\n",&buf[4]);
381 * display the form for editing a room
383 int display_editroom() {
386 char er_password[10];
388 char er_roomaide[26];
395 wprintf("<EM>%s</EM><BR>\n",&buf[4]);
399 extract(er_name,&buf[4],0);
400 extract(er_password,&buf[4],1);
401 extract(er_dirname,&buf[4],2);
402 er_flags=extract_int(&buf[4],3);
405 wprintf("<TABLE WIDTH=100% BORDER=0 BGCOLOR=000077><TR><TD>");
406 wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
407 wprintf("<B>Edit this room</B>\n");
408 wprintf("</FONT></TD></TR></TABLE>\n");
410 wprintf("<FORM METHOD=\"POST\" ACTION=\"/editroom\">\n");
412 wprintf("<UL><LI>Name of room: ");
413 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\"19\">\n",er_name);
415 wprintf("<LI>Type of room:<UL>\n");
417 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
418 if ((er_flags & QR_PRIVATE) == 0) wprintf("CHECKED ");
419 wprintf("> Public room\n");
421 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"guessname\" ");
422 if ((er_flags & QR_PRIVATE)&&
423 (er_flags & QR_GUESSNAME)) wprintf("CHECKED ");
424 wprintf("> Private - guess name\n");
426 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
427 if ((er_flags & QR_PRIVATE)&&
428 (er_flags & QR_PASSWORDED)) wprintf("CHECKED ");
429 wprintf("> Private - require password:\n");
430 wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n",er_password);
432 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
433 if ( (er_flags & QR_PRIVATE)
434 && ((er_flags & QR_GUESSNAME) == 0)
435 && ((er_flags & QR_PASSWORDED) == 0) )
437 wprintf("> Private - invitation only\n");
439 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
440 wprintf("> If private, cause current users to forget room\n");
444 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
445 if (er_flags & QR_PREFONLY) wprintf("CHECKED ");
446 wprintf("> Preferred users only\n");
448 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
449 if (er_flags & QR_READONLY) wprintf("CHECKED ");
450 wprintf("> Read-only room\n");
452 /* directory stuff */
453 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
454 if (er_flags & QR_DIRECTORY) wprintf("CHECKED ");
455 wprintf("> File directory room\n");
457 wprintf("<UL><LI>Directory name: ");
458 wprintf("<INPUT TYPE=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n",er_dirname);
460 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
461 if (er_flags & QR_UPLOAD) wprintf("CHECKED ");
462 wprintf("> Uploading allowed\n");
464 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
465 if (er_flags & QR_DOWNLOAD) wprintf("CHECKED ");
466 wprintf("> Downloading allowed\n");
468 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
469 if (er_flags & QR_VISDIR) wprintf("CHECKED ");
470 wprintf("> Visible directory</UL>\n");
472 /* end of directory stuff */
474 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
475 if (er_flags & QR_NETWORK) wprintf("CHECKED ");
476 wprintf("> Network shared room\n");
478 /* start of anon options */
480 wprintf("<LI>Anonymous messages<UL>\n");
482 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
483 if ( ((er_flags & QR_ANONONLY)==0)
484 && ((er_flags & QR_ANONOPT)==0)) wprintf("CHECKED ");
485 wprintf("> No anonymous messages\n");
487 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
488 if (er_flags & QR_ANONONLY) wprintf("CHECKED ");
489 wprintf("> All messages are anonymous\n");
491 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
492 if (er_flags & QR_ANONOPT) wprintf("CHECKED ");
493 wprintf("> Prompt user when entering messages</UL>\n");
495 /* end of anon options */
497 wprintf("<LI>Room aide: \n");
501 wprintf("<EM>%s</EM>\n",&buf[4]);
504 extract(er_roomaide,&buf[4],0);
505 wprintf("<INPUT TYPE=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n",er_roomaide);
508 wprintf("</UL><CENTER>\n");
509 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
510 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
511 wprintf("</CENTER>\n");
513 wprintf("</FORM>\n");
519 * save new parameters for a room
524 char er_password[10];
526 char er_roomaide[26];
531 if (strcmp(bstr("sc"),"OK")) {
532 wprintf("<EM>Changes have <STRONG>not</STRONG> been saved.</EM><BR>");
540 wprintf("<EM>%s</EM><BR>\n",&buf[4]);
544 extract(er_name,&buf[4],0);
545 extract(er_password,&buf[4],1);
546 extract(er_dirname,&buf[4],2);
547 er_flags=extract_int(&buf[4],3);
549 strcpy(er_roomaide,bstr("er_roomaide"));
550 if (strlen(er_roomaide)==0) {
554 strcpy(er_roomaide,"");
557 extract(er_roomaide,&buf[4],0);
561 strcpy(buf,bstr("er_name")); buf[20] = 0;
562 if (strlen(buf)>0) strcpy(er_name,buf);
564 strcpy(buf,bstr("er_password")); buf[10] = 0;
565 if (strlen(buf)>0) strcpy(er_password,buf);
567 strcpy(buf,bstr("er_dirname")); buf[15] = 0;
568 if (strlen(buf)>0) strcpy(er_dirname,buf);
570 strcpy(buf,bstr("type"));
571 er_flags &= !(QR_PRIVATE|QR_PASSWORDED|QR_GUESSNAME);
573 if (!strcmp(buf,"invonly")) {
574 er_flags |= (QR_PRIVATE);
576 if (!strcmp(buf,"guessname")) {
577 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
579 if (!strcmp(buf,"passworded")) {
580 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
583 if (!strcmp(bstr("prefonly"),"yes")) {
584 er_flags |= QR_PREFONLY;
587 er_flags &= ~QR_PREFONLY;
590 if (!strcmp(bstr("readonly"),"yes")) {
591 er_flags |= QR_READONLY;
594 er_flags &= ~QR_READONLY;
597 if (!strcmp(bstr("network"),"yes")) {
598 er_flags |= QR_NETWORK;
601 er_flags &= ~QR_NETWORK;
604 if (!strcmp(bstr("directory"),"yes")) {
605 er_flags |= QR_DIRECTORY;
608 er_flags &= ~QR_DIRECTORY;
611 if (!strcmp(bstr("ulallowed"),"yes")) {
612 er_flags |= QR_UPLOAD;
615 er_flags &= ~QR_UPLOAD;
618 if (!strcmp(bstr("dlallowed"),"yes")) {
619 er_flags |= QR_DOWNLOAD;
622 er_flags &= ~QR_DOWNLOAD;
625 if (!strcmp(bstr("visdir"),"yes")) {
626 er_flags |= QR_VISDIR;
629 er_flags &= ~QR_VISDIR;
632 strcpy(buf,bstr("anon"));
634 er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
635 if (!strcmp(buf,"anononly")) er_flags |= QR_ANONONLY;
636 if (!strcmp(buf,"anon2")) er_flags |= QR_ANONOPT;
639 if (!strcmp(bstr("bump"),"yes")) bump = 1;
641 sprintf(buf,"SETR %s|%s|%s|%u|%d",
642 er_name,er_password,er_dirname,er_flags,bump);
646 wprintf("<EM>%s</EM><HR>\n",&buf[4]);
647 return(display_editroom());
651 if (strlen(er_roomaide)>0) {
652 sprintf(buf,"SETA %s",er_roomaide);
656 wprintf("<EM>%s</EM><HR>\n",&buf[4]);
657 return(display_editroom());
661 wprintf("<EM>Changes have been saved.</EM><BR>");
668 * display the form for entering a new room
670 int display_entroom() {
677 wprintf("<EM>%s</EM><HR>\n",&buf[4]);
681 wprintf("<TABLE WIDTH=100% BORDER=0 BGCOLOR=000077><TR><TD>");
682 wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
683 wprintf("<B>Enter (create) a new room</B>\n");
684 wprintf("</FONT></TD></TR></TABLE>\n");
686 wprintf("<FORM METHOD=\"POST\" ACTION=\"/entroom\">\n");
688 wprintf("<UL><LI>Name of room: ");
689 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" MAXLENGTH=\"19\">\n");
691 wprintf("<LI>Type of room:<UL>\n");
693 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
694 wprintf("CHECKED > Public room\n");
696 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"guessname\" ");
697 wprintf("> Private - guess name\n");
699 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
700 wprintf("> Private - require password:\n");
701 wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
703 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
704 wprintf("> Private - invitation only\n");
706 wprintf("<CENTER>\n");
707 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
708 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
709 wprintf("</CENTER>\n");
710 wprintf("</FORM>\n");
723 char er_password[10];
726 if (strcmp(bstr("sc"),"OK")) {
727 wprintf("<EM>Changes have <STRONG>not</STRONG> been saved.</EM><BR>");
731 strcpy(er_name,bstr("er_name"));
732 strcpy(er_type,bstr("type"));
733 strcpy(er_password,bstr("er_password"));
736 if (!strcmp(er_type,"guessname")) er_num_type = 1;
737 if (!strcmp(er_type,"passworded")) er_num_type = 2;
738 if (!strcmp(er_type,"invonly")) er_num_type = 3;
740 sprintf(buf,"CRE8 1|%s|%d|%s",er_name,er_num_type,er_password);
744 wprintf("<EM>%s</EM><HR>\n",&buf[4]);
745 return(display_editroom());
753 * display the screen to enter a private room
755 void display_private(rname,req_pass)
760 wprintf("<TABLE WIDTH=100% BORDER=0 BGCOLOR=770000><TR><TD>");
761 wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
762 wprintf("<B>Enter a private room</B>\n");
763 wprintf("</FONT></TD></TR></TABLE>\n");
765 wprintf("<CENTER>\n");
766 wprintf("If you know the name of a hidden (guess-name) or\n");
767 wprintf("passworded room, you can enter that room by typing\n");
768 wprintf("its name below. Once you gain access to a private\n");
769 wprintf("room, it will appear in your regular room listings\n");
770 wprintf("so you don't have to keep returning here.\n");
773 wprintf("<FORM METHOD=\"POST\" ACTION=\"/goto_private\">\n");
775 wprintf("<TABLE border><TR><TD>");
776 wprintf("Enter room name:</TD><TD>");
777 wprintf("<INPUT TYPE=\"text\" NAME=\"gr_name\" VALUE=\"%s\" MAXLENGTH=\"19\">\n",rname);
780 wprintf("</TD></TR><TR><TD>");
781 wprintf("Enter room password:</TD><TD>");
782 wprintf("<INPUT TYPE=\"password\" NAME=\"gr_pass\" MAXLENGTH=\"9\">\n");
785 wprintf("</TD></TR></TABLE>\n");
787 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
788 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
793 * goto a private room
799 if (strcmp(bstr("sc"),"OK")) {
803 strcpy(hold_rm,wc_roomname);
805 strcat(buf,bstr("gr_name"));
807 strcat(buf,bstr("gr_pass"));
812 gotoroom(bstr("gr_name"),1);
816 if (!strncmp(buf,"540",3)) {
817 display_private(bstr("gr_name"),1);
821 wprintf("<EM>%s</EM>\n",&buf[4]);
827 * display the screen to zap a room
832 strcpy(zaproom, bstr("room"));
834 wprintf("<TABLE WIDTH=100% BORDER=0 BGCOLOR=770000><TR><TD>");
835 wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
836 wprintf("<B>Zap (forget) the current room</B>\n");
837 wprintf("</FONT></TD></TR></TABLE>\n");
839 wprintf("If you select this option, <em>%s</em> will ", zaproom);
840 wprintf("disappear from your room list. Is this what you wish ");
841 wprintf("to do?<BR>\n");
843 wprintf("<FORM METHOD=\"POST\" ACTION=\"/zap\">\n");
844 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
845 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
857 if (strcmp(bstr("sc"),"OK")) {
861 strcpy(zaproom, bstr("room"));
862 sprintf(buf, "GOTO %s", zaproom);
866 wprintf("<EM>%s</EM>\n",&buf[4]);
873 wprintf("<EM>%s</EM>\n",&buf[4]);
877 gotoroom(bstr("_BASEROOM_"),1);