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 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 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(2 * strlen(strbuf));
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(2 * strlen(strbuf));
331 msgesc(outbuf, strbuf);
332 wprintf("%s", outbuf);
340 * Output all that important stuff that the browser will want to see
345 * 0 = Nothing. Do not display any leading HTTP or HTML.
346 * 1 = HTTP headers plus the room banner
347 * 2 = HTTP headers required to terminate the session (unset cookies)
348 * 3 = HTTP and HTML headers, but no room banner
350 * Bit 2: Set to 1 to auto-refresh page every 30 seconds
351 * Bit 3: suppress check for express messages
352 * Bit 4: Allow browser to cache this document
355 void output_headers(int controlcode)
358 int print_standard_html_head = 0;
360 int suppress_check = 0;
363 char onload_fcn[SIZ];
364 static int pageseq = 0;
365 print_standard_html_head = controlcode & 0x03;
366 refresh30 = ((controlcode & 0x04) >> 2);
367 suppress_check = ((controlcode & 0x08) >> 3);
368 cache = ((controlcode & 0x10) >> 4);
370 wprintf("HTTP/1.0 200 OK\n");
372 httpdate(httpnow, time(NULL));
374 if (print_standard_html_head > 0) {
375 wprintf("Content-type: text/html\n"
376 "Server: %s\n", SERVER
379 wprintf("Connection: close\n"
381 "Cache-Control: no-store\n"
385 stuff_to_cookie(cookie, WC->wc_session, WC->wc_username,
386 WC->wc_password, WC->wc_roomname);
388 if (print_standard_html_head == 2) {
389 wprintf("Set-cookie: webcit=%s\n", unset);
391 wprintf("Set-cookie: webcit=%s\n", cookie);
392 if (server_cookie != NULL) {
393 wprintf("%s\n", server_cookie);
397 if (print_standard_html_head > 0) {
400 if (refresh30) svprintf("REFRESHTAG", WCS_STRING,
401 "<META HTTP-EQUIV=\"refresh\" CONTENT=\"30\">\n");
402 else svprintf("REFRESHTAG", WCS_STRING,
403 "<META HTTP-EQUIV=\"refresh\" CONTENT=\"500363689;\">\n");
404 /* script for checking for pages (not always launched) */
406 sprintf(onload_fcn, "function onload_fcn() { \n");
407 if (!WC->outside_frameset_allowed) {
408 strcat(onload_fcn, " force_frameset(); \n");
410 if (!suppress_check) if (WC->HaveExpressMessages) {
411 strcat(onload_fcn, " launch_page_popup(); \n");
412 WC->HaveExpressMessages = 0;
414 strcat(onload_fcn, "} \n");
416 svprintf("PAGERSCRIPT", WCS_STRING,
417 "<SCRIPT LANGUAGE=\"JavaScript\">\n"
418 "function launch_page_popup() {\n"
419 "pwin = window.open('/page_popup', 'CitaPage%d', "
420 "'toolbar=no,location=no,copyhistory=no,status=no,"
421 "scrollbars=yes,resizable=no,height=250,width=400');\n"
423 "function force_frameset() { \n"
424 " if (top.frames.length == 0) { \n"
425 " top.location.replace('/do_welcome'); \n"
437 clear_local_substs();
439 svprintf("extrabodyparms", WCS_STRING, "%s",
440 "onload='onload_fcn();' ");
442 do_template("background");
443 clear_local_substs();
446 if (print_standard_html_head == 1) {
447 wprintf("<A NAME=\"TheTop\"></A>");
448 embed_room_banner(NULL);
451 if (strlen(WC->ImportantMessage) > 0) {
452 do_template("beginbox_nt");
453 wprintf("<SPAN CLASS=\"errormsg\">"
454 "%s</SPAN><BR>\n", WC->ImportantMessage);
455 do_template("endbox");
456 strcpy(WC->ImportantMessage, "");
464 void http_redirect(char *whichpage) {
465 wprintf("HTTP/1.0 302 Moved Temporarily\n");
466 wprintf("Location: %s\n", whichpage);
467 wprintf("URI: %s\n", whichpage);
468 wprintf("Content-type: text/html\n\n");
469 wprintf("<html><body>\n");
470 wprintf("you really want to be <A HREF=\"%s\">here</A> now\n",
472 wprintf("</body></html>\n");
477 void check_for_express_messages()
483 if (buf[3] == '*') WC->HaveExpressMessages = 1;
490 * Output a piece of content to the web browser
492 void http_transmit_thing(char *thing, size_t length, char *content_type,
494 output_headers(is_static ? 0x10 : 0x00);
495 wprintf("Content-type: %s\n"
496 "Content-length: %ld\n"
498 "Connection: close\n"
504 client_write(thing, (size_t)length);
510 void output_static(char *what)
517 char content_type[SIZ];
519 lprintf(9, "output_static(%s)\n", what);
520 sprintf(buf, "static/%s", what);
521 fp = fopen(buf, "rb");
523 wprintf("HTTP/1.0 404 %s\n", strerror(errno));
524 wprintf("Content-Type: text/plain\n");
526 wprintf("Cannot open %s: %s\n", what, strerror(errno));
528 if (!strncasecmp(&what[strlen(what) - 4], ".gif", 4))
529 strcpy(content_type, "image/gif");
530 else if (!strncasecmp(&what[strlen(what) - 4], ".txt", 4))
531 strcpy(content_type, "text/plain");
532 else if (!strncasecmp(&what[strlen(what) - 4], ".css", 4))
533 strcpy(content_type, "text/css");
534 else if (!strncasecmp(&what[strlen(what) - 4], ".jpg", 4))
535 strcpy(content_type, "image/jpeg");
536 else if (!strncasecmp(&what[strlen(what) - 4], ".png", 4))
537 strcpy(content_type, "image/png");
538 else if (!strncasecmp(&what[strlen(what) - 4], ".ico", 4))
539 strcpy(content_type, "image/x-icon");
540 else if (!strncasecmp(&what[strlen(what) - 5], ".html", 5))
541 strcpy(content_type, "text/html");
542 else if (!strncasecmp(&what[strlen(what) - 4], ".htm", 4))
543 strcpy(content_type, "text/html");
544 else if (!strncasecmp(&what[strlen(what) - 4], ".wml", 4))
545 strcpy(content_type, "text/vnd.wap.wml");
546 else if (!strncasecmp(&what[strlen(what) - 5], ".wmls", 5))
547 strcpy(content_type, "text/vnd.wap.wmlscript");
548 else if (!strncasecmp(&what[strlen(what) - 5], ".wmlc", 5))
549 strcpy(content_type, "application/vnd.wap.wmlc");
550 else if (!strncasecmp(&what[strlen(what) - 6], ".wmlsc", 6))
551 strcpy(content_type, "application/vnd.wap.wmlscriptc");
552 else if (!strncasecmp(&what[strlen(what) - 5], ".wbmp", 5))
553 strcpy(content_type, "image/vnd.wap.wbmp");
554 else if (!strncasecmp(&what[strlen(what) - 3], ".js", 3))
555 strcpy(content_type, "text/javascript");
557 strcpy(content_type, "application/octet-stream");
559 fstat(fileno(fp), &statbuf);
560 bytes = statbuf.st_size;
561 lprintf(3, "Static: %s, %ld bytes\n", what, bytes);
562 bigbuffer = malloc(bytes);
563 fread(bigbuffer, bytes, 1, fp);
566 http_transmit_thing(bigbuffer, (size_t)bytes, content_type, 1);
569 if (!strcasecmp(bstr("force_close_session"), "yes")) {
570 end_webcit_session();
576 * When the browser requests an image file from the Citadel server,
577 * this function is called to transmit it.
582 char *xferbuf = NULL;
585 serv_printf("OIMG %s|%s", bstr("name"), bstr("parm"));
588 bytes = extract_long(&buf[4], 0);
589 xferbuf = malloc(bytes);
591 /* Read it from the server */
592 read_server_binary(xferbuf, bytes);
596 /* Write it to the browser */
597 http_transmit_thing(xferbuf, (size_t)bytes, "image/gif", 0);
602 /* Instead of an ugly 404, send a 1x1 transparent GIF
603 * when there's no such image on the server.
605 output_static("blank.gif");
608 wprintf("HTTP/1.0 404 %s\n", &buf[4]);
610 wprintf("Content-Type: text/plain\n"
612 "Error retrieving image: %s\n",
625 void output_mimepart()
629 char content_type[SIZ];
630 char *content = NULL;
632 serv_printf("OPNA %s|%s", bstr("msgnum"), bstr("partnum"));
635 bytes = extract_long(&buf[4], 0);
636 content = malloc(bytes);
637 extract(content_type, &buf[4], 3);
639 read_server_binary(content, bytes);
642 http_transmit_thing(content, bytes, content_type, 0);
645 wprintf("HTTP/1.0 404 %s\n", &buf[4]);
647 wprintf("Content-Type: text/plain\n");
649 wprintf("Error retrieving part: %s\n", &buf[4]);
657 char *load_mimepart(long msgnum, char *partnum)
661 char content_type[SIZ];
664 serv_printf("OPNA %ld|%s", msgnum, partnum);
667 bytes = extract_long(&buf[4], 0);
668 extract(content_type, &buf[4], 3);
670 content = malloc(bytes + 1);
671 read_server_binary(content, bytes);
675 content[bytes] = 0; /* null terminate for good measure */
686 * Convenience functions to display a page containing only a string
688 void convenience_page(char *titlebarcolor, char *titlebarmsg, char *messagetext)
690 wprintf("HTTP/1.0 200 OK\n");
692 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#%s\"><TR><TD>", titlebarcolor);
693 wprintf("<SPAN CLASS=\"titlebar\">%s</SPAN>\n", titlebarmsg);
694 wprintf("</TD></TR></TABLE><BR>\n");
695 escputs(messagetext);
703 * Display a blank page.
705 void blank_page(void) {
712 * A template has been requested
714 void url_do_template(void) {
715 do_template(bstr("template"));
721 * Offer to make any page the user's "start page."
723 void offer_start_page(void) {
724 wprintf("<A HREF=\"/change_start_page?startpage=");
725 urlescputs(WC->this_page);
727 "<FONT SIZE=-2 COLOR=\"#AAAAAA\">Make this my start page</FONT>"
734 * Change the user's start page
736 void change_start_page(void) {
738 if (bstr("startpage") == NULL) {
739 strcpy(WC->ImportantMessage,
740 "startpage set to null");
745 set_preference("startpage", bstr("startpage"));
748 do_template("newstartpage");
755 void display_success(char *successmessage)
757 convenience_page("007700", "OK", successmessage);
762 void extract_action(char *actbuf, char *cmdbuf)
766 strcpy(actbuf, cmdbuf);
767 if (!strncasecmp(actbuf, "GET /", 5))
768 strcpy(actbuf, &actbuf[5]);
769 if (!strncasecmp(actbuf, "PUT /", 5))
770 strcpy(actbuf, &actbuf[5]);
771 if (!strncasecmp(actbuf, "POST /", 6))
772 strcpy(actbuf, &actbuf[6]);
774 for (i = 0; i < strlen(actbuf); ++i) {
775 if (actbuf[i] == ' ') {
779 if (actbuf[i] == '/') {
783 if (actbuf[i] == '?') {
787 if (actbuf[i] == '&') {
795 void upload_handler(char *name, char *filename, char *partnum, char *disp,
796 void *content, char *cbtype, size_t length,
797 char *encoding, void *userdata)
799 struct urlcontent *u;
802 if ( (length > 0) && (strlen(cbtype) == 0) ) {
803 u = (struct urlcontent *) malloc(sizeof(struct urlcontent));
804 u->next = WC->urlstrings;
806 safestrncpy(u->url_key, name, sizeof(u->url_key));
807 u->url_data = malloc(length + 1);
808 memcpy(u->url_data, content, length);
809 u->url_data[length] = 0;
813 if ( (length > 0) && (strlen(cbtype) > 0) ) {
814 WC->upload = malloc(length);
815 if (WC->upload != NULL) {
816 WC->upload_length = length;
817 safestrncpy(WC->upload_filename, filename,
818 sizeof(WC->upload_filename));
819 safestrncpy(WC->upload_content_type, cbtype,
820 sizeof(WC->upload_content_type));
821 memcpy(WC->upload, content, length);
824 lprintf(3, "malloc() failed: %s\n", strerror(errno));
834 * Entry point for WebCit transaction
836 void session_loop(struct httprequest *req)
842 int ContentLength = 0;
844 char ContentType[512];
847 struct httprequest *hptr;
848 char browser_host[SIZ];
849 char user_agent[SIZ];
852 /* We stuff these with the values coming from the client cookies,
853 * so we can use them to reconnect a timed out session if we have to.
855 char c_username[SIZ];
856 char c_password[SIZ];
857 char c_roomname[SIZ];
860 strcpy(c_username, "");
861 strcpy(c_password, "");
862 strcpy(c_roomname, "");
864 WC->upload_length = 0;
870 if (hptr == NULL) return;
872 strcpy(cmd, hptr->line);
874 extract_action(action, cmd);
876 while (hptr != NULL) {
877 strcpy(buf, hptr->line);
880 if (!strncasecmp(buf, "Cookie: webcit=", 15)) {
881 strcpy(cookie, &buf[15]);
882 cookie_to_stuff(cookie, NULL,
883 c_username, c_password, c_roomname);
885 else if (!strncasecmp(buf, "Content-length: ", 16)) {
886 ContentLength = atoi(&buf[16]);
888 else if (!strncasecmp(buf, "Content-type: ", 14)) {
889 safestrncpy(ContentType, &buf[14], sizeof ContentType);
891 else if (!strncasecmp(buf, "User-agent: ", 12)) {
892 safestrncpy(user_agent, &buf[12], sizeof user_agent);
894 else if (!strncasecmp(buf, "Host: ", 6)) {
895 safestrncpy(WC->http_host, &buf[6], sizeof WC->http_host);
897 /* Only WAP gateways explicitly name this content-type */
898 else if (strstr(buf, "text/vnd.wap.wml")) {
903 if (ContentLength > 0) {
904 content = malloc(ContentLength + SIZ);
905 memset(content, 0, ContentLength + SIZ);
906 sprintf(content, "Content-type: %s\n"
907 "Content-length: %d\n\n",
908 ContentType, ContentLength);
909 body_start = strlen(content);
913 while (BytesRead < ContentLength) {
914 a=read(WC->http_sock, &content[BytesRead+body_start],
915 ContentLength - BytesRead);
916 if (a <= 0) BytesRead = ContentLength;
921 /* Now we're daring and read it all at once. */
922 client_read(WC->http_sock, &content[BytesRead+body_start], ContentLength);
924 if (!strncasecmp(ContentType,
925 "application/x-www-form-urlencoded", 33)) {
926 addurls(&content[body_start]);
927 } else if (!strncasecmp(ContentType, "multipart", 9)) {
928 content_end = content + ContentLength + body_start;
929 mime_parser(content, content_end, *upload_handler,
930 NULL, NULL, NULL, 0);
936 /* make a note of where we are in case the user wants to save it */
937 safestrncpy(WC->this_page, cmd, sizeof(WC->this_page));
938 remove_token(WC->this_page, 2, ' ');
939 remove_token(WC->this_page, 0, ' ');
941 /* If there are variables in the URL, we must grab them now */
942 for (a = 0; a < strlen(cmd); ++a) {
943 if ((cmd[a] == '?') || (cmd[a] == '&')) {
944 for (b = a; b < strlen(cmd); ++b)
947 addurls(&cmd[a + 1]);
952 /* Static content can be sent without connecting to Citadel. */
953 if (!strcasecmp(action, "static")) {
954 strcpy(buf, &cmd[12]);
955 for (a = 0; a < strlen(buf); ++a)
959 goto SKIP_ALL_THIS_CRAP; /* Don't try to connect */
963 * If we're not connected to a Citadel server, try to hook up the
966 if (!WC->connected) {
967 if (!strcasecmp(ctdlhost, "uds")) {
968 /* unix domain socket */
969 sprintf(buf, "%s/citadel.socket", ctdlport);
970 WC->serv_sock = uds_connectsock(buf);
974 WC->serv_sock = tcp_connectsock(ctdlhost, ctdlport);
977 if (WC->serv_sock < 0) {
979 goto SKIP_ALL_THIS_CRAP;
983 serv_gets(buf); /* get the server welcome message */
984 locate_host(browser_host, WC->http_sock);
985 get_serv_info(browser_host, user_agent);
986 if (serv_info.serv_rev_level < MINIMUM_CIT_VERSION) {
987 wprintf("You are connected to a Citadel "
988 "server running Citadel %d.%02d;\nin "
989 "order to run this version of WebCit "
990 "you must also have Citadel %d.%02d or"
992 serv_info.serv_rev_level / 100,
993 serv_info.serv_rev_level % 100,
994 MINIMUM_CIT_VERSION / 100,
995 MINIMUM_CIT_VERSION % 100
997 end_webcit_session();
998 goto SKIP_ALL_THIS_CRAP;
1004 * Functions which can be performed without logging in
1006 if (!strcasecmp(action, "listsub")) {
1008 goto SKIP_ALL_THIS_CRAP;
1010 #ifdef WEBCIT_WITH_CALENDAR_SERVICE
1011 if (!strcasecmp(action, "freebusy")) {
1013 goto SKIP_ALL_THIS_CRAP;
1017 check_for_express_messages();
1020 * If we're not logged in, but we have username and password cookies
1021 * supplied by the browser, try using them to log in.
1023 if ((!WC->logged_in) && (strlen(c_username) > 0) && (strlen(c_password) > 0)) {
1024 serv_printf("USER %s", c_username);
1026 if (buf[0] == '3') {
1027 serv_printf("PASS %s", c_password);
1029 if (buf[0] == '2') {
1030 become_logged_in(c_username, c_password, buf);
1035 * If we don't have a current room, but a cookie specifying the
1036 * current room is supplied, make an effort to go there.
1038 if ((strlen(WC->wc_roomname) == 0) && (strlen(c_roomname) > 0)) {
1039 serv_printf("GOTO %s", c_roomname);
1041 if (buf[0] == '2') {
1042 strcpy(WC->wc_roomname, c_roomname);
1046 if (!strcasecmp(action, "image")) {
1050 * All functions handled below this point ... make sure we log in
1051 * before doing anything else!
1053 } else if ((!WC->logged_in) && (!strcasecmp(action, "login"))) {
1055 } else if (!WC->logged_in) {
1056 display_login(NULL);
1060 * Various commands...
1063 else if (!strcasecmp(action, "do_welcome")) {
1065 } else if (!strcasecmp(action, "blank")) {
1067 } else if (!strcasecmp(action, "do_template")) {
1069 } else if (!strcasecmp(action, "display_main_menu")) {
1070 display_main_menu();
1071 } else if (!strcasecmp(action, "whobbs")) {
1073 } else if (!strcasecmp(action, "knrooms")) {
1075 } else if (!strcasecmp(action, "gotonext")) {
1078 } else if (!strcasecmp(action, "skip")) {
1080 } else if (!strcasecmp(action, "ungoto")) {
1082 } else if (!strcasecmp(action, "dotgoto")) {
1084 smart_goto(bstr("room"));
1085 } else if (!strcasecmp(action, "dotskip")) {
1086 smart_goto(bstr("room"));
1087 } else if (!strcasecmp(action, "termquit")) {
1089 } else if (!strcasecmp(action, "readnew")) {
1090 readloop("readnew");
1091 } else if (!strcasecmp(action, "readold")) {
1092 readloop("readold");
1093 } else if (!strcasecmp(action, "readfwd")) {
1094 readloop("readfwd");
1095 } else if (!strcasecmp(action, "headers")) {
1096 readloop("headers");
1097 } else if (!strcasecmp(action, "display_enter")) {
1099 } else if (!strcasecmp(action, "post")) {
1101 } else if (!strcasecmp(action, "delete_msg")) {
1103 } else if (!strcasecmp(action, "confirm_move_msg")) {
1105 } else if (!strcasecmp(action, "move_msg")) {
1107 } else if (!strcasecmp(action, "userlist")) {
1109 } else if (!strcasecmp(action, "showuser")) {
1111 } else if (!strcasecmp(action, "display_page")) {
1113 } else if (!strcasecmp(action, "page_user")) {
1115 } else if (!strcasecmp(action, "chat")) {
1117 } else if (!strcasecmp(action, "display_private")) {
1118 display_private("", 0);
1119 } else if (!strcasecmp(action, "goto_private")) {
1121 } else if (!strcasecmp(action, "zapped_list")) {
1123 } else if (!strcasecmp(action, "display_zap")) {
1125 } else if (!strcasecmp(action, "zap")) {
1127 } else if (!strcasecmp(action, "display_entroom")) {
1129 } else if (!strcasecmp(action, "entroom")) {
1131 } else if (!strcasecmp(action, "display_editroom")) {
1133 } else if (!strcasecmp(action, "netedit")) {
1135 } else if (!strcasecmp(action, "editroom")) {
1137 } else if (!strcasecmp(action, "display_whok")) {
1139 } else if (!strcasecmp(action, "display_editinfo")) {
1140 display_edit("Room info", "EINF 0", "RINF", "/editinfo", 1);
1141 } else if (!strcasecmp(action, "editinfo")) {
1142 save_edit("Room info", "EINF 1", 1);
1143 } else if (!strcasecmp(action, "display_editbio")) {
1144 sprintf(buf, "RBIO %s", WC->wc_username);
1145 display_edit("Your bio", "NOOP", buf, "editbio", 3);
1146 } else if (!strcasecmp(action, "editbio")) {
1147 save_edit("Your bio", "EBIO", 0);
1148 } else if (!strcasecmp(action, "confirm_delete_room")) {
1149 confirm_delete_room();
1150 } else if (!strcasecmp(action, "delete_room")) {
1152 } else if (!strcasecmp(action, "validate")) {
1154 } else if (!strcasecmp(action, "display_editpic")) {
1155 display_graphics_upload("your photo",
1158 } else if (!strcasecmp(action, "editpic")) {
1159 do_graphics_upload("UIMG 1|_userpic_");
1160 } else if (!strcasecmp(action, "display_editroompic")) {
1161 display_graphics_upload("the graphic for this room",
1164 } else if (!strcasecmp(action, "editroompic")) {
1165 do_graphics_upload("UIMG 1|_roompic_");
1166 } else if (!strcasecmp(action, "delete_floor")) {
1168 } else if (!strcasecmp(action, "rename_floor")) {
1170 } else if (!strcasecmp(action, "create_floor")) {
1172 } else if (!strcasecmp(action, "display_editfloorpic")) {
1173 sprintf(buf, "UIMG 0|_floorpic_|%s",
1174 bstr("which_floor"));
1175 display_graphics_upload("the graphic for this floor",
1178 } else if (!strcasecmp(action, "editfloorpic")) {
1179 sprintf(buf, "UIMG 1|_floorpic_|%s",
1180 bstr("which_floor"));
1181 do_graphics_upload(buf);
1182 } else if (!strcasecmp(action, "display_reg")) {
1184 } else if (!strcasecmp(action, "display_changepw")) {
1186 } else if (!strcasecmp(action, "changepw")) {
1188 } else if (!strcasecmp(action, "display_edit_node")) {
1189 display_edit_node();
1190 } else if (!strcasecmp(action, "edit_node")) {
1192 } else if (!strcasecmp(action, "display_netconf")) {
1194 } else if (!strcasecmp(action, "display_confirm_delete_node")) {
1195 display_confirm_delete_node();
1196 } else if (!strcasecmp(action, "delete_node")) {
1198 } else if (!strcasecmp(action, "display_add_node")) {
1200 } else if (!strcasecmp(action, "add_node")) {
1202 } else if (!strcasecmp(action, "terminate_session")) {
1204 terminate_session();
1205 } else if (!strcasecmp(action, "edit_me")) {
1207 } else if (!strcasecmp(action, "display_siteconfig")) {
1208 display_siteconfig();
1209 } else if (!strcasecmp(action, "chat_recv")) {
1211 } else if (!strcasecmp(action, "chat_send")) {
1213 } else if (!strcasecmp(action, "page_popup")) {
1215 } else if (!strcasecmp(action, "siteconfig")) {
1217 } else if (!strcasecmp(action, "display_generic")) {
1219 } else if (!strcasecmp(action, "do_generic")) {
1221 } else if (!strcasecmp(action, "display_menubar")) {
1223 } else if (!strcasecmp(action, "output_mimepart")) {
1225 } else if (!strcasecmp(action, "edit_vcard")) {
1227 } else if (!strcasecmp(action, "submit_vcard")) {
1229 } else if (!strcasecmp(action, "select_user_to_edit")) {
1230 select_user_to_edit(NULL, NULL);
1231 } else if (!strcasecmp(action, "display_edituser")) {
1232 display_edituser(NULL, 0);
1233 } else if (!strcasecmp(action, "edituser")) {
1235 } else if (!strcasecmp(action, "create_user")) {
1237 } else if (!strcasecmp(action, "changeview")) {
1239 } else if (!strcasecmp(action, "do_stuff_to_msgs")) {
1241 } else if (!strcasecmp(action, "change_start_page")) {
1242 change_start_page();
1243 } else if (!strcasecmp(action, "display_floorconfig")) {
1244 display_floorconfig(NULL);
1245 } else if (!strcasecmp(action, "toggle_self_service")) {
1246 toggle_self_service();
1247 #ifdef WEBCIT_WITH_CALENDAR_SERVICE
1248 } else if (!strcasecmp(action, "display_edit_task")) {
1249 display_edit_task();
1250 } else if (!strcasecmp(action, "save_task")) {
1252 } else if (!strcasecmp(action, "display_edit_event")) {
1253 display_edit_event();
1254 } else if (!strcasecmp(action, "save_event")) {
1256 } else if (!strcasecmp(action, "respond_to_request")) {
1257 respond_to_request();
1258 } else if (!strcasecmp(action, "handle_rsvp")) {
1261 } else if (!strcasecmp(action, "summary")) {
1263 } else if (!strcasecmp(action, "iconbar")) {
1265 } else if (!strcasecmp(action, "display_customize_iconbar")) {
1266 display_customize_iconbar();
1267 } else if (!strcasecmp(action, "commit_iconbar")) {
1269 } else if (!strcasecmp(action, "set_room_policy")) {
1271 } else if (!strcasecmp(action, "display_inetconf")) {
1273 } else if (!strcasecmp(action, "save_inetconf")) {
1275 } else if (!strcasecmp(action, "diagnostics")) {
1278 wprintf("You're in session %d<HR>\n", WC->wc_session);
1279 wprintf("Command: <BR><PRE>\n");
1281 wprintf("</PRE><HR>\n");
1282 wprintf("Variables: <BR><PRE>\n");
1284 wprintf("</PRE><HR>\n");
1287 /* When all else fais, display the main menu. */
1289 display_main_menu();
1294 if (content != NULL) {
1299 if (WC->upload_length > 0) {
1301 WC->upload_length = 0;