17 char floorlist[128][256];
24 struct march *march = NULL;
27 * load the list of floors
29 void load_floorlist(void) {
33 for (a=0; a<128; ++a) floorlist[a][0] = 0;
38 strcpy(floorlist[0],"Main Floor");
41 while (serv_gets(buf), strcmp(buf,"000")) {
42 extract(floorlist[extract_int(buf,0)],buf,1);
49 * remove a room from the march list
51 void remove_march(char *aaa)
53 struct march *mptr,*mptr2;
55 if (march==NULL) return;
57 if (!strcasecmp(march->march_name,aaa)) {
65 for (mptr=march; mptr!=NULL; mptr=mptr->next) {
66 if (!strcasecmp(mptr->march_name,aaa)) {
67 mptr2->next = mptr->next;
78 void listrms(char *variety)
84 fprintf(stderr, "doing listrms(%s)\n", variety);
87 if (buf[0]!='1') return;
88 while (serv_gets(buf), strcmp(buf,"000")) {
89 extract(rmname,buf,0);
90 wprintf("<A HREF=\"/dotgoto&room=");
92 wprintf("\" TARGET=\"top\">");
94 f = extract_int(buf,1);
95 if ((f & QR_DIRECTORY) && (f & QR_NETWORK)) wprintf("}");
96 else if (f & QR_DIRECTORY) wprintf("]");
97 else if (f & QR_NETWORK) wprintf(")");
100 wprintf("</A><TT> </TT>\n");
108 * list all rooms by floor
110 void list_all_rooms_by_floor(void) {
116 printf("HTTP/1.0 200 OK\n");
118 wprintf("<HTML><HEAD><TITLE>List known rooms</TITLE></HEAD><BODY>\n");
120 wprintf("<TABLE width=100% border><TR><TH>Floor</TH>");
121 wprintf("<TH>Rooms with new messages</TH>");
122 wprintf("<TH>Rooms with no new messages</TH></TR>\n");
124 for (a=0; a<128; ++a) if (floorlist[a][0]!=0) {
126 /* Floor name column */
130 wprintf("<IMG SRC=\"/dynamic/_floorpic_/%d\" ALT=\"%s\">",
133 escputs(&floorlist[a][0]);
137 /* Rooms with new messages column */
139 sprintf(buf,"LKRN %d",a);
141 wprintf("</TD><TD>\n");
143 /* Rooms with old messages column */
144 sprintf(buf,"LKRO %d",a);
146 wprintf("</TD></TR>\n");
148 wprintf("</TABLE>\n");
149 wprintf("</BODY></HTML>\n");
155 * list all forgotten rooms
157 void zapped_list(void) {
158 wprintf("<CENTER><H1>Forgotten rooms</H1>\n");
160 wprintf("</CENTER><HR>\n");
165 * read this room's info file (set v to 1 for verbose mode)
173 if (buf[0]=='1') fmout(NULL);
175 if (v==1) wprintf("<EM>%s</EM><BR>\n",&buf[4]);
181 * generic routine to take the session to a new room
183 * display_name values: 0 = goto only
184 * 1 = goto and display
187 void gotoroom(char *gname, int display_name)
193 printf("HTTP/1.0 200 OK\n");
195 wprintf("<HTML><BODY>\n");
197 if (display_name != 2) {
198 /* store ungoto information */
199 strcpy(ugname,wc_roomname);
203 /* move to the new room */
204 sprintf(buf,"GOTO %s",gname);
208 serv_puts("GOTO _BASEROOM_");
212 wprintf("<EM>%s</EM><BR>\n",&buf[4]);
217 extract(wc_roomname,&buf[4],0);
218 room_flags = extract_int(&buf[4],4);
220 remove_march(wc_roomname);
221 if (!strcasecmp(gname,"_BASEROOM_")) remove_march(gname);
223 /* Display the room banner */
226 wprintf("<CENTER><TABLE border=0><TR>");
228 if ( (strlen(ugname)>0) && (strcasecmp(ugname,wc_roomname)) ) {
229 wprintf("<TD><A HREF=\"/ungoto\">");
230 wprintf("<IMG SRC=\"/static/back.gif\" border=0></A></TD>");
233 wprintf("<TD><H1>%s</H1>",wc_roomname);
234 wprintf("<FONT SIZE=-1>%d new of %d messages</FONT></TD>\n",
235 extract_int(&buf[4],1),
236 extract_int(&buf[4],2));
238 /* FIX add room image here */
244 wprintf("<TD><A HREF=\"/gotonext\">");
245 wprintf("<IMG SRC=\"/static/forward.gif\" border=0></A></TD>");
247 wprintf("</TR></TABLE></CENTER>\n");
250 /* highest_msg_read = extract_int(&buf[4],6);
251 maxmsgnum = extract_int(&buf[4],5);
252 is_mail = (char) extract_int(&buf[4],7); */
253 is_room_aide = (char) extract_int(&buf[4],8);
254 ls = extract_long(&buf[4],6);
256 strcpy(wc_roomname, wc_roomname);
262 * operation to goto a room
265 gotoroom(bstr("room"),1);
269 /* Goto next room having unread messages.
270 * We want to skip over rooms that the user has already been to, and take the
271 * user back to the lobby when done. The room we end up in is placed in
272 * newroom - which is set to 0 (the lobby) initially.
273 * We start the search in the current room rather than the beginning to prevent
274 * two or more concurrent users from dragging each other back to the same room.
276 void gotonext(void) {
278 struct march *mptr,*mptr2;
281 /* First check to see if the march-mode list is already allocated.
282 * If it is, pop the first room off the list and go there.
289 while (serv_gets(buf), strcmp(buf,"000")) {
290 mptr = (struct march *) malloc(sizeof(struct march));
292 extract(mptr->march_name,buf,0);
298 while (mptr2->next != NULL)
304 /* add _BASEROOM_ to the end of the march list, so the user will end up
305 * in the system base room (usually the Lobby>) at the end of the loop
307 mptr = (struct march *) malloc(sizeof(struct march));
309 strcpy(mptr->march_name,"_BASEROOM_");
315 while (mptr2->next != NULL)
320 * ...and remove the room we're currently in, so a <G>oto doesn't make us
321 * walk around in circles
323 remove_march(wc_roomname);
328 strcpy(next_room,march->march_name);
331 strcpy(next_room,"_BASEROOM_");
333 gotoroom(next_room,1);
339 * mark all messages in current room as having been read
341 void slrp_highest(void) {
345 serv_puts("SLRP HIGHEST");
348 wprintf("<EM>%s</EM><BR>\n",&buf[4]);
355 * un-goto the previous room
360 if (!strcmp(ugname,"")) return;
361 sprintf(buf,"GOTO %s",ugname);
365 wprintf("%s\n",&buf[4]);
368 sprintf(buf,"SLRP %ld",uglsn);
371 if (buf[0]!='2') wprintf("%s\n",&buf[4]);
378 * display the form for editing a room
380 int display_editroom(void) {
383 char er_password[10];
385 char er_roomaide[26];
392 wprintf("<EM>%s</EM><BR>\n",&buf[4]);
396 extract(er_name,&buf[4],0);
397 extract(er_password,&buf[4],1);
398 extract(er_dirname,&buf[4],2);
399 er_flags=extract_int(&buf[4],3);
402 wprintf("<TABLE WIDTH=100% BORDER=0 BGCOLOR=000077><TR><TD>");
403 wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
404 wprintf("<B>Edit this room</B>\n");
405 wprintf("</FONT></TD></TR></TABLE>\n");
407 wprintf("<FORM METHOD=\"POST\" ACTION=\"/editroom\">\n");
409 wprintf("<UL><LI>Name of room: ");
410 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\"19\">\n",er_name);
412 wprintf("<LI>Type of room:<UL>\n");
414 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
415 if ((er_flags & QR_PRIVATE) == 0) wprintf("CHECKED ");
416 wprintf("> Public room\n");
418 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"guessname\" ");
419 if ((er_flags & QR_PRIVATE)&&
420 (er_flags & QR_GUESSNAME)) wprintf("CHECKED ");
421 wprintf("> Private - guess name\n");
423 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
424 if ((er_flags & QR_PRIVATE)&&
425 (er_flags & QR_PASSWORDED)) wprintf("CHECKED ");
426 wprintf("> Private - require password:\n");
427 wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n",er_password);
429 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
430 if ( (er_flags & QR_PRIVATE)
431 && ((er_flags & QR_GUESSNAME) == 0)
432 && ((er_flags & QR_PASSWORDED) == 0) )
434 wprintf("> Private - invitation only\n");
436 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
437 wprintf("> If private, cause current users to forget room\n");
441 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
442 if (er_flags & QR_PREFONLY) wprintf("CHECKED ");
443 wprintf("> Preferred users only\n");
445 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
446 if (er_flags & QR_READONLY) wprintf("CHECKED ");
447 wprintf("> Read-only room\n");
449 /* directory stuff */
450 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
451 if (er_flags & QR_DIRECTORY) wprintf("CHECKED ");
452 wprintf("> File directory room\n");
454 wprintf("<UL><LI>Directory name: ");
455 wprintf("<INPUT TYPE=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n",er_dirname);
457 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
458 if (er_flags & QR_UPLOAD) wprintf("CHECKED ");
459 wprintf("> Uploading allowed\n");
461 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
462 if (er_flags & QR_DOWNLOAD) wprintf("CHECKED ");
463 wprintf("> Downloading allowed\n");
465 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
466 if (er_flags & QR_VISDIR) wprintf("CHECKED ");
467 wprintf("> Visible directory</UL>\n");
469 /* end of directory stuff */
471 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
472 if (er_flags & QR_NETWORK) wprintf("CHECKED ");
473 wprintf("> Network shared room\n");
475 /* start of anon options */
477 wprintf("<LI>Anonymous messages<UL>\n");
479 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
480 if ( ((er_flags & QR_ANONONLY)==0)
481 && ((er_flags & QR_ANONOPT)==0)) wprintf("CHECKED ");
482 wprintf("> No anonymous messages\n");
484 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
485 if (er_flags & QR_ANONONLY) wprintf("CHECKED ");
486 wprintf("> All messages are anonymous\n");
488 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
489 if (er_flags & QR_ANONOPT) wprintf("CHECKED ");
490 wprintf("> Prompt user when entering messages</UL>\n");
492 /* end of anon options */
494 wprintf("<LI>Room aide: \n");
498 wprintf("<EM>%s</EM>\n",&buf[4]);
501 extract(er_roomaide,&buf[4],0);
502 wprintf("<INPUT TYPE=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n",er_roomaide);
505 wprintf("</UL><CENTER>\n");
506 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
507 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
508 wprintf("</CENTER>\n");
510 wprintf("</FORM>\n");
516 * save new parameters for a room
521 char er_password[10];
523 char er_roomaide[26];
528 if (strcmp(bstr("sc"),"OK")) {
529 wprintf("<EM>Changes have <STRONG>not</STRONG> been saved.</EM><BR>");
537 wprintf("<EM>%s</EM><BR>\n",&buf[4]);
541 extract(er_name,&buf[4],0);
542 extract(er_password,&buf[4],1);
543 extract(er_dirname,&buf[4],2);
544 er_flags=extract_int(&buf[4],3);
546 strcpy(er_roomaide,bstr("er_roomaide"));
547 if (strlen(er_roomaide)==0) {
551 strcpy(er_roomaide,"");
554 extract(er_roomaide,&buf[4],0);
558 strcpy(buf,bstr("er_name")); buf[20] = 0;
559 if (strlen(buf)>0) strcpy(er_name,buf);
561 strcpy(buf,bstr("er_password")); buf[10] = 0;
562 if (strlen(buf)>0) strcpy(er_password,buf);
564 strcpy(buf,bstr("er_dirname")); buf[15] = 0;
565 if (strlen(buf)>0) strcpy(er_dirname,buf);
567 strcpy(buf,bstr("type"));
568 er_flags &= !(QR_PRIVATE|QR_PASSWORDED|QR_GUESSNAME);
570 if (!strcmp(buf,"invonly")) {
571 er_flags |= (QR_PRIVATE);
573 if (!strcmp(buf,"guessname")) {
574 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
576 if (!strcmp(buf,"passworded")) {
577 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
580 if (!strcmp(bstr("prefonly"),"yes")) {
581 er_flags |= QR_PREFONLY;
584 er_flags &= ~QR_PREFONLY;
587 if (!strcmp(bstr("readonly"),"yes")) {
588 er_flags |= QR_READONLY;
591 er_flags &= ~QR_READONLY;
594 if (!strcmp(bstr("network"),"yes")) {
595 er_flags |= QR_NETWORK;
598 er_flags &= ~QR_NETWORK;
601 if (!strcmp(bstr("directory"),"yes")) {
602 er_flags |= QR_DIRECTORY;
605 er_flags &= ~QR_DIRECTORY;
608 if (!strcmp(bstr("ulallowed"),"yes")) {
609 er_flags |= QR_UPLOAD;
612 er_flags &= ~QR_UPLOAD;
615 if (!strcmp(bstr("dlallowed"),"yes")) {
616 er_flags |= QR_DOWNLOAD;
619 er_flags &= ~QR_DOWNLOAD;
622 if (!strcmp(bstr("visdir"),"yes")) {
623 er_flags |= QR_VISDIR;
626 er_flags &= ~QR_VISDIR;
629 strcpy(buf,bstr("anon"));
631 er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
632 if (!strcmp(buf,"anononly")) er_flags |= QR_ANONONLY;
633 if (!strcmp(buf,"anon2")) er_flags |= QR_ANONOPT;
636 if (!strcmp(bstr("bump"),"yes")) bump = 1;
638 sprintf(buf,"SETR %s|%s|%s|%u|%d",
639 er_name,er_password,er_dirname,er_flags,bump);
643 wprintf("<EM>%s</EM><HR>\n",&buf[4]);
644 return(display_editroom());
648 if (strlen(er_roomaide)>0) {
649 sprintf(buf,"SETA %s",er_roomaide);
653 wprintf("<EM>%s</EM><HR>\n",&buf[4]);
654 return(display_editroom());
658 wprintf("<EM>Changes have been saved.</EM><BR>");
665 * display the form for entering a new room
667 int display_entroom(void) {
674 wprintf("<EM>%s</EM><HR>\n",&buf[4]);
678 wprintf("<TABLE WIDTH=100% BORDER=0 BGCOLOR=000077><TR><TD>");
679 wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
680 wprintf("<B>Enter (create) a new room</B>\n");
681 wprintf("</FONT></TD></TR></TABLE>\n");
683 wprintf("<FORM METHOD=\"POST\" ACTION=\"/entroom\">\n");
685 wprintf("<UL><LI>Name of room: ");
686 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" MAXLENGTH=\"19\">\n");
688 wprintf("<LI>Type of room:<UL>\n");
690 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
691 wprintf("CHECKED > Public room\n");
693 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"guessname\" ");
694 wprintf("> Private - guess name\n");
696 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
697 wprintf("> Private - require password:\n");
698 wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
700 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
701 wprintf("> Private - invitation only\n");
703 wprintf("<CENTER>\n");
704 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
705 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
706 wprintf("</CENTER>\n");
707 wprintf("</FORM>\n");
720 char er_password[10];
723 if (strcmp(bstr("sc"),"OK")) {
724 wprintf("<EM>Changes have <STRONG>not</STRONG> been saved.</EM><BR>");
728 strcpy(er_name,bstr("er_name"));
729 strcpy(er_type,bstr("type"));
730 strcpy(er_password,bstr("er_password"));
733 if (!strcmp(er_type,"guessname")) er_num_type = 1;
734 if (!strcmp(er_type,"passworded")) er_num_type = 2;
735 if (!strcmp(er_type,"invonly")) er_num_type = 3;
737 sprintf(buf,"CRE8 1|%s|%d|%s",er_name,er_num_type,er_password);
741 wprintf("<EM>%s</EM><HR>\n",&buf[4]);
742 return(display_editroom());
750 * display the screen to enter a private room
752 void display_private(char *rname, int req_pass)
756 wprintf("<TABLE WIDTH=100% BORDER=0 BGCOLOR=770000><TR><TD>");
757 wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
758 wprintf("<B>Enter a private room</B>\n");
759 wprintf("</FONT></TD></TR></TABLE>\n");
761 wprintf("<CENTER>\n");
762 wprintf("If you know the name of a hidden (guess-name) or\n");
763 wprintf("passworded room, you can enter that room by typing\n");
764 wprintf("its name below. Once you gain access to a private\n");
765 wprintf("room, it will appear in your regular room listings\n");
766 wprintf("so you don't have to keep returning here.\n");
769 wprintf("<FORM METHOD=\"POST\" ACTION=\"/goto_private\">\n");
771 wprintf("<TABLE border><TR><TD>");
772 wprintf("Enter room name:</TD><TD>");
773 wprintf("<INPUT TYPE=\"text\" NAME=\"gr_name\" VALUE=\"%s\" MAXLENGTH=\"19\">\n",rname);
776 wprintf("</TD></TR><TR><TD>");
777 wprintf("Enter room password:</TD><TD>");
778 wprintf("<INPUT TYPE=\"password\" NAME=\"gr_pass\" MAXLENGTH=\"9\">\n");
781 wprintf("</TD></TR></TABLE>\n");
783 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
784 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
789 * goto a private room
791 int goto_private(void) {
795 if (strcmp(bstr("sc"),"OK")) {
799 strcpy(hold_rm,wc_roomname);
801 strcat(buf,bstr("gr_name"));
803 strcat(buf,bstr("gr_pass"));
808 gotoroom(bstr("gr_name"),1);
812 if (!strncmp(buf,"540",3)) {
813 display_private(bstr("gr_name"),1);
817 wprintf("<EM>%s</EM>\n",&buf[4]);
823 * display the screen to zap a room
825 void display_zap(void) {
828 strcpy(zaproom, bstr("room"));
830 wprintf("<TABLE WIDTH=100% BORDER=0 BGCOLOR=770000><TR><TD>");
831 wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
832 wprintf("<B>Zap (forget) the current room</B>\n");
833 wprintf("</FONT></TD></TR></TABLE>\n");
835 wprintf("If you select this option, <em>%s</em> will ", zaproom);
836 wprintf("disappear from your room list. Is this what you wish ");
837 wprintf("to do?<BR>\n");
839 wprintf("<FORM METHOD=\"POST\" ACTION=\"/zap\">\n");
840 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
841 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
853 if (strcmp(bstr("sc"),"OK")) {
857 strcpy(zaproom, bstr("room"));
858 sprintf(buf, "GOTO %s", zaproom);
862 wprintf("<EM>%s</EM>\n",&buf[4]);
869 wprintf("<EM>%s</EM>\n",&buf[4]);
873 gotoroom(bstr("_BASEROOM_"),1);