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);
157 ssize_t http_write(int fd, void *buf, size_t count) {
160 return gzwrite(WC->gzfd, buf, count);
163 return write(fd, buf, count);
171 ssize_t http_write(int fd, const void *buf, size_t count) {
172 return write(fd, buf, count);
180 void wprintf(const char *format,...)
185 va_start(arg_ptr, format);
186 vsprintf(wbuf, format, arg_ptr);
189 http_write(WC->http_sock, wbuf, strlen(wbuf));
194 * wDumpContent() wraps up an HTTP session, closes tags, etc.
196 * print_standard_html_footer should be set to 0 to transmit only, 1 to
197 * append the main menu and closing tags, or 2 to
198 * append the closing tags only.
200 void wDumpContent(int print_standard_html_footer)
202 if (WC->fake_frames) {
203 wprintf("</TABLE>\n");
207 if (print_standard_html_footer) {
208 if (print_standard_html_footer != 2) {
211 wprintf("</BODY></HTML>\n");
219 * Copy a string, escaping characters which have meaning in HTML. If
220 * nbsp is nonzero, spaces are converted to non-breaking spaces.
222 void stresc(char *target, char *strbuf, int nbsp)
227 for (a = 0; a < strlen(strbuf); ++a) {
228 if (strbuf[a] == '<')
229 strcat(target, "<");
230 else if (strbuf[a] == '>')
231 strcat(target, ">");
232 else if (strbuf[a] == '&')
233 strcat(target, "&");
234 else if (strbuf[a] == '\"')
235 strcat(target, """);
236 else if (strbuf[a] == '\'')
237 strcat(target, "'");
238 else if (strbuf[a] == LB)
240 else if (strbuf[a] == RB)
242 else if (strbuf[a] == QU)
243 strcat(target, "\"");
244 else if ((strbuf[a] == 32) && (nbsp == 1)) {
245 strcat(target, " ");
247 strncat(target, &strbuf[a], 1);
252 void escputs1(char *strbuf, int nbsp)
255 stresc(buf, strbuf, nbsp);
259 void escputs(char *strbuf)
265 * Escape a string for feeding out as a URL.
266 * Returns a pointer to a buffer that must be freed by the caller!
268 void urlesc(char *outbuf, char *strbuf)
271 char *ec = " #&;`'|*?-~<>^()[]{}$\\";
275 for (a = 0; a < strlen(strbuf); ++a) {
277 for (b = 0; b < strlen(ec); ++b) {
278 if (strbuf[a] == ec[b])
283 sprintf(&outbuf[b], "%%%02x", strbuf[a]);
285 sprintf(&outbuf[b], "%c", strbuf[a]);
289 void urlescputs(char *strbuf)
293 urlesc(outbuf, strbuf);
294 wprintf("%s", outbuf);
301 * Output all that important stuff that the browser will want to see
306 * 0 = Nothing. Do not display any leading HTTP or HTML.
307 * 1 = HTTP headers plus the room banner
308 * 2 = HTTP headers required to terminate the session (unset cookies)
309 * 3 = HTTP and HTML headers, but no room banner
311 * Bit 2: Set to 1 to auto-refresh page every 30 seconds
313 * Bit 3: suppress check for express messages
315 void output_headers(int controlcode)
318 int print_standard_html_head = 0;
320 int suppress_check = 0;
322 static int pageseq = 0;
324 gzFile temp_gzfd = NULL;
327 print_standard_html_head = controlcode & 0x03;
328 refresh30 = ((controlcode & 0x04) >> 2);
329 suppress_check = ((controlcode & 0x08) >> 3);
331 wprintf("HTTP/1.0 200 OK\n");
333 httpdate(httpnow, time(NULL));
336 if (WC->gzcompressed) {
337 temp_gzfd = gzdopen(WC->http_sock, "wb9");
341 if (print_standard_html_head > 0) {
342 wprintf("Content-type: text/html\n"
343 "Server: %s\n", SERVER
345 wprintf("Connection: close\n"
347 "Cache-Control: no-store\n"
350 if (temp_gzfd != NULL) {
351 wprintf("Content-Encoding: gzip\n");
355 stuff_to_cookie(cookie, WC->wc_session, WC->wc_username,
356 WC->wc_password, WC->wc_roomname);
357 if (print_standard_html_head == 2) {
358 wprintf("Set-cookie: webcit=%s\n", unset);
360 wprintf("Set-cookie: webcit=%s\n", cookie);
361 if (server_cookie != NULL) {
362 wprintf("%s\n", server_cookie);
366 if (print_standard_html_head > 0) {
370 if (temp_gzfd != NULL) {
371 WC->gzfd = temp_gzfd;
375 wprintf("<HTML><HEAD><TITLE>");
376 escputs(serv_info.serv_humannode);
378 "<META HTTP-EQUIV=\"Pragma\" CONTENT=\"no-cache\">\n"
379 "<META HTTP-EQUIV=\"expired\" CONTENT=\"28-May-1971 18:10:00 GMT\">\n"
380 "<META NAME=\"MSSmartTagsPreventParsing\" CONTENT=\"TRUE\">\n");
381 if (refresh30) wprintf(
382 "<META HTTP-EQUIV=\"refresh\" CONTENT=\"30\">\n");
384 "<META HTTP-EQUIV=\"refresh\" CONTENT=\"500363689;\">\n");
385 wprintf("</HEAD>\n");
387 /* script for checking for pages (not always launched) */
388 wprintf("<SCRIPT LANGUAGE=\"JavaScript\">\n");
389 wprintf("function launch_page_popup() {\n");
390 wprintf("pwin = window.open('/page_popup', 'CitaPage%d', "
391 "'toolbar=no,location=no,copyhistory=no,status=no,"
392 "scrollbars=yes,resizable=no,height=250,width=400');\n",
395 wprintf("</SCRIPT>\n");
398 /* (JavaScript keyboard-based navigation would go here) */
400 if (!suppress_check) if (WC->HaveExpressMessages) {
401 svprintf("extrabodyparms", WCS_STRING, "%s",
402 "onload=\"launch_page_popup()\" ");
403 WC->HaveExpressMessages = 0;
405 do_template("background");
406 clear_local_substs();
408 if (print_standard_html_head == 1) {
409 wprintf("<A NAME=\"TheTop\"></A>");
411 wprintf("<TABLE border=0 width=100%%><TR VALIGN=TOP>"
414 embed_room_banner(NULL);
416 wprintf("</TD></TR><TR VALIGN=TOP><TD>\n");
427 void http_redirect(char *whichpage) {
428 wprintf("HTTP/1.0 302 Moved Temporarily\n");
429 wprintf("Location: %s\n", whichpage);
430 wprintf("URI: %s\n", whichpage);
431 wprintf("Content-type: text/html\n\n");
432 wprintf("<html><body>\n");
433 wprintf("you really want to be <A HREF=\"%s\">here</A> now\n",
435 wprintf("</body></html>\n");
440 void check_for_express_messages()
446 if (buf[3] == '*') WC->HaveExpressMessages = 1;
453 * Output a piece of content to the web browser
455 void http_transmit_thing(char *thing, size_t length, char *content_type) {
457 wprintf("Content-type: %s\n"
458 "Content-length: %ld\n"
460 "Connection: close\n"
466 http_write(WC->http_sock, thing, (size_t)length);
472 void output_static(char *what)
479 char content_type[SIZ];
481 sprintf(buf, "static/%s", what);
482 fp = fopen(buf, "rb");
484 wprintf("HTTP/1.0 404 %s\n", strerror(errno));
485 wprintf("Content-Type: text/plain\n");
487 wprintf("Cannot open %s: %s\n", what, strerror(errno));
489 if (!strncasecmp(&what[strlen(what) - 4], ".gif", 4))
490 strcpy(content_type, "image/gif");
491 else if (!strncasecmp(&what[strlen(what) - 4], ".txt", 4))
492 strcpy(content_type, "text/plain");
493 else if (!strncasecmp(&what[strlen(what) - 4], ".css", 4))
494 strcpy(content_type, "text/css");
495 else if (!strncasecmp(&what[strlen(what) - 4], ".jpg", 4))
496 strcpy(content_type, "image/jpeg");
497 else if (!strncasecmp(&what[strlen(what) - 4], ".png", 4))
498 strcpy(content_type, "image/png");
499 else if (!strncasecmp(&what[strlen(what) - 5], ".html", 5))
500 strcpy(content_type, "text/html");
501 else if (!strncasecmp(&what[strlen(what) - 4], ".wml", 4))
502 strcpy(content_type, "text/vnd.wap.wml");
503 else if (!strncasecmp(&what[strlen(what) - 5], ".wmls", 5))
504 strcpy(content_type, "text/vnd.wap.wmlscript");
505 else if (!strncasecmp(&what[strlen(what) - 5], ".wmlc", 5))
506 strcpy(content_type, "application/vnd.wap.wmlc");
507 else if (!strncasecmp(&what[strlen(what) - 6], ".wmlsc", 6))
508 strcpy(content_type, "application/vnd.wap.wmlscriptc");
509 else if (!strncasecmp(&what[strlen(what) - 5], ".wbmp", 5))
510 wprintf("Content-type: image/vnd.wap.wbmp");
512 wprintf("Content-type: application/octet-stream");
514 fstat(fileno(fp), &statbuf);
515 bytes = statbuf.st_size;
516 lprintf(3, "Static: %s, %ld bytes\n", what, bytes);
517 bigbuffer = malloc(bytes);
518 fread(bigbuffer, bytes, 1, fp);
521 http_transmit_thing(bigbuffer, (size_t)bytes, content_type);
524 if (!strcasecmp(bstr("force_close_session"), "yes")) {
525 end_webcit_session();
531 * When the browser requests an image file from the Citadel server,
532 * this function is called to transmit it.
537 char *xferbuf = NULL;
540 off_t accomplished = 0L;
542 serv_printf("OIMG %s|%s", bstr("name"), bstr("parm"));
545 bytes = extract_long(&buf[4], 0);
546 xferbuf = malloc(bytes);
548 /* Read it from the server */
549 while (bytes > (off_t) 0) {
551 if (thisblock > bytes) {
554 serv_printf("READ %ld|%ld", accomplished, thisblock);
557 thisblock = extract_long(&buf[4], 0);
558 serv_read(&xferbuf[accomplished],
562 memset(&xferbuf[accomplished], 0, thisblock);
564 bytes = bytes - thisblock;
565 accomplished += thisblock;
570 /* Write it to the browser */
571 http_transmit_thing(xferbuf, (size_t)accomplished,
575 wprintf("HTTP/1.0 404 %s\n", &buf[4]);
577 wprintf("Content-Type: text/plain\n"
579 "Error retrieving image: %s\n",
593 void output_mimepart()
599 off_t accomplished = 0L;
600 char content_type[SIZ];
602 serv_printf("OPNA %s|%s", bstr("msgnum"), bstr("partnum"));
605 bytes = extract_long(&buf[4], 0);
606 extract(content_type, &buf[4], 3);
608 wprintf("Content-type: %s\n", content_type);
609 wprintf("Content-length: %ld\n", (long) bytes);
612 while (bytes > (off_t) 0) {
613 thisblock = (off_t) sizeof(xferbuf);
614 if (thisblock > bytes) {
617 serv_printf("READ %ld|%ld", accomplished, thisblock);
620 thisblock = extract_long(&buf[4], 0);
621 serv_read(xferbuf, (int) thisblock);
624 memset(xferbuf, 0, thisblock);
626 http_write(WC->http_sock, xferbuf, thisblock);
627 bytes = bytes - thisblock;
628 accomplished = accomplished + thisblock;
633 wprintf("HTTP/1.0 404 %s\n", &buf[4]);
635 wprintf("Content-Type: text/plain\n");
637 wprintf("Error retrieving part: %s\n", &buf[4]);
645 char *load_mimepart(long msgnum, char *partnum)
650 off_t accomplished = 0L;
651 char content_type[SIZ];
654 serv_printf("OPNA %ld|%s", msgnum, partnum);
657 bytes = extract_long(&buf[4], 0);
658 extract(content_type, &buf[4], 3);
660 content = malloc(bytes + 1);
662 while (bytes > (off_t) 0) {
664 if (thisblock > 4096L) {
667 if (thisblock > bytes) {
670 serv_printf("READ %ld|%ld", accomplished, thisblock);
673 thisblock = extract_long(&buf[4], 0);
674 serv_read(&content[accomplished], (int) thisblock);
677 memset(&content[accomplished], 0, thisblock);
679 bytes = bytes - thisblock;
680 accomplished = accomplished + thisblock;
684 content[accomplished] = 0; /* null terminate for good measure */
695 * Convenience functions to display a page containing only a string
697 void convenience_page(char *titlebarcolor, char *titlebarmsg, char *messagetext)
699 wprintf("HTTP/1.0 200 OK\n");
701 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=%s><TR><TD>", titlebarcolor);
702 wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
703 wprintf("<B>%s</B>\n", titlebarmsg);
704 wprintf("</FONT></TD></TR></TABLE><BR>\n");
705 escputs(messagetext);
713 * Display a blank page.
715 void blank_page(void) {
724 * Offer to make any page the user's "start page."
726 void offer_start_page(void) {
727 wprintf("<A HREF=\"/change_start_page?startpage=");
728 urlescputs(WC->this_page);
730 "<FONT SIZE=-2 COLOR=#AAAAAA>Make this my start page</FONT>"
737 * Change the user's start page
739 void change_start_page(void) {
741 if (bstr("startpage") == NULL) {
742 display_error("startpage set to null");
746 set_preference("startpage", bstr("startpage"));
749 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=000077><TR><TD>");
750 wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
751 wprintf("<B>New start page</B>\n");
752 wprintf("</FONT></TD></TR></TABLE>\n");
755 "<font size=+2>Your start page has been changed.</font>"
757 "<I>(Note: this does not change your browser's home page. "
758 "It changes the page you begin on when you log on to ");
759 escputs(serv_info.serv_humannode);
760 wprintf(".)</I><BR><BR>"
761 "<a href = \"javascript:history.back()\">Back...</a>"
770 void display_error(char *errormessage)
772 convenience_page("770000", "Error", errormessage);
775 void display_success(char *successmessage)
777 convenience_page("007700", "OK", successmessage);
782 void extract_action(char *actbuf, char *cmdbuf)
786 strcpy(actbuf, cmdbuf);
787 if (!strncasecmp(actbuf, "GET /", 5))
788 strcpy(actbuf, &actbuf[5]);
789 if (!strncasecmp(actbuf, "PUT /", 5))
790 strcpy(actbuf, &actbuf[5]);
791 if (!strncasecmp(actbuf, "POST /", 6))
792 strcpy(actbuf, &actbuf[6]);
794 for (i = 0; i < strlen(actbuf); ++i) {
795 if (actbuf[i] == ' ') {
799 if (actbuf[i] == '/') {
803 if (actbuf[i] == '?') {
807 if (actbuf[i] == '&') {
815 void upload_handler(char *name, char *filename, char *partnum, char *disp,
816 void *content, char *cbtype, size_t length,
817 char *encoding, void *userdata)
820 lprintf(5, "UPLOAD HANDLER CALLED\n");
821 lprintf(5, " name = %s\n", name);
822 lprintf(5, "filename = %s\n", filename);
823 lprintf(5, "encoding = %s\n", encoding);
824 lprintf(5, " type = %s\n", cbtype);
825 lprintf(5, " length = %ld\n", (long)length);
828 WC->upload = malloc(length);
829 if (WC->upload != NULL) {
830 WC->upload_length = length;
831 memcpy(WC->upload, content, length);
834 lprintf(9, "malloc() failed: %s\n",
844 * Entry point for WebCit transaction
846 void session_loop(struct httprequest *req, int gzip)
852 int ContentLength = 0;
854 char ContentType[512];
857 struct httprequest *hptr;
858 char browser_host[SIZ];
859 char user_agent[SIZ];
861 /* We stuff these with the values coming from the client cookies,
862 * so we can use them to reconnect a timed out session if we have to.
866 char c_username[SIZ];
867 char c_password[SIZ];
868 char c_roomname[SIZ];
871 strcpy(c_host, defaulthost);
872 strcpy(c_port, defaultport);
873 strcpy(c_username, "");
874 strcpy(c_password, "");
875 strcpy(c_roomname, "");
877 WC->upload_length = 0;
884 WC->gzcompressed = 1;
887 WC->gzcompressed = 0;
892 if (hptr == NULL) return;
894 strcpy(cmd, hptr->line);
896 extract_action(action, cmd);
898 while (hptr != NULL) {
899 strcpy(buf, hptr->line);
902 if (!strncasecmp(buf, "Cookie: webcit=", 15)) {
903 strcpy(cookie, &buf[15]);
904 cookie_to_stuff(cookie, NULL,
905 c_username, c_password, c_roomname);
907 else if (!strncasecmp(buf, "Content-length: ", 16)) {
908 ContentLength = atoi(&buf[16]);
910 else if (!strncasecmp(buf, "Content-type: ", 14)) {
911 safestrncpy(ContentType, &buf[14], sizeof ContentType);
913 else if (!strncasecmp(buf, "User-agent: ", 12)) {
914 safestrncpy(user_agent, &buf[12], sizeof user_agent);
916 else if (!strncasecmp(buf, "Host: ", 6)) {
917 safestrncpy(WC->http_host, &buf[6], sizeof WC->http_host);
919 /* Only WAP gateways explicitly name this content-type */
920 else if (strstr(buf, "text/vnd.wap.wml")) {
925 if (ContentLength > 0) {
926 lprintf(5, "Content length: %d\n", ContentLength);
927 content = malloc(ContentLength + 1);
928 memset(content, 0, ContentLength+1);
931 while (BytesRead < ContentLength) {
932 a=read(WC->http_sock, &content[BytesRead],
933 ContentLength - BytesRead);
934 if (a <= 0) BytesRead = ContentLength;
938 if (!strncasecmp(ContentType,
939 "application/x-www-form-urlencoded", 33)) {
941 } else if (!strncasecmp(ContentType, "multipart", 9)) {
942 content_end = content + ContentLength;
943 mime_parser(content, content_end, *upload_handler,
944 NULL, NULL, NULL, 0);
950 /* make a note of where we are in case the user wants to save it */
951 safestrncpy(WC->this_page, cmd, sizeof(WC->this_page));
952 remove_token(WC->this_page, 2, ' ');
953 remove_token(WC->this_page, 0, ' ');
955 /* If there are variables in the URL, we must grab them now */
956 for (a = 0; a < strlen(cmd); ++a) {
957 if ((cmd[a] == '?') || (cmd[a] == '&')) {
958 for (b = a; b < strlen(cmd); ++b)
961 addurls(&cmd[a + 1]);
967 * If we're not connected to a Citadel server, try to hook up the
968 * connection now. Preference is given to the host and port specified
969 * by browser cookies, if cookies have been supplied.
971 if (!WC->connected) {
972 if (strlen(bstr("host")) > 0)
973 strcpy(c_host, bstr("host"));
974 if (strlen(bstr("port")) > 0)
975 strcpy(c_port, bstr("port"));
977 if (!strcasecmp(c_host, "uds")) {
978 /* unix domain socket */
979 sprintf(buf, "%s/citadel.socket", c_port);
980 WC->serv_sock = uds_connectsock(buf);
984 WC->serv_sock = tcp_connectsock(c_host, c_port);
987 if (WC->serv_sock < 0) {
989 goto SKIP_ALL_THIS_CRAP;
993 serv_gets(buf); /* get the server welcome message */
994 locate_host(browser_host, WC->http_sock);
995 get_serv_info(browser_host, user_agent);
1000 * Functions which can be performed without logging in
1002 if (!strcasecmp(action, "listsub")) {
1004 goto SKIP_ALL_THIS_CRAP;
1007 check_for_express_messages();
1010 * If we're not logged in, but we have username and password cookies
1011 * supplied by the browser, try using them to log in.
1013 if ((!WC->logged_in) && (strlen(c_username) > 0) && (strlen(c_password) > 0)) {
1014 serv_printf("USER %s", c_username);
1016 if (buf[0] == '3') {
1017 serv_printf("PASS %s", c_password);
1019 if (buf[0] == '2') {
1020 become_logged_in(c_username, c_password, buf);
1025 * If we don't have a current room, but a cookie specifying the
1026 * current room is supplied, make an effort to go there.
1028 if ((strlen(WC->wc_roomname) == 0) && (strlen(c_roomname) > 0)) {
1029 serv_printf("GOTO %s", c_roomname);
1031 if (buf[0] == '2') {
1032 strcpy(WC->wc_roomname, c_roomname);
1035 if (!strcasecmp(action, "static")) {
1036 strcpy(buf, &cmd[12]);
1037 for (a = 0; a < strlen(buf); ++a)
1038 if (isspace(buf[a]))
1041 } else if (!strcasecmp(action, "image")) {
1045 * All functions handled below this point ... make sure we log in
1046 * before doing anything else!
1048 } else if ((!WC->logged_in) && (!strcasecmp(action, "login"))) {
1050 } else if (!WC->logged_in) {
1051 display_login(NULL);
1055 * Various commands...
1058 else if (!strcasecmp(action, "do_welcome")) {
1060 } else if (!strcasecmp(action, "blank")) {
1062 } else if (!strcasecmp(action, "display_main_menu")) {
1063 display_main_menu();
1064 } else if (!strcasecmp(action, "whobbs")) {
1066 } else if (!strcasecmp(action, "knrooms")) {
1068 } else if (!strcasecmp(action, "gotonext")) {
1071 } else if (!strcasecmp(action, "skip")) {
1073 } else if (!strcasecmp(action, "ungoto")) {
1075 } else if (!strcasecmp(action, "dotgoto")) {
1077 smart_goto(bstr("room"));
1078 } else if (!strcasecmp(action, "dotskip")) {
1079 smart_goto(bstr("room"));
1080 } else if (!strcasecmp(action, "termquit")) {
1082 } else if (!strcasecmp(action, "readnew")) {
1083 readloop("readnew");
1084 } else if (!strcasecmp(action, "readold")) {
1085 readloop("readold");
1086 } else if (!strcasecmp(action, "readfwd")) {
1087 readloop("readfwd");
1088 } else if (!strcasecmp(action, "headers")) {
1089 readloop("headers");
1090 } else if (!strcasecmp(action, "display_enter")) {
1092 } else if (!strcasecmp(action, "post")) {
1094 } else if (!strcasecmp(action, "delete_msg")) {
1096 } else if (!strcasecmp(action, "confirm_move_msg")) {
1098 } else if (!strcasecmp(action, "move_msg")) {
1100 } else if (!strcasecmp(action, "userlist")) {
1102 } else if (!strcasecmp(action, "showuser")) {
1104 } else if (!strcasecmp(action, "display_page")) {
1106 } else if (!strcasecmp(action, "page_user")) {
1108 } else if (!strcasecmp(action, "chat")) {
1110 } else if (!strcasecmp(action, "display_private")) {
1111 display_private("", 0);
1112 } else if (!strcasecmp(action, "goto_private")) {
1114 } else if (!strcasecmp(action, "zapped_list")) {
1116 } else if (!strcasecmp(action, "display_zap")) {
1118 } else if (!strcasecmp(action, "zap")) {
1120 } else if (!strcasecmp(action, "display_entroom")) {
1122 } else if (!strcasecmp(action, "entroom")) {
1124 } else if (!strcasecmp(action, "display_editroom")) {
1126 } else if (!strcasecmp(action, "netedit")) {
1128 } else if (!strcasecmp(action, "editroom")) {
1130 } else if (!strcasecmp(action, "display_whok")) {
1132 } else if (!strcasecmp(action, "display_editinfo")) {
1133 display_edit("Room info", "EINF 0", "RINF", "/editinfo");
1134 } else if (!strcasecmp(action, "editinfo")) {
1135 save_edit("Room info", "EINF 1", 1);
1136 } else if (!strcasecmp(action, "display_editbio")) {
1137 sprintf(buf, "RBIO %s", WC->wc_username);
1138 display_edit("Your bio", "NOOP", buf, "editbio");
1139 } else if (!strcasecmp(action, "editbio")) {
1140 save_edit("Your bio", "EBIO", 0);
1141 } else if (!strcasecmp(action, "confirm_delete_room")) {
1142 confirm_delete_room();
1143 } else if (!strcasecmp(action, "delete_room")) {
1145 } else if (!strcasecmp(action, "validate")) {
1147 } else if (!strcasecmp(action, "display_editpic")) {
1148 display_graphics_upload("your photo",
1151 } else if (!strcasecmp(action, "editpic")) {
1152 do_graphics_upload("UIMG 1|_userpic_");
1153 } else if (!strcasecmp(action, "display_editroompic")) {
1154 display_graphics_upload("the graphic for this room",
1157 } else if (!strcasecmp(action, "editroompic")) {
1158 do_graphics_upload("UIMG 1|_roompic_");
1159 } else if (!strcasecmp(action, "delete_floor")) {
1161 } else if (!strcasecmp(action, "rename_floor")) {
1163 } else if (!strcasecmp(action, "create_floor")) {
1165 } else if (!strcasecmp(action, "display_editfloorpic")) {
1166 sprintf(buf, "UIMG 0|_floorpic_|%s",
1167 bstr("which_floor"));
1168 display_graphics_upload("the graphic for this floor",
1171 } else if (!strcasecmp(action, "editfloorpic")) {
1172 sprintf(buf, "UIMG 1|_floorpic_|%s",
1173 bstr("which_floor"));
1174 do_graphics_upload(buf);
1175 } else if (!strcasecmp(action, "display_reg")) {
1177 } else if (!strcasecmp(action, "register")) {
1179 } else if (!strcasecmp(action, "display_changepw")) {
1181 } else if (!strcasecmp(action, "changepw")) {
1183 } else if (!strcasecmp(action, "display_edit_node")) {
1184 display_edit_node();
1185 } else if (!strcasecmp(action, "edit_node")) {
1187 } else if (!strcasecmp(action, "display_netconf")) {
1189 } else if (!strcasecmp(action, "display_confirm_delete_node")) {
1190 display_confirm_delete_node();
1191 } else if (!strcasecmp(action, "delete_node")) {
1193 } else if (!strcasecmp(action, "display_add_node")) {
1195 } else if (!strcasecmp(action, "add_node")) {
1197 } else if (!strcasecmp(action, "terminate_session")) {
1199 terminate_session();
1200 } else if (!strcasecmp(action, "edit_me")) {
1202 } else if (!strcasecmp(action, "display_siteconfig")) {
1203 display_siteconfig();
1204 } else if (!strcasecmp(action, "page_popup")) {
1206 } else if (!strcasecmp(action, "siteconfig")) {
1208 } else if (!strcasecmp(action, "display_generic")) {
1210 } else if (!strcasecmp(action, "do_generic")) {
1212 } else if (!strcasecmp(action, "display_menubar")) {
1214 } else if (!strcasecmp(action, "output_mimepart")) {
1216 } else if (!strcasecmp(action, "edit_vcard")) {
1218 } else if (!strcasecmp(action, "submit_vcard")) {
1220 } else if (!strcasecmp(action, "select_user_to_edit")) {
1221 select_user_to_edit(NULL, NULL);
1222 } else if (!strcasecmp(action, "display_edituser")) {
1223 display_edituser(NULL);
1224 } else if (!strcasecmp(action, "edituser")) {
1226 } else if (!strcasecmp(action, "create_user")) {
1228 } else if (!strcasecmp(action, "changeview")) {
1230 } else if (!strcasecmp(action, "folders")) {
1232 } else if (!strcasecmp(action, "do_stuff_to_msgs")) {
1234 } else if (!strcasecmp(action, "change_start_page")) {
1235 change_start_page();
1236 } else if (!strcasecmp(action, "display_floorconfig")) {
1237 display_floorconfig(NULL);
1238 } else if (!strcasecmp(action, "toggle_self_service")) {
1239 toggle_self_service();
1241 } else if (!strcasecmp(action, "display_edit_task")) {
1242 display_edit_task();
1243 } else if (!strcasecmp(action, "save_task")) {
1246 } else if (!strcasecmp(action, "summary")) {
1248 } else if (!strcasecmp(action, "diagnostics")) {
1251 wprintf("You're in session %d<HR>\n", WC->wc_session);
1252 wprintf("Command: <BR><PRE>\n");
1254 wprintf("</PRE><HR>\n");
1255 wprintf("Variables: <BR><PRE>\n");
1257 wprintf("</PRE><HR>\n");
1260 /* When all else fais, display the main menu. */
1262 display_main_menu();
1267 if (content != NULL) {
1272 if (WC->upload_length > 0) {
1274 WC->upload_length = 0;
1281 WC->gzcompressed = 0;