10 #include <sys/types.h>
19 char floorlist[128][256];
26 struct march *march = NULL;
29 * load the list of floors
31 void load_floorlist(void) {
35 for (a=0; a<128; ++a) floorlist[a][0] = 0;
40 strcpy(floorlist[0],"Main Floor");
43 while (serv_gets(buf), strcmp(buf,"000")) {
44 extract(floorlist[extract_int(buf,0)],buf,1);
51 * remove a room from the march list
53 void remove_march(char *aaa)
55 struct march *mptr,*mptr2;
57 if (march==NULL) return;
59 if (!strcasecmp(march->march_name,aaa)) {
67 for (mptr=march; mptr!=NULL; mptr=mptr->next) {
68 if (!strcasecmp(mptr->march_name,aaa)) {
69 mptr2->next = mptr->next;
80 void listrms(char *variety)
86 fprintf(stderr, "doing listrms(%s)\n", variety);
89 if (buf[0]!='1') return;
90 while (serv_gets(buf), strcmp(buf,"000")) {
91 extract(rmname,buf,0);
92 wprintf("<A HREF=\"/dotgoto&room=");
94 wprintf("\" TARGET=\"top\">");
96 f = extract_int(buf,1);
97 if ((f & QR_DIRECTORY) && (f & QR_NETWORK)) wprintf("}");
98 else if (f & QR_DIRECTORY) wprintf("]");
99 else if (f & QR_NETWORK) wprintf(")");
100 else wprintf(">");
102 wprintf("</A><TT> </TT>\n");
110 * list all rooms by floor
112 void list_all_rooms_by_floor(void) {
118 printf("HTTP/1.0 200 OK\n");
121 wprintf("<TABLE width=100% border><TR><TH>Floor</TH>");
122 wprintf("<TH>Rooms with new messages</TH>");
123 wprintf("<TH>Rooms with no new messages</TH></TR>\n");
125 for (a=0; a<128; ++a) if (floorlist[a][0]!=0) {
127 /* Floor name column */
130 /* FIX ... don't link to a floor pic that doesn't exist
131 wprintf("<IMG SRC=\"/dynamic/_floorpic_/%d\" ALT=\"%s\">",
134 escputs(&floorlist[a][0]);
138 /* Rooms with new messages column */
140 sprintf(buf,"LKRN %d",a);
142 wprintf("</TD><TD>\n");
144 /* Rooms with old messages column */
145 sprintf(buf,"LKRO %d",a);
147 wprintf("</TD></TR>\n");
149 wprintf("</TABLE>\n");
150 wprintf("</BODY></HTML>\n");
156 * list all forgotten rooms
158 void zapped_list(void) {
159 printf("HTTP/1.0 200 OK\n");
161 wprintf("<TABLE WIDTH=100% BORDER=0 BGCOLOR=770000><TR><TD>");
162 wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
163 wprintf("<B>Zapped (forgotten) rooms</B>\n");
164 wprintf("</FONT></TD></TR></TABLE><BR>\n");
166 wprintf("<BR><BR>\n");
167 wprintf("Click on any room to un-zap it and goto that room.\n");
168 wprintf("</BODY></HTML>\n");
174 * read this room's info file (set v to 1 for verbose mode)
182 if (buf[0]=='1') fmout(NULL);
184 if (v==1) wprintf("<EM>%s</EM><BR>\n",&buf[4]);
190 * generic routine to take the session to a new room
192 * display_name values: 0 = goto only
193 * 1 = goto and display
196 void gotoroom(char *gname, int display_name)
199 static long ls = (-1L);
203 printf("HTTP/1.0 200 OK\n");
204 printf("Window-target: top\n");
206 wprintf("<HTML><HEAD></HEAD><BODY \n");
208 /* automatically fire up a read-new-msgs in the bottom frame */
209 wprintf("onload=location=\"/readnew\" ");
210 wprintf("BACKGROUND=\"/image&name=background\" TEXT=\"#000000\" LINK=\"#004400\">\n");
213 if (display_name != 2) {
214 /* store ungoto information */
215 strcpy(ugname, wc_roomname);
217 fprintf(stderr, "setting ugname to %s and uglsn to %ld\n",
221 /* move to the new room */
222 sprintf(buf,"GOTO %s",gname);
226 serv_puts("GOTO _BASEROOM_");
230 if (display_name) wprintf("<EM>%s</EM><BR>\n",&buf[4]);
235 extract(wc_roomname,&buf[4],0);
236 room_flags = extract_int(&buf[4],4);
237 /* highest_msg_read = extract_int(&buf[4],6);
238 maxmsgnum = extract_int(&buf[4],5);
239 is_mail = (char) extract_int(&buf[4],7); */
240 ls = extract_long(&buf[4], 6);
242 if (is_aide) is_room_aide = is_aide;
243 else is_room_aide = (char) extract_int(&buf[4],8);
245 remove_march(wc_roomname);
246 if (!strcasecmp(gname,"_BASEROOM_")) remove_march(gname);
248 /* Display the room banner */
251 wprintf("<CENTER><TABLE border=0><TR>");
253 if ( (strlen(ugname)>0) && (strcasecmp(ugname,wc_roomname)) ) {
254 wprintf("<TD><A HREF=\"/ungoto\">");
255 wprintf("<IMG SRC=\"/static/back.gif\" border=0></A></TD>");
257 wprintf("<TD><H1>%s</H1>",wc_roomname);
258 wprintf("<FONT SIZE=-1>%d new of %d messages</FONT></TD>\n",
259 extract_int(&buf[4],1),
260 extract_int(&buf[4],2));
262 /* Display room graphic. The server doesn't actually
263 * need the room name, but we supply it in order to
264 * keep the browser from using a cached graphic from
267 serv_puts("OIMG _roompic_");
271 wprintf("<IMG SRC=\"/image&name=_roompic_&room=");
272 escputs(wc_roomname);
282 wprintf("<TD><A HREF=\"/gotonext\">");
283 wprintf("<IMG SRC=\"/static/forward.gif\" border=0></A></TD>");
285 wprintf("</TR></TABLE></CENTER>\n");
290 strcpy(wc_roomname, wc_roomname);
295 * operation to goto a room
298 fprintf(stderr, "DOTGOTO: <%s>\n", bstr("room"));
299 gotoroom(bstr("room"),1);
303 /* Goto next room having unread messages.
304 * We want to skip over rooms that the user has already been to, and take the
305 * user back to the lobby when done. The room we end up in is placed in
306 * newroom - which is set to 0 (the lobby) initially.
307 * We start the search in the current room rather than the beginning to prevent
308 * two or more concurrent users from dragging each other back to the same room.
310 void gotonext(void) {
312 struct march *mptr,*mptr2;
315 /* First check to see if the march-mode list is already allocated.
316 * If it is, pop the first room off the list and go there.
323 while (serv_gets(buf), strcmp(buf,"000")) {
324 mptr = (struct march *) malloc(sizeof(struct march));
326 extract(mptr->march_name,buf,0);
332 while (mptr2->next != NULL)
338 /* add _BASEROOM_ to the end of the march list, so the user will end up
339 * in the system base room (usually the Lobby>) at the end of the loop
341 mptr = (struct march *) malloc(sizeof(struct march));
343 strcpy(mptr->march_name,"_BASEROOM_");
349 while (mptr2->next != NULL)
354 * ...and remove the room we're currently in, so a <G>oto doesn't make us
355 * walk around in circles
357 remove_march(wc_roomname);
362 strcpy(next_room,march->march_name);
365 strcpy(next_room,"_BASEROOM_");
367 gotoroom(next_room,1);
373 * mark all messages in current room as having been read
375 void slrp_highest(void) {
379 serv_puts("SLRP HIGHEST");
382 wprintf("<EM>%s</EM><BR>\n",&buf[4]);
389 * un-goto the previous room
394 if (!strcmp(ugname, "")) {
395 gotoroom(wc_roomname, 1);
398 serv_printf("GOTO %s", ugname);
401 gotoroom(wc_roomname, 1);
405 serv_printf("SLRP %ld",uglsn);
414 * display the form for editing a room
416 void display_editroom(void) {
419 char er_password[10];
421 char er_roomaide[26];
428 display_error(&buf[4]);
432 extract(er_name,&buf[4],0);
433 extract(er_password,&buf[4],1);
434 extract(er_dirname,&buf[4],2);
435 er_flags=extract_int(&buf[4],3);
438 printf("HTTP/1.0 200 OK\n");
441 wprintf("<TABLE WIDTH=100% BORDER=0 BGCOLOR=000077><TR><TD>");
442 wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
443 wprintf("<B>Edit this room</B>\n");
444 wprintf("</FONT></TD></TR></TABLE>\n");
446 wprintf("<FORM METHOD=\"POST\" ACTION=\"/editroom\">\n");
448 wprintf("<UL><LI>Name of room: ");
449 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\"19\">\n",er_name);
451 wprintf("<LI>Type of room:<UL>\n");
453 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
454 if ((er_flags & QR_PRIVATE) == 0) wprintf("CHECKED ");
455 wprintf("> Public room\n");
457 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"guessname\" ");
458 if ((er_flags & QR_PRIVATE)&&
459 (er_flags & QR_GUESSNAME)) wprintf("CHECKED ");
460 wprintf("> Private - guess name\n");
462 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
463 if ((er_flags & QR_PRIVATE)&&
464 (er_flags & QR_PASSWORDED)) wprintf("CHECKED ");
465 wprintf("> Private - require password:\n");
466 wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n",er_password);
468 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
469 if ( (er_flags & QR_PRIVATE)
470 && ((er_flags & QR_GUESSNAME) == 0)
471 && ((er_flags & QR_PASSWORDED) == 0) )
473 wprintf("> Private - invitation only\n");
475 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
476 wprintf("> If private, cause current users to forget room\n");
480 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
481 if (er_flags & QR_PREFONLY) wprintf("CHECKED ");
482 wprintf("> Preferred users only\n");
484 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
485 if (er_flags & QR_READONLY) wprintf("CHECKED ");
486 wprintf("> Read-only room\n");
488 /* directory stuff */
489 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
490 if (er_flags & QR_DIRECTORY) wprintf("CHECKED ");
491 wprintf("> File directory room\n");
493 wprintf("<UL><LI>Directory name: ");
494 wprintf("<INPUT TYPE=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n",er_dirname);
496 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
497 if (er_flags & QR_UPLOAD) wprintf("CHECKED ");
498 wprintf("> Uploading allowed\n");
500 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
501 if (er_flags & QR_DOWNLOAD) wprintf("CHECKED ");
502 wprintf("> Downloading allowed\n");
504 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
505 if (er_flags & QR_VISDIR) wprintf("CHECKED ");
506 wprintf("> Visible directory</UL>\n");
508 /* end of directory stuff */
510 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
511 if (er_flags & QR_NETWORK) wprintf("CHECKED ");
512 wprintf("> Network shared room\n");
514 /* start of anon options */
516 wprintf("<LI>Anonymous messages<UL>\n");
518 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
519 if ( ((er_flags & QR_ANONONLY)==0)
520 && ((er_flags & QR_ANONOPT)==0)) wprintf("CHECKED ");
521 wprintf("> No anonymous messages\n");
523 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
524 if (er_flags & QR_ANONONLY) wprintf("CHECKED ");
525 wprintf("> All messages are anonymous\n");
527 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
528 if (er_flags & QR_ANONOPT) wprintf("CHECKED ");
529 wprintf("> Prompt user when entering messages</UL>\n");
531 /* end of anon options */
533 wprintf("<LI>Room aide: \n");
537 wprintf("<EM>%s</EM>\n",&buf[4]);
540 extract(er_roomaide,&buf[4],0);
541 wprintf("<INPUT TYPE=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n",er_roomaide);
544 wprintf("</UL><CENTER>\n");
545 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
546 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
547 wprintf("</CENTER>\n");
549 wprintf("</FORM></HTML>\n");
555 * save new parameters for a room
557 void editroom(void) {
560 char er_password[10];
562 char er_roomaide[26];
567 if (strcmp(bstr("sc"),"OK")) {
568 display_error("Cancelled. Changes were not saved.");
576 display_error(&buf[4]);
580 extract(er_name,&buf[4],0);
581 extract(er_password,&buf[4],1);
582 extract(er_dirname,&buf[4],2);
583 er_flags=extract_int(&buf[4],3);
585 strcpy(er_roomaide,bstr("er_roomaide"));
586 if (strlen(er_roomaide)==0) {
590 strcpy(er_roomaide,"");
593 extract(er_roomaide,&buf[4],0);
597 strcpy(buf,bstr("er_name")); buf[20] = 0;
598 if (strlen(buf)>0) strcpy(er_name,buf);
600 strcpy(buf,bstr("er_password")); buf[10] = 0;
601 if (strlen(buf)>0) strcpy(er_password,buf);
603 strcpy(buf,bstr("er_dirname")); buf[15] = 0;
604 if (strlen(buf)>0) strcpy(er_dirname,buf);
606 strcpy(buf,bstr("type"));
607 er_flags &= !(QR_PRIVATE|QR_PASSWORDED|QR_GUESSNAME);
609 if (!strcmp(buf,"invonly")) {
610 er_flags |= (QR_PRIVATE);
612 if (!strcmp(buf,"guessname")) {
613 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
615 if (!strcmp(buf,"passworded")) {
616 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
619 if (!strcmp(bstr("prefonly"),"yes")) {
620 er_flags |= QR_PREFONLY;
623 er_flags &= ~QR_PREFONLY;
626 if (!strcmp(bstr("readonly"),"yes")) {
627 er_flags |= QR_READONLY;
630 er_flags &= ~QR_READONLY;
633 if (!strcmp(bstr("network"),"yes")) {
634 er_flags |= QR_NETWORK;
637 er_flags &= ~QR_NETWORK;
640 if (!strcmp(bstr("directory"),"yes")) {
641 er_flags |= QR_DIRECTORY;
644 er_flags &= ~QR_DIRECTORY;
647 if (!strcmp(bstr("ulallowed"),"yes")) {
648 er_flags |= QR_UPLOAD;
651 er_flags &= ~QR_UPLOAD;
654 if (!strcmp(bstr("dlallowed"),"yes")) {
655 er_flags |= QR_DOWNLOAD;
658 er_flags &= ~QR_DOWNLOAD;
661 if (!strcmp(bstr("visdir"),"yes")) {
662 er_flags |= QR_VISDIR;
665 er_flags &= ~QR_VISDIR;
668 strcpy(buf,bstr("anon"));
670 er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
671 if (!strcmp(buf,"anononly")) er_flags |= QR_ANONONLY;
672 if (!strcmp(buf,"anon2")) er_flags |= QR_ANONOPT;
675 if (!strcmp(bstr("bump"),"yes")) bump = 1;
677 sprintf(buf,"SETR %s|%s|%s|%u|%d",
678 er_name,er_password,er_dirname,er_flags,bump);
682 display_error(&buf[4]);
685 gotoroom(er_name, 0);
687 if (strlen(er_roomaide)>0) {
688 sprintf(buf,"SETA %s",er_roomaide);
692 display_error(&buf[4]);
697 gotoroom(er_name, 1);
703 * display the form for entering a new room
705 void display_entroom(void) {
712 display_error(&buf[4]);
716 printf("HTTP/1.0 200 OK\n");
719 wprintf("<TABLE WIDTH=100% BORDER=0 BGCOLOR=000077><TR><TD>");
720 wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
721 wprintf("<B>Enter (create) a new room</B>\n");
722 wprintf("</FONT></TD></TR></TABLE>\n");
724 wprintf("<FORM METHOD=\"POST\" ACTION=\"/entroom\">\n");
726 wprintf("<UL><LI>Name of room: ");
727 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" MAXLENGTH=\"19\">\n");
729 wprintf("<LI>Type of room:<UL>\n");
731 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
732 wprintf("CHECKED > Public room\n");
734 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"guessname\" ");
735 wprintf("> Private - guess name\n");
737 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
738 wprintf("> Private - require password:\n");
739 wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
741 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
742 wprintf("> Private - invitation only\n");
744 wprintf("<CENTER>\n");
745 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
746 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
747 wprintf("</CENTER>\n");
748 wprintf("</FORM></HTML>\n");
761 char er_password[10];
764 if (strcmp(bstr("sc"),"OK")) {
765 display_error("Cancelled. No new room was created.");
769 strcpy(er_name,bstr("er_name"));
770 strcpy(er_type,bstr("type"));
771 strcpy(er_password,bstr("er_password"));
774 if (!strcmp(er_type,"guessname")) er_num_type = 1;
775 if (!strcmp(er_type,"passworded")) er_num_type = 2;
776 if (!strcmp(er_type,"invonly")) er_num_type = 3;
778 sprintf(buf,"CRE8 1|%s|%d|%s",er_name,er_num_type,er_password);
782 display_error(&buf[4]);
785 gotoroom(er_name, 1);
790 * display the screen to enter a private room
792 void display_private(char *rname, int req_pass)
795 printf("HTTP/1.0 200 OK\n");
798 wprintf("<TABLE WIDTH=100% BORDER=0 BGCOLOR=770000><TR><TD>");
799 wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
800 wprintf("<B>Goto a private room</B>\n");
801 wprintf("</FONT></TD></TR></TABLE>\n");
803 wprintf("<CENTER>\n");
804 wprintf("If you know the name of a hidden (guess-name) or\n");
805 wprintf("passworded room, you can enter that room by typing\n");
806 wprintf("its name below. Once you gain access to a private\n");
807 wprintf("room, it will appear in your regular room listings\n");
808 wprintf("so you don't have to keep returning here.\n");
811 wprintf("<FORM METHOD=\"POST\" ACTION=\"/goto_private\">\n");
813 wprintf("<TABLE border><TR><TD>");
814 wprintf("Enter room name:</TD><TD>");
815 wprintf("<INPUT TYPE=\"text\" NAME=\"gr_name\" VALUE=\"%s\" MAXLENGTH=\"19\">\n",rname);
818 wprintf("</TD></TR><TR><TD>");
819 wprintf("Enter room password:</TD><TD>");
820 wprintf("<INPUT TYPE=\"password\" NAME=\"gr_pass\" MAXLENGTH=\"9\">\n");
823 wprintf("</TD></TR></TABLE>\n");
825 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
826 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
827 wprintf("</FORM></HTML>\n");
832 * goto a private room
834 void goto_private(void) {
838 if (strcasecmp(bstr("sc"),"OK")) {
843 strcpy(hold_rm,wc_roomname);
845 strcat(buf,bstr("gr_name"));
847 strcat(buf,bstr("gr_pass"));
852 gotoroom(bstr("gr_name"),1);
856 if (!strncmp(buf,"540",3)) {
857 display_private(bstr("gr_name"),1);
861 printf("HTTP/1.0 200 OK\n");
863 wprintf("%s\n",&buf[4]);
870 * display the screen to zap a room
872 void display_zap(void) {
873 printf("HTTP/1.0 200 OK\n");
876 wprintf("<TABLE WIDTH=100% BORDER=0 BGCOLOR=770000><TR><TD>");
877 wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
878 wprintf("<B>Zap (forget) the current room</B>\n");
879 wprintf("</FONT></TD></TR></TABLE>\n");
881 wprintf("If you select this option, <em>%s</em> will ", wc_roomname);
882 wprintf("disappear from your room list. Is this what you wish ");
883 wprintf("to do?<BR>\n");
885 wprintf("<FORM METHOD=\"POST\" ACTION=\"/zap\">\n");
886 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
887 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
888 wprintf("</FORM></HTML>\n");
899 if (strcmp(bstr("sc"),"OK")) {
904 serv_printf("GOTO %s", wc_roomname);
907 display_error(&buf[4]);
914 display_error(&buf[4]);
918 gotoroom(bstr("_BASEROOM_"),1);