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>\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>\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 gotoroom(bstr("room"),1);
271 /* Goto next room having unread messages.
272 * We want to skip over rooms that the user has already been to, and take the
273 * user back to the lobby when done. The room we end up in is placed in
274 * newroom - which is set to 0 (the lobby) initially.
275 * We start the search in the current room rather than the beginning to prevent
276 * two or more concurrent users from dragging each other back to the same room.
278 void gotonext(void) {
280 struct march *mptr,*mptr2;
283 /* First check to see if the march-mode list is already allocated.
284 * If it is, pop the first room off the list and go there.
291 while (serv_gets(buf), strcmp(buf,"000")) {
292 mptr = (struct march *) malloc(sizeof(struct march));
294 extract(mptr->march_name,buf,0);
300 while (mptr2->next != NULL)
306 /* add _BASEROOM_ to the end of the march list, so the user will end up
307 * in the system base room (usually the Lobby>) at the end of the loop
309 mptr = (struct march *) malloc(sizeof(struct march));
311 strcpy(mptr->march_name,"_BASEROOM_");
317 while (mptr2->next != NULL)
322 * ...and remove the room we're currently in, so a <G>oto doesn't make us
323 * walk around in circles
325 remove_march(wc_roomname);
330 strcpy(next_room,march->march_name);
333 strcpy(next_room,"_BASEROOM_");
335 gotoroom(next_room,1);
341 * mark all messages in current room as having been read
343 void slrp_highest(void) {
347 serv_puts("SLRP HIGHEST");
350 wprintf("<EM>%s</EM><BR>\n",&buf[4]);
357 * un-goto the previous room
362 if (!strcmp(ugname,"")) return;
363 sprintf(buf,"GOTO %s",ugname);
367 wprintf("%s\n",&buf[4]);
370 sprintf(buf,"SLRP %ld",uglsn);
373 if (buf[0]!='2') wprintf("%s\n",&buf[4]);
380 * display the form for editing a room
382 int display_editroom(void) {
385 char er_password[10];
387 char er_roomaide[26];
394 wprintf("<EM>%s</EM><BR>\n",&buf[4]);
398 extract(er_name,&buf[4],0);
399 extract(er_password,&buf[4],1);
400 extract(er_dirname,&buf[4],2);
401 er_flags=extract_int(&buf[4],3);
404 wprintf("<TABLE WIDTH=100% BORDER=0 BGCOLOR=000077><TR><TD>");
405 wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
406 wprintf("<B>Edit this room</B>\n");
407 wprintf("</FONT></TD></TR></TABLE>\n");
409 wprintf("<FORM METHOD=\"POST\" ACTION=\"/editroom\">\n");
411 wprintf("<UL><LI>Name of room: ");
412 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\"19\">\n",er_name);
414 wprintf("<LI>Type of room:<UL>\n");
416 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
417 if ((er_flags & QR_PRIVATE) == 0) wprintf("CHECKED ");
418 wprintf("> Public room\n");
420 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"guessname\" ");
421 if ((er_flags & QR_PRIVATE)&&
422 (er_flags & QR_GUESSNAME)) wprintf("CHECKED ");
423 wprintf("> Private - guess name\n");
425 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
426 if ((er_flags & QR_PRIVATE)&&
427 (er_flags & QR_PASSWORDED)) wprintf("CHECKED ");
428 wprintf("> Private - require password:\n");
429 wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n",er_password);
431 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
432 if ( (er_flags & QR_PRIVATE)
433 && ((er_flags & QR_GUESSNAME) == 0)
434 && ((er_flags & QR_PASSWORDED) == 0) )
436 wprintf("> Private - invitation only\n");
438 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
439 wprintf("> If private, cause current users to forget room\n");
443 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
444 if (er_flags & QR_PREFONLY) wprintf("CHECKED ");
445 wprintf("> Preferred users only\n");
447 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
448 if (er_flags & QR_READONLY) wprintf("CHECKED ");
449 wprintf("> Read-only room\n");
451 /* directory stuff */
452 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
453 if (er_flags & QR_DIRECTORY) wprintf("CHECKED ");
454 wprintf("> File directory room\n");
456 wprintf("<UL><LI>Directory name: ");
457 wprintf("<INPUT TYPE=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n",er_dirname);
459 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
460 if (er_flags & QR_UPLOAD) wprintf("CHECKED ");
461 wprintf("> Uploading allowed\n");
463 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
464 if (er_flags & QR_DOWNLOAD) wprintf("CHECKED ");
465 wprintf("> Downloading allowed\n");
467 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
468 if (er_flags & QR_VISDIR) wprintf("CHECKED ");
469 wprintf("> Visible directory</UL>\n");
471 /* end of directory stuff */
473 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
474 if (er_flags & QR_NETWORK) wprintf("CHECKED ");
475 wprintf("> Network shared room\n");
477 /* start of anon options */
479 wprintf("<LI>Anonymous messages<UL>\n");
481 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
482 if ( ((er_flags & QR_ANONONLY)==0)
483 && ((er_flags & QR_ANONOPT)==0)) wprintf("CHECKED ");
484 wprintf("> No anonymous messages\n");
486 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
487 if (er_flags & QR_ANONONLY) wprintf("CHECKED ");
488 wprintf("> All messages are anonymous\n");
490 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
491 if (er_flags & QR_ANONOPT) wprintf("CHECKED ");
492 wprintf("> Prompt user when entering messages</UL>\n");
494 /* end of anon options */
496 wprintf("<LI>Room aide: \n");
500 wprintf("<EM>%s</EM>\n",&buf[4]);
503 extract(er_roomaide,&buf[4],0);
504 wprintf("<INPUT TYPE=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n",er_roomaide);
507 wprintf("</UL><CENTER>\n");
508 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
509 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
510 wprintf("</CENTER>\n");
512 wprintf("</FORM>\n");
518 * save new parameters for a room
523 char er_password[10];
525 char er_roomaide[26];
530 if (strcmp(bstr("sc"),"OK")) {
531 wprintf("<EM>Changes have <STRONG>not</STRONG> been saved.</EM><BR>");
539 wprintf("<EM>%s</EM><BR>\n",&buf[4]);
543 extract(er_name,&buf[4],0);
544 extract(er_password,&buf[4],1);
545 extract(er_dirname,&buf[4],2);
546 er_flags=extract_int(&buf[4],3);
548 strcpy(er_roomaide,bstr("er_roomaide"));
549 if (strlen(er_roomaide)==0) {
553 strcpy(er_roomaide,"");
556 extract(er_roomaide,&buf[4],0);
560 strcpy(buf,bstr("er_name")); buf[20] = 0;
561 if (strlen(buf)>0) strcpy(er_name,buf);
563 strcpy(buf,bstr("er_password")); buf[10] = 0;
564 if (strlen(buf)>0) strcpy(er_password,buf);
566 strcpy(buf,bstr("er_dirname")); buf[15] = 0;
567 if (strlen(buf)>0) strcpy(er_dirname,buf);
569 strcpy(buf,bstr("type"));
570 er_flags &= !(QR_PRIVATE|QR_PASSWORDED|QR_GUESSNAME);
572 if (!strcmp(buf,"invonly")) {
573 er_flags |= (QR_PRIVATE);
575 if (!strcmp(buf,"guessname")) {
576 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
578 if (!strcmp(buf,"passworded")) {
579 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
582 if (!strcmp(bstr("prefonly"),"yes")) {
583 er_flags |= QR_PREFONLY;
586 er_flags &= ~QR_PREFONLY;
589 if (!strcmp(bstr("readonly"),"yes")) {
590 er_flags |= QR_READONLY;
593 er_flags &= ~QR_READONLY;
596 if (!strcmp(bstr("network"),"yes")) {
597 er_flags |= QR_NETWORK;
600 er_flags &= ~QR_NETWORK;
603 if (!strcmp(bstr("directory"),"yes")) {
604 er_flags |= QR_DIRECTORY;
607 er_flags &= ~QR_DIRECTORY;
610 if (!strcmp(bstr("ulallowed"),"yes")) {
611 er_flags |= QR_UPLOAD;
614 er_flags &= ~QR_UPLOAD;
617 if (!strcmp(bstr("dlallowed"),"yes")) {
618 er_flags |= QR_DOWNLOAD;
621 er_flags &= ~QR_DOWNLOAD;
624 if (!strcmp(bstr("visdir"),"yes")) {
625 er_flags |= QR_VISDIR;
628 er_flags &= ~QR_VISDIR;
631 strcpy(buf,bstr("anon"));
633 er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
634 if (!strcmp(buf,"anononly")) er_flags |= QR_ANONONLY;
635 if (!strcmp(buf,"anon2")) er_flags |= QR_ANONOPT;
638 if (!strcmp(bstr("bump"),"yes")) bump = 1;
640 sprintf(buf,"SETR %s|%s|%s|%u|%d",
641 er_name,er_password,er_dirname,er_flags,bump);
645 wprintf("<EM>%s</EM><HR>\n",&buf[4]);
646 return(display_editroom());
650 if (strlen(er_roomaide)>0) {
651 sprintf(buf,"SETA %s",er_roomaide);
655 wprintf("<EM>%s</EM><HR>\n",&buf[4]);
656 return(display_editroom());
660 wprintf("<EM>Changes have been saved.</EM><BR>");
667 * display the form for entering a new room
669 int display_entroom(void) {
676 wprintf("<EM>%s</EM><HR>\n",&buf[4]);
680 wprintf("<TABLE WIDTH=100% BORDER=0 BGCOLOR=000077><TR><TD>");
681 wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
682 wprintf("<B>Enter (create) a new room</B>\n");
683 wprintf("</FONT></TD></TR></TABLE>\n");
685 wprintf("<FORM METHOD=\"POST\" ACTION=\"/entroom\">\n");
687 wprintf("<UL><LI>Name of room: ");
688 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" MAXLENGTH=\"19\">\n");
690 wprintf("<LI>Type of room:<UL>\n");
692 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
693 wprintf("CHECKED > Public room\n");
695 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"guessname\" ");
696 wprintf("> Private - guess name\n");
698 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
699 wprintf("> Private - require password:\n");
700 wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
702 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
703 wprintf("> Private - invitation only\n");
705 wprintf("<CENTER>\n");
706 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
707 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
708 wprintf("</CENTER>\n");
709 wprintf("</FORM>\n");
722 char er_password[10];
725 if (strcmp(bstr("sc"),"OK")) {
726 wprintf("<EM>Changes have <STRONG>not</STRONG> been saved.</EM><BR>");
730 strcpy(er_name,bstr("er_name"));
731 strcpy(er_type,bstr("type"));
732 strcpy(er_password,bstr("er_password"));
735 if (!strcmp(er_type,"guessname")) er_num_type = 1;
736 if (!strcmp(er_type,"passworded")) er_num_type = 2;
737 if (!strcmp(er_type,"invonly")) er_num_type = 3;
739 sprintf(buf,"CRE8 1|%s|%d|%s",er_name,er_num_type,er_password);
743 wprintf("<EM>%s</EM><HR>\n",&buf[4]);
744 return(display_editroom());
752 * display the screen to enter a private room
754 void display_private(char *rname, int req_pass)
758 wprintf("<TABLE WIDTH=100% BORDER=0 BGCOLOR=770000><TR><TD>");
759 wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
760 wprintf("<B>Enter a private room</B>\n");
761 wprintf("</FONT></TD></TR></TABLE>\n");
763 wprintf("<CENTER>\n");
764 wprintf("If you know the name of a hidden (guess-name) or\n");
765 wprintf("passworded room, you can enter that room by typing\n");
766 wprintf("its name below. Once you gain access to a private\n");
767 wprintf("room, it will appear in your regular room listings\n");
768 wprintf("so you don't have to keep returning here.\n");
771 wprintf("<FORM METHOD=\"POST\" ACTION=\"/goto_private\">\n");
773 wprintf("<TABLE border><TR><TD>");
774 wprintf("Enter room name:</TD><TD>");
775 wprintf("<INPUT TYPE=\"text\" NAME=\"gr_name\" VALUE=\"%s\" MAXLENGTH=\"19\">\n",rname);
778 wprintf("</TD></TR><TR><TD>");
779 wprintf("Enter room password:</TD><TD>");
780 wprintf("<INPUT TYPE=\"password\" NAME=\"gr_pass\" MAXLENGTH=\"9\">\n");
783 wprintf("</TD></TR></TABLE>\n");
785 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
786 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
791 * goto a private room
793 int goto_private(void) {
797 if (strcmp(bstr("sc"),"OK")) {
801 strcpy(hold_rm,wc_roomname);
803 strcat(buf,bstr("gr_name"));
805 strcat(buf,bstr("gr_pass"));
810 gotoroom(bstr("gr_name"),1);
814 if (!strncmp(buf,"540",3)) {
815 display_private(bstr("gr_name"),1);
819 wprintf("<EM>%s</EM>\n",&buf[4]);
825 * display the screen to zap a room
827 void display_zap(void) {
830 strcpy(zaproom, bstr("room"));
832 wprintf("<TABLE WIDTH=100% BORDER=0 BGCOLOR=770000><TR><TD>");
833 wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
834 wprintf("<B>Zap (forget) the current room</B>\n");
835 wprintf("</FONT></TD></TR></TABLE>\n");
837 wprintf("If you select this option, <em>%s</em> will ", zaproom);
838 wprintf("disappear from your room list. Is this what you wish ");
839 wprintf("to do?<BR>\n");
841 wprintf("<FORM METHOD=\"POST\" ACTION=\"/zap\">\n");
842 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
843 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
855 if (strcmp(bstr("sc"),"OK")) {
859 strcpy(zaproom, bstr("room"));
860 sprintf(buf, "GOTO %s", zaproom);
864 wprintf("<EM>%s</EM>\n",&buf[4]);
871 wprintf("<EM>%s</EM>\n",&buf[4]);
875 gotoroom(bstr("_BASEROOM_"),1);