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) + 2);
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 vsnprintf(wbuf, sizeof wbuf, format, arg_ptr);
164 client_write(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 wprintf("</DIV>\n"); /* end of "text" div */
179 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, int nolinebreaks)
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, " ");
213 else if ((strbuf[a] == '\n') && (nolinebreaks))
214 strcat(target, ""); /* nothing */
215 else if ((strbuf[a] == '\r') && (nolinebreaks))
216 strcat(target, ""); /* nothing */
218 strncat(target, &strbuf[a], 1);
222 void escputs1(char *strbuf, int nbsp, int nolinebreaks)
226 if (strbuf == NULL) return;
227 buf = malloc( (3 * strlen(strbuf)) + SIZ );
228 stresc(buf, strbuf, nbsp, nolinebreaks);
233 void escputs(char *strbuf)
235 escputs1(strbuf, 0, 0);
239 * Escape a string for feeding out as a URL.
240 * Returns a pointer to a buffer that must be freed by the caller!
242 void urlesc(char *outbuf, char *strbuf)
245 char *ec = " #&;`'|*?-~<>^()[]{}$\\";
249 for (a = 0; a < strlen(strbuf); ++a) {
251 for (b = 0; b < strlen(ec); ++b) {
252 if (strbuf[a] == ec[b])
257 sprintf(&outbuf[b], "%%%02x", strbuf[a]);
259 sprintf(&outbuf[b], "%c", strbuf[a]);
263 void urlescputs(char *strbuf)
267 urlesc(outbuf, strbuf);
268 wprintf("%s", outbuf);
273 * Copy a string, escaping characters for JavaScript strings.
275 void jsesc(char *target, char *strbuf)
280 for (a = 0; a < strlen(strbuf); ++a) {
281 if (strbuf[a] == '<')
283 else if (strbuf[a] == '>')
285 else if (strbuf[a] == '\"')
286 strcat(target, """);
287 else if (strbuf[a] == '&')
288 strcat(target, "&;");
289 else if (strbuf[a] == '\'')
290 strcat(target, "\\'");
292 strncat(target, &strbuf[a], 1);
297 void jsescputs(char *strbuf)
301 jsesc(outbuf, strbuf);
302 wprintf("%s", outbuf);
306 * Copy a string, escaping characters for message text hold
308 void msgesc(char *target, char *strbuf)
313 for (a = 0; a < strlen(strbuf); ++a) {
314 if (strbuf[a] == '\'')
315 strcat(target, "\\'");
316 else if (strbuf[a] == '\n')
318 else if (strbuf[a] == '\r')
321 strncat(target, &strbuf[a], 1);
326 void msgescputs(char *strbuf) {
329 if (strbuf == NULL) return;
330 outbuf = malloc( (3 * strlen(strbuf)) + SIZ);
331 msgesc(outbuf, strbuf);
332 wprintf("%s", outbuf);
340 * Output all that important stuff that the browser will want to see
342 void output_headers( int do_httpheaders, /* 1 = output HTTP headers */
343 int do_htmlhead, /* 1 = output HTML <head> section and <body> opener */
345 int do_room_banner, /* 0=no, 1=yes, */
346 /* 2 = I'm going to embed my own, so don't open the */
347 /* <div id="text"> either. */
349 int unset_cookies, /* 1 = session is terminating, so unset the cookies */
350 int refresh30, /* 1 = automatically refresh page every 30 seconds */
351 int suppress_check, /* 1 = suppress check for instant messages */
352 int cache /* 1 = allow browser to cache this page */
357 wprintf("HTTP/1.0 200 OK\n");
358 httpdate(httpnow, time(NULL));
360 if (do_httpheaders) {
361 wprintf("Content-type: text/html\n"
362 "Server: %s\n", SERVER
365 wprintf("Connection: close\n"
367 "Cache-Control: no-store\n"
371 stuff_to_cookie(cookie, WC->wc_session, WC->wc_username,
372 WC->wc_password, WC->wc_roomname);
375 wprintf("Set-cookie: webcit=%s; path=/\n", unset);
377 wprintf("Set-cookie: webcit=%s; path=/\n", cookie);
378 if (server_cookie != NULL) {
379 wprintf("%s\n", server_cookie);
387 svprintf("REFRESHTAG", WCS_STRING, "%s",
388 "<meta http-equiv=\"refresh\" content=\"30\" />\n");
391 svprintf("REFRESHTAG", WCS_STRING, "%s",
392 "<meta http-equiv=\"refresh\" content=\"500363689;\" />\n");
401 if (WC->HaveInstantMessages) {
402 wprintf("<div id=\"page_popup\">\n");
406 if ( (WC->logged_in) && (!unset_cookies) ) {
407 wprintf("<div id=\"iconbar\">");
411 if (do_room_banner == 1) {
412 wprintf("<div id=\"banner\">\n");
413 embed_room_banner(NULL, navbar_default);
418 if (do_room_banner != 2) {
419 wprintf("<div id=\"content\">\n");
422 if (strlen(WC->ImportantMessage) > 0) {
423 do_template("beginbox_nt");
424 wprintf("<SPAN CLASS=\"errormsg\">"
425 "%s</SPAN><br />\n", WC->ImportantMessage);
426 do_template("endbox");
427 strcpy(WC->ImportantMessage, "");
435 * Generic function to do an HTTP redirect. Easy and fun.
437 void http_redirect(char *whichpage) {
438 wprintf("HTTP/1.0 302 Moved Temporarily\n");
439 wprintf("Location: %s\n", whichpage);
440 wprintf("URI: %s\n", whichpage);
441 wprintf("Content-type: text/html\n\n");
442 wprintf("<html><body>\n");
443 wprintf("you really want to be <A HREF=\"%s\">here</A> now\n",
445 wprintf("</body></html>\n");
450 void check_for_instant_messages()
456 if (buf[3] == '*') WC->HaveInstantMessages = 1;
463 * Output a piece of content to the web browser
465 void http_transmit_thing(char *thing, size_t length, char *content_type,
468 output_headers(0, 0, 0, 0, 0, 0, 1);
471 output_headers(0, 0, 0, 0, 0, 0, 0);
473 wprintf("Content-type: %s\n"
474 "Content-length: %ld\n"
476 "Connection: close\n"
482 client_write(thing, (size_t)length);
488 void output_static(char *what)
495 char content_type[SIZ];
497 sprintf(buf, "static/%s", what);
498 fp = fopen(buf, "rb");
500 wprintf("HTTP/1.0 404 %s\n", strerror(errno));
501 wprintf("Content-Type: text/plain\n");
503 wprintf("Cannot open %s: %s\n", what, strerror(errno));
505 if (!strncasecmp(&what[strlen(what) - 4], ".gif", 4))
506 strcpy(content_type, "image/gif");
507 else if (!strncasecmp(&what[strlen(what) - 4], ".txt", 4))
508 strcpy(content_type, "text/plain");
509 else if (!strncasecmp(&what[strlen(what) - 4], ".css", 4))
510 strcpy(content_type, "text/css");
511 else if (!strncasecmp(&what[strlen(what) - 4], ".jpg", 4))
512 strcpy(content_type, "image/jpeg");
513 else if (!strncasecmp(&what[strlen(what) - 4], ".png", 4))
514 strcpy(content_type, "image/png");
515 else if (!strncasecmp(&what[strlen(what) - 4], ".ico", 4))
516 strcpy(content_type, "image/x-icon");
517 else if (!strncasecmp(&what[strlen(what) - 5], ".html", 5))
518 strcpy(content_type, "text/html");
519 else if (!strncasecmp(&what[strlen(what) - 4], ".htm", 4))
520 strcpy(content_type, "text/html");
521 else if (!strncasecmp(&what[strlen(what) - 4], ".wml", 4))
522 strcpy(content_type, "text/vnd.wap.wml");
523 else if (!strncasecmp(&what[strlen(what) - 5], ".wmls", 5))
524 strcpy(content_type, "text/vnd.wap.wmlscript");
525 else if (!strncasecmp(&what[strlen(what) - 5], ".wmlc", 5))
526 strcpy(content_type, "application/vnd.wap.wmlc");
527 else if (!strncasecmp(&what[strlen(what) - 6], ".wmlsc", 6))
528 strcpy(content_type, "application/vnd.wap.wmlscriptc");
529 else if (!strncasecmp(&what[strlen(what) - 5], ".wbmp", 5))
530 strcpy(content_type, "image/vnd.wap.wbmp");
531 else if (!strncasecmp(&what[strlen(what) - 3], ".js", 3))
532 strcpy(content_type, "text/javascript");
534 strcpy(content_type, "application/octet-stream");
536 fstat(fileno(fp), &statbuf);
537 bytes = statbuf.st_size;
538 lprintf(3, "Static: %s, (%s; %ld bytes)\n", what, content_type, bytes);
539 bigbuffer = malloc(bytes + 2);
540 fread(bigbuffer, bytes, 1, fp);
543 http_transmit_thing(bigbuffer, (size_t)bytes, content_type, 1);
546 if (!strcasecmp(bstr("force_close_session"), "yes")) {
547 end_webcit_session();
553 * When the browser requests an image file from the Citadel server,
554 * this function is called to transmit it.
559 char *xferbuf = NULL;
562 serv_printf("OIMG %s|%s", bstr("name"), bstr("parm"));
565 bytes = extract_long(&buf[4], 0);
566 xferbuf = malloc(bytes + 2);
568 /* Read it from the server */
569 read_server_binary(xferbuf, bytes);
573 /* Write it to the browser */
574 http_transmit_thing(xferbuf, (size_t)bytes, "image/gif", 0);
579 /* Instead of an ugly 404, send a 1x1 transparent GIF
580 * when there's no such image on the server.
582 output_static("blank.gif");
585 wprintf("HTTP/1.0 404 %s\n", &buf[4]);
586 output_headers(0, 0, 0, 0, 0, 0, 0);
587 wprintf("Content-Type: text/plain\n"
589 "Error retrieving image: %s\n",
602 void output_mimepart()
606 char content_type[SIZ];
607 char *content = NULL;
609 serv_printf("OPNA %s|%s", bstr("msgnum"), bstr("partnum"));
612 bytes = extract_long(&buf[4], 0);
613 content = malloc(bytes + 2);
614 extract(content_type, &buf[4], 3);
615 output_headers(0, 0, 0, 0, 0, 0, 0);
616 read_server_binary(content, bytes);
619 http_transmit_thing(content, bytes, content_type, 0);
622 wprintf("HTTP/1.0 404 %s\n", &buf[4]);
623 output_headers(0, 0, 0, 0, 0, 0, 0);
624 wprintf("Content-Type: text/plain\n");
626 wprintf("Error retrieving part: %s\n", &buf[4]);
634 char *load_mimepart(long msgnum, char *partnum)
638 char content_type[SIZ];
641 serv_printf("OPNA %ld|%s", msgnum, partnum);
644 bytes = extract_long(&buf[4], 0);
645 extract(content_type, &buf[4], 3);
647 content = malloc(bytes + 2);
648 read_server_binary(content, bytes);
652 content[bytes] = 0; /* null terminate for good measure */
663 * Convenience functions to display a page containing only a string
665 void convenience_page(char *titlebarcolor, char *titlebarmsg, char *messagetext)
667 wprintf("HTTP/1.0 200 OK\n");
668 output_headers(1, 1, 2, 0, 0, 0, 0);
669 wprintf("<div id=\"banner\">\n");
670 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#%s\"><TR><TD>", titlebarcolor);
671 wprintf("<SPAN CLASS=\"titlebar\">%s</SPAN>\n", titlebarmsg);
672 wprintf("</TD></TR></TABLE>\n");
673 wprintf("</div>\n<div id=\"content\">\n");
674 escputs(messagetext);
682 * Display a blank page.
684 void blank_page(void) {
685 output_headers(1, 1, 0, 0, 1, 0, 0);
691 * A template has been requested
693 void url_do_template(void) {
694 do_template(bstr("template"));
700 * Offer to make any page the user's "start page."
702 void offer_start_page(void) {
703 wprintf("<A HREF=\"/change_start_page?startpage=");
704 urlescputs(WC->this_page);
706 "<FONT SIZE=-2 COLOR=\"#AAAAAA\">Make this my start page</FONT>"
713 * Change the user's start page
715 void change_start_page(void) {
717 if (bstr("startpage") == NULL) {
718 strcpy(WC->ImportantMessage,
719 "startpage set to null");
724 set_preference("startpage", bstr("startpage"));
726 output_headers(1, 1, 0, 0, 0, 0, 0);
727 do_template("newstartpage");
734 void display_success(char *successmessage)
736 convenience_page("007700", "OK", successmessage);
741 void extract_action(char *actbuf, char *cmdbuf)
745 strcpy(actbuf, cmdbuf);
746 if (!strncasecmp(actbuf, "GET /", 5))
747 strcpy(actbuf, &actbuf[5]);
748 if (!strncasecmp(actbuf, "PUT /", 5))
749 strcpy(actbuf, &actbuf[5]);
750 if (!strncasecmp(actbuf, "POST /", 6))
751 strcpy(actbuf, &actbuf[6]);
753 for (i = 0; i < strlen(actbuf); ++i) {
754 if (actbuf[i] == ' ') {
758 if (actbuf[i] == '/') {
762 if (actbuf[i] == '?') {
766 if (actbuf[i] == '&') {
774 void upload_handler(char *name, char *filename, char *partnum, char *disp,
775 void *content, char *cbtype, size_t length,
776 char *encoding, void *userdata)
778 struct urlcontent *u;
781 if ( (length > 0) && (strlen(cbtype) == 0) ) {
782 u = (struct urlcontent *) malloc(sizeof(struct urlcontent));
783 u->next = WC->urlstrings;
785 safestrncpy(u->url_key, name, sizeof(u->url_key));
786 u->url_data = malloc(length + 1);
787 memcpy(u->url_data, content, length);
788 u->url_data[length] = 0;
792 if ( (length > 0) && (strlen(cbtype) > 0) ) {
793 WC->upload = malloc(length);
794 if (WC->upload != NULL) {
795 WC->upload_length = length;
796 safestrncpy(WC->upload_filename, filename,
797 sizeof(WC->upload_filename));
798 safestrncpy(WC->upload_content_type, cbtype,
799 sizeof(WC->upload_content_type));
800 memcpy(WC->upload, content, length);
803 lprintf(3, "malloc() failed: %s\n", strerror(errno));
813 * Entry point for WebCit transaction
815 void session_loop(struct httprequest *req)
821 int ContentLength = 0;
823 char ContentType[512];
826 struct httprequest *hptr;
827 char browser_host[SIZ];
828 char user_agent[SIZ];
831 /* We stuff these with the values coming from the client cookies,
832 * so we can use them to reconnect a timed out session if we have to.
834 char c_username[SIZ];
835 char c_password[SIZ];
836 char c_roomname[SIZ];
839 strcpy(c_username, "");
840 strcpy(c_password, "");
841 strcpy(c_roomname, "");
843 WC->upload_length = 0;
850 if (hptr == NULL) return;
852 strcpy(cmd, hptr->line);
854 extract_action(action, cmd);
856 while (hptr != NULL) {
857 strcpy(buf, hptr->line);
860 if (!strncasecmp(buf, "Cookie: webcit=", 15)) {
861 safestrncpy(cookie, &buf[15], sizeof cookie);
862 cookie_to_stuff(cookie, NULL,
863 c_username, c_password, c_roomname);
865 else if (!strncasecmp(buf, "Content-length: ", 16)) {
866 ContentLength = atoi(&buf[16]);
868 else if (!strncasecmp(buf, "Content-type: ", 14)) {
869 safestrncpy(ContentType, &buf[14], sizeof ContentType);
871 else if (!strncasecmp(buf, "User-agent: ", 12)) {
872 safestrncpy(user_agent, &buf[12], sizeof user_agent);
874 else if (!strncasecmp(buf, "Host: ", 6)) {
875 safestrncpy(WC->http_host, &buf[6], sizeof WC->http_host);
877 /* Only WAP gateways explicitly name this content-type */
878 else if (strstr(buf, "text/vnd.wap.wml")) {
883 if (ContentLength > 0) {
884 content = malloc(ContentLength + SIZ);
885 memset(content, 0, ContentLength + SIZ);
886 sprintf(content, "Content-type: %s\n"
887 "Content-length: %d\n\n",
888 ContentType, ContentLength);
889 body_start = strlen(content);
893 while (BytesRead < ContentLength) {
894 a=read(WC->http_sock, &content[BytesRead+body_start],
895 ContentLength - BytesRead);
896 if (a <= 0) BytesRead = ContentLength;
901 /* Now we're daring and read it all at once. */
902 client_read(WC->http_sock, &content[BytesRead+body_start], ContentLength);
904 if (!strncasecmp(ContentType,
905 "application/x-www-form-urlencoded", 33)) {
906 addurls(&content[body_start]);
907 } else if (!strncasecmp(ContentType, "multipart", 9)) {
908 content_end = content + ContentLength + body_start;
909 mime_parser(content, content_end, *upload_handler,
910 NULL, NULL, NULL, 0);
916 /* make a note of where we are in case the user wants to save it */
917 safestrncpy(WC->this_page, cmd, sizeof(WC->this_page));
918 remove_token(WC->this_page, 2, ' ');
919 remove_token(WC->this_page, 0, ' ');
921 /* If there are variables in the URL, we must grab them now */
922 for (a = 0; a < strlen(cmd); ++a) {
923 if ((cmd[a] == '?') || (cmd[a] == '&')) {
924 for (b = a; b < strlen(cmd); ++b)
927 addurls(&cmd[a + 1]);
932 /* Static content can be sent without connecting to Citadel. */
933 if (!strcasecmp(action, "static")) {
934 strcpy(buf, &cmd[12]);
935 for (a = 0; a < strlen(buf); ++a)
939 goto SKIP_ALL_THIS_CRAP; /* Don't try to connect */
943 * If we're not connected to a Citadel server, try to hook up the
946 if (!WC->connected) {
947 if (!strcasecmp(ctdlhost, "uds")) {
948 /* unix domain socket */
949 sprintf(buf, "%s/citadel.socket", ctdlport);
950 WC->serv_sock = uds_connectsock(buf);
954 WC->serv_sock = tcp_connectsock(ctdlhost, ctdlport);
957 if (WC->serv_sock < 0) {
959 goto SKIP_ALL_THIS_CRAP;
963 serv_gets(buf); /* get the server welcome message */
964 locate_host(browser_host, WC->http_sock);
965 get_serv_info(browser_host, user_agent);
966 if (serv_info.serv_rev_level < MINIMUM_CIT_VERSION) {
967 wprintf("You are connected to a Citadel "
968 "server running Citadel %d.%02d;\nin "
969 "order to run this version of WebCit "
970 "you must also have Citadel %d.%02d or"
972 serv_info.serv_rev_level / 100,
973 serv_info.serv_rev_level % 100,
974 MINIMUM_CIT_VERSION / 100,
975 MINIMUM_CIT_VERSION % 100
977 end_webcit_session();
978 goto SKIP_ALL_THIS_CRAP;
984 * Functions which can be performed without logging in
986 if (!strcasecmp(action, "listsub")) {
988 goto SKIP_ALL_THIS_CRAP;
990 #ifdef WEBCIT_WITH_CALENDAR_SERVICE
991 if (!strcasecmp(action, "freebusy")) {
993 goto SKIP_ALL_THIS_CRAP;
997 check_for_instant_messages();
1000 * If we're not logged in, but we have username and password cookies
1001 * supplied by the browser, try using them to log in.
1003 if ((!WC->logged_in) && (strlen(c_username) > 0) && (strlen(c_password) > 0)) {
1004 serv_printf("USER %s", c_username);
1006 if (buf[0] == '3') {
1007 serv_printf("PASS %s", c_password);
1009 if (buf[0] == '2') {
1010 become_logged_in(c_username, c_password, buf);
1015 * If we don't have a current room, but a cookie specifying the
1016 * current room is supplied, make an effort to go there.
1018 if ((strlen(WC->wc_roomname) == 0) && (strlen(c_roomname) > 0)) {
1019 serv_printf("GOTO %s", c_roomname);
1021 if (buf[0] == '2') {
1022 strcpy(WC->wc_roomname, c_roomname);
1026 if (!strcasecmp(action, "image")) {
1030 * All functions handled below this point ... make sure we log in
1031 * before doing anything else!
1033 } else if ((!WC->logged_in) && (!strcasecmp(action, "login"))) {
1035 } else if (!WC->logged_in) {
1036 display_login(NULL);
1040 * Various commands...
1043 else if (!strcasecmp(action, "do_welcome")) {
1045 } else if (!strcasecmp(action, "blank")) {
1047 } else if (!strcasecmp(action, "do_template")) {
1049 } else if (!strcasecmp(action, "display_main_menu")) {
1050 display_main_menu();
1051 } else if (!strcasecmp(action, "whobbs")) {
1053 } else if (!strcasecmp(action, "knrooms")) {
1055 } else if (!strcasecmp(action, "gotonext")) {
1058 } else if (!strcasecmp(action, "skip")) {
1060 } else if (!strcasecmp(action, "ungoto")) {
1062 } else if (!strcasecmp(action, "dotgoto")) {
1064 smart_goto(bstr("room"));
1065 } else if (!strcasecmp(action, "dotskip")) {
1066 smart_goto(bstr("room"));
1067 } else if (!strcasecmp(action, "termquit")) {
1069 } else if (!strcasecmp(action, "readnew")) {
1070 readloop("readnew");
1071 } else if (!strcasecmp(action, "readold")) {
1072 readloop("readold");
1073 } else if (!strcasecmp(action, "readfwd")) {
1074 readloop("readfwd");
1075 } else if (!strcasecmp(action, "headers")) {
1076 readloop("headers");
1077 } else if (!strcasecmp(action, "display_enter")) {
1079 } else if (!strcasecmp(action, "post")) {
1081 } else if (!strcasecmp(action, "do_stuff_to_one_msg")) {
1082 do_stuff_to_one_msg();
1083 } else if (!strcasecmp(action, "move_msg")) {
1085 } else if (!strcasecmp(action, "userlist")) {
1087 } else if (!strcasecmp(action, "showuser")) {
1089 } else if (!strcasecmp(action, "display_page")) {
1091 } else if (!strcasecmp(action, "page_user")) {
1093 } else if (!strcasecmp(action, "chat")) {
1095 } else if (!strcasecmp(action, "display_private")) {
1096 display_private("", 0);
1097 } else if (!strcasecmp(action, "goto_private")) {
1099 } else if (!strcasecmp(action, "zapped_list")) {
1101 } else if (!strcasecmp(action, "display_zap")) {
1103 } else if (!strcasecmp(action, "zap")) {
1105 } else if (!strcasecmp(action, "display_entroom")) {
1107 } else if (!strcasecmp(action, "entroom")) {
1109 } else if (!strcasecmp(action, "display_editroom")) {
1111 } else if (!strcasecmp(action, "netedit")) {
1113 } else if (!strcasecmp(action, "editroom")) {
1115 } else if (!strcasecmp(action, "display_whok")) {
1117 } else if (!strcasecmp(action, "display_editinfo")) {
1118 display_edit("Room info", "EINF 0", "RINF", "/editinfo", 1);
1119 } else if (!strcasecmp(action, "editinfo")) {
1120 save_edit("Room info", "EINF 1", 1);
1121 } else if (!strcasecmp(action, "display_editbio")) {
1122 sprintf(buf, "RBIO %s", WC->wc_username);
1123 display_edit("Your bio", "NOOP", buf, "editbio", 3);
1124 } else if (!strcasecmp(action, "editbio")) {
1125 save_edit("Your bio", "EBIO", 0);
1126 } else if (!strcasecmp(action, "confirm_delete_room")) {
1127 confirm_delete_room();
1128 } else if (!strcasecmp(action, "delete_room")) {
1130 } else if (!strcasecmp(action, "validate")) {
1132 } else if (!strcasecmp(action, "display_editpic")) {
1133 display_graphics_upload("your photo",
1136 } else if (!strcasecmp(action, "editpic")) {
1137 do_graphics_upload("UIMG 1|_userpic_");
1138 } else if (!strcasecmp(action, "display_editroompic")) {
1139 display_graphics_upload("the graphic for this room",
1142 } else if (!strcasecmp(action, "editroompic")) {
1143 do_graphics_upload("UIMG 1|_roompic_");
1144 } else if (!strcasecmp(action, "delete_floor")) {
1146 } else if (!strcasecmp(action, "rename_floor")) {
1148 } else if (!strcasecmp(action, "create_floor")) {
1150 } else if (!strcasecmp(action, "display_editfloorpic")) {
1151 sprintf(buf, "UIMG 0|_floorpic_|%s",
1152 bstr("which_floor"));
1153 display_graphics_upload("the graphic for this floor",
1156 } else if (!strcasecmp(action, "editfloorpic")) {
1157 sprintf(buf, "UIMG 1|_floorpic_|%s",
1158 bstr("which_floor"));
1159 do_graphics_upload(buf);
1160 } else if (!strcasecmp(action, "display_reg")) {
1162 } else if (!strcasecmp(action, "display_changepw")) {
1164 } else if (!strcasecmp(action, "changepw")) {
1166 } else if (!strcasecmp(action, "display_edit_node")) {
1167 display_edit_node();
1168 } else if (!strcasecmp(action, "edit_node")) {
1170 } else if (!strcasecmp(action, "display_netconf")) {
1172 } else if (!strcasecmp(action, "display_confirm_delete_node")) {
1173 display_confirm_delete_node();
1174 } else if (!strcasecmp(action, "delete_node")) {
1176 } else if (!strcasecmp(action, "display_add_node")) {
1178 } else if (!strcasecmp(action, "add_node")) {
1180 } else if (!strcasecmp(action, "terminate_session")) {
1182 terminate_session();
1183 } else if (!strcasecmp(action, "edit_me")) {
1185 } else if (!strcasecmp(action, "display_siteconfig")) {
1186 display_siteconfig();
1187 } else if (!strcasecmp(action, "chat_recv")) {
1189 } else if (!strcasecmp(action, "chat_send")) {
1191 } else if (!strcasecmp(action, "siteconfig")) {
1193 } else if (!strcasecmp(action, "display_generic")) {
1195 } else if (!strcasecmp(action, "do_generic")) {
1197 } else if (!strcasecmp(action, "display_menubar")) {
1199 } else if (!strcasecmp(action, "output_mimepart")) {
1201 } else if (!strcasecmp(action, "edit_vcard")) {
1203 } else if (!strcasecmp(action, "submit_vcard")) {
1205 } else if (!strcasecmp(action, "select_user_to_edit")) {
1206 select_user_to_edit(NULL, NULL);
1207 } else if (!strcasecmp(action, "display_edituser")) {
1208 display_edituser(NULL, 0);
1209 } else if (!strcasecmp(action, "edituser")) {
1211 } else if (!strcasecmp(action, "create_user")) {
1213 } else if (!strcasecmp(action, "changeview")) {
1215 } else if (!strcasecmp(action, "do_stuff_to_msgs")) {
1217 } else if (!strcasecmp(action, "change_start_page")) {
1218 change_start_page();
1219 } else if (!strcasecmp(action, "display_floorconfig")) {
1220 display_floorconfig(NULL);
1221 } else if (!strcasecmp(action, "toggle_self_service")) {
1222 toggle_self_service();
1223 #ifdef WEBCIT_WITH_CALENDAR_SERVICE
1224 } else if (!strcasecmp(action, "display_edit_task")) {
1225 display_edit_task();
1226 } else if (!strcasecmp(action, "save_task")) {
1228 } else if (!strcasecmp(action, "display_edit_event")) {
1229 display_edit_event();
1230 } else if (!strcasecmp(action, "save_event")) {
1232 } else if (!strcasecmp(action, "respond_to_request")) {
1233 respond_to_request();
1234 } else if (!strcasecmp(action, "handle_rsvp")) {
1237 } else if (!strcasecmp(action, "summary")) {
1239 } else if (!strcasecmp(action, "iconbar")) {
1241 } else if (!strcasecmp(action, "display_customize_iconbar")) {
1242 display_customize_iconbar();
1243 } else if (!strcasecmp(action, "commit_iconbar")) {
1245 } else if (!strcasecmp(action, "set_room_policy")) {
1247 } else if (!strcasecmp(action, "display_inetconf")) {
1249 } else if (!strcasecmp(action, "save_inetconf")) {
1251 } else if (!strcasecmp(action, "diagnostics")) {
1252 output_headers(1, 1, 1, 0, 0, 0, 0);
1254 wprintf("You're in session %d<hr />\n", WC->wc_session);
1255 wprintf("Command: <br /><PRE>\n");
1257 wprintf("</PRE><hr />\n");
1258 wprintf("Variables: <br /><PRE>\n");
1260 wprintf("</PRE><hr />\n");
1263 /* When all else fais, display the main menu. */
1265 display_main_menu();
1270 if (content != NULL) {
1275 if (WC->upload_length > 0) {
1277 WC->upload_length = 0;