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 static int pageseq = 0;
292 print_standard_html_head = controlcode & 0x03;
293 refresh30 = ((controlcode & 0x04) >> 2);
294 suppress_check = ((controlcode & 0x08) >> 3);
295 cache = ((controlcode & 0x10) >> 4);
297 wprintf("HTTP/1.0 200 OK\n");
299 httpdate(httpnow, time(NULL));
301 if (print_standard_html_head > 0) {
302 wprintf("Content-type: text/html\n"
303 "Server: %s\n", SERVER
306 wprintf("Connection: close\n"
308 "Cache-Control: no-store\n"
312 stuff_to_cookie(cookie, WC->wc_session, WC->wc_username,
313 WC->wc_password, WC->wc_roomname);
315 if (print_standard_html_head == 2) {
316 wprintf("Set-cookie: webcit=%s\n", unset);
318 wprintf("Set-cookie: webcit=%s\n", cookie);
319 if (server_cookie != NULL) {
320 wprintf("%s\n", server_cookie);
324 if (print_standard_html_head > 0) {
327 if (refresh30) svprintf("REFRESHTAG", WCS_STRING,
328 "<META HTTP-EQUIV=\"refresh\" CONTENT=\"30\">\n");
329 else svprintf("REFRESHTAG", WCS_STRING,
330 "<META HTTP-EQUIV=\"refresh\" CONTENT=\"500363689;\">\n");
331 /* script for checking for pages (not always launched) */
332 svprintf("PAGERSCRIPT", WCS_STRING,
333 "<SCRIPT LANGUAGE=\"JavaScript\">\n"
334 "function launch_page_popup() {\n"
335 "pwin = window.open('/page_popup', 'CitaPage%d', "
336 "'toolbar=no,location=no,copyhistory=no,status=no,"
337 "scrollbars=yes,resizable=no,height=250,width=400');\n"
344 if (!WC->outside_frameset_allowed) {
345 /* FIXME put this here */
349 clear_local_substs();
351 if (!suppress_check) if (WC->HaveExpressMessages) {
352 svprintf("extrabodyparms", WCS_STRING, "%s",
353 "onload=\"launch_page_popup()\" ");
354 WC->HaveExpressMessages = 0;
357 do_template("background");
358 clear_local_substs();
361 if (print_standard_html_head == 1) {
362 wprintf("<A NAME=\"TheTop\"></A>");
363 embed_room_banner(NULL);
366 if (strlen(WC->ImportantMessage) > 0) {
367 do_template("beginbox_nt");
368 wprintf("<SPAN CLASS=\"errormsg\">"
369 "%s</SPAN><BR>\n", WC->ImportantMessage);
370 do_template("endbox");
371 strcpy(WC->ImportantMessage, "");
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;
405 * Output a piece of content to the web browser
407 void http_transmit_thing(char *thing, size_t length, char *content_type,
409 output_headers(is_static ? 0x10 : 0x00);
410 wprintf("Content-type: %s\n"
411 "Content-length: %ld\n"
413 "Connection: close\n"
419 write(WC->http_sock, thing, (size_t)length);
425 void output_static(char *what)
432 char content_type[SIZ];
434 lprintf(9, "output_static(%s)\n", what);
435 sprintf(buf, "static/%s", what);
436 fp = fopen(buf, "rb");
438 wprintf("HTTP/1.0 404 %s\n", strerror(errno));
439 wprintf("Content-Type: text/plain\n");
441 wprintf("Cannot open %s: %s\n", what, strerror(errno));
443 if (!strncasecmp(&what[strlen(what) - 4], ".gif", 4))
444 strcpy(content_type, "image/gif");
445 else if (!strncasecmp(&what[strlen(what) - 4], ".txt", 4))
446 strcpy(content_type, "text/plain");
447 else if (!strncasecmp(&what[strlen(what) - 4], ".css", 4))
448 strcpy(content_type, "text/css");
449 else if (!strncasecmp(&what[strlen(what) - 4], ".jpg", 4))
450 strcpy(content_type, "image/jpeg");
451 else if (!strncasecmp(&what[strlen(what) - 4], ".png", 4))
452 strcpy(content_type, "image/png");
453 else if (!strncasecmp(&what[strlen(what) - 5], ".html", 5))
454 strcpy(content_type, "text/html");
455 else if (!strncasecmp(&what[strlen(what) - 4], ".wml", 4))
456 strcpy(content_type, "text/vnd.wap.wml");
457 else if (!strncasecmp(&what[strlen(what) - 5], ".wmls", 5))
458 strcpy(content_type, "text/vnd.wap.wmlscript");
459 else if (!strncasecmp(&what[strlen(what) - 5], ".wmlc", 5))
460 strcpy(content_type, "application/vnd.wap.wmlc");
461 else if (!strncasecmp(&what[strlen(what) - 6], ".wmlsc", 6))
462 strcpy(content_type, "application/vnd.wap.wmlscriptc");
463 else if (!strncasecmp(&what[strlen(what) - 5], ".wbmp", 5))
464 wprintf("Content-type: image/vnd.wap.wbmp");
466 wprintf("Content-type: application/octet-stream");
468 fstat(fileno(fp), &statbuf);
469 bytes = statbuf.st_size;
470 lprintf(3, "Static: %s, %ld bytes\n", what, bytes);
471 bigbuffer = malloc(bytes);
472 fread(bigbuffer, bytes, 1, fp);
475 http_transmit_thing(bigbuffer, (size_t)bytes, content_type, 1);
478 if (!strcasecmp(bstr("force_close_session"), "yes")) {
479 end_webcit_session();
485 * When the browser requests an image file from the Citadel server,
486 * this function is called to transmit it.
491 char *xferbuf = NULL;
494 serv_printf("OIMG %s|%s", bstr("name"), bstr("parm"));
497 bytes = extract_long(&buf[4], 0);
498 xferbuf = malloc(bytes);
500 /* Read it from the server */
501 read_server_binary(xferbuf, bytes);
505 /* Write it to the browser */
506 http_transmit_thing(xferbuf, (size_t)bytes, "image/gif", 0);
511 /* Instead of an ugly 404, send a 1x1 transparent GIF
512 * when there's no such image on the server.
514 output_static("blank.gif");
517 wprintf("HTTP/1.0 404 %s\n", &buf[4]);
519 wprintf("Content-Type: text/plain\n"
521 "Error retrieving image: %s\n",
534 void output_mimepart()
538 char content_type[SIZ];
539 char *content = NULL;
541 serv_printf("OPNA %s|%s", bstr("msgnum"), bstr("partnum"));
544 bytes = extract_long(&buf[4], 0);
545 content = malloc(bytes);
546 extract(content_type, &buf[4], 3);
548 read_server_binary(content, bytes);
551 http_transmit_thing(content, bytes, content_type, 0);
554 wprintf("HTTP/1.0 404 %s\n", &buf[4]);
556 wprintf("Content-Type: text/plain\n");
558 wprintf("Error retrieving part: %s\n", &buf[4]);
566 char *load_mimepart(long msgnum, char *partnum)
570 char content_type[SIZ];
573 serv_printf("OPNA %ld|%s", msgnum, partnum);
576 bytes = extract_long(&buf[4], 0);
577 extract(content_type, &buf[4], 3);
579 content = malloc(bytes + 1);
580 read_server_binary(content, bytes);
584 content[bytes] = 0; /* null terminate for good measure */
595 * Convenience functions to display a page containing only a string
597 void convenience_page(char *titlebarcolor, char *titlebarmsg, char *messagetext)
599 wprintf("HTTP/1.0 200 OK\n");
601 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#%s\"><TR><TD>", titlebarcolor);
602 wprintf("<SPAN CLASS=\"titlebar\">%s</SPAN>\n", titlebarmsg);
603 wprintf("</TD></TR></TABLE><BR>\n");
604 escputs(messagetext);
612 * Display a blank page.
614 void blank_page(void) {
621 * A template has been requested
623 void url_do_template(void) {
624 do_template(bstr("template"));
630 * Offer to make any page the user's "start page."
632 void offer_start_page(void) {
633 wprintf("<A HREF=\"/change_start_page?startpage=");
634 urlescputs(WC->this_page);
636 "<FONT SIZE=-2 COLOR=\"#AAAAAA\">Make this my start page</FONT>"
643 * Change the user's start page
645 void change_start_page(void) {
647 if (bstr("startpage") == NULL) {
648 strcpy(WC->ImportantMessage,
649 "startpage set to null");
654 set_preference("startpage", bstr("startpage"));
657 do_template("newstartpage");
664 void display_success(char *successmessage)
666 convenience_page("007700", "OK", successmessage);
671 void extract_action(char *actbuf, char *cmdbuf)
675 strcpy(actbuf, cmdbuf);
676 if (!strncasecmp(actbuf, "GET /", 5))
677 strcpy(actbuf, &actbuf[5]);
678 if (!strncasecmp(actbuf, "PUT /", 5))
679 strcpy(actbuf, &actbuf[5]);
680 if (!strncasecmp(actbuf, "POST /", 6))
681 strcpy(actbuf, &actbuf[6]);
683 for (i = 0; i < strlen(actbuf); ++i) {
684 if (actbuf[i] == ' ') {
688 if (actbuf[i] == '/') {
692 if (actbuf[i] == '?') {
696 if (actbuf[i] == '&') {
704 void upload_handler(char *name, char *filename, char *partnum, char *disp,
705 void *content, char *cbtype, size_t length,
706 char *encoding, void *userdata)
708 struct urlcontent *u;
711 if ( (length > 0) && (strlen(cbtype) == 0) ) {
712 u = (struct urlcontent *) malloc(sizeof(struct urlcontent));
713 u->next = WC->urlstrings;
715 safestrncpy(u->url_key, name, sizeof(u->url_key));
716 u->url_data = malloc(length + 1);
717 memcpy(u->url_data, content, length);
718 u->url_data[length] = 0;
722 if ( (length > 0) && (strlen(cbtype) > 0) ) {
723 WC->upload = malloc(length);
724 if (WC->upload != NULL) {
725 WC->upload_length = length;
726 safestrncpy(WC->upload_filename, filename,
727 sizeof(WC->upload_filename));
728 safestrncpy(WC->upload_content_type, cbtype,
729 sizeof(WC->upload_content_type));
730 memcpy(WC->upload, content, length);
733 lprintf(3, "malloc() failed: %s\n", strerror(errno));
743 * Entry point for WebCit transaction
745 void session_loop(struct httprequest *req)
751 int ContentLength = 0;
753 char ContentType[512];
756 struct httprequest *hptr;
757 char browser_host[SIZ];
758 char user_agent[SIZ];
761 /* We stuff these with the values coming from the client cookies,
762 * so we can use them to reconnect a timed out session if we have to.
764 char c_username[SIZ];
765 char c_password[SIZ];
766 char c_roomname[SIZ];
769 strcpy(c_username, "");
770 strcpy(c_password, "");
771 strcpy(c_roomname, "");
773 WC->upload_length = 0;
779 if (hptr == NULL) return;
781 strcpy(cmd, hptr->line);
783 extract_action(action, cmd);
785 while (hptr != NULL) {
786 strcpy(buf, hptr->line);
789 if (!strncasecmp(buf, "Cookie: webcit=", 15)) {
790 strcpy(cookie, &buf[15]);
791 cookie_to_stuff(cookie, NULL,
792 c_username, c_password, c_roomname);
794 else if (!strncasecmp(buf, "Content-length: ", 16)) {
795 ContentLength = atoi(&buf[16]);
797 else if (!strncasecmp(buf, "Content-type: ", 14)) {
798 safestrncpy(ContentType, &buf[14], sizeof ContentType);
800 else if (!strncasecmp(buf, "User-agent: ", 12)) {
801 safestrncpy(user_agent, &buf[12], sizeof user_agent);
803 else if (!strncasecmp(buf, "Host: ", 6)) {
804 safestrncpy(WC->http_host, &buf[6], sizeof WC->http_host);
806 /* Only WAP gateways explicitly name this content-type */
807 else if (strstr(buf, "text/vnd.wap.wml")) {
812 if (ContentLength > 0) {
813 content = malloc(ContentLength + SIZ);
814 memset(content, 0, ContentLength + SIZ);
815 sprintf(content, "Content-type: %s\n"
816 "Content-length: %d\n\n",
817 ContentType, ContentLength);
818 body_start = strlen(content);
821 while (BytesRead < ContentLength) {
822 a=read(WC->http_sock, &content[BytesRead+body_start],
823 ContentLength - BytesRead);
824 if (a <= 0) BytesRead = ContentLength;
828 if (!strncasecmp(ContentType,
829 "application/x-www-form-urlencoded", 33)) {
830 addurls(&content[body_start]);
831 } else if (!strncasecmp(ContentType, "multipart", 9)) {
832 content_end = content + ContentLength + body_start;
833 mime_parser(content, content_end, *upload_handler,
834 NULL, NULL, NULL, 0);
840 /* make a note of where we are in case the user wants to save it */
841 safestrncpy(WC->this_page, cmd, sizeof(WC->this_page));
842 remove_token(WC->this_page, 2, ' ');
843 remove_token(WC->this_page, 0, ' ');
845 /* If there are variables in the URL, we must grab them now */
846 for (a = 0; a < strlen(cmd); ++a) {
847 if ((cmd[a] == '?') || (cmd[a] == '&')) {
848 for (b = a; b < strlen(cmd); ++b)
851 addurls(&cmd[a + 1]);
856 /* Static content can be sent without connecting to Citadel. */
857 if (!strcasecmp(action, "static")) {
858 strcpy(buf, &cmd[12]);
859 for (a = 0; a < strlen(buf); ++a)
863 goto SKIP_ALL_THIS_CRAP; /* Don't try to connect */
867 * If we're not connected to a Citadel server, try to hook up the
870 if (!WC->connected) {
871 if (!strcasecmp(ctdlhost, "uds")) {
872 /* unix domain socket */
873 sprintf(buf, "%s/citadel.socket", ctdlport);
874 WC->serv_sock = uds_connectsock(buf);
878 WC->serv_sock = tcp_connectsock(ctdlhost, ctdlport);
881 if (WC->serv_sock < 0) {
883 goto SKIP_ALL_THIS_CRAP;
887 serv_gets(buf); /* get the server welcome message */
888 locate_host(browser_host, WC->http_sock);
889 get_serv_info(browser_host, user_agent);
890 if (serv_info.serv_rev_level < MINIMUM_CIT_VERSION) {
891 wprintf("You are connected to a Citadel "
892 "server running Citadel %d.%02d;\nin "
893 "order to run this version of WebCit "
894 "you must also have Citadel %d.%02d or"
896 serv_info.serv_rev_level / 100,
897 serv_info.serv_rev_level % 100,
898 MINIMUM_CIT_VERSION / 100,
899 MINIMUM_CIT_VERSION % 100
901 end_webcit_session();
902 goto SKIP_ALL_THIS_CRAP;
908 * Functions which can be performed without logging in
910 if (!strcasecmp(action, "listsub")) {
912 goto SKIP_ALL_THIS_CRAP;
914 #ifdef WEBCIT_WITH_CALENDAR_SERVICE
915 if (!strcasecmp(action, "freebusy")) {
917 goto SKIP_ALL_THIS_CRAP;
921 check_for_express_messages();
924 * If we're not logged in, but we have username and password cookies
925 * supplied by the browser, try using them to log in.
927 if ((!WC->logged_in) && (strlen(c_username) > 0) && (strlen(c_password) > 0)) {
928 serv_printf("USER %s", c_username);
931 serv_printf("PASS %s", c_password);
934 become_logged_in(c_username, c_password, buf);
939 * If we don't have a current room, but a cookie specifying the
940 * current room is supplied, make an effort to go there.
942 if ((strlen(WC->wc_roomname) == 0) && (strlen(c_roomname) > 0)) {
943 serv_printf("GOTO %s", c_roomname);
946 strcpy(WC->wc_roomname, c_roomname);
950 if (!strcasecmp(action, "image")) {
954 * All functions handled below this point ... make sure we log in
955 * before doing anything else!
957 } else if ((!WC->logged_in) && (!strcasecmp(action, "login"))) {
959 } else if (!WC->logged_in) {
964 * Various commands...
967 else if (!strcasecmp(action, "do_welcome")) {
969 } else if (!strcasecmp(action, "blank")) {
971 } else if (!strcasecmp(action, "do_template")) {
973 } else if (!strcasecmp(action, "display_main_menu")) {
975 } else if (!strcasecmp(action, "whobbs")) {
977 } else if (!strcasecmp(action, "knrooms")) {
979 } else if (!strcasecmp(action, "gotonext")) {
982 } else if (!strcasecmp(action, "skip")) {
984 } else if (!strcasecmp(action, "ungoto")) {
986 } else if (!strcasecmp(action, "dotgoto")) {
988 smart_goto(bstr("room"));
989 } else if (!strcasecmp(action, "dotskip")) {
990 smart_goto(bstr("room"));
991 } else if (!strcasecmp(action, "termquit")) {
993 } else if (!strcasecmp(action, "readnew")) {
995 } else if (!strcasecmp(action, "readold")) {
997 } else if (!strcasecmp(action, "readfwd")) {
999 } else if (!strcasecmp(action, "headers")) {
1000 readloop("headers");
1001 } else if (!strcasecmp(action, "display_enter")) {
1003 } else if (!strcasecmp(action, "post")) {
1005 } else if (!strcasecmp(action, "delete_msg")) {
1007 } else if (!strcasecmp(action, "confirm_move_msg")) {
1009 } else if (!strcasecmp(action, "move_msg")) {
1011 } else if (!strcasecmp(action, "userlist")) {
1013 } else if (!strcasecmp(action, "showuser")) {
1015 } else if (!strcasecmp(action, "display_page")) {
1017 } else if (!strcasecmp(action, "page_user")) {
1019 } else if (!strcasecmp(action, "chat")) {
1021 } else if (!strcasecmp(action, "display_private")) {
1022 display_private("", 0);
1023 } else if (!strcasecmp(action, "goto_private")) {
1025 } else if (!strcasecmp(action, "zapped_list")) {
1027 } else if (!strcasecmp(action, "display_zap")) {
1029 } else if (!strcasecmp(action, "zap")) {
1031 } else if (!strcasecmp(action, "display_entroom")) {
1033 } else if (!strcasecmp(action, "entroom")) {
1035 } else if (!strcasecmp(action, "display_editroom")) {
1037 } else if (!strcasecmp(action, "netedit")) {
1039 } else if (!strcasecmp(action, "editroom")) {
1041 } else if (!strcasecmp(action, "display_whok")) {
1043 } else if (!strcasecmp(action, "display_editinfo")) {
1044 display_edit("Room info", "EINF 0", "RINF", "/editinfo", 1);
1045 } else if (!strcasecmp(action, "editinfo")) {
1046 save_edit("Room info", "EINF 1", 1);
1047 } else if (!strcasecmp(action, "display_editbio")) {
1048 sprintf(buf, "RBIO %s", WC->wc_username);
1049 display_edit("Your bio", "NOOP", buf, "editbio", 3);
1050 } else if (!strcasecmp(action, "editbio")) {
1051 save_edit("Your bio", "EBIO", 0);
1052 } else if (!strcasecmp(action, "confirm_delete_room")) {
1053 confirm_delete_room();
1054 } else if (!strcasecmp(action, "delete_room")) {
1056 } else if (!strcasecmp(action, "validate")) {
1058 } else if (!strcasecmp(action, "display_editpic")) {
1059 display_graphics_upload("your photo",
1062 } else if (!strcasecmp(action, "editpic")) {
1063 do_graphics_upload("UIMG 1|_userpic_");
1064 } else if (!strcasecmp(action, "display_editroompic")) {
1065 display_graphics_upload("the graphic for this room",
1068 } else if (!strcasecmp(action, "editroompic")) {
1069 do_graphics_upload("UIMG 1|_roompic_");
1070 } else if (!strcasecmp(action, "delete_floor")) {
1072 } else if (!strcasecmp(action, "rename_floor")) {
1074 } else if (!strcasecmp(action, "create_floor")) {
1076 } else if (!strcasecmp(action, "display_editfloorpic")) {
1077 sprintf(buf, "UIMG 0|_floorpic_|%s",
1078 bstr("which_floor"));
1079 display_graphics_upload("the graphic for this floor",
1082 } else if (!strcasecmp(action, "editfloorpic")) {
1083 sprintf(buf, "UIMG 1|_floorpic_|%s",
1084 bstr("which_floor"));
1085 do_graphics_upload(buf);
1086 } else if (!strcasecmp(action, "display_reg")) {
1088 } else if (!strcasecmp(action, "display_changepw")) {
1090 } else if (!strcasecmp(action, "changepw")) {
1092 } else if (!strcasecmp(action, "display_edit_node")) {
1093 display_edit_node();
1094 } else if (!strcasecmp(action, "edit_node")) {
1096 } else if (!strcasecmp(action, "display_netconf")) {
1098 } else if (!strcasecmp(action, "display_confirm_delete_node")) {
1099 display_confirm_delete_node();
1100 } else if (!strcasecmp(action, "delete_node")) {
1102 } else if (!strcasecmp(action, "display_add_node")) {
1104 } else if (!strcasecmp(action, "add_node")) {
1106 } else if (!strcasecmp(action, "terminate_session")) {
1108 terminate_session();
1109 } else if (!strcasecmp(action, "edit_me")) {
1111 } else if (!strcasecmp(action, "display_siteconfig")) {
1112 display_siteconfig();
1113 } else if (!strcasecmp(action, "page_popup")) {
1115 } else if (!strcasecmp(action, "siteconfig")) {
1117 } else if (!strcasecmp(action, "display_generic")) {
1119 } else if (!strcasecmp(action, "do_generic")) {
1121 } else if (!strcasecmp(action, "display_menubar")) {
1123 } else if (!strcasecmp(action, "output_mimepart")) {
1125 } else if (!strcasecmp(action, "edit_vcard")) {
1127 } else if (!strcasecmp(action, "submit_vcard")) {
1129 } else if (!strcasecmp(action, "select_user_to_edit")) {
1130 select_user_to_edit(NULL, NULL);
1131 } else if (!strcasecmp(action, "display_edituser")) {
1132 display_edituser(NULL);
1133 } else if (!strcasecmp(action, "edituser")) {
1135 } else if (!strcasecmp(action, "create_user")) {
1137 } else if (!strcasecmp(action, "changeview")) {
1139 } else if (!strcasecmp(action, "do_stuff_to_msgs")) {
1141 } else if (!strcasecmp(action, "change_start_page")) {
1142 change_start_page();
1143 } else if (!strcasecmp(action, "display_floorconfig")) {
1144 display_floorconfig(NULL);
1145 } else if (!strcasecmp(action, "toggle_self_service")) {
1146 toggle_self_service();
1147 #ifdef WEBCIT_WITH_CALENDAR_SERVICE
1148 } else if (!strcasecmp(action, "display_edit_task")) {
1149 display_edit_task();
1150 } else if (!strcasecmp(action, "save_task")) {
1152 } else if (!strcasecmp(action, "display_edit_event")) {
1153 display_edit_event();
1154 } else if (!strcasecmp(action, "save_event")) {
1156 } else if (!strcasecmp(action, "respond_to_request")) {
1157 respond_to_request();
1158 } else if (!strcasecmp(action, "handle_rsvp")) {
1161 } else if (!strcasecmp(action, "summary")) {
1163 } else if (!strcasecmp(action, "iconbar")) {
1165 } else if (!strcasecmp(action, "display_customize_iconbar")) {
1166 display_customize_iconbar();
1167 } else if (!strcasecmp(action, "commit_iconbar")) {
1169 } else if (!strcasecmp(action, "diagnostics")) {
1172 wprintf("You're in session %d<HR>\n", WC->wc_session);
1173 wprintf("Command: <BR><PRE>\n");
1175 wprintf("</PRE><HR>\n");
1176 wprintf("Variables: <BR><PRE>\n");
1178 wprintf("</PRE><HR>\n");
1181 /* When all else fais, display the main menu. */
1183 display_main_menu();
1188 if (content != NULL) {
1193 if (WC->upload_length > 0) {
1195 WC->upload_length = 0;