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 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
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);
371 wprintf("HTTP/1.0 200 OK\n");
373 httpdate(httpnow, time(NULL));
375 if (print_standard_html_head > 0) {
376 wprintf("Content-type: text/html\n"
377 "Server: %s\n", SERVER
380 wprintf("Connection: close\n"
382 "Cache-Control: no-store\n"
386 stuff_to_cookie(cookie, WC->wc_session, WC->wc_username,
387 WC->wc_password, WC->wc_roomname);
389 if (print_standard_html_head == 2) {
390 wprintf("Set-cookie: webcit=%s; path=/\n", unset);
392 wprintf("Set-cookie: webcit=%s; path=/\n", cookie);
393 if (server_cookie != NULL) {
394 wprintf("%s\n", server_cookie);
398 if (print_standard_html_head > 0) {
402 svprintf("REFRESHTAG", WCS_STRING, "%s",
403 "<META HTTP-EQUIV=\"refresh\" CONTENT=\"30\">\n");
406 svprintf("REFRESHTAG", WCS_STRING, "%s",
407 "<META HTTP-EQUIV=\"refresh\" CONTENT=\"500363689;\">\n");
410 /* script for checking for pages (not always launched) */
412 sprintf(onload_fcn, "function onload_fcn() { \n");
413 if (!WC->outside_frameset_allowed) {
414 strcat(onload_fcn, " force_frameset(); \n");
416 if (!suppress_check) if (WC->HaveExpressMessages) {
417 strcat(onload_fcn, " launch_page_popup(); \n");
418 WC->HaveExpressMessages = 0;
420 strcat(onload_fcn, "} \n");
422 svprintf("PAGERSCRIPT", WCS_STRING,
423 "<SCRIPT LANGUAGE=\"JavaScript\">\n"
424 "function launch_page_popup() {\n"
425 "pwin = window.open('/page_popup', 'CitaPage%d', "
426 "'toolbar=no,location=no,copyhistory=no,status=no,"
427 "scrollbars=yes,resizable=no,height=250,width=400');\n"
429 "function force_frameset() { \n"
430 " if (top.frames.length == 0) { \n"
431 " top.location.replace('/do_welcome'); \n"
443 svprintf("extrabodyparms", WCS_STRING, "%s",
444 "onload='onload_fcn();' ");
446 do_template("background");
449 if (print_standard_html_head == 1) {
450 wprintf("<A NAME=\"TheTop\"></A>");
451 embed_room_banner(NULL);
454 if (strlen(WC->ImportantMessage) > 0) {
455 do_template("beginbox_nt");
456 wprintf("<SPAN CLASS=\"errormsg\">"
457 "%s</SPAN><BR>\n", WC->ImportantMessage);
458 do_template("endbox");
459 strcpy(WC->ImportantMessage, "");
467 void http_redirect(char *whichpage) {
468 wprintf("HTTP/1.0 302 Moved Temporarily\n");
469 wprintf("Location: %s\n", whichpage);
470 wprintf("URI: %s\n", whichpage);
471 wprintf("Content-type: text/html\n\n");
472 wprintf("<html><body>\n");
473 wprintf("you really want to be <A HREF=\"%s\">here</A> now\n",
475 wprintf("</body></html>\n");
480 void check_for_express_messages()
486 if (buf[3] == '*') WC->HaveExpressMessages = 1;
493 * Output a piece of content to the web browser
495 void http_transmit_thing(char *thing, size_t length, char *content_type,
497 output_headers(is_static ? 0x10 : 0x00);
498 wprintf("Content-type: %s\n"
499 "Content-length: %ld\n"
501 "Connection: close\n"
507 client_write(thing, (size_t)length);
513 void output_static(char *what)
520 char content_type[SIZ];
522 sprintf(buf, "static/%s", what);
523 fp = fopen(buf, "rb");
525 wprintf("HTTP/1.0 404 %s\n", strerror(errno));
526 wprintf("Content-Type: text/plain\n");
528 wprintf("Cannot open %s: %s\n", what, strerror(errno));
530 if (!strncasecmp(&what[strlen(what) - 4], ".gif", 4))
531 strcpy(content_type, "image/gif");
532 else if (!strncasecmp(&what[strlen(what) - 4], ".txt", 4))
533 strcpy(content_type, "text/plain");
534 else if (!strncasecmp(&what[strlen(what) - 4], ".css", 4))
535 strcpy(content_type, "text/css");
536 else if (!strncasecmp(&what[strlen(what) - 4], ".jpg", 4))
537 strcpy(content_type, "image/jpeg");
538 else if (!strncasecmp(&what[strlen(what) - 4], ".png", 4))
539 strcpy(content_type, "image/png");
540 else if (!strncasecmp(&what[strlen(what) - 4], ".ico", 4))
541 strcpy(content_type, "image/x-icon");
542 else if (!strncasecmp(&what[strlen(what) - 5], ".html", 5))
543 strcpy(content_type, "text/html");
544 else if (!strncasecmp(&what[strlen(what) - 4], ".htm", 4))
545 strcpy(content_type, "text/html");
546 else if (!strncasecmp(&what[strlen(what) - 4], ".wml", 4))
547 strcpy(content_type, "text/vnd.wap.wml");
548 else if (!strncasecmp(&what[strlen(what) - 5], ".wmls", 5))
549 strcpy(content_type, "text/vnd.wap.wmlscript");
550 else if (!strncasecmp(&what[strlen(what) - 5], ".wmlc", 5))
551 strcpy(content_type, "application/vnd.wap.wmlc");
552 else if (!strncasecmp(&what[strlen(what) - 6], ".wmlsc", 6))
553 strcpy(content_type, "application/vnd.wap.wmlscriptc");
554 else if (!strncasecmp(&what[strlen(what) - 5], ".wbmp", 5))
555 strcpy(content_type, "image/vnd.wap.wbmp");
556 else if (!strncasecmp(&what[strlen(what) - 3], ".js", 3))
557 strcpy(content_type, "text/javascript");
559 strcpy(content_type, "application/octet-stream");
561 fstat(fileno(fp), &statbuf);
562 bytes = statbuf.st_size;
563 lprintf(3, "Static: %s, (%s; %ld bytes)\n", what, content_type, bytes);
564 bigbuffer = malloc(bytes + 2);
565 fread(bigbuffer, bytes, 1, fp);
568 http_transmit_thing(bigbuffer, (size_t)bytes, content_type, 1);
571 if (!strcasecmp(bstr("force_close_session"), "yes")) {
572 end_webcit_session();
578 * When the browser requests an image file from the Citadel server,
579 * this function is called to transmit it.
584 char *xferbuf = NULL;
587 serv_printf("OIMG %s|%s", bstr("name"), bstr("parm"));
590 bytes = extract_long(&buf[4], 0);
591 xferbuf = malloc(bytes + 2);
593 /* Read it from the server */
594 read_server_binary(xferbuf, bytes);
598 /* Write it to the browser */
599 http_transmit_thing(xferbuf, (size_t)bytes, "image/gif", 0);
604 /* Instead of an ugly 404, send a 1x1 transparent GIF
605 * when there's no such image on the server.
607 output_static("blank.gif");
610 wprintf("HTTP/1.0 404 %s\n", &buf[4]);
612 wprintf("Content-Type: text/plain\n"
614 "Error retrieving image: %s\n",
627 void output_mimepart()
631 char content_type[SIZ];
632 char *content = NULL;
634 serv_printf("OPNA %s|%s", bstr("msgnum"), bstr("partnum"));
637 bytes = extract_long(&buf[4], 0);
638 content = malloc(bytes + 2);
639 extract(content_type, &buf[4], 3);
641 read_server_binary(content, bytes);
644 http_transmit_thing(content, bytes, content_type, 0);
647 wprintf("HTTP/1.0 404 %s\n", &buf[4]);
649 wprintf("Content-Type: text/plain\n");
651 wprintf("Error retrieving part: %s\n", &buf[4]);
659 char *load_mimepart(long msgnum, char *partnum)
663 char content_type[SIZ];
666 serv_printf("OPNA %ld|%s", msgnum, partnum);
669 bytes = extract_long(&buf[4], 0);
670 extract(content_type, &buf[4], 3);
672 content = malloc(bytes + 2);
673 read_server_binary(content, bytes);
677 content[bytes] = 0; /* null terminate for good measure */
688 * Convenience functions to display a page containing only a string
690 void convenience_page(char *titlebarcolor, char *titlebarmsg, char *messagetext)
692 wprintf("HTTP/1.0 200 OK\n");
694 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#%s\"><TR><TD>", titlebarcolor);
695 wprintf("<SPAN CLASS=\"titlebar\">%s</SPAN>\n", titlebarmsg);
696 wprintf("</TD></TR></TABLE><BR>\n");
697 escputs(messagetext);
705 * Display a blank page.
707 void blank_page(void) {
714 * A template has been requested
716 void url_do_template(void) {
717 do_template(bstr("template"));
723 * Offer to make any page the user's "start page."
725 void offer_start_page(void) {
726 wprintf("<A HREF=\"/change_start_page?startpage=");
727 urlescputs(WC->this_page);
729 "<FONT SIZE=-2 COLOR=\"#AAAAAA\">Make this my start page</FONT>"
736 * Change the user's start page
738 void change_start_page(void) {
740 if (bstr("startpage") == NULL) {
741 strcpy(WC->ImportantMessage,
742 "startpage set to null");
747 set_preference("startpage", bstr("startpage"));
750 do_template("newstartpage");
757 void display_success(char *successmessage)
759 convenience_page("007700", "OK", successmessage);
764 void extract_action(char *actbuf, char *cmdbuf)
768 strcpy(actbuf, cmdbuf);
769 if (!strncasecmp(actbuf, "GET /", 5))
770 strcpy(actbuf, &actbuf[5]);
771 if (!strncasecmp(actbuf, "PUT /", 5))
772 strcpy(actbuf, &actbuf[5]);
773 if (!strncasecmp(actbuf, "POST /", 6))
774 strcpy(actbuf, &actbuf[6]);
776 for (i = 0; i < strlen(actbuf); ++i) {
777 if (actbuf[i] == ' ') {
781 if (actbuf[i] == '/') {
785 if (actbuf[i] == '?') {
789 if (actbuf[i] == '&') {
797 void upload_handler(char *name, char *filename, char *partnum, char *disp,
798 void *content, char *cbtype, size_t length,
799 char *encoding, void *userdata)
801 struct urlcontent *u;
804 if ( (length > 0) && (strlen(cbtype) == 0) ) {
805 u = (struct urlcontent *) malloc(sizeof(struct urlcontent));
806 u->next = WC->urlstrings;
808 safestrncpy(u->url_key, name, sizeof(u->url_key));
809 u->url_data = malloc(length + 1);
810 memcpy(u->url_data, content, length);
811 u->url_data[length] = 0;
815 if ( (length > 0) && (strlen(cbtype) > 0) ) {
816 WC->upload = malloc(length);
817 if (WC->upload != NULL) {
818 WC->upload_length = length;
819 safestrncpy(WC->upload_filename, filename,
820 sizeof(WC->upload_filename));
821 safestrncpy(WC->upload_content_type, cbtype,
822 sizeof(WC->upload_content_type));
823 memcpy(WC->upload, content, length);
826 lprintf(3, "malloc() failed: %s\n", strerror(errno));
836 * Entry point for WebCit transaction
838 void session_loop(struct httprequest *req)
844 int ContentLength = 0;
846 char ContentType[512];
849 struct httprequest *hptr;
850 char browser_host[SIZ];
851 char user_agent[SIZ];
854 /* We stuff these with the values coming from the client cookies,
855 * so we can use them to reconnect a timed out session if we have to.
857 char c_username[SIZ];
858 char c_password[SIZ];
859 char c_roomname[SIZ];
862 strcpy(c_username, "");
863 strcpy(c_password, "");
864 strcpy(c_roomname, "");
866 WC->upload_length = 0;
873 if (hptr == NULL) return;
875 strcpy(cmd, hptr->line);
877 extract_action(action, cmd);
879 while (hptr != NULL) {
880 strcpy(buf, hptr->line);
883 if (!strncasecmp(buf, "Cookie: webcit=", 15)) {
884 safestrncpy(cookie, &buf[15], sizeof cookie);
885 cookie_to_stuff(cookie, NULL,
886 c_username, c_password, c_roomname);
888 else if (!strncasecmp(buf, "Content-length: ", 16)) {
889 ContentLength = atoi(&buf[16]);
891 else if (!strncasecmp(buf, "Content-type: ", 14)) {
892 safestrncpy(ContentType, &buf[14], sizeof ContentType);
894 else if (!strncasecmp(buf, "User-agent: ", 12)) {
895 safestrncpy(user_agent, &buf[12], sizeof user_agent);
897 else if (!strncasecmp(buf, "Host: ", 6)) {
898 safestrncpy(WC->http_host, &buf[6], sizeof WC->http_host);
900 /* Only WAP gateways explicitly name this content-type */
901 else if (strstr(buf, "text/vnd.wap.wml")) {
906 if (ContentLength > 0) {
907 content = malloc(ContentLength + SIZ);
908 memset(content, 0, ContentLength + SIZ);
909 sprintf(content, "Content-type: %s\n"
910 "Content-length: %d\n\n",
911 ContentType, ContentLength);
912 body_start = strlen(content);
916 while (BytesRead < ContentLength) {
917 a=read(WC->http_sock, &content[BytesRead+body_start],
918 ContentLength - BytesRead);
919 if (a <= 0) BytesRead = ContentLength;
924 /* Now we're daring and read it all at once. */
925 client_read(WC->http_sock, &content[BytesRead+body_start], ContentLength);
927 if (!strncasecmp(ContentType,
928 "application/x-www-form-urlencoded", 33)) {
929 addurls(&content[body_start]);
930 } else if (!strncasecmp(ContentType, "multipart", 9)) {
931 content_end = content + ContentLength + body_start;
932 mime_parser(content, content_end, *upload_handler,
933 NULL, NULL, NULL, 0);
939 /* make a note of where we are in case the user wants to save it */
940 safestrncpy(WC->this_page, cmd, sizeof(WC->this_page));
941 remove_token(WC->this_page, 2, ' ');
942 remove_token(WC->this_page, 0, ' ');
944 /* If there are variables in the URL, we must grab them now */
945 for (a = 0; a < strlen(cmd); ++a) {
946 if ((cmd[a] == '?') || (cmd[a] == '&')) {
947 for (b = a; b < strlen(cmd); ++b)
950 addurls(&cmd[a + 1]);
955 /* Static content can be sent without connecting to Citadel. */
956 if (!strcasecmp(action, "static")) {
957 strcpy(buf, &cmd[12]);
958 for (a = 0; a < strlen(buf); ++a)
962 goto SKIP_ALL_THIS_CRAP; /* Don't try to connect */
966 * If we're not connected to a Citadel server, try to hook up the
969 if (!WC->connected) {
970 if (!strcasecmp(ctdlhost, "uds")) {
971 /* unix domain socket */
972 sprintf(buf, "%s/citadel.socket", ctdlport);
973 WC->serv_sock = uds_connectsock(buf);
977 WC->serv_sock = tcp_connectsock(ctdlhost, ctdlport);
980 if (WC->serv_sock < 0) {
982 goto SKIP_ALL_THIS_CRAP;
986 serv_gets(buf); /* get the server welcome message */
987 locate_host(browser_host, WC->http_sock);
988 get_serv_info(browser_host, user_agent);
989 if (serv_info.serv_rev_level < MINIMUM_CIT_VERSION) {
990 wprintf("You are connected to a Citadel "
991 "server running Citadel %d.%02d;\nin "
992 "order to run this version of WebCit "
993 "you must also have Citadel %d.%02d or"
995 serv_info.serv_rev_level / 100,
996 serv_info.serv_rev_level % 100,
997 MINIMUM_CIT_VERSION / 100,
998 MINIMUM_CIT_VERSION % 100
1000 end_webcit_session();
1001 goto SKIP_ALL_THIS_CRAP;
1007 * Functions which can be performed without logging in
1009 if (!strcasecmp(action, "listsub")) {
1011 goto SKIP_ALL_THIS_CRAP;
1013 #ifdef WEBCIT_WITH_CALENDAR_SERVICE
1014 if (!strcasecmp(action, "freebusy")) {
1016 goto SKIP_ALL_THIS_CRAP;
1020 check_for_express_messages();
1023 * If we're not logged in, but we have username and password cookies
1024 * supplied by the browser, try using them to log in.
1026 if ((!WC->logged_in) && (strlen(c_username) > 0) && (strlen(c_password) > 0)) {
1027 serv_printf("USER %s", c_username);
1029 if (buf[0] == '3') {
1030 serv_printf("PASS %s", c_password);
1032 if (buf[0] == '2') {
1033 become_logged_in(c_username, c_password, buf);
1038 * If we don't have a current room, but a cookie specifying the
1039 * current room is supplied, make an effort to go there.
1041 if ((strlen(WC->wc_roomname) == 0) && (strlen(c_roomname) > 0)) {
1042 serv_printf("GOTO %s", c_roomname);
1044 if (buf[0] == '2') {
1045 strcpy(WC->wc_roomname, c_roomname);
1049 if (!strcasecmp(action, "image")) {
1053 * All functions handled below this point ... make sure we log in
1054 * before doing anything else!
1056 } else if ((!WC->logged_in) && (!strcasecmp(action, "login"))) {
1058 } else if (!WC->logged_in) {
1059 display_login(NULL);
1063 * Various commands...
1066 else if (!strcasecmp(action, "do_welcome")) {
1068 } else if (!strcasecmp(action, "blank")) {
1070 } else if (!strcasecmp(action, "do_template")) {
1072 } else if (!strcasecmp(action, "display_main_menu")) {
1073 display_main_menu();
1074 } else if (!strcasecmp(action, "whobbs")) {
1076 } else if (!strcasecmp(action, "knrooms")) {
1078 } else if (!strcasecmp(action, "gotonext")) {
1081 } else if (!strcasecmp(action, "skip")) {
1083 } else if (!strcasecmp(action, "ungoto")) {
1085 } else if (!strcasecmp(action, "dotgoto")) {
1087 smart_goto(bstr("room"));
1088 } else if (!strcasecmp(action, "dotskip")) {
1089 smart_goto(bstr("room"));
1090 } else if (!strcasecmp(action, "termquit")) {
1092 } else if (!strcasecmp(action, "readnew")) {
1093 readloop("readnew");
1094 } else if (!strcasecmp(action, "readold")) {
1095 readloop("readold");
1096 } else if (!strcasecmp(action, "readfwd")) {
1097 readloop("readfwd");
1098 } else if (!strcasecmp(action, "headers")) {
1099 readloop("headers");
1100 } else if (!strcasecmp(action, "display_enter")) {
1102 } else if (!strcasecmp(action, "post")) {
1104 } else if (!strcasecmp(action, "do_stuff_to_one_msg")) {
1105 do_stuff_to_one_msg();
1106 } else if (!strcasecmp(action, "move_msg")) {
1108 } else if (!strcasecmp(action, "userlist")) {
1110 } else if (!strcasecmp(action, "showuser")) {
1112 } else if (!strcasecmp(action, "display_page")) {
1114 } else if (!strcasecmp(action, "page_user")) {
1116 } else if (!strcasecmp(action, "chat")) {
1118 } else if (!strcasecmp(action, "display_private")) {
1119 display_private("", 0);
1120 } else if (!strcasecmp(action, "goto_private")) {
1122 } else if (!strcasecmp(action, "zapped_list")) {
1124 } else if (!strcasecmp(action, "display_zap")) {
1126 } else if (!strcasecmp(action, "zap")) {
1128 } else if (!strcasecmp(action, "display_entroom")) {
1130 } else if (!strcasecmp(action, "entroom")) {
1132 } else if (!strcasecmp(action, "display_editroom")) {
1134 } else if (!strcasecmp(action, "netedit")) {
1136 } else if (!strcasecmp(action, "editroom")) {
1138 } else if (!strcasecmp(action, "display_whok")) {
1140 } else if (!strcasecmp(action, "display_editinfo")) {
1141 display_edit("Room info", "EINF 0", "RINF", "/editinfo", 1);
1142 } else if (!strcasecmp(action, "editinfo")) {
1143 save_edit("Room info", "EINF 1", 1);
1144 } else if (!strcasecmp(action, "display_editbio")) {
1145 sprintf(buf, "RBIO %s", WC->wc_username);
1146 display_edit("Your bio", "NOOP", buf, "editbio", 3);
1147 } else if (!strcasecmp(action, "editbio")) {
1148 save_edit("Your bio", "EBIO", 0);
1149 } else if (!strcasecmp(action, "confirm_delete_room")) {
1150 confirm_delete_room();
1151 } else if (!strcasecmp(action, "delete_room")) {
1153 } else if (!strcasecmp(action, "validate")) {
1155 } else if (!strcasecmp(action, "display_editpic")) {
1156 display_graphics_upload("your photo",
1159 } else if (!strcasecmp(action, "editpic")) {
1160 do_graphics_upload("UIMG 1|_userpic_");
1161 } else if (!strcasecmp(action, "display_editroompic")) {
1162 display_graphics_upload("the graphic for this room",
1165 } else if (!strcasecmp(action, "editroompic")) {
1166 do_graphics_upload("UIMG 1|_roompic_");
1167 } else if (!strcasecmp(action, "delete_floor")) {
1169 } else if (!strcasecmp(action, "rename_floor")) {
1171 } else if (!strcasecmp(action, "create_floor")) {
1173 } else if (!strcasecmp(action, "display_editfloorpic")) {
1174 sprintf(buf, "UIMG 0|_floorpic_|%s",
1175 bstr("which_floor"));
1176 display_graphics_upload("the graphic for this floor",
1179 } else if (!strcasecmp(action, "editfloorpic")) {
1180 sprintf(buf, "UIMG 1|_floorpic_|%s",
1181 bstr("which_floor"));
1182 do_graphics_upload(buf);
1183 } else if (!strcasecmp(action, "display_reg")) {
1185 } else if (!strcasecmp(action, "display_changepw")) {
1187 } else if (!strcasecmp(action, "changepw")) {
1189 } else if (!strcasecmp(action, "display_edit_node")) {
1190 display_edit_node();
1191 } else if (!strcasecmp(action, "edit_node")) {
1193 } else if (!strcasecmp(action, "display_netconf")) {
1195 } else if (!strcasecmp(action, "display_confirm_delete_node")) {
1196 display_confirm_delete_node();
1197 } else if (!strcasecmp(action, "delete_node")) {
1199 } else if (!strcasecmp(action, "display_add_node")) {
1201 } else if (!strcasecmp(action, "add_node")) {
1203 } else if (!strcasecmp(action, "terminate_session")) {
1205 terminate_session();
1206 } else if (!strcasecmp(action, "edit_me")) {
1208 } else if (!strcasecmp(action, "display_siteconfig")) {
1209 display_siteconfig();
1210 } else if (!strcasecmp(action, "chat_recv")) {
1212 } else if (!strcasecmp(action, "chat_send")) {
1214 } else if (!strcasecmp(action, "page_popup")) {
1216 } else if (!strcasecmp(action, "siteconfig")) {
1218 } else if (!strcasecmp(action, "display_generic")) {
1220 } else if (!strcasecmp(action, "do_generic")) {
1222 } else if (!strcasecmp(action, "display_menubar")) {
1224 } else if (!strcasecmp(action, "output_mimepart")) {
1226 } else if (!strcasecmp(action, "edit_vcard")) {
1228 } else if (!strcasecmp(action, "submit_vcard")) {
1230 } else if (!strcasecmp(action, "select_user_to_edit")) {
1231 select_user_to_edit(NULL, NULL);
1232 } else if (!strcasecmp(action, "display_edituser")) {
1233 display_edituser(NULL, 0);
1234 } else if (!strcasecmp(action, "edituser")) {
1236 } else if (!strcasecmp(action, "create_user")) {
1238 } else if (!strcasecmp(action, "changeview")) {
1240 } else if (!strcasecmp(action, "do_stuff_to_msgs")) {
1242 } else if (!strcasecmp(action, "change_start_page")) {
1243 change_start_page();
1244 } else if (!strcasecmp(action, "display_floorconfig")) {
1245 display_floorconfig(NULL);
1246 } else if (!strcasecmp(action, "toggle_self_service")) {
1247 toggle_self_service();
1248 #ifdef WEBCIT_WITH_CALENDAR_SERVICE
1249 } else if (!strcasecmp(action, "display_edit_task")) {
1250 display_edit_task();
1251 } else if (!strcasecmp(action, "save_task")) {
1253 } else if (!strcasecmp(action, "display_edit_event")) {
1254 display_edit_event();
1255 } else if (!strcasecmp(action, "save_event")) {
1257 } else if (!strcasecmp(action, "respond_to_request")) {
1258 respond_to_request();
1259 } else if (!strcasecmp(action, "handle_rsvp")) {
1262 } else if (!strcasecmp(action, "summary")) {
1264 } else if (!strcasecmp(action, "iconbar")) {
1266 } else if (!strcasecmp(action, "display_customize_iconbar")) {
1267 display_customize_iconbar();
1268 } else if (!strcasecmp(action, "commit_iconbar")) {
1270 } else if (!strcasecmp(action, "set_room_policy")) {
1272 } else if (!strcasecmp(action, "display_inetconf")) {
1274 } else if (!strcasecmp(action, "save_inetconf")) {
1276 } else if (!strcasecmp(action, "diagnostics")) {
1279 wprintf("You're in session %d<HR>\n", WC->wc_session);
1280 wprintf("Command: <BR><PRE>\n");
1282 wprintf("</PRE><HR>\n");
1283 wprintf("Variables: <BR><PRE>\n");
1285 wprintf("</PRE><HR>\n");
1288 /* When all else fais, display the main menu. */
1290 display_main_menu();
1295 if (content != NULL) {
1300 if (WC->upload_length > 0) {
1302 WC->upload_length = 0;