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 (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"
345 clear_local_substs();
347 if (!suppress_check) if (WC->HaveExpressMessages) {
348 svprintf("extrabodyparms", WCS_STRING, "%s",
349 "onload=\"launch_page_popup()\" ");
350 WC->HaveExpressMessages = 0;
353 do_template("background");
354 clear_local_substs();
357 if (print_standard_html_head == 1) {
358 wprintf("<A NAME=\"TheTop\"></A>");
359 embed_room_banner(NULL);
362 if (strlen(WC->ImportantMessage) > 0) {
363 do_template("beginbox_nt");
364 wprintf("<SPAN CLASS=\"errormsg\">"
365 "%s</SPAN><BR>\n", WC->ImportantMessage);
366 do_template("endbox");
367 strcpy(WC->ImportantMessage, "");
375 void http_redirect(char *whichpage) {
376 wprintf("HTTP/1.0 302 Moved Temporarily\n");
377 wprintf("Location: %s\n", whichpage);
378 wprintf("URI: %s\n", whichpage);
379 wprintf("Content-type: text/html\n\n");
380 wprintf("<html><body>\n");
381 wprintf("you really want to be <A HREF=\"%s\">here</A> now\n",
383 wprintf("</body></html>\n");
388 void check_for_express_messages()
394 if (buf[3] == '*') WC->HaveExpressMessages = 1;
401 * Output a piece of content to the web browser
403 void http_transmit_thing(char *thing, size_t length, char *content_type,
405 output_headers(is_static ? 0x10 : 0x00);
406 wprintf("Content-type: %s\n"
407 "Content-length: %ld\n"
409 "Connection: close\n"
415 write(WC->http_sock, thing, (size_t)length);
421 void output_static(char *what)
428 char content_type[SIZ];
430 lprintf(9, "output_static(%s)\n", what);
431 sprintf(buf, "static/%s", what);
432 fp = fopen(buf, "rb");
434 wprintf("HTTP/1.0 404 %s\n", strerror(errno));
435 wprintf("Content-Type: text/plain\n");
437 wprintf("Cannot open %s: %s\n", what, strerror(errno));
439 if (!strncasecmp(&what[strlen(what) - 4], ".gif", 4))
440 strcpy(content_type, "image/gif");
441 else if (!strncasecmp(&what[strlen(what) - 4], ".txt", 4))
442 strcpy(content_type, "text/plain");
443 else if (!strncasecmp(&what[strlen(what) - 4], ".css", 4))
444 strcpy(content_type, "text/css");
445 else if (!strncasecmp(&what[strlen(what) - 4], ".jpg", 4))
446 strcpy(content_type, "image/jpeg");
447 else if (!strncasecmp(&what[strlen(what) - 4], ".png", 4))
448 strcpy(content_type, "image/png");
449 else if (!strncasecmp(&what[strlen(what) - 5], ".html", 5))
450 strcpy(content_type, "text/html");
451 else if (!strncasecmp(&what[strlen(what) - 4], ".wml", 4))
452 strcpy(content_type, "text/vnd.wap.wml");
453 else if (!strncasecmp(&what[strlen(what) - 5], ".wmls", 5))
454 strcpy(content_type, "text/vnd.wap.wmlscript");
455 else if (!strncasecmp(&what[strlen(what) - 5], ".wmlc", 5))
456 strcpy(content_type, "application/vnd.wap.wmlc");
457 else if (!strncasecmp(&what[strlen(what) - 6], ".wmlsc", 6))
458 strcpy(content_type, "application/vnd.wap.wmlscriptc");
459 else if (!strncasecmp(&what[strlen(what) - 5], ".wbmp", 5))
460 wprintf("Content-type: image/vnd.wap.wbmp");
462 wprintf("Content-type: application/octet-stream");
464 fstat(fileno(fp), &statbuf);
465 bytes = statbuf.st_size;
466 lprintf(3, "Static: %s, %ld bytes\n", what, bytes);
467 bigbuffer = malloc(bytes);
468 fread(bigbuffer, bytes, 1, fp);
471 http_transmit_thing(bigbuffer, (size_t)bytes, content_type, 1);
474 if (!strcasecmp(bstr("force_close_session"), "yes")) {
475 end_webcit_session();
481 * When the browser requests an image file from the Citadel server,
482 * this function is called to transmit it.
487 char *xferbuf = NULL;
490 serv_printf("OIMG %s|%s", bstr("name"), bstr("parm"));
493 bytes = extract_long(&buf[4], 0);
494 xferbuf = malloc(bytes);
496 /* Read it from the server */
497 read_server_binary(xferbuf, bytes);
501 /* Write it to the browser */
502 http_transmit_thing(xferbuf, (size_t)bytes, "image/gif", 0);
507 /* Instead of an ugly 404, send a 1x1 transparent GIF
508 * when there's no such image on the server.
510 output_static("blank.gif");
513 wprintf("HTTP/1.0 404 %s\n", &buf[4]);
515 wprintf("Content-Type: text/plain\n"
517 "Error retrieving image: %s\n",
530 void output_mimepart()
534 char content_type[SIZ];
535 char *content = NULL;
537 serv_printf("OPNA %s|%s", bstr("msgnum"), bstr("partnum"));
540 bytes = extract_long(&buf[4], 0);
541 content = malloc(bytes);
542 extract(content_type, &buf[4], 3);
544 read_server_binary(content, bytes);
547 http_transmit_thing(content, bytes, content_type, 0);
550 wprintf("HTTP/1.0 404 %s\n", &buf[4]);
552 wprintf("Content-Type: text/plain\n");
554 wprintf("Error retrieving part: %s\n", &buf[4]);
562 char *load_mimepart(long msgnum, char *partnum)
566 char content_type[SIZ];
569 serv_printf("OPNA %ld|%s", msgnum, partnum);
572 bytes = extract_long(&buf[4], 0);
573 extract(content_type, &buf[4], 3);
575 content = malloc(bytes + 1);
576 read_server_binary(content, bytes);
580 content[bytes] = 0; /* null terminate for good measure */
591 * Convenience functions to display a page containing only a string
593 void convenience_page(char *titlebarcolor, char *titlebarmsg, char *messagetext)
595 wprintf("HTTP/1.0 200 OK\n");
597 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#%s\"><TR><TD>", titlebarcolor);
598 wprintf("<SPAN CLASS=\"titlebar\">%s</SPAN>\n", titlebarmsg);
599 wprintf("</TD></TR></TABLE><BR>\n");
600 escputs(messagetext);
608 * Display a blank page.
610 void blank_page(void) {
617 * A template has been requested
619 void url_do_template(void) {
620 do_template(bstr("template"));
626 * Offer to make any page the user's "start page."
628 void offer_start_page(void) {
629 wprintf("<A HREF=\"/change_start_page?startpage=");
630 urlescputs(WC->this_page);
632 "<FONT SIZE=-2 COLOR=\"#AAAAAA\">Make this my start page</FONT>"
639 * Change the user's start page
641 void change_start_page(void) {
643 if (bstr("startpage") == NULL) {
644 strcpy(WC->ImportantMessage,
645 "startpage set to null");
650 set_preference("startpage", bstr("startpage"));
653 do_template("newstartpage");
660 void display_success(char *successmessage)
662 convenience_page("007700", "OK", successmessage);
667 void extract_action(char *actbuf, char *cmdbuf)
671 strcpy(actbuf, cmdbuf);
672 if (!strncasecmp(actbuf, "GET /", 5))
673 strcpy(actbuf, &actbuf[5]);
674 if (!strncasecmp(actbuf, "PUT /", 5))
675 strcpy(actbuf, &actbuf[5]);
676 if (!strncasecmp(actbuf, "POST /", 6))
677 strcpy(actbuf, &actbuf[6]);
679 for (i = 0; i < strlen(actbuf); ++i) {
680 if (actbuf[i] == ' ') {
684 if (actbuf[i] == '/') {
688 if (actbuf[i] == '?') {
692 if (actbuf[i] == '&') {
700 void upload_handler(char *name, char *filename, char *partnum, char *disp,
701 void *content, char *cbtype, size_t length,
702 char *encoding, void *userdata)
704 struct urlcontent *u;
707 if ( (length > 0) && (strlen(cbtype) == 0) ) {
708 u = (struct urlcontent *) malloc(sizeof(struct urlcontent));
709 u->next = WC->urlstrings;
711 safestrncpy(u->url_key, name, sizeof(u->url_key));
712 u->url_data = malloc(length + 1);
713 memcpy(u->url_data, content, length);
714 u->url_data[length] = 0;
718 if ( (length > 0) && (strlen(cbtype) > 0) ) {
719 WC->upload = malloc(length);
720 if (WC->upload != NULL) {
721 WC->upload_length = length;
722 safestrncpy(WC->upload_filename, filename,
723 sizeof(WC->upload_filename));
724 safestrncpy(WC->upload_content_type, cbtype,
725 sizeof(WC->upload_content_type));
726 memcpy(WC->upload, content, length);
729 lprintf(3, "malloc() failed: %s\n", strerror(errno));
739 * Entry point for WebCit transaction
741 void session_loop(struct httprequest *req)
747 int ContentLength = 0;
749 char ContentType[512];
752 struct httprequest *hptr;
753 char browser_host[SIZ];
754 char user_agent[SIZ];
757 /* We stuff these with the values coming from the client cookies,
758 * so we can use them to reconnect a timed out session if we have to.
760 char c_username[SIZ];
761 char c_password[SIZ];
762 char c_roomname[SIZ];
765 strcpy(c_username, "");
766 strcpy(c_password, "");
767 strcpy(c_roomname, "");
769 WC->upload_length = 0;
775 if (hptr == NULL) return;
777 strcpy(cmd, hptr->line);
779 extract_action(action, cmd);
781 while (hptr != NULL) {
782 strcpy(buf, hptr->line);
785 if (!strncasecmp(buf, "Cookie: webcit=", 15)) {
786 strcpy(cookie, &buf[15]);
787 cookie_to_stuff(cookie, NULL,
788 c_username, c_password, c_roomname);
790 else if (!strncasecmp(buf, "Content-length: ", 16)) {
791 ContentLength = atoi(&buf[16]);
793 else if (!strncasecmp(buf, "Content-type: ", 14)) {
794 safestrncpy(ContentType, &buf[14], sizeof ContentType);
796 else if (!strncasecmp(buf, "User-agent: ", 12)) {
797 safestrncpy(user_agent, &buf[12], sizeof user_agent);
799 else if (!strncasecmp(buf, "Host: ", 6)) {
800 safestrncpy(WC->http_host, &buf[6], sizeof WC->http_host);
802 /* Only WAP gateways explicitly name this content-type */
803 else if (strstr(buf, "text/vnd.wap.wml")) {
808 if (ContentLength > 0) {
809 content = malloc(ContentLength + SIZ);
810 memset(content, 0, ContentLength + SIZ);
811 sprintf(content, "Content-type: %s\n"
812 "Content-length: %d\n\n",
813 ContentType, ContentLength);
814 body_start = strlen(content);
817 while (BytesRead < ContentLength) {
818 a=read(WC->http_sock, &content[BytesRead+body_start],
819 ContentLength - BytesRead);
820 if (a <= 0) BytesRead = ContentLength;
824 if (!strncasecmp(ContentType,
825 "application/x-www-form-urlencoded", 33)) {
826 addurls(&content[body_start]);
827 } else if (!strncasecmp(ContentType, "multipart", 9)) {
828 content_end = content + ContentLength + body_start;
829 mime_parser(content, content_end, *upload_handler,
830 NULL, NULL, NULL, 0);
836 /* make a note of where we are in case the user wants to save it */
837 safestrncpy(WC->this_page, cmd, sizeof(WC->this_page));
838 remove_token(WC->this_page, 2, ' ');
839 remove_token(WC->this_page, 0, ' ');
841 /* If there are variables in the URL, we must grab them now */
842 for (a = 0; a < strlen(cmd); ++a) {
843 if ((cmd[a] == '?') || (cmd[a] == '&')) {
844 for (b = a; b < strlen(cmd); ++b)
847 addurls(&cmd[a + 1]);
852 /* Static content can be sent without connecting to Citadel. */
853 if (!strcasecmp(action, "static")) {
854 strcpy(buf, &cmd[12]);
855 for (a = 0; a < strlen(buf); ++a)
859 goto SKIP_ALL_THIS_CRAP; /* Don't try to connect */
863 * If we're not connected to a Citadel server, try to hook up the
866 if (!WC->connected) {
867 if (!strcasecmp(ctdlhost, "uds")) {
868 /* unix domain socket */
869 sprintf(buf, "%s/citadel.socket", ctdlport);
870 WC->serv_sock = uds_connectsock(buf);
874 WC->serv_sock = tcp_connectsock(ctdlhost, ctdlport);
877 if (WC->serv_sock < 0) {
879 goto SKIP_ALL_THIS_CRAP;
883 serv_gets(buf); /* get the server welcome message */
884 locate_host(browser_host, WC->http_sock);
885 get_serv_info(browser_host, user_agent);
886 if (serv_info.serv_rev_level < MINIMUM_CIT_VERSION) {
887 wprintf("You are connected to a Citadel "
888 "server running Citadel %d.%02d;\nin "
889 "order to run this version of WebCit "
890 "you must also have Citadel %d.%02d or"
892 serv_info.serv_rev_level / 100,
893 serv_info.serv_rev_level % 100,
894 MINIMUM_CIT_VERSION / 100,
895 MINIMUM_CIT_VERSION % 100
897 end_webcit_session();
898 goto SKIP_ALL_THIS_CRAP;
904 * Functions which can be performed without logging in
906 if (!strcasecmp(action, "listsub")) {
908 goto SKIP_ALL_THIS_CRAP;
910 #ifdef WEBCIT_WITH_CALENDAR_SERVICE
911 if (!strcasecmp(action, "freebusy")) {
913 goto SKIP_ALL_THIS_CRAP;
917 check_for_express_messages();
920 * If we're not logged in, but we have username and password cookies
921 * supplied by the browser, try using them to log in.
923 if ((!WC->logged_in) && (strlen(c_username) > 0) && (strlen(c_password) > 0)) {
924 serv_printf("USER %s", c_username);
927 serv_printf("PASS %s", c_password);
930 become_logged_in(c_username, c_password, buf);
935 * If we don't have a current room, but a cookie specifying the
936 * current room is supplied, make an effort to go there.
938 if ((strlen(WC->wc_roomname) == 0) && (strlen(c_roomname) > 0)) {
939 serv_printf("GOTO %s", c_roomname);
942 strcpy(WC->wc_roomname, c_roomname);
946 if (!strcasecmp(action, "image")) {
950 * All functions handled below this point ... make sure we log in
951 * before doing anything else!
953 } else if ((!WC->logged_in) && (!strcasecmp(action, "login"))) {
955 } else if (!WC->logged_in) {
960 * Various commands...
963 else if (!strcasecmp(action, "do_welcome")) {
965 } else if (!strcasecmp(action, "blank")) {
967 } else if (!strcasecmp(action, "do_template")) {
969 } else if (!strcasecmp(action, "display_main_menu")) {
971 } else if (!strcasecmp(action, "whobbs")) {
973 } else if (!strcasecmp(action, "knrooms")) {
975 } else if (!strcasecmp(action, "gotonext")) {
978 } else if (!strcasecmp(action, "skip")) {
980 } else if (!strcasecmp(action, "ungoto")) {
982 } else if (!strcasecmp(action, "dotgoto")) {
984 smart_goto(bstr("room"));
985 } else if (!strcasecmp(action, "dotskip")) {
986 smart_goto(bstr("room"));
987 } else if (!strcasecmp(action, "termquit")) {
989 } else if (!strcasecmp(action, "readnew")) {
991 } else if (!strcasecmp(action, "readold")) {
993 } else if (!strcasecmp(action, "readfwd")) {
995 } else if (!strcasecmp(action, "headers")) {
997 } else if (!strcasecmp(action, "display_enter")) {
999 } else if (!strcasecmp(action, "post")) {
1001 } else if (!strcasecmp(action, "delete_msg")) {
1003 } else if (!strcasecmp(action, "confirm_move_msg")) {
1005 } else if (!strcasecmp(action, "move_msg")) {
1007 } else if (!strcasecmp(action, "userlist")) {
1009 } else if (!strcasecmp(action, "showuser")) {
1011 } else if (!strcasecmp(action, "display_page")) {
1013 } else if (!strcasecmp(action, "page_user")) {
1015 } else if (!strcasecmp(action, "chat")) {
1017 } else if (!strcasecmp(action, "display_private")) {
1018 display_private("", 0);
1019 } else if (!strcasecmp(action, "goto_private")) {
1021 } else if (!strcasecmp(action, "zapped_list")) {
1023 } else if (!strcasecmp(action, "display_zap")) {
1025 } else if (!strcasecmp(action, "zap")) {
1027 } else if (!strcasecmp(action, "display_entroom")) {
1029 } else if (!strcasecmp(action, "entroom")) {
1031 } else if (!strcasecmp(action, "display_editroom")) {
1033 } else if (!strcasecmp(action, "netedit")) {
1035 } else if (!strcasecmp(action, "editroom")) {
1037 } else if (!strcasecmp(action, "display_whok")) {
1039 } else if (!strcasecmp(action, "display_editinfo")) {
1040 display_edit("Room info", "EINF 0", "RINF", "/editinfo", 1);
1041 } else if (!strcasecmp(action, "editinfo")) {
1042 save_edit("Room info", "EINF 1", 1);
1043 } else if (!strcasecmp(action, "display_editbio")) {
1044 sprintf(buf, "RBIO %s", WC->wc_username);
1045 display_edit("Your bio", "NOOP", buf, "editbio", 3);
1046 } else if (!strcasecmp(action, "editbio")) {
1047 save_edit("Your bio", "EBIO", 0);
1048 } else if (!strcasecmp(action, "confirm_delete_room")) {
1049 confirm_delete_room();
1050 } else if (!strcasecmp(action, "delete_room")) {
1052 } else if (!strcasecmp(action, "validate")) {
1054 } else if (!strcasecmp(action, "display_editpic")) {
1055 display_graphics_upload("your photo",
1058 } else if (!strcasecmp(action, "editpic")) {
1059 do_graphics_upload("UIMG 1|_userpic_");
1060 } else if (!strcasecmp(action, "display_editroompic")) {
1061 display_graphics_upload("the graphic for this room",
1064 } else if (!strcasecmp(action, "editroompic")) {
1065 do_graphics_upload("UIMG 1|_roompic_");
1066 } else if (!strcasecmp(action, "delete_floor")) {
1068 } else if (!strcasecmp(action, "rename_floor")) {
1070 } else if (!strcasecmp(action, "create_floor")) {
1072 } else if (!strcasecmp(action, "display_editfloorpic")) {
1073 sprintf(buf, "UIMG 0|_floorpic_|%s",
1074 bstr("which_floor"));
1075 display_graphics_upload("the graphic for this floor",
1078 } else if (!strcasecmp(action, "editfloorpic")) {
1079 sprintf(buf, "UIMG 1|_floorpic_|%s",
1080 bstr("which_floor"));
1081 do_graphics_upload(buf);
1082 } else if (!strcasecmp(action, "display_reg")) {
1084 } else if (!strcasecmp(action, "display_changepw")) {
1086 } else if (!strcasecmp(action, "changepw")) {
1088 } else if (!strcasecmp(action, "display_edit_node")) {
1089 display_edit_node();
1090 } else if (!strcasecmp(action, "edit_node")) {
1092 } else if (!strcasecmp(action, "display_netconf")) {
1094 } else if (!strcasecmp(action, "display_confirm_delete_node")) {
1095 display_confirm_delete_node();
1096 } else if (!strcasecmp(action, "delete_node")) {
1098 } else if (!strcasecmp(action, "display_add_node")) {
1100 } else if (!strcasecmp(action, "add_node")) {
1102 } else if (!strcasecmp(action, "terminate_session")) {
1104 terminate_session();
1105 } else if (!strcasecmp(action, "edit_me")) {
1107 } else if (!strcasecmp(action, "display_siteconfig")) {
1108 display_siteconfig();
1109 } else if (!strcasecmp(action, "page_popup")) {
1111 } else if (!strcasecmp(action, "siteconfig")) {
1113 } else if (!strcasecmp(action, "display_generic")) {
1115 } else if (!strcasecmp(action, "do_generic")) {
1117 } else if (!strcasecmp(action, "display_menubar")) {
1119 } else if (!strcasecmp(action, "output_mimepart")) {
1121 } else if (!strcasecmp(action, "edit_vcard")) {
1123 } else if (!strcasecmp(action, "submit_vcard")) {
1125 } else if (!strcasecmp(action, "select_user_to_edit")) {
1126 select_user_to_edit(NULL, NULL);
1127 } else if (!strcasecmp(action, "display_edituser")) {
1128 display_edituser(NULL);
1129 } else if (!strcasecmp(action, "edituser")) {
1131 } else if (!strcasecmp(action, "create_user")) {
1133 } else if (!strcasecmp(action, "changeview")) {
1135 } else if (!strcasecmp(action, "do_stuff_to_msgs")) {
1137 } else if (!strcasecmp(action, "change_start_page")) {
1138 change_start_page();
1139 } else if (!strcasecmp(action, "display_floorconfig")) {
1140 display_floorconfig(NULL);
1141 } else if (!strcasecmp(action, "toggle_self_service")) {
1142 toggle_self_service();
1143 #ifdef WEBCIT_WITH_CALENDAR_SERVICE
1144 } else if (!strcasecmp(action, "display_edit_task")) {
1145 display_edit_task();
1146 } else if (!strcasecmp(action, "save_task")) {
1148 } else if (!strcasecmp(action, "display_edit_event")) {
1149 display_edit_event();
1150 } else if (!strcasecmp(action, "save_event")) {
1152 } else if (!strcasecmp(action, "respond_to_request")) {
1153 respond_to_request();
1154 } else if (!strcasecmp(action, "handle_rsvp")) {
1157 } else if (!strcasecmp(action, "summary")) {
1159 } else if (!strcasecmp(action, "diagnostics")) {
1162 wprintf("You're in session %d<HR>\n", WC->wc_session);
1163 wprintf("Command: <BR><PRE>\n");
1165 wprintf("</PRE><HR>\n");
1166 wprintf("Variables: <BR><PRE>\n");
1168 wprintf("</PRE><HR>\n");
1171 /* When all else fais, display the main menu. */
1173 display_main_menu();
1178 if (content != NULL) {
1183 if (WC->upload_length > 0) {
1185 WC->upload_length = 0;