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");
120 wprintf("<HTML><HEAD><TITLE>List known rooms</TITLE></HEAD><BODY BACKGROUND=\"/image&name=background\" TEXT=\"#000000\" LINK=\"#004400\">\n");
122 wprintf("<TABLE width=100% border><TR><TH>Floor</TH>");
123 wprintf("<TH>Rooms with new messages</TH>");
124 wprintf("<TH>Rooms with no new messages</TH></TR>\n");
126 for (a=0; a<128; ++a) if (floorlist[a][0]!=0) {
128 /* Floor name column */
132 wprintf("<IMG SRC=\"/dynamic/_floorpic_/%d\" ALT=\"%s\">",
135 escputs(&floorlist[a][0]);
139 /* Rooms with new messages column */
141 sprintf(buf,"LKRN %d",a);
143 wprintf("</TD><TD>\n");
145 /* Rooms with old messages column */
146 sprintf(buf,"LKRO %d",a);
148 wprintf("</TD></TR>\n");
150 wprintf("</TABLE>\n");
151 wprintf("</BODY></HTML>\n");
157 * list all forgotten rooms
159 void zapped_list(void) {
160 wprintf("<CENTER><H1>Forgotten rooms</H1>\n");
162 wprintf("</CENTER><HR>\n");
167 * read this room's info file (set v to 1 for verbose mode)
175 if (buf[0]=='1') fmout(NULL);
177 if (v==1) wprintf("<EM>%s</EM><BR>\n",&buf[4]);
183 * generic routine to take the session to a new room
185 * display_name values: 0 = goto only
186 * 1 = goto and display
189 void gotoroom(char *gname, int display_name)
195 printf("HTTP/1.0 200 OK\n");
197 wprintf("<HTML><BODY BACKGROUND=\"/image&name=background\" TEXT=\"#000000\" LINK=\"#004400\">\n");
199 if (display_name != 2) {
200 /* store ungoto information */
201 strcpy(ugname,wc_roomname);
205 /* move to the new room */
206 sprintf(buf,"GOTO %s",gname);
210 serv_puts("GOTO _BASEROOM_");
214 wprintf("<EM>%s</EM><BR>\n",&buf[4]);
219 extract(wc_roomname,&buf[4],0);
220 room_flags = extract_int(&buf[4],4);
222 remove_march(wc_roomname);
223 if (!strcasecmp(gname,"_BASEROOM_")) remove_march(gname);
225 /* Display the room banner */
228 wprintf("<CENTER><TABLE border=0><TR>");
230 if ( (strlen(ugname)>0) && (strcasecmp(ugname,wc_roomname)) ) {
231 wprintf("<TD><A HREF=\"/ungoto\">");
232 wprintf("<IMG SRC=\"/static/back.gif\" border=0></A></TD>");
235 wprintf("<TD><H1>%s</H1>",wc_roomname);
236 wprintf("<FONT SIZE=-1>%d new of %d messages</FONT></TD>\n",
237 extract_int(&buf[4],1),
238 extract_int(&buf[4],2));
240 /* FIX add room image here */
246 wprintf("<TD><A HREF=\"/gotonext\">");
247 wprintf("<IMG SRC=\"/static/forward.gif\" border=0></A></TD>");
249 wprintf("</TR></TABLE></CENTER>\n");
252 /* highest_msg_read = extract_int(&buf[4],6);
253 maxmsgnum = extract_int(&buf[4],5);
254 is_mail = (char) extract_int(&buf[4],7); */
255 is_room_aide = (char) extract_int(&buf[4],8);
256 ls = extract_long(&buf[4],6);
258 strcpy(wc_roomname, wc_roomname);
264 * operation to goto a room
267 fprintf(stderr, "DOTGOTO: <%s>\n", bstr("room"));
268 gotoroom(bstr("room"),1);
272 /* Goto next room having unread messages.
273 * We want to skip over rooms that the user has already been to, and take the
274 * user back to the lobby when done. The room we end up in is placed in
275 * newroom - which is set to 0 (the lobby) initially.
276 * We start the search in the current room rather than the beginning to prevent
277 * two or more concurrent users from dragging each other back to the same room.
279 void gotonext(void) {
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(void) {
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(void) {
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(void) {
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(char *rname, int req_pass)
759 wprintf("<TABLE WIDTH=100% BORDER=0 BGCOLOR=770000><TR><TD>");
760 wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
761 wprintf("<B>Enter a private room</B>\n");
762 wprintf("</FONT></TD></TR></TABLE>\n");
764 wprintf("<CENTER>\n");
765 wprintf("If you know the name of a hidden (guess-name) or\n");
766 wprintf("passworded room, you can enter that room by typing\n");
767 wprintf("its name below. Once you gain access to a private\n");
768 wprintf("room, it will appear in your regular room listings\n");
769 wprintf("so you don't have to keep returning here.\n");
772 wprintf("<FORM METHOD=\"POST\" ACTION=\"/goto_private\">\n");
774 wprintf("<TABLE border><TR><TD>");
775 wprintf("Enter room name:</TD><TD>");
776 wprintf("<INPUT TYPE=\"text\" NAME=\"gr_name\" VALUE=\"%s\" MAXLENGTH=\"19\">\n",rname);
779 wprintf("</TD></TR><TR><TD>");
780 wprintf("Enter room password:</TD><TD>");
781 wprintf("<INPUT TYPE=\"password\" NAME=\"gr_pass\" MAXLENGTH=\"9\">\n");
784 wprintf("</TD></TR></TABLE>\n");
786 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
787 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
792 * goto a private room
794 int goto_private(void) {
798 if (strcmp(bstr("sc"),"OK")) {
802 strcpy(hold_rm,wc_roomname);
804 strcat(buf,bstr("gr_name"));
806 strcat(buf,bstr("gr_pass"));
811 gotoroom(bstr("gr_name"),1);
815 if (!strncmp(buf,"540",3)) {
816 display_private(bstr("gr_name"),1);
820 wprintf("<EM>%s</EM>\n",&buf[4]);
826 * display the screen to zap a room
828 void display_zap(void) {
831 strcpy(zaproom, bstr("room"));
833 wprintf("<TABLE WIDTH=100% BORDER=0 BGCOLOR=770000><TR><TD>");
834 wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
835 wprintf("<B>Zap (forget) the current room</B>\n");
836 wprintf("</FONT></TD></TR></TABLE>\n");
838 wprintf("If you select this option, <em>%s</em> will ", zaproom);
839 wprintf("disappear from your room list. Is this what you wish ");
840 wprintf("to do?<BR>\n");
842 wprintf("<FORM METHOD=\"POST\" ACTION=\"/zap\">\n");
843 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
844 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
856 if (strcmp(bstr("sc"),"OK")) {
860 strcpy(zaproom, bstr("room"));
861 sprintf(buf, "GOTO %s", zaproom);
865 wprintf("<EM>%s</EM>\n",&buf[4]);
872 wprintf("<EM>%s</EM>\n",&buf[4]);
876 gotoroom(bstr("_BASEROOM_"),1);