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 */
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 wprintf("<CENTER><H1>Forgotten rooms</H1>\n");
161 wprintf("</CENTER><HR>\n");
166 * read this room's info file (set v to 1 for verbose mode)
174 if (buf[0]=='1') fmout(NULL);
176 if (v==1) wprintf("<EM>%s</EM><BR>\n",&buf[4]);
182 * generic routine to take the session to a new room
184 * display_name values: 0 = goto only
185 * 1 = goto and display
188 void gotoroom(char *gname, int display_name)
191 static long ls = (-1L);
194 printf("HTTP/1.0 200 OK\n");
197 if (display_name != 2) {
198 /* store ungoto information */
199 strcpy(ugname, wc_roomname);
201 fprintf(stderr, "setting ugname to %s and uglsn to %ld\n",
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);
221 /* highest_msg_read = extract_int(&buf[4],6);
222 maxmsgnum = extract_int(&buf[4],5);
223 is_mail = (char) extract_int(&buf[4],7); */
224 ls = extract_long(&buf[4], 6);
226 if (is_aide) is_room_aide = is_aide;
227 else is_room_aide = (char) extract_int(&buf[4],8);
229 remove_march(wc_roomname);
230 if (!strcasecmp(gname,"_BASEROOM_")) remove_march(gname);
232 /* Display the room banner */
235 wprintf("<CENTER><TABLE border=0><TR>");
237 if ( (strlen(ugname)>0) && (strcasecmp(ugname,wc_roomname)) ) {
238 wprintf("<TD><A HREF=\"/ungoto\">");
239 wprintf("<IMG SRC=\"/static/back.gif\" border=0></A></TD>");
242 wprintf("<TD><H1>%s</H1>",wc_roomname);
243 wprintf("<FONT SIZE=-1>%d new of %d messages</FONT></TD>\n",
244 extract_int(&buf[4],1),
245 extract_int(&buf[4],2));
247 /* Display room graphic. The server doesn't actually need the
248 * room name, but we supply it in order to keep the browser
249 * from using a cached graphic from another room.
251 serv_puts("OIMG _roompic_");
255 wprintf("<IMG SRC=\"/image&name=_roompic_&room=");
256 escputs(wc_roomname);
266 wprintf("<TD><A HREF=\"/gotonext\">");
267 wprintf("<IMG SRC=\"/static/forward.gif\" border=0></A></TD>");
269 wprintf("</TR></TABLE></CENTER>\n");
272 strcpy(wc_roomname, wc_roomname);
278 * operation to goto a room
281 fprintf(stderr, "DOTGOTO: <%s>\n", bstr("room"));
282 gotoroom(bstr("room"),1);
286 /* Goto next room having unread messages.
287 * We want to skip over rooms that the user has already been to, and take the
288 * user back to the lobby when done. The room we end up in is placed in
289 * newroom - which is set to 0 (the lobby) initially.
290 * We start the search in the current room rather than the beginning to prevent
291 * two or more concurrent users from dragging each other back to the same room.
293 void gotonext(void) {
295 struct march *mptr,*mptr2;
298 /* First check to see if the march-mode list is already allocated.
299 * If it is, pop the first room off the list and go there.
306 while (serv_gets(buf), strcmp(buf,"000")) {
307 mptr = (struct march *) malloc(sizeof(struct march));
309 extract(mptr->march_name,buf,0);
315 while (mptr2->next != NULL)
321 /* add _BASEROOM_ to the end of the march list, so the user will end up
322 * in the system base room (usually the Lobby>) at the end of the loop
324 mptr = (struct march *) malloc(sizeof(struct march));
326 strcpy(mptr->march_name,"_BASEROOM_");
332 while (mptr2->next != NULL)
337 * ...and remove the room we're currently in, so a <G>oto doesn't make us
338 * walk around in circles
340 remove_march(wc_roomname);
345 strcpy(next_room,march->march_name);
348 strcpy(next_room,"_BASEROOM_");
350 gotoroom(next_room,1);
356 * mark all messages in current room as having been read
358 void slrp_highest(void) {
362 serv_puts("SLRP HIGHEST");
365 wprintf("<EM>%s</EM><BR>\n",&buf[4]);
372 * un-goto the previous room
377 if (!strcmp(ugname, "")) {
378 gotoroom(wc_roomname, 1);
381 serv_printf("GOTO %s", ugname);
384 gotoroom(wc_roomname, 1);
388 serv_printf("SLRP %ld",uglsn);
397 * display the form for editing a room
399 int display_editroom(void) {
402 char er_password[10];
404 char er_roomaide[26];
411 wprintf("<EM>%s</EM><BR>\n",&buf[4]);
415 extract(er_name,&buf[4],0);
416 extract(er_password,&buf[4],1);
417 extract(er_dirname,&buf[4],2);
418 er_flags=extract_int(&buf[4],3);
421 wprintf("<TABLE WIDTH=100% BORDER=0 BGCOLOR=000077><TR><TD>");
422 wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
423 wprintf("<B>Edit this room</B>\n");
424 wprintf("</FONT></TD></TR></TABLE>\n");
426 wprintf("<FORM METHOD=\"POST\" ACTION=\"/editroom\">\n");
428 wprintf("<UL><LI>Name of room: ");
429 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\"19\">\n",er_name);
431 wprintf("<LI>Type of room:<UL>\n");
433 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
434 if ((er_flags & QR_PRIVATE) == 0) wprintf("CHECKED ");
435 wprintf("> Public room\n");
437 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"guessname\" ");
438 if ((er_flags & QR_PRIVATE)&&
439 (er_flags & QR_GUESSNAME)) wprintf("CHECKED ");
440 wprintf("> Private - guess name\n");
442 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
443 if ((er_flags & QR_PRIVATE)&&
444 (er_flags & QR_PASSWORDED)) wprintf("CHECKED ");
445 wprintf("> Private - require password:\n");
446 wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n",er_password);
448 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
449 if ( (er_flags & QR_PRIVATE)
450 && ((er_flags & QR_GUESSNAME) == 0)
451 && ((er_flags & QR_PASSWORDED) == 0) )
453 wprintf("> Private - invitation only\n");
455 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
456 wprintf("> If private, cause current users to forget room\n");
460 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
461 if (er_flags & QR_PREFONLY) wprintf("CHECKED ");
462 wprintf("> Preferred users only\n");
464 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
465 if (er_flags & QR_READONLY) wprintf("CHECKED ");
466 wprintf("> Read-only room\n");
468 /* directory stuff */
469 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
470 if (er_flags & QR_DIRECTORY) wprintf("CHECKED ");
471 wprintf("> File directory room\n");
473 wprintf("<UL><LI>Directory name: ");
474 wprintf("<INPUT TYPE=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n",er_dirname);
476 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
477 if (er_flags & QR_UPLOAD) wprintf("CHECKED ");
478 wprintf("> Uploading allowed\n");
480 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
481 if (er_flags & QR_DOWNLOAD) wprintf("CHECKED ");
482 wprintf("> Downloading allowed\n");
484 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
485 if (er_flags & QR_VISDIR) wprintf("CHECKED ");
486 wprintf("> Visible directory</UL>\n");
488 /* end of directory stuff */
490 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
491 if (er_flags & QR_NETWORK) wprintf("CHECKED ");
492 wprintf("> Network shared room\n");
494 /* start of anon options */
496 wprintf("<LI>Anonymous messages<UL>\n");
498 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
499 if ( ((er_flags & QR_ANONONLY)==0)
500 && ((er_flags & QR_ANONOPT)==0)) wprintf("CHECKED ");
501 wprintf("> No anonymous messages\n");
503 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
504 if (er_flags & QR_ANONONLY) wprintf("CHECKED ");
505 wprintf("> All messages are anonymous\n");
507 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
508 if (er_flags & QR_ANONOPT) wprintf("CHECKED ");
509 wprintf("> Prompt user when entering messages</UL>\n");
511 /* end of anon options */
513 wprintf("<LI>Room aide: \n");
517 wprintf("<EM>%s</EM>\n",&buf[4]);
520 extract(er_roomaide,&buf[4],0);
521 wprintf("<INPUT TYPE=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n",er_roomaide);
524 wprintf("</UL><CENTER>\n");
525 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
526 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
527 wprintf("</CENTER>\n");
529 wprintf("</FORM>\n");
535 * save new parameters for a room
540 char er_password[10];
542 char er_roomaide[26];
547 if (strcmp(bstr("sc"),"OK")) {
548 wprintf("<EM>Changes have <STRONG>not</STRONG> been saved.</EM><BR>");
556 wprintf("<EM>%s</EM><BR>\n",&buf[4]);
560 extract(er_name,&buf[4],0);
561 extract(er_password,&buf[4],1);
562 extract(er_dirname,&buf[4],2);
563 er_flags=extract_int(&buf[4],3);
565 strcpy(er_roomaide,bstr("er_roomaide"));
566 if (strlen(er_roomaide)==0) {
570 strcpy(er_roomaide,"");
573 extract(er_roomaide,&buf[4],0);
577 strcpy(buf,bstr("er_name")); buf[20] = 0;
578 if (strlen(buf)>0) strcpy(er_name,buf);
580 strcpy(buf,bstr("er_password")); buf[10] = 0;
581 if (strlen(buf)>0) strcpy(er_password,buf);
583 strcpy(buf,bstr("er_dirname")); buf[15] = 0;
584 if (strlen(buf)>0) strcpy(er_dirname,buf);
586 strcpy(buf,bstr("type"));
587 er_flags &= !(QR_PRIVATE|QR_PASSWORDED|QR_GUESSNAME);
589 if (!strcmp(buf,"invonly")) {
590 er_flags |= (QR_PRIVATE);
592 if (!strcmp(buf,"guessname")) {
593 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
595 if (!strcmp(buf,"passworded")) {
596 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
599 if (!strcmp(bstr("prefonly"),"yes")) {
600 er_flags |= QR_PREFONLY;
603 er_flags &= ~QR_PREFONLY;
606 if (!strcmp(bstr("readonly"),"yes")) {
607 er_flags |= QR_READONLY;
610 er_flags &= ~QR_READONLY;
613 if (!strcmp(bstr("network"),"yes")) {
614 er_flags |= QR_NETWORK;
617 er_flags &= ~QR_NETWORK;
620 if (!strcmp(bstr("directory"),"yes")) {
621 er_flags |= QR_DIRECTORY;
624 er_flags &= ~QR_DIRECTORY;
627 if (!strcmp(bstr("ulallowed"),"yes")) {
628 er_flags |= QR_UPLOAD;
631 er_flags &= ~QR_UPLOAD;
634 if (!strcmp(bstr("dlallowed"),"yes")) {
635 er_flags |= QR_DOWNLOAD;
638 er_flags &= ~QR_DOWNLOAD;
641 if (!strcmp(bstr("visdir"),"yes")) {
642 er_flags |= QR_VISDIR;
645 er_flags &= ~QR_VISDIR;
648 strcpy(buf,bstr("anon"));
650 er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
651 if (!strcmp(buf,"anononly")) er_flags |= QR_ANONONLY;
652 if (!strcmp(buf,"anon2")) er_flags |= QR_ANONOPT;
655 if (!strcmp(bstr("bump"),"yes")) bump = 1;
657 sprintf(buf,"SETR %s|%s|%s|%u|%d",
658 er_name,er_password,er_dirname,er_flags,bump);
662 wprintf("<EM>%s</EM><HR>\n",&buf[4]);
663 return(display_editroom());
667 if (strlen(er_roomaide)>0) {
668 sprintf(buf,"SETA %s",er_roomaide);
672 wprintf("<EM>%s</EM><HR>\n",&buf[4]);
673 return(display_editroom());
677 wprintf("<EM>Changes have been saved.</EM><BR>");
684 * display the form for entering a new room
686 int display_entroom(void) {
693 wprintf("<EM>%s</EM><HR>\n",&buf[4]);
697 wprintf("<TABLE WIDTH=100% BORDER=0 BGCOLOR=000077><TR><TD>");
698 wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
699 wprintf("<B>Enter (create) a new room</B>\n");
700 wprintf("</FONT></TD></TR></TABLE>\n");
702 wprintf("<FORM METHOD=\"POST\" ACTION=\"/entroom\">\n");
704 wprintf("<UL><LI>Name of room: ");
705 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" MAXLENGTH=\"19\">\n");
707 wprintf("<LI>Type of room:<UL>\n");
709 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
710 wprintf("CHECKED > Public room\n");
712 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"guessname\" ");
713 wprintf("> Private - guess name\n");
715 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
716 wprintf("> Private - require password:\n");
717 wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
719 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
720 wprintf("> Private - invitation only\n");
722 wprintf("<CENTER>\n");
723 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
724 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
725 wprintf("</CENTER>\n");
726 wprintf("</FORM>\n");
739 char er_password[10];
742 if (strcmp(bstr("sc"),"OK")) {
743 wprintf("<EM>Changes have <STRONG>not</STRONG> been saved.</EM><BR>");
747 strcpy(er_name,bstr("er_name"));
748 strcpy(er_type,bstr("type"));
749 strcpy(er_password,bstr("er_password"));
752 if (!strcmp(er_type,"guessname")) er_num_type = 1;
753 if (!strcmp(er_type,"passworded")) er_num_type = 2;
754 if (!strcmp(er_type,"invonly")) er_num_type = 3;
756 sprintf(buf,"CRE8 1|%s|%d|%s",er_name,er_num_type,er_password);
760 wprintf("<EM>%s</EM><HR>\n",&buf[4]);
761 return(display_editroom());
769 * display the screen to enter a private room
771 void display_private(char *rname, int req_pass)
775 wprintf("<TABLE WIDTH=100% BORDER=0 BGCOLOR=770000><TR><TD>");
776 wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
777 wprintf("<B>Enter a private room</B>\n");
778 wprintf("</FONT></TD></TR></TABLE>\n");
780 wprintf("<CENTER>\n");
781 wprintf("If you know the name of a hidden (guess-name) or\n");
782 wprintf("passworded room, you can enter that room by typing\n");
783 wprintf("its name below. Once you gain access to a private\n");
784 wprintf("room, it will appear in your regular room listings\n");
785 wprintf("so you don't have to keep returning here.\n");
788 wprintf("<FORM METHOD=\"POST\" ACTION=\"/goto_private\">\n");
790 wprintf("<TABLE border><TR><TD>");
791 wprintf("Enter room name:</TD><TD>");
792 wprintf("<INPUT TYPE=\"text\" NAME=\"gr_name\" VALUE=\"%s\" MAXLENGTH=\"19\">\n",rname);
795 wprintf("</TD></TR><TR><TD>");
796 wprintf("Enter room password:</TD><TD>");
797 wprintf("<INPUT TYPE=\"password\" NAME=\"gr_pass\" MAXLENGTH=\"9\">\n");
800 wprintf("</TD></TR></TABLE>\n");
802 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
803 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
808 * goto a private room
810 int goto_private(void) {
814 if (strcmp(bstr("sc"),"OK")) {
818 strcpy(hold_rm,wc_roomname);
820 strcat(buf,bstr("gr_name"));
822 strcat(buf,bstr("gr_pass"));
827 gotoroom(bstr("gr_name"),1);
831 if (!strncmp(buf,"540",3)) {
832 display_private(bstr("gr_name"),1);
836 wprintf("<EM>%s</EM>\n",&buf[4]);
842 * display the screen to zap a room
844 void display_zap(void) {
847 strcpy(zaproom, bstr("room"));
849 wprintf("<TABLE WIDTH=100% BORDER=0 BGCOLOR=770000><TR><TD>");
850 wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
851 wprintf("<B>Zap (forget) the current room</B>\n");
852 wprintf("</FONT></TD></TR></TABLE>\n");
854 wprintf("If you select this option, <em>%s</em> will ", zaproom);
855 wprintf("disappear from your room list. Is this what you wish ");
856 wprintf("to do?<BR>\n");
858 wprintf("<FORM METHOD=\"POST\" ACTION=\"/zap\">\n");
859 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
860 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
872 if (strcmp(bstr("sc"),"OK")) {
876 strcpy(zaproom, bstr("room"));
877 sprintf(buf, "GOTO %s", zaproom);
881 wprintf("<EM>%s</EM>\n",&buf[4]);
888 wprintf("<EM>%s</EM>\n",&buf[4]);
892 gotoroom(bstr("_BASEROOM_"),1);