4 * This is the actual program called by the webserver. It maintains a
5 * persistent session to the Citadel server, handling HTTP WebCit requests as
6 * they arrive and presenting a user interface.
17 #include <sys/types.h>
19 #include <sys/socket.h>
23 #include <netinet/in.h>
32 #include "webserver.h"
33 #include "mime_parser.h"
36 * String to unset the cookie.
37 * Any date "in the past" will work, so I chose my birthday, right down to
38 * the exact minute. :)
40 static char *unset = "; expires=28-May-1971 18:10:00 GMT";
42 void unescape_input(char *buf)
47 while ((isspace(buf[strlen(buf) - 1])) && (strlen(buf) > 0))
48 buf[strlen(buf) - 1] = 0;
50 for (a = 0; a < strlen(buf); ++a) {
57 sscanf(hex, "%02x", &b);
59 strcpy(&buf[a + 1], &buf[a + 3]);
66 void addurls(char *url)
74 while (strlen(up) > 0) {
76 /* locate the = sign */
77 safestrncpy(buf, up, sizeof buf);
79 for (a = 255; a >= 0; --a)
86 u = (struct urlcontent *) malloc(sizeof(struct urlcontent));
87 u->next = WC->urlstrings;
89 strcpy(u->url_key, buf);
91 /* now chop that part off */
92 for (a = 0; a <= b; ++a)
95 /* locate the & sign */
98 for (a = 0; a < strlen(up); ++a) {
99 if (!strncmp(ptr, "&", 1)) {
106 for (a = 0; a < b; ++a)
110 u->url_data = malloc(strlen(up) + 1);
111 strcpy(u->url_data, up);
113 unescape_input(u->url_data);
121 struct urlcontent *u;
123 while (WC->urlstrings != NULL) {
124 free(WC->urlstrings->url_data);
125 u = WC->urlstrings->next;
126 free(WC->urlstrings);
132 * Diagnostic function to display the contents of all variables
136 struct urlcontent *u;
138 for (u = WC->urlstrings; u != NULL; u = u->next) {
139 wprintf("%38s = %s\n", u->url_key, u->url_data);
143 char *bstr(char *key)
145 struct urlcontent *u;
147 for (u = WC->urlstrings; u != NULL; u = u->next) {
148 if (!strcasecmp(u->url_key, key))
149 return (u->url_data);
155 void wprintf(const char *format,...)
160 va_start(arg_ptr, format);
161 vsprintf(wbuf, format, arg_ptr);
164 write(WC->http_sock, wbuf, strlen(wbuf));
169 * wDumpContent() wraps up an HTTP session, closes tags, etc.
171 * print_standard_html_footer should be set to 0 to transmit only, 1 to
172 * append the main menu and closing tags, or 2 to
173 * append the closing tags only.
175 void wDumpContent(int print_standard_html_footer)
177 if (WC->fake_frames) {
178 wprintf("</TABLE>\n");
182 if (print_standard_html_footer) {
183 if (print_standard_html_footer != 2) {
186 wprintf("</BODY></HTML>\n");
194 * Copy a string, escaping characters which have meaning in HTML. If
195 * nbsp is nonzero, spaces are converted to non-breaking spaces.
197 void stresc(char *target, char *strbuf, int nbsp)
202 for (a = 0; a < strlen(strbuf); ++a) {
203 if (strbuf[a] == '<')
204 strcat(target, "<");
205 else if (strbuf[a] == '>')
206 strcat(target, ">");
207 else if (strbuf[a] == '&')
208 strcat(target, "&");
209 else if (strbuf[a] == '\"')
210 strcat(target, """);
211 else if (strbuf[a] == '\'')
212 strcat(target, "'");
213 else if (strbuf[a] == LB)
215 else if (strbuf[a] == RB)
217 else if (strbuf[a] == QU)
218 strcat(target, "\"");
219 else if ((strbuf[a] == 32) && (nbsp == 1)) {
220 strcat(target, " ");
222 strncat(target, &strbuf[a], 1);
227 void escputs1(char *strbuf, int nbsp)
230 stresc(buf, strbuf, nbsp);
234 void escputs(char *strbuf)
240 * Escape a string for feeding out as a URL.
241 * Returns a pointer to a buffer that must be freed by the caller!
243 void urlesc(char *outbuf, char *strbuf)
246 char *ec = " #&;`'|*?-~<>^()[]{}$\\";
250 for (a = 0; a < strlen(strbuf); ++a) {
252 for (b = 0; b < strlen(ec); ++b) {
253 if (strbuf[a] == ec[b])
258 sprintf(&outbuf[b], "%%%02x", strbuf[a]);
260 sprintf(&outbuf[b], "%c", strbuf[a]);
264 void urlescputs(char *strbuf)
268 urlesc(outbuf, strbuf);
269 wprintf("%s", outbuf);
276 * Output all that important stuff that the browser will want to see
281 * 0 = Nothing. Do not display any leading HTTP or HTML.
282 * 1 = HTTP headers plus the room banner
283 * 2 = HTTP headers required to terminate the session (unset cookies)
284 * 3 = HTTP and HTML headers, but no room banner
286 * Bit 2: Set to 1 to auto-refresh page every 30 seconds
288 * Bit 3: suppress check for express messages
290 void output_headers(int controlcode)
293 int print_standard_html_head = 0;
295 int suppress_check = 0;
297 static int pageseq = 0;
299 print_standard_html_head = controlcode & 0x03;
300 refresh30 = ((controlcode & 0x04) >> 2);
301 suppress_check = ((controlcode & 0x08) >> 3);
303 wprintf("HTTP/1.0 200 OK\n");
305 httpdate(httpnow, time(NULL));
307 if (print_standard_html_head > 0) {
308 wprintf("Content-type: text/html\n");
309 wprintf("Server: %s\n", SERVER);
310 wprintf("Connection: close\n");
311 wprintf("Pragma: no-cache\n");
312 wprintf("Cache-Control: no-store\n");
314 stuff_to_cookie(cookie, WC->wc_session, WC->wc_username,
315 WC->wc_password, WC->wc_roomname);
316 if (print_standard_html_head == 2) {
317 wprintf("Set-cookie: webcit=%s\n", unset);
319 wprintf("Set-cookie: webcit=%s\n", cookie);
320 if (server_cookie != NULL) {
321 wprintf("%s\n", server_cookie);
325 if (print_standard_html_head > 0) {
327 wprintf("<HTML><HEAD><TITLE>");
328 escputs(serv_info.serv_humannode);
330 "<META HTTP-EQUIV=\"Pragma\" CONTENT=\"no-cache\">\n"
331 "<META HTTP-EQUIV=\"expired\" CONTENT=\"28-May-1971 18:10:00 GMT\">\n"
332 "<META NAME=\"MSSmartTagsPreventParsing\" CONTENT=\"TRUE\">\n");
333 if (refresh30) wprintf(
334 "<META HTTP-EQUIV=\"refresh\" CONTENT=\"30\">\n");
336 "<META HTTP-EQUIV=\"refresh\" CONTENT=\"500363689;\">\n");
337 wprintf("</HEAD>\n");
339 /* script for checking for pages (not always launched) */
340 wprintf("<SCRIPT LANGUAGE=\"JavaScript\">\n");
341 wprintf("function launch_page_popup() {\n");
342 wprintf("pwin = window.open('/page_popup', 'CitaPage%d', "
343 "'toolbar=no,location=no,copyhistory=no,status=no,"
344 "scrollbars=yes,resizable=no,height=250,width=400');\n",
347 wprintf("</SCRIPT>\n");
350 /* (JavaScript keyboard-based navigation would go here) */
352 if (!suppress_check) if (WC->HaveExpressMessages) {
353 svprintf("extrabodyparms", WCS_STRING, "%s",
354 "onload=\"launch_page_popup()\" ");
355 WC->HaveExpressMessages = 0;
357 do_template("background");
358 clear_local_substs();
360 if (print_standard_html_head == 1) {
361 wprintf("<A NAME=\"TheTop\"></A>");
363 wprintf("<TABLE border=0 width=100%%><TR VALIGN=TOP>"
366 embed_room_banner(NULL);
368 wprintf("</TD></TR><TR VALIGN=TOP><TD>\n");
379 void http_redirect(char *whichpage) {
380 wprintf("HTTP/1.0 302 Moved Temporarily\n");
381 wprintf("Location: %s\n", whichpage);
382 wprintf("URI: %s\n", whichpage);
383 wprintf("Content-type: text/html\n\n");
384 wprintf("<html><body>\n");
385 wprintf("you really want to be <A HREF=\"%s\">here</A> now\n",
387 wprintf("</body></html>\n");
392 void check_for_express_messages()
398 if (buf[3] == '*') WC->HaveExpressMessages = 1;
404 void output_static(char *what)
412 sprintf(buf, "static/%s", what);
413 fp = fopen(buf, "rb");
415 wprintf("HTTP/1.0 404 %s\n", strerror(errno));
416 wprintf("Content-Type: text/plain\n");
418 wprintf("Cannot open %s: %s\n", what, strerror(errno));
422 if (!strncasecmp(&what[strlen(what) - 4], ".gif", 4))
423 wprintf("Content-type: image/gif\n");
424 else if (!strncasecmp(&what[strlen(what) - 4], ".txt", 4))
425 wprintf("Content-type: text/plain\n");
426 else if (!strncasecmp(&what[strlen(what) - 4], ".css", 4))
427 wprintf("Content-type: text/css\n");
428 else if (!strncasecmp(&what[strlen(what) - 4], ".jpg", 4))
429 wprintf("Content-type: image/jpeg\n");
430 else if (!strncasecmp(&what[strlen(what) - 4], ".png", 4))
431 wprintf("Content-type: image/png\n");
432 else if (!strncasecmp(&what[strlen(what) - 5], ".html", 5))
433 wprintf("Content-type: text/html\n");
434 else if (!strncasecmp(&what[strlen(what) - 4], ".wml", 4))
435 wprintf("Content-type: text/vnd.wap.wml\n");
436 else if (!strncasecmp(&what[strlen(what) - 5], ".wmls", 5))
437 wprintf("Content-type: text/vnd.wap.wmlscript\n");
438 else if (!strncasecmp(&what[strlen(what) - 5], ".wmlc", 5))
439 wprintf("Content-type: application/vnd.wap.wmlc\n");
440 else if (!strncasecmp(&what[strlen(what) - 6], ".wmlsc", 6))
441 wprintf("Content-type: application/vnd.wap.wmlscriptc\n");
442 else if (!strncasecmp(&what[strlen(what) - 5], ".wbmp", 5))
443 wprintf("Content-type: image/vnd.wap.wbmp\n");
445 wprintf("Content-type: application/octet-stream\n");
447 fstat(fileno(fp), &statbuf);
448 bytes = statbuf.st_size;
449 lprintf(3, "Static: %s, %ld bytes\n", what, bytes);
450 wprintf("Content-length: %ld\n", (long) bytes);
452 bigbuffer = malloc(bytes);
453 fread(bigbuffer, bytes, 1, fp);
455 write(WC->http_sock, bigbuffer, bytes);
458 if (!strcasecmp(bstr("force_close_session"), "yes")) {
459 end_webcit_session();
465 * When the browser requests an image file from the Citadel server,
466 * this function is called to transmit it.
474 off_t accomplished = 0L;
476 lprintf(5, "output_image() called\n");
477 serv_printf("OIMG %s|%s", bstr("name"), bstr("parm"));
480 bytes = extract_long(&buf[4], 0);
482 wprintf("Content-type: image/gif\n");
483 wprintf("Content-length: %ld\n", (long) bytes);
486 while (bytes > (off_t) 0) {
487 thisblock = (off_t) sizeof(xferbuf);
488 if (thisblock > bytes) {
491 serv_printf("READ %ld|%ld", accomplished, thisblock);
494 thisblock = extract_long(&buf[4], 0);
495 serv_read(xferbuf, (int) thisblock);
498 memset(xferbuf, 0, thisblock);
500 write(WC->http_sock, xferbuf, thisblock);
501 bytes = bytes - thisblock;
502 accomplished = accomplished + thisblock;
507 wprintf("HTTP/1.0 404 %s\n", &buf[4]);
509 wprintf("Content-Type: text/plain\n");
511 wprintf("Error retrieving image: %s\n", &buf[4]);
518 void output_mimepart()
524 off_t accomplished = 0L;
525 char content_type[SIZ];
527 serv_printf("OPNA %s|%s", bstr("msgnum"), bstr("partnum"));
530 bytes = extract_long(&buf[4], 0);
531 extract(content_type, &buf[4], 3);
533 wprintf("Content-type: %s\n", content_type);
534 wprintf("Content-length: %ld\n", (long) bytes);
537 while (bytes > (off_t) 0) {
538 thisblock = (off_t) sizeof(xferbuf);
539 if (thisblock > bytes) {
542 serv_printf("READ %ld|%ld", accomplished, thisblock);
545 thisblock = extract_long(&buf[4], 0);
546 serv_read(xferbuf, (int) thisblock);
549 memset(xferbuf, 0, thisblock);
551 write(WC->http_sock, xferbuf, thisblock);
552 bytes = bytes - thisblock;
553 accomplished = accomplished + thisblock;
558 wprintf("HTTP/1.0 404 %s\n", &buf[4]);
560 wprintf("Content-Type: text/plain\n");
562 wprintf("Error retrieving part: %s\n", &buf[4]);
570 char *load_mimepart(long msgnum, char *partnum)
575 off_t accomplished = 0L;
576 char content_type[SIZ];
579 serv_printf("OPNA %ld|%s", msgnum, partnum);
582 bytes = extract_long(&buf[4], 0);
583 extract(content_type, &buf[4], 3);
585 content = malloc(bytes + 1);
587 while (bytes > (off_t) 0) {
589 if (thisblock > 4096L) {
592 if (thisblock > bytes) {
595 serv_printf("READ %ld|%ld", accomplished, thisblock);
598 thisblock = extract_long(&buf[4], 0);
599 serv_read(&content[accomplished], (int) thisblock);
602 memset(&content[accomplished], 0, thisblock);
604 bytes = bytes - thisblock;
605 accomplished = accomplished + thisblock;
609 content[accomplished] = 0; /* null terminate for good measure */
620 * Convenience functions to display a page containing only a string
622 void convenience_page(char *titlebarcolor, char *titlebarmsg, char *messagetext)
624 wprintf("HTTP/1.0 200 OK\n");
626 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=%s><TR><TD>", titlebarcolor);
627 wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
628 wprintf("<B>%s</B>\n", titlebarmsg);
629 wprintf("</FONT></TD></TR></TABLE><BR>\n");
630 escputs(messagetext);
638 * Display a blank page.
640 void blank_page(void) {
649 * Offer to make any page the user's "start page."
651 void offer_start_page(void) {
652 wprintf("<A HREF=\"/change_start_page?startpage=");
653 urlescputs(WC->this_page);
655 "<FONT SIZE=-2 COLOR=#AAAAAA>Make this my start page</FONT>"
662 * Change the user's start page
664 void change_start_page(void) {
666 if (bstr("startpage") == NULL) {
667 display_error("startpage set to null");
671 set_preference("startpage", bstr("startpage"));
674 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=000077><TR><TD>");
675 wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
676 wprintf("<B>New start page</B>\n");
677 wprintf("</FONT></TD></TR></TABLE>\n");
680 "<font size=+2>Your start page has been changed.</font>"
682 "<I>(Note: this does not change your browser's home page. "
683 "It changes the page you begin on when you log on to ");
684 escputs(serv_info.serv_humannode);
685 wprintf(".)</I><BR><BR>"
686 "<a href = \"javascript:history.back()\">Back...</a>"
695 void display_error(char *errormessage)
697 convenience_page("770000", "Error", errormessage);
700 void display_success(char *successmessage)
702 convenience_page("007700", "OK", successmessage);
707 void extract_action(char *actbuf, char *cmdbuf)
711 strcpy(actbuf, cmdbuf);
712 if (!strncasecmp(actbuf, "GET /", 5))
713 strcpy(actbuf, &actbuf[5]);
714 if (!strncasecmp(actbuf, "PUT /", 5))
715 strcpy(actbuf, &actbuf[5]);
716 if (!strncasecmp(actbuf, "POST /", 6))
717 strcpy(actbuf, &actbuf[6]);
719 for (i = 0; i < strlen(actbuf); ++i) {
720 if (actbuf[i] == ' ') {
724 if (actbuf[i] == '/') {
728 if (actbuf[i] == '?') {
732 if (actbuf[i] == '&') {
740 void upload_handler(char *name, char *filename, char *partnum, char *disp,
741 void *content, char *cbtype, size_t length,
742 char *encoding, void *userdata)
745 lprintf(5, "UPLOAD HANDLER CALLED\n");
746 lprintf(5, " name = %s\n", name);
747 lprintf(5, "filename = %s\n", filename);
748 lprintf(5, "encoding = %s\n", encoding);
749 lprintf(5, " type = %s\n", cbtype);
750 lprintf(5, " length = %ld\n", (long)length);
753 WC->upload = malloc(length);
754 if (WC->upload != NULL) {
755 WC->upload_length = length;
756 memcpy(WC->upload, content, length);
759 lprintf(9, "malloc() failed: %s\n",
769 * Entry point for WebCit transaction
771 void session_loop(struct httprequest *req)
777 int ContentLength = 0;
779 char ContentType[512];
782 struct httprequest *hptr;
783 char browser_host[SIZ];
784 char user_agent[SIZ];
786 /* We stuff these with the values coming from the client cookies,
787 * so we can use them to reconnect a timed out session if we have to.
791 char c_username[SIZ];
792 char c_password[SIZ];
793 char c_roomname[SIZ];
796 strcpy(c_host, defaulthost);
797 strcpy(c_port, defaultport);
798 strcpy(c_username, "");
799 strcpy(c_password, "");
800 strcpy(c_roomname, "");
802 WC->upload_length = 0;
808 if (hptr == NULL) return;
810 strcpy(cmd, hptr->line);
812 extract_action(action, cmd);
814 while (hptr != NULL) {
815 strcpy(buf, hptr->line);
818 if (!strncasecmp(buf, "Cookie: webcit=", 15)) {
819 strcpy(cookie, &buf[15]);
820 cookie_to_stuff(cookie, NULL,
821 c_username, c_password, c_roomname);
823 else if (!strncasecmp(buf, "Content-length: ", 16)) {
824 ContentLength = atoi(&buf[16]);
826 else if (!strncasecmp(buf, "Content-type: ", 14)) {
827 safestrncpy(ContentType, &buf[14], sizeof ContentType);
829 else if (!strncasecmp(buf, "User-agent: ", 12)) {
830 safestrncpy(user_agent, &buf[12], sizeof user_agent);
832 else if (!strncasecmp(buf, "Host: ", 6)) {
833 safestrncpy(WC->http_host, &buf[6], sizeof WC->http_host);
835 /* Only WAP gateways explicitly name this content-type */
836 else if (strstr(buf, "text/vnd.wap.wml")) {
841 if (ContentLength > 0) {
842 lprintf(5, "Content length: %d\n", ContentLength);
843 content = malloc(ContentLength + 1);
844 memset(content, 0, ContentLength+1);
847 while (BytesRead < ContentLength) {
848 a=read(WC->http_sock, &content[BytesRead],
849 ContentLength - BytesRead);
850 if (a <= 0) BytesRead = ContentLength;
854 if (!strncasecmp(ContentType,
855 "application/x-www-form-urlencoded", 33)) {
857 } else if (!strncasecmp(ContentType, "multipart", 9)) {
858 content_end = content + ContentLength;
859 mime_parser(content, content_end, *upload_handler,
860 NULL, NULL, NULL, 0);
866 /* make a note of where we are in case the user wants to save it */
867 safestrncpy(WC->this_page, cmd, sizeof(WC->this_page));
868 remove_token(WC->this_page, 2, ' ');
869 remove_token(WC->this_page, 0, ' ');
871 /* If there are variables in the URL, we must grab them now */
872 for (a = 0; a < strlen(cmd); ++a) {
873 if ((cmd[a] == '?') || (cmd[a] == '&')) {
874 for (b = a; b < strlen(cmd); ++b)
877 addurls(&cmd[a + 1]);
883 * If we're not connected to a Citadel server, try to hook up the
884 * connection now. Preference is given to the host and port specified
885 * by browser cookies, if cookies have been supplied.
887 if (!WC->connected) {
888 if (strlen(bstr("host")) > 0)
889 strcpy(c_host, bstr("host"));
890 if (strlen(bstr("port")) > 0)
891 strcpy(c_port, bstr("port"));
893 if (!strcasecmp(c_host, "uds")) {
894 /* unix domain socket */
895 sprintf(buf, "%s/citadel.socket", c_port);
896 WC->serv_sock = uds_connectsock(buf);
900 WC->serv_sock = tcp_connectsock(c_host, c_port);
903 if (WC->serv_sock < 0) {
905 goto SKIP_ALL_THIS_CRAP;
909 serv_gets(buf); /* get the server welcome message */
910 locate_host(browser_host, WC->http_sock);
911 get_serv_info(browser_host, user_agent);
915 check_for_express_messages();
918 * If we're not logged in, but we have username and password cookies
919 * supplied by the browser, try using them to log in.
921 if ((!WC->logged_in) && (strlen(c_username) > 0) && (strlen(c_password) > 0)) {
922 serv_printf("USER %s", c_username);
925 serv_printf("PASS %s", c_password);
928 become_logged_in(c_username, c_password, buf);
933 * If we don't have a current room, but a cookie specifying the
934 * current room is supplied, make an effort to go there.
936 if ((strlen(WC->wc_roomname) == 0) && (strlen(c_roomname) > 0)) {
937 serv_printf("GOTO %s", c_roomname);
940 strcpy(WC->wc_roomname, c_roomname);
943 if (!strcasecmp(action, "static")) {
944 strcpy(buf, &cmd[12]);
945 for (a = 0; a < strlen(buf); ++a)
949 } else if (!strcasecmp(action, "image")) {
951 } else if ((!WC->logged_in) && (!strcasecmp(action, "login"))) {
953 } else if (!WC->logged_in) {
956 /* Various commands... */
958 else if (!strcasecmp(action, "do_welcome")) {
960 } else if (!strcasecmp(action, "blank")) {
962 } else if (!strcasecmp(action, "display_main_menu")) {
964 } else if (!strcasecmp(action, "whobbs")) {
966 } else if (!strcasecmp(action, "knrooms")) {
968 } else if (!strcasecmp(action, "gotonext")) {
971 } else if (!strcasecmp(action, "skip")) {
973 } else if (!strcasecmp(action, "ungoto")) {
975 } else if (!strcasecmp(action, "dotgoto")) {
977 smart_goto(bstr("room"));
978 } else if (!strcasecmp(action, "dotskip")) {
979 smart_goto(bstr("room"));
980 } else if (!strcasecmp(action, "termquit")) {
982 } else if (!strcasecmp(action, "readnew")) {
984 } else if (!strcasecmp(action, "readold")) {
986 } else if (!strcasecmp(action, "readfwd")) {
988 } else if (!strcasecmp(action, "headers")) {
990 } else if (!strcasecmp(action, "display_enter")) {
992 } else if (!strcasecmp(action, "post")) {
994 } else if (!strcasecmp(action, "delete_msg")) {
996 } else if (!strcasecmp(action, "confirm_move_msg")) {
998 } else if (!strcasecmp(action, "move_msg")) {
1000 } else if (!strcasecmp(action, "userlist")) {
1002 } else if (!strcasecmp(action, "showuser")) {
1004 } else if (!strcasecmp(action, "display_page")) {
1006 } else if (!strcasecmp(action, "page_user")) {
1008 } else if (!strcasecmp(action, "chat")) {
1010 } else if (!strcasecmp(action, "display_private")) {
1011 display_private("", 0);
1012 } else if (!strcasecmp(action, "goto_private")) {
1014 } else if (!strcasecmp(action, "zapped_list")) {
1016 } else if (!strcasecmp(action, "display_zap")) {
1018 } else if (!strcasecmp(action, "zap")) {
1020 } else if (!strcasecmp(action, "display_entroom")) {
1022 } else if (!strcasecmp(action, "entroom")) {
1024 } else if (!strcasecmp(action, "display_editroom")) {
1026 } else if (!strcasecmp(action, "netedit")) {
1028 } else if (!strcasecmp(action, "editroom")) {
1030 } else if (!strcasecmp(action, "display_whok")) {
1032 } else if (!strcasecmp(action, "display_editinfo")) {
1033 display_edit("Room info", "EINF 0", "RINF", "/editinfo");
1034 } else if (!strcasecmp(action, "editinfo")) {
1035 save_edit("Room info", "EINF 1", 1);
1036 } else if (!strcasecmp(action, "display_editbio")) {
1037 sprintf(buf, "RBIO %s", WC->wc_username);
1038 display_edit("Your bio", "NOOP", buf, "editbio");
1039 } else if (!strcasecmp(action, "editbio")) {
1040 save_edit("Your bio", "EBIO", 0);
1041 } else if (!strcasecmp(action, "confirm_delete_room")) {
1042 confirm_delete_room();
1043 } else if (!strcasecmp(action, "delete_room")) {
1045 } else if (!strcasecmp(action, "validate")) {
1047 } else if (!strcasecmp(action, "display_editpic")) {
1048 display_graphics_upload("your photo",
1051 } else if (!strcasecmp(action, "editpic")) {
1052 do_graphics_upload("UIMG 1|_userpic_");
1053 } else if (!strcasecmp(action, "display_editroompic")) {
1054 display_graphics_upload("the graphic for this room",
1057 } else if (!strcasecmp(action, "editroompic")) {
1058 do_graphics_upload("UIMG 1|_roompic_");
1059 } else if (!strcasecmp(action, "delete_floor")) {
1061 } else if (!strcasecmp(action, "rename_floor")) {
1063 } else if (!strcasecmp(action, "create_floor")) {
1065 } else if (!strcasecmp(action, "display_editfloorpic")) {
1066 sprintf(buf, "UIMG 0|_floorpic_|%s",
1067 bstr("which_floor"));
1068 display_graphics_upload("the graphic for this floor",
1071 } else if (!strcasecmp(action, "editfloorpic")) {
1072 sprintf(buf, "UIMG 1|_floorpic_|%s",
1073 bstr("which_floor"));
1074 do_graphics_upload(buf);
1075 } else if (!strcasecmp(action, "display_reg")) {
1077 } else if (!strcasecmp(action, "register")) {
1079 } else if (!strcasecmp(action, "display_changepw")) {
1081 } else if (!strcasecmp(action, "changepw")) {
1083 } else if (!strcasecmp(action, "display_edit_node")) {
1084 display_edit_node();
1085 } else if (!strcasecmp(action, "edit_node")) {
1087 } else if (!strcasecmp(action, "display_netconf")) {
1089 } else if (!strcasecmp(action, "display_confirm_delete_node")) {
1090 display_confirm_delete_node();
1091 } else if (!strcasecmp(action, "delete_node")) {
1093 } else if (!strcasecmp(action, "display_add_node")) {
1095 } else if (!strcasecmp(action, "add_node")) {
1097 } else if (!strcasecmp(action, "terminate_session")) {
1099 terminate_session();
1100 } else if (!strcasecmp(action, "edit_me")) {
1102 } else if (!strcasecmp(action, "display_siteconfig")) {
1103 display_siteconfig();
1104 } else if (!strcasecmp(action, "page_popup")) {
1106 } else if (!strcasecmp(action, "siteconfig")) {
1108 } else if (!strcasecmp(action, "display_generic")) {
1110 } else if (!strcasecmp(action, "do_generic")) {
1112 } else if (!strcasecmp(action, "display_menubar")) {
1114 } else if (!strcasecmp(action, "output_mimepart")) {
1116 } else if (!strcasecmp(action, "edit_vcard")) {
1118 } else if (!strcasecmp(action, "submit_vcard")) {
1120 } else if (!strcasecmp(action, "select_user_to_edit")) {
1121 select_user_to_edit(NULL, NULL);
1122 } else if (!strcasecmp(action, "display_edituser")) {
1123 display_edituser(NULL);
1124 } else if (!strcasecmp(action, "edituser")) {
1126 } else if (!strcasecmp(action, "create_user")) {
1128 } else if (!strcasecmp(action, "changeview")) {
1130 } else if (!strcasecmp(action, "folders")) {
1132 } else if (!strcasecmp(action, "do_stuff_to_msgs")) {
1134 } else if (!strcasecmp(action, "change_start_page")) {
1135 change_start_page();
1136 } else if (!strcasecmp(action, "display_floorconfig")) {
1137 display_floorconfig(NULL);
1138 } else if (!strcasecmp(action, "diagnostics")) {
1141 wprintf("You're in session %d<HR>\n", WC->wc_session);
1142 wprintf("Command: <BR><PRE>\n");
1144 wprintf("</PRE><HR>\n");
1145 wprintf("Variables: <BR><PRE>\n");
1147 wprintf("</PRE><HR>\n");
1150 /* When all else fais, display the main menu. */
1152 display_main_menu();
1157 if (content != NULL) {
1162 if (WC->upload_length > 0) {
1164 WC->upload_length = 0;