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);
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; path=/\n", unset);
391 wprintf("Set-cookie: webcit=%s; path=/\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 sprintf(buf, "static/%s", what);
520 fp = fopen(buf, "rb");
522 wprintf("HTTP/1.0 404 %s\n", strerror(errno));
523 wprintf("Content-Type: text/plain\n");
525 wprintf("Cannot open %s: %s\n", what, strerror(errno));
527 if (!strncasecmp(&what[strlen(what) - 4], ".gif", 4))
528 strcpy(content_type, "image/gif");
529 else if (!strncasecmp(&what[strlen(what) - 4], ".txt", 4))
530 strcpy(content_type, "text/plain");
531 else if (!strncasecmp(&what[strlen(what) - 4], ".css", 4))
532 strcpy(content_type, "text/css");
533 else if (!strncasecmp(&what[strlen(what) - 4], ".jpg", 4))
534 strcpy(content_type, "image/jpeg");
535 else if (!strncasecmp(&what[strlen(what) - 4], ".png", 4))
536 strcpy(content_type, "image/png");
537 else if (!strncasecmp(&what[strlen(what) - 4], ".ico", 4))
538 strcpy(content_type, "image/x-icon");
539 else if (!strncasecmp(&what[strlen(what) - 5], ".html", 5))
540 strcpy(content_type, "text/html");
541 else if (!strncasecmp(&what[strlen(what) - 4], ".htm", 4))
542 strcpy(content_type, "text/html");
543 else if (!strncasecmp(&what[strlen(what) - 4], ".wml", 4))
544 strcpy(content_type, "text/vnd.wap.wml");
545 else if (!strncasecmp(&what[strlen(what) - 5], ".wmls", 5))
546 strcpy(content_type, "text/vnd.wap.wmlscript");
547 else if (!strncasecmp(&what[strlen(what) - 5], ".wmlc", 5))
548 strcpy(content_type, "application/vnd.wap.wmlc");
549 else if (!strncasecmp(&what[strlen(what) - 6], ".wmlsc", 6))
550 strcpy(content_type, "application/vnd.wap.wmlscriptc");
551 else if (!strncasecmp(&what[strlen(what) - 5], ".wbmp", 5))
552 strcpy(content_type, "image/vnd.wap.wbmp");
553 else if (!strncasecmp(&what[strlen(what) - 3], ".js", 3))
554 strcpy(content_type, "text/javascript");
556 strcpy(content_type, "application/octet-stream");
558 fstat(fileno(fp), &statbuf);
559 bytes = statbuf.st_size;
560 lprintf(3, "Static: %s, (%s; %ld bytes)\n", what, content_type, bytes);
561 bigbuffer = malloc(bytes + 2);
562 fread(bigbuffer, bytes, 1, fp);
565 http_transmit_thing(bigbuffer, (size_t)bytes, content_type, 1);
568 if (!strcasecmp(bstr("force_close_session"), "yes")) {
569 end_webcit_session();
575 * When the browser requests an image file from the Citadel server,
576 * this function is called to transmit it.
581 char *xferbuf = NULL;
584 serv_printf("OIMG %s|%s", bstr("name"), bstr("parm"));
587 bytes = extract_long(&buf[4], 0);
588 xferbuf = malloc(bytes + 2);
590 /* Read it from the server */
591 read_server_binary(xferbuf, bytes);
595 /* Write it to the browser */
596 http_transmit_thing(xferbuf, (size_t)bytes, "image/gif", 0);
601 /* Instead of an ugly 404, send a 1x1 transparent GIF
602 * when there's no such image on the server.
604 output_static("blank.gif");
607 wprintf("HTTP/1.0 404 %s\n", &buf[4]);
609 wprintf("Content-Type: text/plain\n"
611 "Error retrieving image: %s\n",
624 void output_mimepart()
628 char content_type[SIZ];
629 char *content = NULL;
631 serv_printf("OPNA %s|%s", bstr("msgnum"), bstr("partnum"));
634 bytes = extract_long(&buf[4], 0);
635 content = malloc(bytes + 2);
636 extract(content_type, &buf[4], 3);
638 read_server_binary(content, bytes);
641 http_transmit_thing(content, bytes, content_type, 0);
644 wprintf("HTTP/1.0 404 %s\n", &buf[4]);
646 wprintf("Content-Type: text/plain\n");
648 wprintf("Error retrieving part: %s\n", &buf[4]);
656 char *load_mimepart(long msgnum, char *partnum)
660 char content_type[SIZ];
663 serv_printf("OPNA %ld|%s", msgnum, partnum);
666 bytes = extract_long(&buf[4], 0);
667 extract(content_type, &buf[4], 3);
669 content = malloc(bytes + 2);
670 read_server_binary(content, bytes);
674 content[bytes] = 0; /* null terminate for good measure */
685 * Convenience functions to display a page containing only a string
687 void convenience_page(char *titlebarcolor, char *titlebarmsg, char *messagetext)
689 wprintf("HTTP/1.0 200 OK\n");
691 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#%s\"><TR><TD>", titlebarcolor);
692 wprintf("<SPAN CLASS=\"titlebar\">%s</SPAN>\n", titlebarmsg);
693 wprintf("</TD></TR></TABLE><BR>\n");
694 escputs(messagetext);
702 * Display a blank page.
704 void blank_page(void) {
711 * A template has been requested
713 void url_do_template(void) {
714 do_template(bstr("template"));
720 * Offer to make any page the user's "start page."
722 void offer_start_page(void) {
723 wprintf("<A HREF=\"/change_start_page?startpage=");
724 urlescputs(WC->this_page);
726 "<FONT SIZE=-2 COLOR=\"#AAAAAA\">Make this my start page</FONT>"
733 * Change the user's start page
735 void change_start_page(void) {
737 if (bstr("startpage") == NULL) {
738 strcpy(WC->ImportantMessage,
739 "startpage set to null");
744 set_preference("startpage", bstr("startpage"));
747 do_template("newstartpage");
754 void display_success(char *successmessage)
756 convenience_page("007700", "OK", successmessage);
761 void extract_action(char *actbuf, char *cmdbuf)
765 strcpy(actbuf, cmdbuf);
766 if (!strncasecmp(actbuf, "GET /", 5))
767 strcpy(actbuf, &actbuf[5]);
768 if (!strncasecmp(actbuf, "PUT /", 5))
769 strcpy(actbuf, &actbuf[5]);
770 if (!strncasecmp(actbuf, "POST /", 6))
771 strcpy(actbuf, &actbuf[6]);
773 for (i = 0; i < strlen(actbuf); ++i) {
774 if (actbuf[i] == ' ') {
778 if (actbuf[i] == '/') {
782 if (actbuf[i] == '?') {
786 if (actbuf[i] == '&') {
794 void upload_handler(char *name, char *filename, char *partnum, char *disp,
795 void *content, char *cbtype, size_t length,
796 char *encoding, void *userdata)
798 struct urlcontent *u;
801 if ( (length > 0) && (strlen(cbtype) == 0) ) {
802 u = (struct urlcontent *) malloc(sizeof(struct urlcontent));
803 u->next = WC->urlstrings;
805 safestrncpy(u->url_key, name, sizeof(u->url_key));
806 u->url_data = malloc(length + 1);
807 memcpy(u->url_data, content, length);
808 u->url_data[length] = 0;
812 if ( (length > 0) && (strlen(cbtype) > 0) ) {
813 WC->upload = malloc(length);
814 if (WC->upload != NULL) {
815 WC->upload_length = length;
816 safestrncpy(WC->upload_filename, filename,
817 sizeof(WC->upload_filename));
818 safestrncpy(WC->upload_content_type, cbtype,
819 sizeof(WC->upload_content_type));
820 memcpy(WC->upload, content, length);
823 lprintf(3, "malloc() failed: %s\n", strerror(errno));
833 * Entry point for WebCit transaction
835 void session_loop(struct httprequest *req)
841 int ContentLength = 0;
843 char ContentType[512];
846 struct httprequest *hptr;
847 char browser_host[SIZ];
848 char user_agent[SIZ];
851 /* We stuff these with the values coming from the client cookies,
852 * so we can use them to reconnect a timed out session if we have to.
854 char c_username[SIZ];
855 char c_password[SIZ];
856 char c_roomname[SIZ];
859 strcpy(c_username, "");
860 strcpy(c_password, "");
861 strcpy(c_roomname, "");
863 WC->upload_length = 0;
869 if (hptr == NULL) return;
871 strcpy(cmd, hptr->line);
873 extract_action(action, cmd);
875 while (hptr != NULL) {
876 strcpy(buf, hptr->line);
879 if (!strncasecmp(buf, "Cookie: webcit=", 15)) {
880 strcpy(cookie, &buf[15]);
881 cookie_to_stuff(cookie, NULL,
882 c_username, c_password, c_roomname);
884 else if (!strncasecmp(buf, "Content-length: ", 16)) {
885 ContentLength = atoi(&buf[16]);
887 else if (!strncasecmp(buf, "Content-type: ", 14)) {
888 safestrncpy(ContentType, &buf[14], sizeof ContentType);
890 else if (!strncasecmp(buf, "User-agent: ", 12)) {
891 safestrncpy(user_agent, &buf[12], sizeof user_agent);
893 else if (!strncasecmp(buf, "Host: ", 6)) {
894 safestrncpy(WC->http_host, &buf[6], sizeof WC->http_host);
896 /* Only WAP gateways explicitly name this content-type */
897 else if (strstr(buf, "text/vnd.wap.wml")) {
902 if (ContentLength > 0) {
903 content = malloc(ContentLength + SIZ);
904 memset(content, 0, ContentLength + SIZ);
905 sprintf(content, "Content-type: %s\n"
906 "Content-length: %d\n\n",
907 ContentType, ContentLength);
908 body_start = strlen(content);
912 while (BytesRead < ContentLength) {
913 a=read(WC->http_sock, &content[BytesRead+body_start],
914 ContentLength - BytesRead);
915 if (a <= 0) BytesRead = ContentLength;
920 /* Now we're daring and read it all at once. */
921 client_read(WC->http_sock, &content[BytesRead+body_start], ContentLength);
923 if (!strncasecmp(ContentType,
924 "application/x-www-form-urlencoded", 33)) {
925 addurls(&content[body_start]);
926 } else if (!strncasecmp(ContentType, "multipart", 9)) {
927 content_end = content + ContentLength + body_start;
928 mime_parser(content, content_end, *upload_handler,
929 NULL, NULL, NULL, 0);
935 /* make a note of where we are in case the user wants to save it */
936 safestrncpy(WC->this_page, cmd, sizeof(WC->this_page));
937 remove_token(WC->this_page, 2, ' ');
938 remove_token(WC->this_page, 0, ' ');
940 /* If there are variables in the URL, we must grab them now */
941 for (a = 0; a < strlen(cmd); ++a) {
942 if ((cmd[a] == '?') || (cmd[a] == '&')) {
943 for (b = a; b < strlen(cmd); ++b)
946 addurls(&cmd[a + 1]);
951 /* Static content can be sent without connecting to Citadel. */
952 if (!strcasecmp(action, "static")) {
953 strcpy(buf, &cmd[12]);
954 for (a = 0; a < strlen(buf); ++a)
958 goto SKIP_ALL_THIS_CRAP; /* Don't try to connect */
962 * If we're not connected to a Citadel server, try to hook up the
965 if (!WC->connected) {
966 if (!strcasecmp(ctdlhost, "uds")) {
967 /* unix domain socket */
968 sprintf(buf, "%s/citadel.socket", ctdlport);
969 WC->serv_sock = uds_connectsock(buf);
973 WC->serv_sock = tcp_connectsock(ctdlhost, ctdlport);
976 if (WC->serv_sock < 0) {
978 goto SKIP_ALL_THIS_CRAP;
982 serv_gets(buf); /* get the server welcome message */
983 locate_host(browser_host, WC->http_sock);
984 get_serv_info(browser_host, user_agent);
985 if (serv_info.serv_rev_level < MINIMUM_CIT_VERSION) {
986 wprintf("You are connected to a Citadel "
987 "server running Citadel %d.%02d;\nin "
988 "order to run this version of WebCit "
989 "you must also have Citadel %d.%02d or"
991 serv_info.serv_rev_level / 100,
992 serv_info.serv_rev_level % 100,
993 MINIMUM_CIT_VERSION / 100,
994 MINIMUM_CIT_VERSION % 100
996 end_webcit_session();
997 goto SKIP_ALL_THIS_CRAP;
1003 * Functions which can be performed without logging in
1005 if (!strcasecmp(action, "listsub")) {
1007 goto SKIP_ALL_THIS_CRAP;
1009 #ifdef WEBCIT_WITH_CALENDAR_SERVICE
1010 if (!strcasecmp(action, "freebusy")) {
1012 goto SKIP_ALL_THIS_CRAP;
1016 check_for_express_messages();
1019 * If we're not logged in, but we have username and password cookies
1020 * supplied by the browser, try using them to log in.
1022 if ((!WC->logged_in) && (strlen(c_username) > 0) && (strlen(c_password) > 0)) {
1023 serv_printf("USER %s", c_username);
1025 if (buf[0] == '3') {
1026 serv_printf("PASS %s", c_password);
1028 if (buf[0] == '2') {
1029 become_logged_in(c_username, c_password, buf);
1034 * If we don't have a current room, but a cookie specifying the
1035 * current room is supplied, make an effort to go there.
1037 if ((strlen(WC->wc_roomname) == 0) && (strlen(c_roomname) > 0)) {
1038 serv_printf("GOTO %s", c_roomname);
1040 if (buf[0] == '2') {
1041 strcpy(WC->wc_roomname, c_roomname);
1045 if (!strcasecmp(action, "image")) {
1049 * All functions handled below this point ... make sure we log in
1050 * before doing anything else!
1052 } else if ((!WC->logged_in) && (!strcasecmp(action, "login"))) {
1054 } else if (!WC->logged_in) {
1055 display_login(NULL);
1059 * Various commands...
1062 else if (!strcasecmp(action, "do_welcome")) {
1064 } else if (!strcasecmp(action, "blank")) {
1066 } else if (!strcasecmp(action, "do_template")) {
1068 } else if (!strcasecmp(action, "display_main_menu")) {
1069 display_main_menu();
1070 } else if (!strcasecmp(action, "whobbs")) {
1072 } else if (!strcasecmp(action, "knrooms")) {
1074 } else if (!strcasecmp(action, "gotonext")) {
1077 } else if (!strcasecmp(action, "skip")) {
1079 } else if (!strcasecmp(action, "ungoto")) {
1081 } else if (!strcasecmp(action, "dotgoto")) {
1083 smart_goto(bstr("room"));
1084 } else if (!strcasecmp(action, "dotskip")) {
1085 smart_goto(bstr("room"));
1086 } else if (!strcasecmp(action, "termquit")) {
1088 } else if (!strcasecmp(action, "readnew")) {
1089 readloop("readnew");
1090 } else if (!strcasecmp(action, "readold")) {
1091 readloop("readold");
1092 } else if (!strcasecmp(action, "readfwd")) {
1093 readloop("readfwd");
1094 } else if (!strcasecmp(action, "headers")) {
1095 readloop("headers");
1096 } else if (!strcasecmp(action, "display_enter")) {
1098 } else if (!strcasecmp(action, "post")) {
1100 } else if (!strcasecmp(action, "do_stuff_to_one_msg")) {
1101 do_stuff_to_one_msg();
1102 } else if (!strcasecmp(action, "move_msg")) {
1104 } else if (!strcasecmp(action, "userlist")) {
1106 } else if (!strcasecmp(action, "showuser")) {
1108 } else if (!strcasecmp(action, "display_page")) {
1110 } else if (!strcasecmp(action, "page_user")) {
1112 } else if (!strcasecmp(action, "chat")) {
1114 } else if (!strcasecmp(action, "display_private")) {
1115 display_private("", 0);
1116 } else if (!strcasecmp(action, "goto_private")) {
1118 } else if (!strcasecmp(action, "zapped_list")) {
1120 } else if (!strcasecmp(action, "display_zap")) {
1122 } else if (!strcasecmp(action, "zap")) {
1124 } else if (!strcasecmp(action, "display_entroom")) {
1126 } else if (!strcasecmp(action, "entroom")) {
1128 } else if (!strcasecmp(action, "display_editroom")) {
1130 } else if (!strcasecmp(action, "netedit")) {
1132 } else if (!strcasecmp(action, "editroom")) {
1134 } else if (!strcasecmp(action, "display_whok")) {
1136 } else if (!strcasecmp(action, "display_editinfo")) {
1137 display_edit("Room info", "EINF 0", "RINF", "/editinfo", 1);
1138 } else if (!strcasecmp(action, "editinfo")) {
1139 save_edit("Room info", "EINF 1", 1);
1140 } else if (!strcasecmp(action, "display_editbio")) {
1141 sprintf(buf, "RBIO %s", WC->wc_username);
1142 display_edit("Your bio", "NOOP", buf, "editbio", 3);
1143 } else if (!strcasecmp(action, "editbio")) {
1144 save_edit("Your bio", "EBIO", 0);
1145 } else if (!strcasecmp(action, "confirm_delete_room")) {
1146 confirm_delete_room();
1147 } else if (!strcasecmp(action, "delete_room")) {
1149 } else if (!strcasecmp(action, "validate")) {
1151 } else if (!strcasecmp(action, "display_editpic")) {
1152 display_graphics_upload("your photo",
1155 } else if (!strcasecmp(action, "editpic")) {
1156 do_graphics_upload("UIMG 1|_userpic_");
1157 } else if (!strcasecmp(action, "display_editroompic")) {
1158 display_graphics_upload("the graphic for this room",
1161 } else if (!strcasecmp(action, "editroompic")) {
1162 do_graphics_upload("UIMG 1|_roompic_");
1163 } else if (!strcasecmp(action, "delete_floor")) {
1165 } else if (!strcasecmp(action, "rename_floor")) {
1167 } else if (!strcasecmp(action, "create_floor")) {
1169 } else if (!strcasecmp(action, "display_editfloorpic")) {
1170 sprintf(buf, "UIMG 0|_floorpic_|%s",
1171 bstr("which_floor"));
1172 display_graphics_upload("the graphic for this floor",
1175 } else if (!strcasecmp(action, "editfloorpic")) {
1176 sprintf(buf, "UIMG 1|_floorpic_|%s",
1177 bstr("which_floor"));
1178 do_graphics_upload(buf);
1179 } else if (!strcasecmp(action, "display_reg")) {
1181 } else if (!strcasecmp(action, "display_changepw")) {
1183 } else if (!strcasecmp(action, "changepw")) {
1185 } else if (!strcasecmp(action, "display_edit_node")) {
1186 display_edit_node();
1187 } else if (!strcasecmp(action, "edit_node")) {
1189 } else if (!strcasecmp(action, "display_netconf")) {
1191 } else if (!strcasecmp(action, "display_confirm_delete_node")) {
1192 display_confirm_delete_node();
1193 } else if (!strcasecmp(action, "delete_node")) {
1195 } else if (!strcasecmp(action, "display_add_node")) {
1197 } else if (!strcasecmp(action, "add_node")) {
1199 } else if (!strcasecmp(action, "terminate_session")) {
1201 terminate_session();
1202 } else if (!strcasecmp(action, "edit_me")) {
1204 } else if (!strcasecmp(action, "display_siteconfig")) {
1205 display_siteconfig();
1206 } else if (!strcasecmp(action, "chat_recv")) {
1208 } else if (!strcasecmp(action, "chat_send")) {
1210 } else if (!strcasecmp(action, "page_popup")) {
1212 } else if (!strcasecmp(action, "siteconfig")) {
1214 } else if (!strcasecmp(action, "display_generic")) {
1216 } else if (!strcasecmp(action, "do_generic")) {
1218 } else if (!strcasecmp(action, "display_menubar")) {
1220 } else if (!strcasecmp(action, "output_mimepart")) {
1222 } else if (!strcasecmp(action, "edit_vcard")) {
1224 } else if (!strcasecmp(action, "submit_vcard")) {
1226 } else if (!strcasecmp(action, "select_user_to_edit")) {
1227 select_user_to_edit(NULL, NULL);
1228 } else if (!strcasecmp(action, "display_edituser")) {
1229 display_edituser(NULL, 0);
1230 } else if (!strcasecmp(action, "edituser")) {
1232 } else if (!strcasecmp(action, "create_user")) {
1234 } else if (!strcasecmp(action, "changeview")) {
1236 } else if (!strcasecmp(action, "do_stuff_to_msgs")) {
1238 } else if (!strcasecmp(action, "change_start_page")) {
1239 change_start_page();
1240 } else if (!strcasecmp(action, "display_floorconfig")) {
1241 display_floorconfig(NULL);
1242 } else if (!strcasecmp(action, "toggle_self_service")) {
1243 toggle_self_service();
1244 #ifdef WEBCIT_WITH_CALENDAR_SERVICE
1245 } else if (!strcasecmp(action, "display_edit_task")) {
1246 display_edit_task();
1247 } else if (!strcasecmp(action, "save_task")) {
1249 } else if (!strcasecmp(action, "display_edit_event")) {
1250 display_edit_event();
1251 } else if (!strcasecmp(action, "save_event")) {
1253 } else if (!strcasecmp(action, "respond_to_request")) {
1254 respond_to_request();
1255 } else if (!strcasecmp(action, "handle_rsvp")) {
1258 } else if (!strcasecmp(action, "summary")) {
1260 } else if (!strcasecmp(action, "iconbar")) {
1262 } else if (!strcasecmp(action, "display_customize_iconbar")) {
1263 display_customize_iconbar();
1264 } else if (!strcasecmp(action, "commit_iconbar")) {
1266 } else if (!strcasecmp(action, "set_room_policy")) {
1268 } else if (!strcasecmp(action, "display_inetconf")) {
1270 } else if (!strcasecmp(action, "save_inetconf")) {
1272 } else if (!strcasecmp(action, "diagnostics")) {
1275 wprintf("You're in session %d<HR>\n", WC->wc_session);
1276 wprintf("Command: <BR><PRE>\n");
1278 wprintf("</PRE><HR>\n");
1279 wprintf("Variables: <BR><PRE>\n");
1281 wprintf("</PRE><HR>\n");
1284 /* When all else fais, display the main menu. */
1286 display_main_menu();
1291 if (content != NULL) {
1296 if (WC->upload_length > 0) {
1298 WC->upload_length = 0;