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);
219 /* move to the new room */
220 serv_printf("GOTO %s", gname);
223 serv_puts("GOTO _BASEROOM_");
228 wprintf("<EM>%s</EM><BR>\n",&buf[4]);
234 extract(wc_roomname,&buf[4],0);
235 room_flags = extract_int(&buf[4],4);
236 /* highest_msg_read = extract_int(&buf[4],6);
237 maxmsgnum = extract_int(&buf[4],5);
238 is_mail = (char) extract_int(&buf[4],7); */
239 ls = extract_long(&buf[4], 6);
241 if (is_aide) is_room_aide = is_aide;
242 else is_room_aide = (char) extract_int(&buf[4],8);
244 remove_march(wc_roomname);
245 if (!strcasecmp(gname,"_BASEROOM_")) remove_march(gname);
247 /* Display the room banner */
249 wprintf("<CENTER><TABLE border=0><TR>");
251 if ( (strlen(ugname)>0) && (strcasecmp(ugname,wc_roomname)) ) {
252 wprintf("<TD><A HREF=\"/ungoto\">");
253 wprintf("<IMG SRC=\"/static/back.gif\" border=0></A></TD>");
255 wprintf("<TD><H1>%s</H1>",wc_roomname);
256 wprintf("<FONT SIZE=-1>%d new of %d messages</FONT></TD>\n",
257 extract_int(&buf[4],1),
258 extract_int(&buf[4],2));
260 /* Display room graphic. The server doesn't actually
261 * need the room name, but we supply it in order to
262 * keep the browser from using a cached graphic from
265 serv_puts("OIMG _roompic_");
269 wprintf("<IMG SRC=\"/image&name=_roompic_&room=");
270 escputs(wc_roomname);
280 wprintf("<TD><A HREF=\"/gotonext\">");
281 wprintf("<IMG SRC=\"/static/forward.gif\" border=0></A></TD>");
283 wprintf("</TR></TABLE></CENTER>\n");
285 wprintf("</BODY></HTML>\n");
289 strcpy(wc_roomname, wc_roomname);
294 * operation to goto a room
297 gotoroom(bstr("room"), 1);
301 /* Goto next room having unread messages.
302 * We want to skip over rooms that the user has already been to, and take the
303 * user back to the lobby when done. The room we end up in is placed in
304 * newroom - which is set to 0 (the lobby) initially.
305 * We start the search in the current room rather than the beginning to prevent
306 * two or more concurrent users from dragging each other back to the same room.
308 void gotonext(void) {
310 struct march *mptr,*mptr2;
313 /* First check to see if the march-mode list is already allocated.
314 * If it is, pop the first room off the list and go there.
321 while (serv_gets(buf), strcmp(buf,"000")) {
322 mptr = (struct march *) malloc(sizeof(struct march));
324 extract(mptr->march_name,buf,0);
330 while (mptr2->next != NULL)
336 /* add _BASEROOM_ to the end of the march list, so the user will end up
337 * in the system base room (usually the Lobby>) at the end of the loop
339 mptr = (struct march *) malloc(sizeof(struct march));
341 strcpy(mptr->march_name,"_BASEROOM_");
347 while (mptr2->next != NULL)
352 * ...and remove the room we're currently in, so a <G>oto doesn't make us
353 * walk around in circles
355 remove_march(wc_roomname);
360 strcpy(next_room,march->march_name);
363 strcpy(next_room,"_BASEROOM_");
365 gotoroom(next_room,1);
371 * mark all messages in current room as having been read
373 void slrp_highest(void) {
377 serv_puts("SLRP HIGHEST");
380 wprintf("<EM>%s</EM><BR>\n",&buf[4]);
387 * un-goto the previous room
392 if (!strcmp(ugname, "")) {
393 gotoroom(wc_roomname, 1);
396 serv_printf("GOTO %s", ugname);
399 gotoroom(wc_roomname, 1);
403 serv_printf("SLRP %ld",uglsn);
412 * display the form for editing a room
414 void display_editroom(void) {
417 char er_password[10];
419 char er_roomaide[26];
426 display_error(&buf[4]);
430 extract(er_name,&buf[4],0);
431 extract(er_password,&buf[4],1);
432 extract(er_dirname,&buf[4],2);
433 er_flags=extract_int(&buf[4],3);
436 printf("HTTP/1.0 200 OK\n");
439 wprintf("<TABLE WIDTH=100% BORDER=0 BGCOLOR=000077><TR><TD>");
440 wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
441 wprintf("<B>Edit this room</B>\n");
442 wprintf("</FONT></TD></TR></TABLE>\n");
444 wprintf("<FORM METHOD=\"POST\" ACTION=\"/editroom\">\n");
446 wprintf("<UL><LI>Name of room: ");
447 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\"19\">\n",er_name);
449 wprintf("<LI>Type of room:<UL>\n");
451 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
452 if ((er_flags & QR_PRIVATE) == 0) wprintf("CHECKED ");
453 wprintf("> Public room\n");
455 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"guessname\" ");
456 if ((er_flags & QR_PRIVATE)&&
457 (er_flags & QR_GUESSNAME)) wprintf("CHECKED ");
458 wprintf("> Private - guess name\n");
460 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
461 if ((er_flags & QR_PRIVATE)&&
462 (er_flags & QR_PASSWORDED)) wprintf("CHECKED ");
463 wprintf("> Private - require password:\n");
464 wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n",er_password);
466 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
467 if ( (er_flags & QR_PRIVATE)
468 && ((er_flags & QR_GUESSNAME) == 0)
469 && ((er_flags & QR_PASSWORDED) == 0) )
471 wprintf("> Private - invitation only\n");
473 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
474 wprintf("> If private, cause current users to forget room\n");
478 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
479 if (er_flags & QR_PREFONLY) wprintf("CHECKED ");
480 wprintf("> Preferred users only\n");
482 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
483 if (er_flags & QR_READONLY) wprintf("CHECKED ");
484 wprintf("> Read-only room\n");
486 /* directory stuff */
487 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
488 if (er_flags & QR_DIRECTORY) wprintf("CHECKED ");
489 wprintf("> File directory room\n");
491 wprintf("<UL><LI>Directory name: ");
492 wprintf("<INPUT TYPE=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n",er_dirname);
494 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
495 if (er_flags & QR_UPLOAD) wprintf("CHECKED ");
496 wprintf("> Uploading allowed\n");
498 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
499 if (er_flags & QR_DOWNLOAD) wprintf("CHECKED ");
500 wprintf("> Downloading allowed\n");
502 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
503 if (er_flags & QR_VISDIR) wprintf("CHECKED ");
504 wprintf("> Visible directory</UL>\n");
506 /* end of directory stuff */
508 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
509 if (er_flags & QR_NETWORK) wprintf("CHECKED ");
510 wprintf("> Network shared room\n");
512 /* start of anon options */
514 wprintf("<LI>Anonymous messages<UL>\n");
516 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
517 if ( ((er_flags & QR_ANONONLY)==0)
518 && ((er_flags & QR_ANONOPT)==0)) wprintf("CHECKED ");
519 wprintf("> No anonymous messages\n");
521 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
522 if (er_flags & QR_ANONONLY) wprintf("CHECKED ");
523 wprintf("> All messages are anonymous\n");
525 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
526 if (er_flags & QR_ANONOPT) wprintf("CHECKED ");
527 wprintf("> Prompt user when entering messages</UL>\n");
529 /* end of anon options */
531 wprintf("<LI>Room aide: \n");
535 wprintf("<EM>%s</EM>\n",&buf[4]);
538 extract(er_roomaide,&buf[4],0);
539 wprintf("<INPUT TYPE=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n",er_roomaide);
542 wprintf("</UL><CENTER>\n");
543 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
544 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
545 wprintf("</CENTER>\n");
547 wprintf("</FORM></HTML>\n");
553 * save new parameters for a room
555 void editroom(void) {
558 char er_password[10];
560 char er_roomaide[26];
565 if (strcmp(bstr("sc"),"OK")) {
566 display_error("Cancelled. Changes were not saved.");
574 display_error(&buf[4]);
578 extract(er_name,&buf[4],0);
579 extract(er_password,&buf[4],1);
580 extract(er_dirname,&buf[4],2);
581 er_flags=extract_int(&buf[4],3);
583 strcpy(er_roomaide,bstr("er_roomaide"));
584 if (strlen(er_roomaide)==0) {
588 strcpy(er_roomaide,"");
591 extract(er_roomaide,&buf[4],0);
595 strcpy(buf,bstr("er_name")); buf[20] = 0;
596 if (strlen(buf)>0) strcpy(er_name,buf);
598 strcpy(buf,bstr("er_password")); buf[10] = 0;
599 if (strlen(buf)>0) strcpy(er_password,buf);
601 strcpy(buf,bstr("er_dirname")); buf[15] = 0;
602 if (strlen(buf)>0) strcpy(er_dirname,buf);
604 strcpy(buf,bstr("type"));
605 er_flags &= !(QR_PRIVATE|QR_PASSWORDED|QR_GUESSNAME);
607 if (!strcmp(buf,"invonly")) {
608 er_flags |= (QR_PRIVATE);
610 if (!strcmp(buf,"guessname")) {
611 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
613 if (!strcmp(buf,"passworded")) {
614 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
617 if (!strcmp(bstr("prefonly"),"yes")) {
618 er_flags |= QR_PREFONLY;
621 er_flags &= ~QR_PREFONLY;
624 if (!strcmp(bstr("readonly"),"yes")) {
625 er_flags |= QR_READONLY;
628 er_flags &= ~QR_READONLY;
631 if (!strcmp(bstr("network"),"yes")) {
632 er_flags |= QR_NETWORK;
635 er_flags &= ~QR_NETWORK;
638 if (!strcmp(bstr("directory"),"yes")) {
639 er_flags |= QR_DIRECTORY;
642 er_flags &= ~QR_DIRECTORY;
645 if (!strcmp(bstr("ulallowed"),"yes")) {
646 er_flags |= QR_UPLOAD;
649 er_flags &= ~QR_UPLOAD;
652 if (!strcmp(bstr("dlallowed"),"yes")) {
653 er_flags |= QR_DOWNLOAD;
656 er_flags &= ~QR_DOWNLOAD;
659 if (!strcmp(bstr("visdir"),"yes")) {
660 er_flags |= QR_VISDIR;
663 er_flags &= ~QR_VISDIR;
666 strcpy(buf,bstr("anon"));
668 er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
669 if (!strcmp(buf,"anononly")) er_flags |= QR_ANONONLY;
670 if (!strcmp(buf,"anon2")) er_flags |= QR_ANONOPT;
673 if (!strcmp(bstr("bump"),"yes")) bump = 1;
675 sprintf(buf,"SETR %s|%s|%s|%u|%d",
676 er_name,er_password,er_dirname,er_flags,bump);
680 display_error(&buf[4]);
683 gotoroom(er_name, 0);
685 if (strlen(er_roomaide)>0) {
686 sprintf(buf,"SETA %s",er_roomaide);
690 display_error(&buf[4]);
695 gotoroom(er_name, 1);
701 * display the form for entering a new room
703 void display_entroom(void) {
710 display_error(&buf[4]);
714 printf("HTTP/1.0 200 OK\n");
717 wprintf("<TABLE WIDTH=100% BORDER=0 BGCOLOR=000077><TR><TD>");
718 wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
719 wprintf("<B>Enter (create) a new room</B>\n");
720 wprintf("</FONT></TD></TR></TABLE>\n");
722 wprintf("<FORM METHOD=\"POST\" ACTION=\"/entroom\">\n");
724 wprintf("<UL><LI>Name of room: ");
725 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" MAXLENGTH=\"19\">\n");
727 wprintf("<LI>Type of room:<UL>\n");
729 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
730 wprintf("CHECKED > Public room\n");
732 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"guessname\" ");
733 wprintf("> Private - guess name\n");
735 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
736 wprintf("> Private - require password:\n");
737 wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
739 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
740 wprintf("> Private - invitation only\n");
742 wprintf("<CENTER>\n");
743 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
744 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
745 wprintf("</CENTER>\n");
746 wprintf("</FORM></HTML>\n");
759 char er_password[10];
762 if (strcmp(bstr("sc"),"OK")) {
763 display_error("Cancelled. No new room was created.");
767 strcpy(er_name,bstr("er_name"));
768 strcpy(er_type,bstr("type"));
769 strcpy(er_password,bstr("er_password"));
772 if (!strcmp(er_type,"guessname")) er_num_type = 1;
773 if (!strcmp(er_type,"passworded")) er_num_type = 2;
774 if (!strcmp(er_type,"invonly")) er_num_type = 3;
776 sprintf(buf,"CRE8 1|%s|%d|%s",er_name,er_num_type,er_password);
780 display_error(&buf[4]);
783 gotoroom(er_name, 1);
788 * display the screen to enter a private room
790 void display_private(char *rname, int req_pass)
793 printf("HTTP/1.0 200 OK\n");
796 wprintf("<TABLE WIDTH=100% BORDER=0 BGCOLOR=770000><TR><TD>");
797 wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
798 wprintf("<B>Goto a private room</B>\n");
799 wprintf("</FONT></TD></TR></TABLE>\n");
801 wprintf("<CENTER>\n");
802 wprintf("If you know the name of a hidden (guess-name) or\n");
803 wprintf("passworded room, you can enter that room by typing\n");
804 wprintf("its name below. Once you gain access to a private\n");
805 wprintf("room, it will appear in your regular room listings\n");
806 wprintf("so you don't have to keep returning here.\n");
809 wprintf("<FORM METHOD=\"POST\" ACTION=\"/goto_private\">\n");
811 wprintf("<TABLE border><TR><TD>");
812 wprintf("Enter room name:</TD><TD>");
813 wprintf("<INPUT TYPE=\"text\" NAME=\"gr_name\" VALUE=\"%s\" MAXLENGTH=\"19\">\n",rname);
816 wprintf("</TD></TR><TR><TD>");
817 wprintf("Enter room password:</TD><TD>");
818 wprintf("<INPUT TYPE=\"password\" NAME=\"gr_pass\" MAXLENGTH=\"9\">\n");
821 wprintf("</TD></TR></TABLE>\n");
823 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
824 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
825 wprintf("</FORM></HTML>\n");
830 * goto a private room
832 void goto_private(void) {
836 if (strcasecmp(bstr("sc"),"OK")) {
841 strcpy(hold_rm,wc_roomname);
843 strcat(buf,bstr("gr_name"));
845 strcat(buf,bstr("gr_pass"));
850 gotoroom(bstr("gr_name"),1);
854 if (!strncmp(buf,"540",3)) {
855 display_private(bstr("gr_name"),1);
859 printf("HTTP/1.0 200 OK\n");
861 wprintf("%s\n",&buf[4]);
868 * display the screen to zap a room
870 void display_zap(void) {
871 printf("HTTP/1.0 200 OK\n");
874 wprintf("<TABLE WIDTH=100% BORDER=0 BGCOLOR=770000><TR><TD>");
875 wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
876 wprintf("<B>Zap (forget) the current room</B>\n");
877 wprintf("</FONT></TD></TR></TABLE>\n");
879 wprintf("If you select this option, <em>%s</em> will ", wc_roomname);
880 wprintf("disappear from your room list. Is this what you wish ");
881 wprintf("to do?<BR>\n");
883 wprintf("<FORM METHOD=\"POST\" ACTION=\"/zap\">\n");
884 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
885 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
886 wprintf("</FORM></HTML>\n");
897 if (strcmp(bstr("sc"),"OK")) {
902 serv_printf("GOTO %s", wc_roomname);
905 display_error(&buf[4]);
912 display_error(&buf[4]);
916 gotoroom(bstr("_BASEROOM_"),1);