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 "&" and "?" delimiters */
98 for (a = 0; a < strlen(up); ++a) {
99 if ( (ptr[0] == '&') || (ptr[0] == '?') ) {
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 (print_standard_html_footer) {
178 do_template("trailing");
186 * Copy a string, escaping characters which have meaning in HTML. If
187 * nbsp is nonzero, spaces are converted to non-breaking spaces.
189 void stresc(char *target, char *strbuf, int nbsp)
194 for (a = 0; a < strlen(strbuf); ++a) {
195 if (strbuf[a] == '<')
196 strcat(target, "<");
197 else if (strbuf[a] == '>')
198 strcat(target, ">");
199 else if (strbuf[a] == '&')
200 strcat(target, "&");
201 else if (strbuf[a] == '\"')
202 strcat(target, """);
203 else if (strbuf[a] == '\'')
204 strcat(target, "'");
205 else if (strbuf[a] == LB)
207 else if (strbuf[a] == RB)
209 else if (strbuf[a] == QU)
210 strcat(target, "\"");
211 else if ((strbuf[a] == 32) && (nbsp == 1)) {
212 strcat(target, " ");
214 strncat(target, &strbuf[a], 1);
219 void escputs1(char *strbuf, int nbsp)
222 stresc(buf, strbuf, nbsp);
226 void escputs(char *strbuf)
232 * Escape a string for feeding out as a URL.
233 * Returns a pointer to a buffer that must be freed by the caller!
235 void urlesc(char *outbuf, char *strbuf)
238 char *ec = " #&;`'|*?-~<>^()[]{}$\\";
242 for (a = 0; a < strlen(strbuf); ++a) {
244 for (b = 0; b < strlen(ec); ++b) {
245 if (strbuf[a] == ec[b])
250 sprintf(&outbuf[b], "%%%02x", strbuf[a]);
252 sprintf(&outbuf[b], "%c", strbuf[a]);
256 void urlescputs(char *strbuf)
260 urlesc(outbuf, strbuf);
261 wprintf("%s", outbuf);
268 * Output all that important stuff that the browser will want to see
273 * 0 = Nothing. Do not display any leading HTTP or HTML.
274 * 1 = HTTP headers plus the room banner
275 * 2 = HTTP headers required to terminate the session (unset cookies)
276 * 3 = HTTP and HTML headers, but no room banner
278 * Bit 2: Set to 1 to auto-refresh page every 30 seconds
279 * Bit 3: suppress check for express messages
280 * Bit 4: Allow browser to cache this document
283 void output_headers(int controlcode)
286 int print_standard_html_head = 0;
288 int suppress_check = 0;
291 char onload_fcn[SIZ];
292 static int pageseq = 0;
293 print_standard_html_head = controlcode & 0x03;
294 refresh30 = ((controlcode & 0x04) >> 2);
295 suppress_check = ((controlcode & 0x08) >> 3);
296 cache = ((controlcode & 0x10) >> 4);
298 wprintf("HTTP/1.0 200 OK\n");
300 httpdate(httpnow, time(NULL));
302 if (print_standard_html_head > 0) {
303 wprintf("Content-type: text/html\n"
304 "Server: %s\n", SERVER
307 wprintf("Connection: close\n"
309 "Cache-Control: no-store\n"
313 stuff_to_cookie(cookie, WC->wc_session, WC->wc_username,
314 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) {
328 if (refresh30) svprintf("REFRESHTAG", WCS_STRING,
329 "<META HTTP-EQUIV=\"refresh\" CONTENT=\"30\">\n");
330 else svprintf("REFRESHTAG", WCS_STRING,
331 "<META HTTP-EQUIV=\"refresh\" CONTENT=\"500363689;\">\n");
332 /* script for checking for pages (not always launched) */
334 sprintf(onload_fcn, "function onload_fcn() { \n");
335 if (!WC->outside_frameset_allowed) {
336 strcat(onload_fcn, " force_frameset(); \n");
338 if (!suppress_check) if (WC->HaveExpressMessages) {
339 strcat(onload_fcn, " launch_page_popup(); \n");
340 WC->HaveExpressMessages = 0;
342 strcat(onload_fcn, "} \n");
344 svprintf("PAGERSCRIPT", WCS_STRING,
345 "<SCRIPT LANGUAGE=\"JavaScript\">\n"
346 "function launch_page_popup() {\n"
347 "pwin = window.open('/page_popup', 'CitaPage%d', "
348 "'toolbar=no,location=no,copyhistory=no,status=no,"
349 "scrollbars=yes,resizable=no,height=250,width=400');\n"
351 "function force_frameset() { \n"
352 " if (top.frames.length == 0) { \n"
353 " top.location.replace('/do_welcome'); \n"
365 clear_local_substs();
367 svprintf("extrabodyparms", WCS_STRING, "%s",
368 "onload='onload_fcn();' ");
370 do_template("background");
371 clear_local_substs();
374 if (print_standard_html_head == 1) {
375 wprintf("<A NAME=\"TheTop\"></A>");
376 embed_room_banner(NULL);
379 if (strlen(WC->ImportantMessage) > 0) {
380 do_template("beginbox_nt");
381 wprintf("<SPAN CLASS=\"errormsg\">"
382 "%s</SPAN><BR>\n", WC->ImportantMessage);
383 do_template("endbox");
384 strcpy(WC->ImportantMessage, "");
392 void http_redirect(char *whichpage) {
393 wprintf("HTTP/1.0 302 Moved Temporarily\n");
394 wprintf("Location: %s\n", whichpage);
395 wprintf("URI: %s\n", whichpage);
396 wprintf("Content-type: text/html\n\n");
397 wprintf("<html><body>\n");
398 wprintf("you really want to be <A HREF=\"%s\">here</A> now\n",
400 wprintf("</body></html>\n");
405 void check_for_express_messages()
411 if (buf[3] == '*') WC->HaveExpressMessages = 1;
418 * Output a piece of content to the web browser
420 void http_transmit_thing(char *thing, size_t length, char *content_type,
422 output_headers(is_static ? 0x10 : 0x00);
423 wprintf("Content-type: %s\n"
424 "Content-length: %ld\n"
426 "Connection: close\n"
432 write(WC->http_sock, thing, (size_t)length);
438 void output_static(char *what)
445 char content_type[SIZ];
447 lprintf(9, "output_static(%s)\n", what);
448 sprintf(buf, "static/%s", what);
449 fp = fopen(buf, "rb");
451 wprintf("HTTP/1.0 404 %s\n", strerror(errno));
452 wprintf("Content-Type: text/plain\n");
454 wprintf("Cannot open %s: %s\n", what, strerror(errno));
456 if (!strncasecmp(&what[strlen(what) - 4], ".gif", 4))
457 strcpy(content_type, "image/gif");
458 else if (!strncasecmp(&what[strlen(what) - 4], ".txt", 4))
459 strcpy(content_type, "text/plain");
460 else if (!strncasecmp(&what[strlen(what) - 4], ".css", 4))
461 strcpy(content_type, "text/css");
462 else if (!strncasecmp(&what[strlen(what) - 4], ".jpg", 4))
463 strcpy(content_type, "image/jpeg");
464 else if (!strncasecmp(&what[strlen(what) - 4], ".png", 4))
465 strcpy(content_type, "image/png");
466 else if (!strncasecmp(&what[strlen(what) - 5], ".html", 5))
467 strcpy(content_type, "text/html");
468 else if (!strncasecmp(&what[strlen(what) - 4], ".wml", 4))
469 strcpy(content_type, "text/vnd.wap.wml");
470 else if (!strncasecmp(&what[strlen(what) - 5], ".wmls", 5))
471 strcpy(content_type, "text/vnd.wap.wmlscript");
472 else if (!strncasecmp(&what[strlen(what) - 5], ".wmlc", 5))
473 strcpy(content_type, "application/vnd.wap.wmlc");
474 else if (!strncasecmp(&what[strlen(what) - 6], ".wmlsc", 6))
475 strcpy(content_type, "application/vnd.wap.wmlscriptc");
476 else if (!strncasecmp(&what[strlen(what) - 5], ".wbmp", 5))
477 wprintf("Content-type: image/vnd.wap.wbmp");
479 wprintf("Content-type: application/octet-stream");
481 fstat(fileno(fp), &statbuf);
482 bytes = statbuf.st_size;
483 lprintf(3, "Static: %s, %ld bytes\n", what, bytes);
484 bigbuffer = malloc(bytes);
485 fread(bigbuffer, bytes, 1, fp);
488 http_transmit_thing(bigbuffer, (size_t)bytes, content_type, 1);
491 if (!strcasecmp(bstr("force_close_session"), "yes")) {
492 end_webcit_session();
498 * When the browser requests an image file from the Citadel server,
499 * this function is called to transmit it.
504 char *xferbuf = NULL;
507 serv_printf("OIMG %s|%s", bstr("name"), bstr("parm"));
510 bytes = extract_long(&buf[4], 0);
511 xferbuf = malloc(bytes);
513 /* Read it from the server */
514 read_server_binary(xferbuf, bytes);
518 /* Write it to the browser */
519 http_transmit_thing(xferbuf, (size_t)bytes, "image/gif", 0);
524 /* Instead of an ugly 404, send a 1x1 transparent GIF
525 * when there's no such image on the server.
527 output_static("blank.gif");
530 wprintf("HTTP/1.0 404 %s\n", &buf[4]);
532 wprintf("Content-Type: text/plain\n"
534 "Error retrieving image: %s\n",
547 void output_mimepart()
551 char content_type[SIZ];
552 char *content = NULL;
554 serv_printf("OPNA %s|%s", bstr("msgnum"), bstr("partnum"));
557 bytes = extract_long(&buf[4], 0);
558 content = malloc(bytes);
559 extract(content_type, &buf[4], 3);
561 read_server_binary(content, bytes);
564 http_transmit_thing(content, bytes, content_type, 0);
567 wprintf("HTTP/1.0 404 %s\n", &buf[4]);
569 wprintf("Content-Type: text/plain\n");
571 wprintf("Error retrieving part: %s\n", &buf[4]);
579 char *load_mimepart(long msgnum, char *partnum)
583 char content_type[SIZ];
586 serv_printf("OPNA %ld|%s", msgnum, partnum);
589 bytes = extract_long(&buf[4], 0);
590 extract(content_type, &buf[4], 3);
592 content = malloc(bytes + 1);
593 read_server_binary(content, bytes);
597 content[bytes] = 0; /* null terminate for good measure */
608 * Convenience functions to display a page containing only a string
610 void convenience_page(char *titlebarcolor, char *titlebarmsg, char *messagetext)
612 wprintf("HTTP/1.0 200 OK\n");
614 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#%s\"><TR><TD>", titlebarcolor);
615 wprintf("<SPAN CLASS=\"titlebar\">%s</SPAN>\n", titlebarmsg);
616 wprintf("</TD></TR></TABLE><BR>\n");
617 escputs(messagetext);
625 * Display a blank page.
627 void blank_page(void) {
634 * A template has been requested
636 void url_do_template(void) {
637 do_template(bstr("template"));
643 * Offer to make any page the user's "start page."
645 void offer_start_page(void) {
646 wprintf("<A HREF=\"/change_start_page?startpage=");
647 urlescputs(WC->this_page);
649 "<FONT SIZE=-2 COLOR=\"#AAAAAA\">Make this my start page</FONT>"
656 * Change the user's start page
658 void change_start_page(void) {
660 if (bstr("startpage") == NULL) {
661 strcpy(WC->ImportantMessage,
662 "startpage set to null");
667 set_preference("startpage", bstr("startpage"));
670 do_template("newstartpage");
677 void display_success(char *successmessage)
679 convenience_page("007700", "OK", successmessage);
684 void extract_action(char *actbuf, char *cmdbuf)
688 strcpy(actbuf, cmdbuf);
689 if (!strncasecmp(actbuf, "GET /", 5))
690 strcpy(actbuf, &actbuf[5]);
691 if (!strncasecmp(actbuf, "PUT /", 5))
692 strcpy(actbuf, &actbuf[5]);
693 if (!strncasecmp(actbuf, "POST /", 6))
694 strcpy(actbuf, &actbuf[6]);
696 for (i = 0; i < strlen(actbuf); ++i) {
697 if (actbuf[i] == ' ') {
701 if (actbuf[i] == '/') {
705 if (actbuf[i] == '?') {
709 if (actbuf[i] == '&') {
717 void upload_handler(char *name, char *filename, char *partnum, char *disp,
718 void *content, char *cbtype, size_t length,
719 char *encoding, void *userdata)
721 struct urlcontent *u;
724 if ( (length > 0) && (strlen(cbtype) == 0) ) {
725 u = (struct urlcontent *) malloc(sizeof(struct urlcontent));
726 u->next = WC->urlstrings;
728 safestrncpy(u->url_key, name, sizeof(u->url_key));
729 u->url_data = malloc(length + 1);
730 memcpy(u->url_data, content, length);
731 u->url_data[length] = 0;
735 if ( (length > 0) && (strlen(cbtype) > 0) ) {
736 WC->upload = malloc(length);
737 if (WC->upload != NULL) {
738 WC->upload_length = length;
739 safestrncpy(WC->upload_filename, filename,
740 sizeof(WC->upload_filename));
741 safestrncpy(WC->upload_content_type, cbtype,
742 sizeof(WC->upload_content_type));
743 memcpy(WC->upload, content, length);
746 lprintf(3, "malloc() failed: %s\n", strerror(errno));
756 * Entry point for WebCit transaction
758 void session_loop(struct httprequest *req)
764 int ContentLength = 0;
766 char ContentType[512];
769 struct httprequest *hptr;
770 char browser_host[SIZ];
771 char user_agent[SIZ];
774 /* We stuff these with the values coming from the client cookies,
775 * so we can use them to reconnect a timed out session if we have to.
777 char c_username[SIZ];
778 char c_password[SIZ];
779 char c_roomname[SIZ];
782 strcpy(c_username, "");
783 strcpy(c_password, "");
784 strcpy(c_roomname, "");
786 WC->upload_length = 0;
792 if (hptr == NULL) return;
794 strcpy(cmd, hptr->line);
796 extract_action(action, cmd);
798 while (hptr != NULL) {
799 strcpy(buf, hptr->line);
802 if (!strncasecmp(buf, "Cookie: webcit=", 15)) {
803 strcpy(cookie, &buf[15]);
804 cookie_to_stuff(cookie, NULL,
805 c_username, c_password, c_roomname);
807 else if (!strncasecmp(buf, "Content-length: ", 16)) {
808 ContentLength = atoi(&buf[16]);
810 else if (!strncasecmp(buf, "Content-type: ", 14)) {
811 safestrncpy(ContentType, &buf[14], sizeof ContentType);
813 else if (!strncasecmp(buf, "User-agent: ", 12)) {
814 safestrncpy(user_agent, &buf[12], sizeof user_agent);
816 else if (!strncasecmp(buf, "Host: ", 6)) {
817 safestrncpy(WC->http_host, &buf[6], sizeof WC->http_host);
819 /* Only WAP gateways explicitly name this content-type */
820 else if (strstr(buf, "text/vnd.wap.wml")) {
825 if (ContentLength > 0) {
826 content = malloc(ContentLength + SIZ);
827 memset(content, 0, ContentLength + SIZ);
828 sprintf(content, "Content-type: %s\n"
829 "Content-length: %d\n\n",
830 ContentType, ContentLength);
831 body_start = strlen(content);
834 while (BytesRead < ContentLength) {
835 a=read(WC->http_sock, &content[BytesRead+body_start],
836 ContentLength - BytesRead);
837 if (a <= 0) BytesRead = ContentLength;
841 if (!strncasecmp(ContentType,
842 "application/x-www-form-urlencoded", 33)) {
843 addurls(&content[body_start]);
844 } else if (!strncasecmp(ContentType, "multipart", 9)) {
845 content_end = content + ContentLength + body_start;
846 mime_parser(content, content_end, *upload_handler,
847 NULL, NULL, NULL, 0);
853 /* make a note of where we are in case the user wants to save it */
854 safestrncpy(WC->this_page, cmd, sizeof(WC->this_page));
855 remove_token(WC->this_page, 2, ' ');
856 remove_token(WC->this_page, 0, ' ');
858 /* If there are variables in the URL, we must grab them now */
859 for (a = 0; a < strlen(cmd); ++a) {
860 if ((cmd[a] == '?') || (cmd[a] == '&')) {
861 for (b = a; b < strlen(cmd); ++b)
864 addurls(&cmd[a + 1]);
869 /* Static content can be sent without connecting to Citadel. */
870 if (!strcasecmp(action, "static")) {
871 strcpy(buf, &cmd[12]);
872 for (a = 0; a < strlen(buf); ++a)
876 goto SKIP_ALL_THIS_CRAP; /* Don't try to connect */
880 * If we're not connected to a Citadel server, try to hook up the
883 if (!WC->connected) {
884 if (!strcasecmp(ctdlhost, "uds")) {
885 /* unix domain socket */
886 sprintf(buf, "%s/citadel.socket", ctdlport);
887 WC->serv_sock = uds_connectsock(buf);
891 WC->serv_sock = tcp_connectsock(ctdlhost, ctdlport);
894 if (WC->serv_sock < 0) {
896 goto SKIP_ALL_THIS_CRAP;
900 serv_gets(buf); /* get the server welcome message */
901 locate_host(browser_host, WC->http_sock);
902 get_serv_info(browser_host, user_agent);
903 if (serv_info.serv_rev_level < MINIMUM_CIT_VERSION) {
904 wprintf("You are connected to a Citadel "
905 "server running Citadel %d.%02d;\nin "
906 "order to run this version of WebCit "
907 "you must also have Citadel %d.%02d or"
909 serv_info.serv_rev_level / 100,
910 serv_info.serv_rev_level % 100,
911 MINIMUM_CIT_VERSION / 100,
912 MINIMUM_CIT_VERSION % 100
914 end_webcit_session();
915 goto SKIP_ALL_THIS_CRAP;
921 * Functions which can be performed without logging in
923 if (!strcasecmp(action, "listsub")) {
925 goto SKIP_ALL_THIS_CRAP;
927 #ifdef WEBCIT_WITH_CALENDAR_SERVICE
928 if (!strcasecmp(action, "freebusy")) {
930 goto SKIP_ALL_THIS_CRAP;
934 check_for_express_messages();
937 * If we're not logged in, but we have username and password cookies
938 * supplied by the browser, try using them to log in.
940 if ((!WC->logged_in) && (strlen(c_username) > 0) && (strlen(c_password) > 0)) {
941 serv_printf("USER %s", c_username);
944 serv_printf("PASS %s", c_password);
947 become_logged_in(c_username, c_password, buf);
952 * If we don't have a current room, but a cookie specifying the
953 * current room is supplied, make an effort to go there.
955 if ((strlen(WC->wc_roomname) == 0) && (strlen(c_roomname) > 0)) {
956 serv_printf("GOTO %s", c_roomname);
959 strcpy(WC->wc_roomname, c_roomname);
963 if (!strcasecmp(action, "image")) {
967 * All functions handled below this point ... make sure we log in
968 * before doing anything else!
970 } else if ((!WC->logged_in) && (!strcasecmp(action, "login"))) {
972 } else if (!WC->logged_in) {
977 * Various commands...
980 else if (!strcasecmp(action, "do_welcome")) {
982 } else if (!strcasecmp(action, "blank")) {
984 } else if (!strcasecmp(action, "do_template")) {
986 } else if (!strcasecmp(action, "display_main_menu")) {
988 } else if (!strcasecmp(action, "whobbs")) {
990 } else if (!strcasecmp(action, "knrooms")) {
992 } else if (!strcasecmp(action, "gotonext")) {
995 } else if (!strcasecmp(action, "skip")) {
997 } else if (!strcasecmp(action, "ungoto")) {
999 } else if (!strcasecmp(action, "dotgoto")) {
1001 smart_goto(bstr("room"));
1002 } else if (!strcasecmp(action, "dotskip")) {
1003 smart_goto(bstr("room"));
1004 } else if (!strcasecmp(action, "termquit")) {
1006 } else if (!strcasecmp(action, "readnew")) {
1007 readloop("readnew");
1008 } else if (!strcasecmp(action, "readold")) {
1009 readloop("readold");
1010 } else if (!strcasecmp(action, "readfwd")) {
1011 readloop("readfwd");
1012 } else if (!strcasecmp(action, "headers")) {
1013 readloop("headers");
1014 } else if (!strcasecmp(action, "display_enter")) {
1016 } else if (!strcasecmp(action, "post")) {
1018 } else if (!strcasecmp(action, "delete_msg")) {
1020 } else if (!strcasecmp(action, "confirm_move_msg")) {
1022 } else if (!strcasecmp(action, "move_msg")) {
1024 } else if (!strcasecmp(action, "userlist")) {
1026 } else if (!strcasecmp(action, "showuser")) {
1028 } else if (!strcasecmp(action, "display_page")) {
1030 } else if (!strcasecmp(action, "page_user")) {
1032 } else if (!strcasecmp(action, "chat")) {
1034 } else if (!strcasecmp(action, "display_private")) {
1035 display_private("", 0);
1036 } else if (!strcasecmp(action, "goto_private")) {
1038 } else if (!strcasecmp(action, "zapped_list")) {
1040 } else if (!strcasecmp(action, "display_zap")) {
1042 } else if (!strcasecmp(action, "zap")) {
1044 } else if (!strcasecmp(action, "display_entroom")) {
1046 } else if (!strcasecmp(action, "entroom")) {
1048 } else if (!strcasecmp(action, "display_editroom")) {
1050 } else if (!strcasecmp(action, "netedit")) {
1052 } else if (!strcasecmp(action, "editroom")) {
1054 } else if (!strcasecmp(action, "display_whok")) {
1056 } else if (!strcasecmp(action, "display_editinfo")) {
1057 display_edit("Room info", "EINF 0", "RINF", "/editinfo", 1);
1058 } else if (!strcasecmp(action, "editinfo")) {
1059 save_edit("Room info", "EINF 1", 1);
1060 } else if (!strcasecmp(action, "display_editbio")) {
1061 sprintf(buf, "RBIO %s", WC->wc_username);
1062 display_edit("Your bio", "NOOP", buf, "editbio", 3);
1063 } else if (!strcasecmp(action, "editbio")) {
1064 save_edit("Your bio", "EBIO", 0);
1065 } else if (!strcasecmp(action, "confirm_delete_room")) {
1066 confirm_delete_room();
1067 } else if (!strcasecmp(action, "delete_room")) {
1069 } else if (!strcasecmp(action, "validate")) {
1071 } else if (!strcasecmp(action, "display_editpic")) {
1072 display_graphics_upload("your photo",
1075 } else if (!strcasecmp(action, "editpic")) {
1076 do_graphics_upload("UIMG 1|_userpic_");
1077 } else if (!strcasecmp(action, "display_editroompic")) {
1078 display_graphics_upload("the graphic for this room",
1081 } else if (!strcasecmp(action, "editroompic")) {
1082 do_graphics_upload("UIMG 1|_roompic_");
1083 } else if (!strcasecmp(action, "delete_floor")) {
1085 } else if (!strcasecmp(action, "rename_floor")) {
1087 } else if (!strcasecmp(action, "create_floor")) {
1089 } else if (!strcasecmp(action, "display_editfloorpic")) {
1090 sprintf(buf, "UIMG 0|_floorpic_|%s",
1091 bstr("which_floor"));
1092 display_graphics_upload("the graphic for this floor",
1095 } else if (!strcasecmp(action, "editfloorpic")) {
1096 sprintf(buf, "UIMG 1|_floorpic_|%s",
1097 bstr("which_floor"));
1098 do_graphics_upload(buf);
1099 } else if (!strcasecmp(action, "display_reg")) {
1101 } else if (!strcasecmp(action, "display_changepw")) {
1103 } else if (!strcasecmp(action, "changepw")) {
1105 } else if (!strcasecmp(action, "display_edit_node")) {
1106 display_edit_node();
1107 } else if (!strcasecmp(action, "edit_node")) {
1109 } else if (!strcasecmp(action, "display_netconf")) {
1111 } else if (!strcasecmp(action, "display_confirm_delete_node")) {
1112 display_confirm_delete_node();
1113 } else if (!strcasecmp(action, "delete_node")) {
1115 } else if (!strcasecmp(action, "display_add_node")) {
1117 } else if (!strcasecmp(action, "add_node")) {
1119 } else if (!strcasecmp(action, "terminate_session")) {
1121 terminate_session();
1122 } else if (!strcasecmp(action, "edit_me")) {
1124 } else if (!strcasecmp(action, "display_siteconfig")) {
1125 display_siteconfig();
1126 } else if (!strcasecmp(action, "page_popup")) {
1128 } else if (!strcasecmp(action, "siteconfig")) {
1130 } else if (!strcasecmp(action, "display_generic")) {
1132 } else if (!strcasecmp(action, "do_generic")) {
1134 } else if (!strcasecmp(action, "display_menubar")) {
1136 } else if (!strcasecmp(action, "output_mimepart")) {
1138 } else if (!strcasecmp(action, "edit_vcard")) {
1140 } else if (!strcasecmp(action, "submit_vcard")) {
1142 } else if (!strcasecmp(action, "select_user_to_edit")) {
1143 select_user_to_edit(NULL, NULL);
1144 } else if (!strcasecmp(action, "display_edituser")) {
1145 display_edituser(NULL);
1146 } else if (!strcasecmp(action, "edituser")) {
1148 } else if (!strcasecmp(action, "create_user")) {
1150 } else if (!strcasecmp(action, "changeview")) {
1152 } else if (!strcasecmp(action, "do_stuff_to_msgs")) {
1154 } else if (!strcasecmp(action, "change_start_page")) {
1155 change_start_page();
1156 } else if (!strcasecmp(action, "display_floorconfig")) {
1157 display_floorconfig(NULL);
1158 } else if (!strcasecmp(action, "toggle_self_service")) {
1159 toggle_self_service();
1160 #ifdef WEBCIT_WITH_CALENDAR_SERVICE
1161 } else if (!strcasecmp(action, "display_edit_task")) {
1162 display_edit_task();
1163 } else if (!strcasecmp(action, "save_task")) {
1165 } else if (!strcasecmp(action, "display_edit_event")) {
1166 display_edit_event();
1167 } else if (!strcasecmp(action, "save_event")) {
1169 } else if (!strcasecmp(action, "respond_to_request")) {
1170 respond_to_request();
1171 } else if (!strcasecmp(action, "handle_rsvp")) {
1174 } else if (!strcasecmp(action, "summary")) {
1176 } else if (!strcasecmp(action, "iconbar")) {
1178 } else if (!strcasecmp(action, "display_customize_iconbar")) {
1179 display_customize_iconbar();
1180 } else if (!strcasecmp(action, "commit_iconbar")) {
1182 } else if (!strcasecmp(action, "diagnostics")) {
1185 wprintf("You're in session %d<HR>\n", WC->wc_session);
1186 wprintf("Command: <BR><PRE>\n");
1188 wprintf("</PRE><HR>\n");
1189 wprintf("Variables: <BR><PRE>\n");
1191 wprintf("</PRE><HR>\n");
1194 /* When all else fais, display the main menu. */
1196 display_main_menu();
1201 if (content != NULL) {
1206 if (WC->upload_length > 0) {
1208 WC->upload_length = 0;