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 */
181 wprintf("<div id=\"navbar\">");
182 wprintf("FIXME the navbar should go here, dude...\n");
186 do_template("trailing");
193 * Copy a string, escaping characters which have meaning in HTML. If
194 * nbsp is nonzero, spaces are converted to non-breaking spaces.
196 void stresc(char *target, char *strbuf, int nbsp, int nolinebreaks)
201 for (a = 0; a < strlen(strbuf); ++a) {
202 if (strbuf[a] == '<')
203 strcat(target, "<");
204 else if (strbuf[a] == '>')
205 strcat(target, ">");
206 else if (strbuf[a] == '&')
207 strcat(target, "&");
208 else if (strbuf[a] == '\"')
209 strcat(target, """);
210 else if (strbuf[a] == '\'')
211 strcat(target, "'");
212 else if (strbuf[a] == LB)
214 else if (strbuf[a] == RB)
216 else if (strbuf[a] == QU)
217 strcat(target, "\"");
218 else if ((strbuf[a] == 32) && (nbsp == 1))
219 strcat(target, " ");
220 else if ((strbuf[a] == '\n') && (nolinebreaks))
221 strcat(target, ""); /* nothing */
222 else if ((strbuf[a] == '\r') && (nolinebreaks))
223 strcat(target, ""); /* nothing */
225 strncat(target, &strbuf[a], 1);
229 void escputs1(char *strbuf, int nbsp, int nolinebreaks)
233 if (strbuf == NULL) return;
234 buf = malloc( (3 * strlen(strbuf)) + SIZ );
235 stresc(buf, strbuf, nbsp, nolinebreaks);
240 void escputs(char *strbuf)
242 escputs1(strbuf, 0, 0);
246 * Escape a string for feeding out as a URL.
247 * Returns a pointer to a buffer that must be freed by the caller!
249 void urlesc(char *outbuf, char *strbuf)
252 char *ec = " #&;`'|*?-~<>^()[]{}$\\";
256 for (a = 0; a < strlen(strbuf); ++a) {
258 for (b = 0; b < strlen(ec); ++b) {
259 if (strbuf[a] == ec[b])
264 sprintf(&outbuf[b], "%%%02x", strbuf[a]);
266 sprintf(&outbuf[b], "%c", strbuf[a]);
270 void urlescputs(char *strbuf)
274 urlesc(outbuf, strbuf);
275 wprintf("%s", outbuf);
280 * Copy a string, escaping characters for JavaScript strings.
282 void jsesc(char *target, char *strbuf)
287 for (a = 0; a < strlen(strbuf); ++a) {
288 if (strbuf[a] == '<')
290 else if (strbuf[a] == '>')
292 else if (strbuf[a] == '\"')
293 strcat(target, """);
294 else if (strbuf[a] == '&')
295 strcat(target, "&;");
296 else if (strbuf[a] == '\'')
297 strcat(target, "\\'");
299 strncat(target, &strbuf[a], 1);
304 void jsescputs(char *strbuf)
308 jsesc(outbuf, strbuf);
309 wprintf("%s", outbuf);
313 * Copy a string, escaping characters for message text hold
315 void msgesc(char *target, char *strbuf)
320 for (a = 0; a < strlen(strbuf); ++a) {
321 if (strbuf[a] == '\'')
322 strcat(target, "\\'");
323 else if (strbuf[a] == '\n')
325 else if (strbuf[a] == '\r')
328 strncat(target, &strbuf[a], 1);
333 void msgescputs(char *strbuf) {
336 if (strbuf == NULL) return;
337 outbuf = malloc( (3 * strlen(strbuf)) + SIZ);
338 msgesc(outbuf, strbuf);
339 wprintf("%s", outbuf);
347 * Output all that important stuff that the browser will want to see
349 void output_headers( int do_httpheaders, /* 1 = output HTTP headers */
350 int do_htmlhead, /* 1 = output HTML <head> section and <body> opener */
352 int do_room_banner, /* 0=no, 1=yes, */
353 /* 2 = I'm going to embed my own, so don't open the */
354 /* <div id="text"> either. */
356 int unset_cookies, /* 1 = session is terminating, so unset the cookies */
357 int refresh30, /* 1 = automatically refresh page every 30 seconds */
358 int suppress_check, /* 1 = suppress check for instant messages */
359 int cache /* 1 = allow browser to cache this page */
363 char onload_fcn[SIZ];
364 static int pageseq = 0;
366 wprintf("HTTP/1.0 200 OK\n");
367 httpdate(httpnow, time(NULL));
369 if (do_httpheaders) {
370 wprintf("Content-type: text/html\n"
371 "Server: %s\n", SERVER
374 wprintf("Connection: close\n"
376 "Cache-Control: no-store\n"
380 stuff_to_cookie(cookie, WC->wc_session, WC->wc_username,
381 WC->wc_password, WC->wc_roomname);
384 wprintf("Set-cookie: webcit=%s; path=/\n", unset);
386 wprintf("Set-cookie: webcit=%s; path=/\n", cookie);
387 if (server_cookie != NULL) {
388 wprintf("%s\n", server_cookie);
396 svprintf("REFRESHTAG", WCS_STRING, "%s",
397 "<meta http-equiv=\"refresh\" content=\"30\" />\n");
400 svprintf("REFRESHTAG", WCS_STRING, "%s",
401 "<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 (!suppress_check) if (WC->HaveExpressMessages) {
408 strcat(onload_fcn, " launch_page_popup(); \n");
409 WC->HaveExpressMessages = 0;
411 strcat(onload_fcn, "} \n");
413 svprintf("PAGERscript", WCS_STRING,
414 "<script type=\"text/javascript\">\n"
415 "function launch_page_popup() {\n"
416 "pwin = window.open('/page_popup', 'CitaPage%d', "
417 "'toolbar=no,location=no,copyhistory=no,status=no,"
418 "scrollbars=yes,resizable=no,height=250,width=400');\n"
430 svprintf("extrabodyparms", WCS_STRING, "%s",
431 "onload='onload_fcn();' ");
433 do_template("background");
438 if ( (WC->logged_in) && (!unset_cookies) ) {
439 wprintf("<div id=\"iconbar\">");
443 if (do_room_banner == 1) {
444 wprintf("<div id=\"banner\">\n");
445 embed_room_banner(NULL);
450 if (do_room_banner != 2) {
451 wprintf("<div id=\"content\">\n");
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,
498 output_headers(0, 0, 0, 0, 0, 0, 1);
501 output_headers(0, 0, 0, 0, 0, 0, 0);
503 wprintf("Content-type: %s\n"
504 "Content-length: %ld\n"
506 "Connection: close\n"
512 client_write(thing, (size_t)length);
518 void output_static(char *what)
525 char content_type[SIZ];
527 sprintf(buf, "static/%s", what);
528 fp = fopen(buf, "rb");
530 wprintf("HTTP/1.0 404 %s\n", strerror(errno));
531 wprintf("Content-Type: text/plain\n");
533 wprintf("Cannot open %s: %s\n", what, strerror(errno));
535 if (!strncasecmp(&what[strlen(what) - 4], ".gif", 4))
536 strcpy(content_type, "image/gif");
537 else if (!strncasecmp(&what[strlen(what) - 4], ".txt", 4))
538 strcpy(content_type, "text/plain");
539 else if (!strncasecmp(&what[strlen(what) - 4], ".css", 4))
540 strcpy(content_type, "text/css");
541 else if (!strncasecmp(&what[strlen(what) - 4], ".jpg", 4))
542 strcpy(content_type, "image/jpeg");
543 else if (!strncasecmp(&what[strlen(what) - 4], ".png", 4))
544 strcpy(content_type, "image/png");
545 else if (!strncasecmp(&what[strlen(what) - 4], ".ico", 4))
546 strcpy(content_type, "image/x-icon");
547 else if (!strncasecmp(&what[strlen(what) - 5], ".html", 5))
548 strcpy(content_type, "text/html");
549 else if (!strncasecmp(&what[strlen(what) - 4], ".htm", 4))
550 strcpy(content_type, "text/html");
551 else if (!strncasecmp(&what[strlen(what) - 4], ".wml", 4))
552 strcpy(content_type, "text/vnd.wap.wml");
553 else if (!strncasecmp(&what[strlen(what) - 5], ".wmls", 5))
554 strcpy(content_type, "text/vnd.wap.wmlscript");
555 else if (!strncasecmp(&what[strlen(what) - 5], ".wmlc", 5))
556 strcpy(content_type, "application/vnd.wap.wmlc");
557 else if (!strncasecmp(&what[strlen(what) - 6], ".wmlsc", 6))
558 strcpy(content_type, "application/vnd.wap.wmlscriptc");
559 else if (!strncasecmp(&what[strlen(what) - 5], ".wbmp", 5))
560 strcpy(content_type, "image/vnd.wap.wbmp");
561 else if (!strncasecmp(&what[strlen(what) - 3], ".js", 3))
562 strcpy(content_type, "text/javascript");
564 strcpy(content_type, "application/octet-stream");
566 fstat(fileno(fp), &statbuf);
567 bytes = statbuf.st_size;
568 lprintf(3, "Static: %s, (%s; %ld bytes)\n", what, content_type, bytes);
569 bigbuffer = malloc(bytes + 2);
570 fread(bigbuffer, bytes, 1, fp);
573 http_transmit_thing(bigbuffer, (size_t)bytes, content_type, 1);
576 if (!strcasecmp(bstr("force_close_session"), "yes")) {
577 end_webcit_session();
583 * When the browser requests an image file from the Citadel server,
584 * this function is called to transmit it.
589 char *xferbuf = NULL;
592 serv_printf("OIMG %s|%s", bstr("name"), bstr("parm"));
595 bytes = extract_long(&buf[4], 0);
596 xferbuf = malloc(bytes + 2);
598 /* Read it from the server */
599 read_server_binary(xferbuf, bytes);
603 /* Write it to the browser */
604 http_transmit_thing(xferbuf, (size_t)bytes, "image/gif", 0);
609 /* Instead of an ugly 404, send a 1x1 transparent GIF
610 * when there's no such image on the server.
612 output_static("blank.gif");
615 wprintf("HTTP/1.0 404 %s\n", &buf[4]);
616 output_headers(0, 0, 0, 0, 0, 0, 0);
617 wprintf("Content-Type: text/plain\n"
619 "Error retrieving image: %s\n",
632 void output_mimepart()
636 char content_type[SIZ];
637 char *content = NULL;
639 serv_printf("OPNA %s|%s", bstr("msgnum"), bstr("partnum"));
642 bytes = extract_long(&buf[4], 0);
643 content = malloc(bytes + 2);
644 extract(content_type, &buf[4], 3);
645 output_headers(0, 0, 0, 0, 0, 0, 0);
646 read_server_binary(content, bytes);
649 http_transmit_thing(content, bytes, content_type, 0);
652 wprintf("HTTP/1.0 404 %s\n", &buf[4]);
653 output_headers(0, 0, 0, 0, 0, 0, 0);
654 wprintf("Content-Type: text/plain\n");
656 wprintf("Error retrieving part: %s\n", &buf[4]);
664 char *load_mimepart(long msgnum, char *partnum)
668 char content_type[SIZ];
671 serv_printf("OPNA %ld|%s", msgnum, partnum);
674 bytes = extract_long(&buf[4], 0);
675 extract(content_type, &buf[4], 3);
677 content = malloc(bytes + 2);
678 read_server_binary(content, bytes);
682 content[bytes] = 0; /* null terminate for good measure */
693 * Convenience functions to display a page containing only a string
695 void convenience_page(char *titlebarcolor, char *titlebarmsg, char *messagetext)
697 wprintf("HTTP/1.0 200 OK\n");
698 output_headers(1, 1, 2, 0, 0, 0, 0);
699 wprintf("<div id=\"banner\">\n");
700 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#%s\"><TR><TD>", titlebarcolor);
701 wprintf("<SPAN CLASS=\"titlebar\">%s</SPAN>\n", titlebarmsg);
702 wprintf("</TD></TR></TABLE>\n");
703 wprintf("</div>\n<div id=\"content\">\n");
704 escputs(messagetext);
712 * Display a blank page.
714 void blank_page(void) {
715 output_headers(1, 1, 0, 0, 1, 0, 0);
721 * A template has been requested
723 void url_do_template(void) {
724 do_template(bstr("template"));
730 * Offer to make any page the user's "start page."
732 void offer_start_page(void) {
733 wprintf("<A HREF=\"/change_start_page?startpage=");
734 urlescputs(WC->this_page);
736 "<FONT SIZE=-2 COLOR=\"#AAAAAA\">Make this my start page</FONT>"
743 * Change the user's start page
745 void change_start_page(void) {
747 if (bstr("startpage") == NULL) {
748 strcpy(WC->ImportantMessage,
749 "startpage set to null");
754 set_preference("startpage", bstr("startpage"));
756 output_headers(1, 1, 0, 0, 0, 0, 0);
757 do_template("newstartpage");
764 void display_success(char *successmessage)
766 convenience_page("007700", "OK", successmessage);
771 void extract_action(char *actbuf, char *cmdbuf)
775 strcpy(actbuf, cmdbuf);
776 if (!strncasecmp(actbuf, "GET /", 5))
777 strcpy(actbuf, &actbuf[5]);
778 if (!strncasecmp(actbuf, "PUT /", 5))
779 strcpy(actbuf, &actbuf[5]);
780 if (!strncasecmp(actbuf, "POST /", 6))
781 strcpy(actbuf, &actbuf[6]);
783 for (i = 0; i < strlen(actbuf); ++i) {
784 if (actbuf[i] == ' ') {
788 if (actbuf[i] == '/') {
792 if (actbuf[i] == '?') {
796 if (actbuf[i] == '&') {
804 void upload_handler(char *name, char *filename, char *partnum, char *disp,
805 void *content, char *cbtype, size_t length,
806 char *encoding, void *userdata)
808 struct urlcontent *u;
811 if ( (length > 0) && (strlen(cbtype) == 0) ) {
812 u = (struct urlcontent *) malloc(sizeof(struct urlcontent));
813 u->next = WC->urlstrings;
815 safestrncpy(u->url_key, name, sizeof(u->url_key));
816 u->url_data = malloc(length + 1);
817 memcpy(u->url_data, content, length);
818 u->url_data[length] = 0;
822 if ( (length > 0) && (strlen(cbtype) > 0) ) {
823 WC->upload = malloc(length);
824 if (WC->upload != NULL) {
825 WC->upload_length = length;
826 safestrncpy(WC->upload_filename, filename,
827 sizeof(WC->upload_filename));
828 safestrncpy(WC->upload_content_type, cbtype,
829 sizeof(WC->upload_content_type));
830 memcpy(WC->upload, content, length);
833 lprintf(3, "malloc() failed: %s\n", strerror(errno));
843 * Entry point for WebCit transaction
845 void session_loop(struct httprequest *req)
851 int ContentLength = 0;
853 char ContentType[512];
856 struct httprequest *hptr;
857 char browser_host[SIZ];
858 char user_agent[SIZ];
861 /* We stuff these with the values coming from the client cookies,
862 * so we can use them to reconnect a timed out session if we have to.
864 char c_username[SIZ];
865 char c_password[SIZ];
866 char c_roomname[SIZ];
869 strcpy(c_username, "");
870 strcpy(c_password, "");
871 strcpy(c_roomname, "");
873 WC->upload_length = 0;
880 if (hptr == NULL) return;
882 strcpy(cmd, hptr->line);
884 extract_action(action, cmd);
886 while (hptr != NULL) {
887 strcpy(buf, hptr->line);
890 if (!strncasecmp(buf, "Cookie: webcit=", 15)) {
891 safestrncpy(cookie, &buf[15], sizeof cookie);
892 cookie_to_stuff(cookie, NULL,
893 c_username, c_password, c_roomname);
895 else if (!strncasecmp(buf, "Content-length: ", 16)) {
896 ContentLength = atoi(&buf[16]);
898 else if (!strncasecmp(buf, "Content-type: ", 14)) {
899 safestrncpy(ContentType, &buf[14], sizeof ContentType);
901 else if (!strncasecmp(buf, "User-agent: ", 12)) {
902 safestrncpy(user_agent, &buf[12], sizeof user_agent);
904 else if (!strncasecmp(buf, "Host: ", 6)) {
905 safestrncpy(WC->http_host, &buf[6], sizeof WC->http_host);
907 /* Only WAP gateways explicitly name this content-type */
908 else if (strstr(buf, "text/vnd.wap.wml")) {
913 if (ContentLength > 0) {
914 content = malloc(ContentLength + SIZ);
915 memset(content, 0, ContentLength + SIZ);
916 sprintf(content, "Content-type: %s\n"
917 "Content-length: %d\n\n",
918 ContentType, ContentLength);
919 body_start = strlen(content);
923 while (BytesRead < ContentLength) {
924 a=read(WC->http_sock, &content[BytesRead+body_start],
925 ContentLength - BytesRead);
926 if (a <= 0) BytesRead = ContentLength;
931 /* Now we're daring and read it all at once. */
932 client_read(WC->http_sock, &content[BytesRead+body_start], ContentLength);
934 if (!strncasecmp(ContentType,
935 "application/x-www-form-urlencoded", 33)) {
936 addurls(&content[body_start]);
937 } else if (!strncasecmp(ContentType, "multipart", 9)) {
938 content_end = content + ContentLength + body_start;
939 mime_parser(content, content_end, *upload_handler,
940 NULL, NULL, NULL, 0);
946 /* make a note of where we are in case the user wants to save it */
947 safestrncpy(WC->this_page, cmd, sizeof(WC->this_page));
948 remove_token(WC->this_page, 2, ' ');
949 remove_token(WC->this_page, 0, ' ');
951 /* If there are variables in the URL, we must grab them now */
952 for (a = 0; a < strlen(cmd); ++a) {
953 if ((cmd[a] == '?') || (cmd[a] == '&')) {
954 for (b = a; b < strlen(cmd); ++b)
957 addurls(&cmd[a + 1]);
962 /* Static content can be sent without connecting to Citadel. */
963 if (!strcasecmp(action, "static")) {
964 strcpy(buf, &cmd[12]);
965 for (a = 0; a < strlen(buf); ++a)
969 goto SKIP_ALL_THIS_CRAP; /* Don't try to connect */
973 * If we're not connected to a Citadel server, try to hook up the
976 if (!WC->connected) {
977 if (!strcasecmp(ctdlhost, "uds")) {
978 /* unix domain socket */
979 sprintf(buf, "%s/citadel.socket", ctdlport);
980 WC->serv_sock = uds_connectsock(buf);
984 WC->serv_sock = tcp_connectsock(ctdlhost, ctdlport);
987 if (WC->serv_sock < 0) {
989 goto SKIP_ALL_THIS_CRAP;
993 serv_gets(buf); /* get the server welcome message */
994 locate_host(browser_host, WC->http_sock);
995 get_serv_info(browser_host, user_agent);
996 if (serv_info.serv_rev_level < MINIMUM_CIT_VERSION) {
997 wprintf("You are connected to a Citadel "
998 "server running Citadel %d.%02d;\nin "
999 "order to run this version of WebCit "
1000 "you must also have Citadel %d.%02d or"
1002 serv_info.serv_rev_level / 100,
1003 serv_info.serv_rev_level % 100,
1004 MINIMUM_CIT_VERSION / 100,
1005 MINIMUM_CIT_VERSION % 100
1007 end_webcit_session();
1008 goto SKIP_ALL_THIS_CRAP;
1014 * Functions which can be performed without logging in
1016 if (!strcasecmp(action, "listsub")) {
1018 goto SKIP_ALL_THIS_CRAP;
1020 #ifdef WEBCIT_WITH_CALENDAR_SERVICE
1021 if (!strcasecmp(action, "freebusy")) {
1023 goto SKIP_ALL_THIS_CRAP;
1027 check_for_express_messages();
1030 * If we're not logged in, but we have username and password cookies
1031 * supplied by the browser, try using them to log in.
1033 if ((!WC->logged_in) && (strlen(c_username) > 0) && (strlen(c_password) > 0)) {
1034 serv_printf("USER %s", c_username);
1036 if (buf[0] == '3') {
1037 serv_printf("PASS %s", c_password);
1039 if (buf[0] == '2') {
1040 become_logged_in(c_username, c_password, buf);
1045 * If we don't have a current room, but a cookie specifying the
1046 * current room is supplied, make an effort to go there.
1048 if ((strlen(WC->wc_roomname) == 0) && (strlen(c_roomname) > 0)) {
1049 serv_printf("GOTO %s", c_roomname);
1051 if (buf[0] == '2') {
1052 strcpy(WC->wc_roomname, c_roomname);
1056 if (!strcasecmp(action, "image")) {
1060 * All functions handled below this point ... make sure we log in
1061 * before doing anything else!
1063 } else if ((!WC->logged_in) && (!strcasecmp(action, "login"))) {
1065 } else if (!WC->logged_in) {
1066 display_login(NULL);
1070 * Various commands...
1073 else if (!strcasecmp(action, "do_welcome")) {
1075 } else if (!strcasecmp(action, "blank")) {
1077 } else if (!strcasecmp(action, "do_template")) {
1079 } else if (!strcasecmp(action, "display_main_menu")) {
1080 display_main_menu();
1081 } else if (!strcasecmp(action, "whobbs")) {
1083 } else if (!strcasecmp(action, "knrooms")) {
1085 } else if (!strcasecmp(action, "gotonext")) {
1088 } else if (!strcasecmp(action, "skip")) {
1090 } else if (!strcasecmp(action, "ungoto")) {
1092 } else if (!strcasecmp(action, "dotgoto")) {
1094 smart_goto(bstr("room"));
1095 } else if (!strcasecmp(action, "dotskip")) {
1096 smart_goto(bstr("room"));
1097 } else if (!strcasecmp(action, "termquit")) {
1099 } else if (!strcasecmp(action, "readnew")) {
1100 readloop("readnew");
1101 } else if (!strcasecmp(action, "readold")) {
1102 readloop("readold");
1103 } else if (!strcasecmp(action, "readfwd")) {
1104 readloop("readfwd");
1105 } else if (!strcasecmp(action, "headers")) {
1106 readloop("headers");
1107 } else if (!strcasecmp(action, "display_enter")) {
1109 } else if (!strcasecmp(action, "post")) {
1111 } else if (!strcasecmp(action, "do_stuff_to_one_msg")) {
1112 do_stuff_to_one_msg();
1113 } else if (!strcasecmp(action, "move_msg")) {
1115 } else if (!strcasecmp(action, "userlist")) {
1117 } else if (!strcasecmp(action, "showuser")) {
1119 } else if (!strcasecmp(action, "display_page")) {
1121 } else if (!strcasecmp(action, "page_user")) {
1123 } else if (!strcasecmp(action, "chat")) {
1125 } else if (!strcasecmp(action, "display_private")) {
1126 display_private("", 0);
1127 } else if (!strcasecmp(action, "goto_private")) {
1129 } else if (!strcasecmp(action, "zapped_list")) {
1131 } else if (!strcasecmp(action, "display_zap")) {
1133 } else if (!strcasecmp(action, "zap")) {
1135 } else if (!strcasecmp(action, "display_entroom")) {
1137 } else if (!strcasecmp(action, "entroom")) {
1139 } else if (!strcasecmp(action, "display_editroom")) {
1141 } else if (!strcasecmp(action, "netedit")) {
1143 } else if (!strcasecmp(action, "editroom")) {
1145 } else if (!strcasecmp(action, "display_whok")) {
1147 } else if (!strcasecmp(action, "display_editinfo")) {
1148 display_edit("Room info", "EINF 0", "RINF", "/editinfo", 1);
1149 } else if (!strcasecmp(action, "editinfo")) {
1150 save_edit("Room info", "EINF 1", 1);
1151 } else if (!strcasecmp(action, "display_editbio")) {
1152 sprintf(buf, "RBIO %s", WC->wc_username);
1153 display_edit("Your bio", "NOOP", buf, "editbio", 3);
1154 } else if (!strcasecmp(action, "editbio")) {
1155 save_edit("Your bio", "EBIO", 0);
1156 } else if (!strcasecmp(action, "confirm_delete_room")) {
1157 confirm_delete_room();
1158 } else if (!strcasecmp(action, "delete_room")) {
1160 } else if (!strcasecmp(action, "validate")) {
1162 } else if (!strcasecmp(action, "display_editpic")) {
1163 display_graphics_upload("your photo",
1166 } else if (!strcasecmp(action, "editpic")) {
1167 do_graphics_upload("UIMG 1|_userpic_");
1168 } else if (!strcasecmp(action, "display_editroompic")) {
1169 display_graphics_upload("the graphic for this room",
1172 } else if (!strcasecmp(action, "editroompic")) {
1173 do_graphics_upload("UIMG 1|_roompic_");
1174 } else if (!strcasecmp(action, "delete_floor")) {
1176 } else if (!strcasecmp(action, "rename_floor")) {
1178 } else if (!strcasecmp(action, "create_floor")) {
1180 } else if (!strcasecmp(action, "display_editfloorpic")) {
1181 sprintf(buf, "UIMG 0|_floorpic_|%s",
1182 bstr("which_floor"));
1183 display_graphics_upload("the graphic for this floor",
1186 } else if (!strcasecmp(action, "editfloorpic")) {
1187 sprintf(buf, "UIMG 1|_floorpic_|%s",
1188 bstr("which_floor"));
1189 do_graphics_upload(buf);
1190 } else if (!strcasecmp(action, "display_reg")) {
1192 } else if (!strcasecmp(action, "display_changepw")) {
1194 } else if (!strcasecmp(action, "changepw")) {
1196 } else if (!strcasecmp(action, "display_edit_node")) {
1197 display_edit_node();
1198 } else if (!strcasecmp(action, "edit_node")) {
1200 } else if (!strcasecmp(action, "display_netconf")) {
1202 } else if (!strcasecmp(action, "display_confirm_delete_node")) {
1203 display_confirm_delete_node();
1204 } else if (!strcasecmp(action, "delete_node")) {
1206 } else if (!strcasecmp(action, "display_add_node")) {
1208 } else if (!strcasecmp(action, "add_node")) {
1210 } else if (!strcasecmp(action, "terminate_session")) {
1212 terminate_session();
1213 } else if (!strcasecmp(action, "edit_me")) {
1215 } else if (!strcasecmp(action, "display_siteconfig")) {
1216 display_siteconfig();
1217 } else if (!strcasecmp(action, "chat_recv")) {
1219 } else if (!strcasecmp(action, "chat_send")) {
1221 } else if (!strcasecmp(action, "page_popup")) {
1223 } else if (!strcasecmp(action, "siteconfig")) {
1225 } else if (!strcasecmp(action, "display_generic")) {
1227 } else if (!strcasecmp(action, "do_generic")) {
1229 } else if (!strcasecmp(action, "display_menubar")) {
1231 } else if (!strcasecmp(action, "output_mimepart")) {
1233 } else if (!strcasecmp(action, "edit_vcard")) {
1235 } else if (!strcasecmp(action, "submit_vcard")) {
1237 } else if (!strcasecmp(action, "select_user_to_edit")) {
1238 select_user_to_edit(NULL, NULL);
1239 } else if (!strcasecmp(action, "display_edituser")) {
1240 display_edituser(NULL, 0);
1241 } else if (!strcasecmp(action, "edituser")) {
1243 } else if (!strcasecmp(action, "create_user")) {
1245 } else if (!strcasecmp(action, "changeview")) {
1247 } else if (!strcasecmp(action, "do_stuff_to_msgs")) {
1249 } else if (!strcasecmp(action, "change_start_page")) {
1250 change_start_page();
1251 } else if (!strcasecmp(action, "display_floorconfig")) {
1252 display_floorconfig(NULL);
1253 } else if (!strcasecmp(action, "toggle_self_service")) {
1254 toggle_self_service();
1255 #ifdef WEBCIT_WITH_CALENDAR_SERVICE
1256 } else if (!strcasecmp(action, "display_edit_task")) {
1257 display_edit_task();
1258 } else if (!strcasecmp(action, "save_task")) {
1260 } else if (!strcasecmp(action, "display_edit_event")) {
1261 display_edit_event();
1262 } else if (!strcasecmp(action, "save_event")) {
1264 } else if (!strcasecmp(action, "respond_to_request")) {
1265 respond_to_request();
1266 } else if (!strcasecmp(action, "handle_rsvp")) {
1269 } else if (!strcasecmp(action, "summary")) {
1271 } else if (!strcasecmp(action, "iconbar")) {
1273 } else if (!strcasecmp(action, "display_customize_iconbar")) {
1274 display_customize_iconbar();
1275 } else if (!strcasecmp(action, "commit_iconbar")) {
1277 } else if (!strcasecmp(action, "set_room_policy")) {
1279 } else if (!strcasecmp(action, "display_inetconf")) {
1281 } else if (!strcasecmp(action, "save_inetconf")) {
1283 } else if (!strcasecmp(action, "diagnostics")) {
1284 output_headers(1, 1, 1, 0, 0, 0, 0);
1286 wprintf("You're in session %d<hr />\n", WC->wc_session);
1287 wprintf("Command: <br /><PRE>\n");
1289 wprintf("</PRE><hr />\n");
1290 wprintf("Variables: <br /><PRE>\n");
1292 wprintf("</PRE><hr />\n");
1295 /* When all else fais, display the main menu. */
1297 display_main_menu();
1302 if (content != NULL) {
1307 if (WC->upload_length > 0) {
1309 WC->upload_length = 0;