00001
00002
00003
00011 #include "webcit.h"
00012 #include "groupdav.h"
00013 #include "webserver.h"
00014 #include "mime_parser.h"
00015
00021 static char *unset = "; expires=28-May-1971 18:10:00 GMT";
00022
00027 void unescape_input(char *buf)
00028 {
00029 int a, b;
00030 char hex[3];
00031
00032 while ((isspace(buf[strlen(buf) - 1])) && (strlen(buf) > 0))
00033 buf[strlen(buf) - 1] = 0;
00034
00035 for (a = 0; a < strlen(buf); ++a) {
00036 if (buf[a] == '+')
00037 buf[a] = ' ';
00038 if (buf[a] == '%') {
00039 hex[0] = buf[a + 1];
00040 hex[1] = buf[a + 2];
00041 hex[2] = 0;
00042 b = 0;
00043 sscanf(hex, "%02x", &b);
00044 buf[a] = (char) b;
00045 strcpy(&buf[a + 1], &buf[a + 3]);
00046 }
00047 }
00048
00049 }
00050
00055 void addurls(char *url)
00056 {
00057 char *up, *ptr;
00058 char buf[SIZ];
00059 int a, b;
00060 struct urlcontent *u;
00061
00062 up = url;
00063 while (strlen(up) > 0) {
00064
00066 safestrncpy(buf, up, sizeof buf);
00067 b = (-1);
00068 for (a = 255; a >= 0; --a)
00069 if (buf[a] == '=')
00070 b = a;
00071 if (b < 0)
00072 return;
00073 buf[b] = 0;
00074
00075 u = (struct urlcontent *) malloc(sizeof(struct urlcontent));
00076 u->next = WC->urlstrings;
00077 WC->urlstrings = u;
00078 safestrncpy(u->url_key, buf, sizeof u->url_key);
00079
00081 for (a = 0; a <= b; ++a)
00082 ++up;
00083
00085 ptr = up;
00086 b = strlen(up);
00087 for (a = 0; a < strlen(up); ++a) {
00088 if ( (ptr[0] == '&') || (ptr[0] == '?') ) {
00089 b = a;
00090 break;
00091 }
00092 ++ptr;
00093 }
00094 ptr = up;
00095 for (a = 0; a < b; ++a)
00096 ++ptr;
00097 strcpy(ptr, "");
00098
00099 u->url_data = malloc(strlen(up) + 2);
00100 safestrncpy(u->url_data, up, strlen(up) + 1);
00101 u->url_data[b] = 0;
00102 unescape_input(u->url_data);
00103 up = ptr;
00104 ++up;
00105
00106
00107 }
00108 }
00109
00113 void free_urls(void)
00114 {
00115 struct urlcontent *u;
00116
00117 while (WC->urlstrings != NULL) {
00118 free(WC->urlstrings->url_data);
00119 u = WC->urlstrings->next;
00120 free(WC->urlstrings);
00121 WC->urlstrings = u;
00122 }
00123 }
00124
00128 void dump_vars(void)
00129 {
00130 struct urlcontent *u;
00131
00132 for (u = WC->urlstrings; u != NULL; u = u->next) {
00133 wprintf("%38s = %s\n", u->url_key, u->url_data);
00134 }
00135 }
00136
00141 char *bstr(char *key)
00142 {
00143 struct urlcontent *u;
00144
00145 for (u = WC->urlstrings; u != NULL; u = u->next) {
00146 if (!strcasecmp(u->url_key, key))
00147 return (u->url_data);
00148 }
00149 return ("");
00150 }
00151
00157 void wprintf(const char *format,...)
00158 {
00159 va_list arg_ptr;
00160 char wbuf[4096];
00161
00162 va_start(arg_ptr, format);
00163 vsnprintf(wbuf, sizeof wbuf, format, arg_ptr);
00164 va_end(arg_ptr);
00165
00166 client_write(wbuf, strlen(wbuf));
00167 }
00168
00169
00177 void wDumpContent(int print_standard_html_footer)
00178 {
00179 if (print_standard_html_footer) {
00180 wprintf("</div>\n");
00181 do_template("trailing");
00182 }
00183
00184
00185
00186
00187 end_burst();
00188 }
00189
00190
00198 void stresc(char *target, char *strbuf, int nbsp, int nolinebreaks)
00199 {
00200 int a;
00201 strcpy(target, "");
00202
00203 for (a = 0; a < strlen(strbuf); ++a) {
00204 if (strbuf[a] == '<')
00205 strcat(target, "<");
00206 else if (strbuf[a] == '>')
00207 strcat(target, ">");
00208 else if (strbuf[a] == '&')
00209 strcat(target, "&");
00210 else if (strbuf[a] == '\"')
00211 strcat(target, """);
00212 else if (strbuf[a] == '\'')
00213 strcat(target, "'");
00214 else if (strbuf[a] == LB)
00215 strcat(target, "<");
00216 else if (strbuf[a] == RB)
00217 strcat(target, ">");
00218 else if (strbuf[a] == QU)
00219 strcat(target, "\"");
00220 else if ((strbuf[a] == 32) && (nbsp == 1))
00221 strcat(target, " ");
00222 else if ((strbuf[a] == '\n') && (nolinebreaks))
00223 strcat(target, "");
00224 else if ((strbuf[a] == '\r') && (nolinebreaks))
00225 strcat(target, "");
00226 else
00227 strncat(target, &strbuf[a], 1);
00228 }
00229 }
00230
00237 void escputs1(char *strbuf, int nbsp, int nolinebreaks)
00238 {
00239 char *buf;
00240
00241 if (strbuf == NULL) return;
00242 buf = malloc( (3 * strlen(strbuf)) + SIZ );
00243 stresc(buf, strbuf, nbsp, nolinebreaks);
00244 wprintf("%s", buf);
00245 free(buf);
00246 }
00247
00252 void escputs(char *strbuf)
00253 {
00254 escputs1(strbuf, 0, 0);
00255 }
00256
00262 void urlesc(char *outbuf, char *strbuf)
00263 {
00264 int a, b, c;
00265 char *ec = " #&;`'|*?-~<>^()[]{}/$\"\\";
00266
00267 strcpy(outbuf, "");
00268
00269 for (a = 0; a < strlen(strbuf); ++a) {
00270 c = 0;
00271 for (b = 0; b < strlen(ec); ++b) {
00272 if (strbuf[a] == ec[b])
00273 c = 1;
00274 }
00275 b = strlen(outbuf);
00276 if (c == 1)
00277 sprintf(&outbuf[b], "%%%02x", strbuf[a]);
00278 else
00279 sprintf(&outbuf[b], "%c", strbuf[a]);
00280 }
00281 }
00282
00287 void urlescputs(char *strbuf)
00288 {
00289 char outbuf[SIZ];
00290
00291 urlesc(outbuf, strbuf);
00292 wprintf("%s", outbuf);
00293 }
00294
00295
00301 void jsesc(char *target, char *strbuf)
00302 {
00303 int a;
00304 strcpy(target, "");
00305
00306 for (a = 0; a < strlen(strbuf); ++a) {
00307 if (strbuf[a] == '<')
00308 strcat(target, "[");
00309 else if (strbuf[a] == '>')
00310 strcat(target, "]");
00311 else if (strbuf[a] == '\"')
00312 strcat(target, """);
00313 else if (strbuf[a] == '&')
00314 strcat(target, "&;");
00315 else if (strbuf[a] == '\'')
00316 strcat(target, "\\'");
00317 else {
00318 strncat(target, &strbuf[a], 1);
00319 }
00320 }
00321 }
00322
00327 void jsescputs(char *strbuf)
00328 {
00329 char outbuf[SIZ];
00330
00331 jsesc(outbuf, strbuf);
00332 wprintf("%s", outbuf);
00333 }
00334
00340 void msgesc(char *target, char *strbuf)
00341 {
00342 int a;
00343 strcpy(target, "");
00344
00345 for (a = 0; a < strlen(strbuf); ++a) {
00346 if (strbuf[a] == '\n')
00347 strcat(target, " ");
00348 else if (strbuf[a] == '\r')
00349 strcat(target, " ");
00350 else if (strbuf[a] == '\'')
00351 strcat(target, "'");
00352 else {
00353 strncat(target, &strbuf[a], 1);
00354 }
00355 }
00356 }
00357
00362 void msgescputs(char *strbuf) {
00363 char *outbuf;
00364
00365 if (strbuf == NULL) return;
00366 outbuf = malloc( (3 * strlen(strbuf)) + SIZ);
00367 msgesc(outbuf, strbuf);
00368 wprintf("%s", outbuf);
00369 free(outbuf);
00370 }
00371
00372
00373
00374
00378 void output_headers( int do_httpheaders,
00379 int do_htmlhead,
00381 int do_room_banner,
00386 int unset_cookies,
00387 int suppress_check,
00388 int cache
00389 ) {
00390 char cookie[1024];
00391 char httpnow[128];
00392
00393 wprintf("HTTP/1.1 200 OK\n");
00394 http_datestring(httpnow, sizeof httpnow, time(NULL));
00395
00396 if (do_httpheaders) {
00397 wprintf("Content-type: text/html; charset=utf-8\r\n"
00398 "Server: %s / %s\n"
00399 "Connection: close\r\n",
00400 SERVER, serv_info.serv_software
00401 );
00402 }
00403
00404 if (cache) {
00405 wprintf("Pragma: public\r\n"
00406 "Cache-Control: max-age=3600, must-revalidate\r\n"
00407 "Last-modified: %s\r\n",
00408 httpnow
00409 );
00410 }
00411 else {
00412 wprintf("Pragma: no-cache\r\n"
00413 "Cache-Control: no-store\r\n"
00414 );
00415 }
00416
00417 stuff_to_cookie(cookie, WC->wc_session, WC->wc_username,
00418 WC->wc_password, WC->wc_roomname);
00419
00420 if (unset_cookies) {
00421 wprintf("Set-cookie: webcit=%s; path=/\r\n", unset);
00422 } else {
00423 wprintf("Set-cookie: webcit=%s; path=/\r\n", cookie);
00424 if (server_cookie != NULL) {
00425 wprintf("%s\n", server_cookie);
00426 }
00427 }
00428
00429 if (do_htmlhead) {
00430 begin_burst();
00431 if (!access("static.local/webcit.css", R_OK)) {
00432 svprintf("CSSLOCAL", WCS_STRING,
00433 "<link href=\"static.local/webcit.css\" rel=\"stylesheet\" type=\"text/css\">"
00434 );
00435 }
00436 do_template("head");
00437 }
00438
00440 if (do_htmlhead) {
00441
00442
00444 if (strlen(WC->ImportantMessage) > 0) {
00445 wprintf("<div id=\"important_message\">\n");
00446 wprintf("<span class=\"imsg\">"
00447 "%s</span><br />\n", WC->ImportantMessage);
00448 wprintf("</div>\n");
00449 wprintf("<script type=\"text/javascript\">\n"
00450 " setTimeout('hide_imsg_popup()', 3000); \n"
00451 "</script>\n");
00452 safestrncpy(WC->ImportantMessage, "", sizeof WC->ImportantMessage);
00453 }
00454
00455 if ( (WC->logged_in) && (!unset_cookies) ) {
00456 wprintf("<div id=\"iconbar\">");
00457 do_selected_iconbar();
00459 page_popup();
00460 wprintf("</div>");
00461 }
00462
00463 if (do_room_banner == 1) {
00464 wprintf("<div id=\"banner\">\n");
00465 embed_room_banner(NULL, navbar_default);
00466 wprintf("</div>\n");
00467 }
00468 }
00469
00470 if (do_room_banner == 1) {
00471 wprintf("<div id=\"content\">\n");
00472 }
00473 }
00474
00475
00480 void http_redirect(char *whichpage) {
00481 wprintf("HTTP/1.1 302 Moved Temporarily\n");
00482 wprintf("Location: %s\r\n", whichpage);
00483 wprintf("URI: %s\r\n", whichpage);
00484 wprintf("Content-type: text/html; charset=utf-8\r\n\r\n");
00485 wprintf("<html><body>");
00486 wprintf("Go <a href=\"%s\">here</A>.", whichpage);
00487 wprintf("</body></html>\n");
00488 }
00489
00490
00491
00495 void http_transmit_thing(char *thing, size_t length, char *content_type,
00496 int is_static) {
00497
00498 output_headers(0, 0, 0, 0, 0, is_static);
00499
00500 wprintf("Content-type: %s\r\n"
00501 "Server: %s\r\n"
00502 "Connection: close\r\n",
00503 content_type,
00504 SERVER);
00505
00506 #ifdef HAVE_ZLIB
00507
00508 if (WC->gzip_ok) {
00509 char *compressed_data = NULL;
00510 uLongf compressed_len;
00511
00512 compressed_len = (uLongf) ((length * 101) / 100) + 100;
00513 compressed_data = malloc(compressed_len);
00514
00515 if (compress_gzip((Bytef *) compressed_data,
00516 &compressed_len,
00517 (Bytef *) thing,
00518 (uLongf) length, Z_BEST_SPEED) == Z_OK) {
00519 wprintf("Content-encoding: gzip\r\n"
00520 "Content-length: %ld\r\n"
00521 "\r\n",
00522 (long) compressed_len
00523 );
00524 client_write(compressed_data, (size_t)compressed_len);
00525 free(compressed_data);
00526 return;
00527 }
00528 }
00529 #endif
00530
00532 wprintf("Content-length: %ld\r\n"
00533 "\r\n",
00534 (long) length
00535 );
00536 client_write(thing, (size_t)length);
00537 }
00538
00539
00540
00545 void output_static(char *what)
00546 {
00547 FILE *fp;
00548 struct stat statbuf;
00549 off_t bytes;
00550 char *bigbuffer;
00551 char content_type[128];
00552
00553 fp = fopen(what, "rb");
00554 if (fp == NULL) {
00555 lprintf(9, "output_static('%s') -- NOT FOUND --\n", what);
00556 wprintf("HTTP/1.1 404 %s\n", strerror(errno));
00557 wprintf("Content-Type: text/plain\r\n");
00558 wprintf("\r\n");
00559 wprintf("Cannot open %s: %s\n", what, strerror(errno));
00560 } else {
00561 if (!strncasecmp(&what[strlen(what) - 4], ".gif", 4))
00562 safestrncpy(content_type, "image/gif", sizeof content_type);
00563 else if (!strncasecmp(&what[strlen(what) - 4], ".txt", 4))
00564 safestrncpy(content_type, "text/plain", sizeof content_type);
00565 else if (!strncasecmp(&what[strlen(what) - 4], ".css", 4))
00566 safestrncpy(content_type, "text/css", sizeof content_type);
00567 else if (!strncasecmp(&what[strlen(what) - 4], ".jpg", 4))
00568 safestrncpy(content_type, "image/jpeg", sizeof content_type);
00569 else if (!strncasecmp(&what[strlen(what) - 4], ".png", 4))
00570 safestrncpy(content_type, "image/png", sizeof content_type);
00571 else if (!strncasecmp(&what[strlen(what) - 4], ".ico", 4))
00572 safestrncpy(content_type, "image/x-icon", sizeof content_type);
00573 else if (!strncasecmp(&what[strlen(what) - 5], ".html", 5))
00574 safestrncpy(content_type, "text/html", sizeof content_type);
00575 else if (!strncasecmp(&what[strlen(what) - 4], ".htm", 4))
00576 safestrncpy(content_type, "text/html", sizeof content_type);
00577 else if (!strncasecmp(&what[strlen(what) - 4], ".wml", 4))
00578 safestrncpy(content_type, "text/vnd.wap.wml", sizeof content_type);
00579 else if (!strncasecmp(&what[strlen(what) - 5], ".wmls", 5))
00580 safestrncpy(content_type, "text/vnd.wap.wmlscript", sizeof content_type);
00581 else if (!strncasecmp(&what[strlen(what) - 5], ".wmlc", 5))
00582 safestrncpy(content_type, "application/vnd.wap.wmlc", sizeof content_type);
00583 else if (!strncasecmp(&what[strlen(what) - 6], ".wmlsc", 6))
00584 safestrncpy(content_type, "application/vnd.wap.wmlscriptc", sizeof content_type);
00585 else if (!strncasecmp(&what[strlen(what) - 5], ".wbmp", 5))
00586 safestrncpy(content_type, "image/vnd.wap.wbmp", sizeof content_type);
00587 else if (!strncasecmp(&what[strlen(what) - 3], ".js", 3))
00588 safestrncpy(content_type, "text/javascript", sizeof content_type);
00589 else
00590 safestrncpy(content_type, "application/octet-stream", sizeof content_type);
00591
00592 fstat(fileno(fp), &statbuf);
00593 bytes = statbuf.st_size;
00594 bigbuffer = malloc(bytes + 2);
00595 fread(bigbuffer, bytes, 1, fp);
00596 fclose(fp);
00597
00598 lprintf(9, "output_static('%s') %s\n", what, content_type);
00599 http_transmit_thing(bigbuffer, (size_t)bytes, content_type, 1);
00600 free(bigbuffer);
00601 }
00602 if (!strcasecmp(bstr("force_close_session"), "yes")) {
00603 end_webcit_session();
00604 }
00605 }
00606
00607
00612 void output_image()
00613 {
00614 char buf[SIZ];
00615 char *xferbuf = NULL;
00616 off_t bytes;
00617
00618 serv_printf("OIMG %s|%s", bstr("name"), bstr("parm"));
00619 serv_getln(buf, sizeof buf);
00620 if (buf[0] == '2') {
00621 bytes = extract_long(&buf[4], 0);
00622 xferbuf = malloc(bytes + 2);
00623
00625 read_server_binary(xferbuf, bytes);
00626 serv_puts("CLOS");
00627 serv_getln(buf, sizeof buf);
00628
00630 http_transmit_thing(xferbuf, (size_t)bytes, "image/gif", 0);
00631 free(xferbuf);
00632
00633 } else {
00638 output_static("static/blank.gif");
00639 }
00640
00641
00642
00643 }
00644
00654 void mimepart(char *msgnum, char *partnum, int force_download)
00655 {
00656 char buf[256];
00657 off_t bytes;
00658 char content_type[256];
00659 char *content = NULL;
00660
00661 serv_printf("OPNA %s|%s", msgnum, partnum);
00662 serv_getln(buf, sizeof buf);
00663 if (buf[0] == '2') {
00664 bytes = extract_long(&buf[4], 0);
00665 content = malloc(bytes + 2);
00666 if (force_download) {
00667 strcpy(content_type, "application/octet-stream");
00668 }
00669 else {
00670 extract_token(content_type, &buf[4], 3, '|', sizeof content_type);
00671 }
00672 output_headers(0, 0, 0, 0, 0, 0);
00673 read_server_binary(content, bytes);
00674 serv_puts("CLOS");
00675 serv_getln(buf, sizeof buf);
00676 http_transmit_thing(content, bytes, content_type, 0);
00677 free(content);
00678 } else {
00679 wprintf("HTTP/1.1 404 %s\n", &buf[4]);
00680 output_headers(0, 0, 0, 0, 0, 0);
00681 wprintf("Content-Type: text/plain\r\n");
00682 wprintf("\r\n");
00683 wprintf(_("An error occurred while retrieving this part: %s\n"), &buf[4]);
00684 }
00685
00686 }
00687
00688
00694 char *load_mimepart(long msgnum, char *partnum)
00695 {
00696 char buf[SIZ];
00697 off_t bytes;
00698 char content_type[SIZ];
00699 char *content;
00700
00701 serv_printf("DLAT %ld|%s", msgnum, partnum);
00702 serv_getln(buf, sizeof buf);
00703 if (buf[0] == '6') {
00704 bytes = extract_long(&buf[4], 0);
00705 extract_token(content_type, &buf[4], 3, '|', sizeof content_type);
00706
00707 content = malloc(bytes + 2);
00708 serv_read(content, bytes);
00709
00710 content[bytes] = 0;
00711 return(content);
00712 }
00713 else {
00714 return(NULL);
00715 }
00716
00717 }
00718
00719
00726 void convenience_page(char *titlebarcolor, char *titlebarmsg, char *messagetext)
00727 {
00728 wprintf("HTTP/1.1 200 OK\n");
00729 output_headers(1, 1, 2, 0, 0, 0);
00730 wprintf("<div id=\"banner\">\n");
00731 wprintf("<table width=100%% border=0 bgcolor=\"#%s\"><tr><td>", titlebarcolor);
00732 wprintf("<span class=\"titlebar\">%s</span>\n", titlebarmsg);
00733 wprintf("</td></tr></table>\n");
00734 wprintf("</div>\n<div id=\"content\">\n");
00735 escputs(messagetext);
00736
00737 wprintf("<hr />\n");
00738 wDumpContent(1);
00739 }
00740
00741
00745 void blank_page(void) {
00746 output_headers(1, 1, 0, 0, 0, 0);
00747 wDumpContent(2);
00748 }
00749
00750
00754 void url_do_template(void) {
00755 do_template(bstr("template"));
00756 }
00757
00758
00759
00763 void offer_start_page(void) {
00764 wprintf("<a href=\"change_start_page?startpage=");
00765 urlescputs(WC->this_page);
00766 wprintf("\">");
00767 wprintf(_("Make this my start page"));
00768 wprintf("</a>");
00769
00770
00771
00772
00773
00774
00775
00776 }
00777
00778
00782 void change_start_page(void) {
00783
00784 if (bstr("startpage") == NULL) {
00785 safestrncpy(WC->ImportantMessage,
00786 _("You no longer have a start page selected."),
00787 sizeof WC->ImportantMessage);
00788 display_main_menu();
00789 return;
00790 }
00791
00792 set_preference("startpage", bstr("startpage"), 1);
00793
00794 output_headers(1, 1, 0, 0, 0, 0);
00795 do_template("newstartpage");
00796 wDumpContent(1);
00797 }
00798
00799
00800
00805 void display_success(char *successmessage)
00806 {
00807 convenience_page("007700", "OK", successmessage);
00808 }
00809
00810
00816 void authorization_required(const char *message)
00817 {
00818 wprintf("HTTP/1.1 401 Authorization Required\r\n");
00819 wprintf("WWW-Authenticate: Basic realm=\"\"\r\n", serv_info.serv_humannode);
00820 wprintf("Content-Type: text/html\r\n\r\n");
00821 wprintf("<h1>");
00822 wprintf(_("Authorization Required"));
00823 wprintf("</h1>\r\n");
00824 wprintf(_("The resource you requested requires a valid username and password. "
00825 "You could not be logged in: %s\n"), message);
00826 wDumpContent(0);
00827 }
00828
00845 void upload_handler(char *name, char *filename, char *partnum, char *disp,
00846 void *content, char *cbtype, char *cbcharset,
00847 size_t length, char *encoding, void *userdata)
00848 {
00849 struct urlcontent *u;
00850
00851 lprintf(9, "upload_handler() name=%s, type=%s, len=%d\n", name, cbtype, length);
00852
00853
00854 if ( (length > 0) && (strlen(cbtype) == 0) ) {
00855 u = (struct urlcontent *) malloc(sizeof(struct urlcontent));
00856 u->next = WC->urlstrings;
00857 WC->urlstrings = u;
00858 safestrncpy(u->url_key, name, sizeof(u->url_key));
00859 u->url_data = malloc(length + 1);
00860 memcpy(u->url_data, content, length);
00861 u->url_data[length] = 0;
00862
00863 }
00864
00866 if ( (length > 0) && (strlen(cbtype) > 0) ) {
00867 WC->upload = malloc(length);
00868 if (WC->upload != NULL) {
00869 WC->upload_length = length;
00870 safestrncpy(WC->upload_filename, filename,
00871 sizeof(WC->upload_filename));
00872 safestrncpy(WC->upload_content_type, cbtype,
00873 sizeof(WC->upload_content_type));
00874 memcpy(WC->upload, content, length);
00875 }
00876 else {
00877 lprintf(3, "malloc() failed: %s\n", strerror(errno));
00878 }
00879 }
00880
00881 }
00882
00886 void begin_ajax_response(void) {
00887 output_headers(0, 0, 0, 0, 0, 0);
00888
00889 wprintf("Content-type: text/html; charset=UTF-8\r\n"
00890 "Server: %s\r\n"
00891 "Connection: close\r\n"
00892 "Pragma: no-cache\r\n"
00893 "Cache-Control: no-cache\r\n",
00894 SERVER);
00895 begin_burst();
00896 }
00897
00901 void end_ajax_response(void) {
00902 wprintf("\r\n");
00903 wDumpContent(0);
00904 }
00905
00909 void ajax_servcmd(void)
00910 {
00911 char buf[1024];
00912 char gcontent[1024];
00913 char *junk;
00914 size_t len;
00915
00916 begin_ajax_response();
00917
00918 serv_printf("%s", bstr("g_cmd"));
00919 serv_getln(buf, sizeof buf);
00920 wprintf("%s\n", buf);
00921
00922 if (buf[0] == '8') {
00923 serv_printf("\n\n000");
00924 }
00925 if ((buf[0] == '1') || (buf[0] == '8')) {
00926 while (serv_getln(gcontent, sizeof gcontent), strcmp(gcontent, "000")) {
00927 wprintf("%s\n", gcontent);
00928 }
00929 wprintf("000");
00930 }
00931 if (buf[0] == '4') {
00932 text_to_server(bstr("g_input"));
00933 serv_puts("000");
00934 }
00935 if (buf[0] == '6') {
00936 len = atol(&buf[4]);
00937 junk = malloc(len);
00938 serv_read(junk, len);
00939 free(junk);
00940 }
00941 if (buf[0] == '7') {
00942 len = atol(&buf[4]);
00943 junk = malloc(len);
00944 memset(junk, 0, len);
00945 serv_write(junk, len);
00946 free(junk);
00947 }
00948
00949 end_ajax_response();
00950
00957 if (!strncasecmp(bstr("g_cmd"), "GEXP", 4)) {
00958 WC->last_pager_check = time(NULL);
00959 }
00960 }
00961
00962
00967 void seconds_since_last_gexp(void)
00968 {
00969 char buf[256];
00970
00971 begin_ajax_response();
00972 if ( (time(NULL) - WC->last_pager_check) < 30) {
00973 wprintf("NO\n");
00974 }
00975 else {
00976 serv_puts("NOOP");
00977 serv_getln(buf, sizeof buf);
00978 if (buf[3] == '*') {
00979 wprintf("YES");
00980 }
00981 else {
00982 wprintf("NO");
00983 }
00984 }
00985 end_ajax_response();
00986 }
00987
00988
00989
00990
00994 void session_loop(struct httprequest *req)
00995 {
00996 char cmd[1024];
00997 char action[1024];
00998 char arg[8][128];
00999 size_t sizes[10];
01000 char *index[10];
01001 char buf[SIZ];
01002 char request_method[128];
01003 char pathname[1024];
01004 int a, b, nBackDots, nEmpty;
01005 int ContentLength = 0;
01006 int BytesRead = 0;
01007 char ContentType[512];
01008 char *content = NULL;
01009 char *content_end = NULL;
01010 struct httprequest *hptr;
01011 char browser_host[256];
01012 char user_agent[256];
01013 int body_start = 0;
01014 int is_static = 0;
01015 int n_static = 0;
01020 char c_username[SIZ];
01021 char c_password[SIZ];
01022 char c_roomname[SIZ];
01023 char c_httpauth_string[SIZ];
01024 char c_httpauth_user[SIZ];
01025 char c_httpauth_pass[SIZ];
01026 char cookie[SIZ];
01027
01028 safestrncpy(c_username, "", sizeof c_username);
01029 safestrncpy(c_password, "", sizeof c_password);
01030 safestrncpy(c_roomname, "", sizeof c_roomname);
01031 safestrncpy(c_httpauth_string, "", sizeof c_httpauth_string);
01032 safestrncpy(c_httpauth_user, DEFAULT_HTTPAUTH_USER, sizeof c_httpauth_user);
01033 safestrncpy(c_httpauth_pass, DEFAULT_HTTPAUTH_PASS, sizeof c_httpauth_pass);
01034 strcpy(browser_host, "");
01035
01036 WC->upload_length = 0;
01037 WC->upload = NULL;
01038 WC->vars = NULL;
01039 WC->is_wap = 0;
01040
01041 hptr = req;
01042 if (hptr == NULL) return;
01043
01044 safestrncpy(cmd, hptr->line, sizeof cmd);
01045 hptr = hptr->next;
01046 extract_token(request_method, cmd, 0, ' ', sizeof request_method);
01047 extract_token(pathname, cmd, 1, ' ', sizeof pathname);
01048
01050 index[0] = action;
01051 sizes[0] = sizeof action;
01052 for (a=1; a<9; a++)
01053 {
01054 index[a] = arg[a-1];
01055 sizes[a] = sizeof arg[a-1];
01056 }
01058 nBackDots = 0;
01059 nEmpty = 0;
01060 for ( a = 0; a < 9; ++a)
01061 {
01062 extract_token(index[a], pathname, a + 1, '/', sizes[a]);
01063 if (strstr(index[a], "?")) *strstr(index[a], "?") = 0;
01064 if (strstr(index[a], "&")) *strstr(index[a], "&") = 0;
01065 if (strstr(index[a], " ")) *strstr(index[a], " ") = 0;
01066 if ((index[a][0] == '.') && (index[a][1] == '.'))
01067 nBackDots++;
01068 if (index[a][0] == '\0')
01069 nEmpty++;
01070 }
01071
01072 while (hptr != NULL) {
01073 safestrncpy(buf, hptr->line, sizeof buf);
01074
01075 hptr = hptr->next;
01076
01077 if (!strncasecmp(buf, "Cookie: webcit=", 15)) {
01078 safestrncpy(cookie, &buf[15], sizeof cookie);
01079 cookie_to_stuff(cookie, NULL,
01080 c_username, sizeof c_username,
01081 c_password, sizeof c_password,
01082 c_roomname, sizeof c_roomname);
01083 }
01084 else if (!strncasecmp(buf, "Authorization: Basic ", 21)) {
01085 CtdlDecodeBase64(c_httpauth_string, &buf[21], strlen(&buf[21]));
01086 extract_token(c_httpauth_user, c_httpauth_string, 0, ':', sizeof c_httpauth_user);
01087 extract_token(c_httpauth_pass, c_httpauth_string, 1, ':', sizeof c_httpauth_pass);
01088 }
01089 else if (!strncasecmp(buf, "Content-length: ", 16)) {
01090 ContentLength = atoi(&buf[16]);
01091 }
01092 else if (!strncasecmp(buf, "Content-type: ", 14)) {
01093 safestrncpy(ContentType, &buf[14], sizeof ContentType);
01094 }
01095 else if (!strncasecmp(buf, "User-agent: ", 12)) {
01096 safestrncpy(user_agent, &buf[12], sizeof user_agent);
01097 }
01098 else if (!strncasecmp(buf, "X-Forwarded-Host: ", 18)) {
01099 if (follow_xff) {
01100 safestrncpy(WC->http_host, &buf[18], sizeof WC->http_host);
01101 }
01102 }
01103 else if (!strncasecmp(buf, "Host: ", 6)) {
01104 if (strlen(WC->http_host) == 0) {
01105 safestrncpy(WC->http_host, &buf[6], sizeof WC->http_host);
01106 }
01107 }
01108 else if (!strncasecmp(buf, "X-Forwarded-For: ", 17)) {
01109 safestrncpy(browser_host, &buf[17], sizeof browser_host);
01110 while (num_tokens(browser_host, ',') > 1) {
01111 remove_token(browser_host, 0, ',');
01112 }
01113 striplt(browser_host);
01114 }
01116 else if (strstr(buf, "text/vnd.wap.wml")) {
01117 WC->is_wap = 1;
01118 }
01119 }
01120
01121 if (ContentLength > 0) {
01122 content = malloc(ContentLength + SIZ);
01123 memset(content, 0, ContentLength + SIZ);
01124 sprintf(content, "Content-type: %s\n"
01125 "Content-length: %d\n\n",
01126 ContentType, ContentLength);
01127 body_start = strlen(content);
01128
01130 client_read(WC->http_sock, &content[BytesRead+body_start], ContentLength);
01131
01132 if (!strncasecmp(ContentType, "application/x-www-form-urlencoded", 33)) {
01133 addurls(&content[body_start]);
01134 } else if (!strncasecmp(ContentType, "multipart", 9)) {
01135 content_end = content + ContentLength + body_start;
01136 mime_parser(content, content_end, *upload_handler, NULL, NULL, NULL, 0);
01137 }
01138 } else {
01139 content = NULL;
01140 }
01141
01143 safestrncpy(WC->this_page, cmd, sizeof(WC->this_page));
01144 remove_token(WC->this_page, 2, ' ');
01145 remove_token(WC->this_page, 0, ' ');
01146
01148 for (a = 0; a < strlen(cmd); ++a) {
01149 if ((cmd[a] == '?') || (cmd[a] == '&')) {
01150 for (b = a; b < strlen(cmd); ++b)
01151 if (isspace(cmd[b]))
01152 cmd[b] = 0;
01153 addurls(&cmd[a + 1]);
01154 cmd[a] = 0;
01155 }
01156 }
01157
01159 if (!strcmp(action, "404")) {
01160 wprintf("HTTP/1.1 404 Not found\r\n");
01161 wprintf("Content-Type: text/plain\r\n");
01162 wprintf("\r\n");
01163 wprintf("Not found\r\n");
01164 goto SKIP_ALL_THIS_CRAP;
01165 }
01166
01168 is_static = 0;
01169 for (a=0; a<ndirs; ++a) {
01170 if (!strcasecmp(action, (char*)static_content_dirs[a])) {
01171 is_static = 1;
01172 n_static = a;
01173 }
01174 }
01175 if (is_static) {
01176 if (nBackDots < 2)
01177 {
01178 snprintf(buf, sizeof buf, "%s/%s/%s/%s/%s/%s/%s/%s",
01179 static_dirs[n_static],
01180 index[1], index[2], index[3], index[4], index[5], index[6], index[7]);
01181 for (a=0; a<8; ++a) {
01182 if (buf[strlen(buf)-1] == '/') {
01183 buf[strlen(buf)-1] = 0;
01184 }
01185 }
01186 for (a = 0; a < strlen(buf); ++a) {
01187 if (isspace(buf[a])) {
01188 buf[a] = 0;
01189 }
01190 }
01191 output_static(buf);
01192 }
01193 else
01194 {
01195 lprintf(9, "Suspicious request. Ignoring.");
01196 wprintf("HTTP/1.1 404 Not found. Don't try to Trick me DUDE!\r\n");
01197 wprintf("Content-Type: text/plain\r\n");
01198 wprintf("\r\n");
01199 wprintf("Not found. Don't play games on me!\r\n");
01200 }
01201 goto SKIP_ALL_THIS_CRAP;
01202 }
01203
01208 if (!WC->connected) {
01209 if (!strcasecmp(ctdlhost, "uds")) {
01210
01211 sprintf(buf, "%s/citadel.socket", ctdlport);
01212 WC->serv_sock = uds_connectsock(buf);
01213 }
01214 else {
01215
01216 WC->serv_sock = tcp_connectsock(ctdlhost, ctdlport);
01217 }
01218
01219 if (WC->serv_sock < 0) {
01220 do_logout();
01221 goto SKIP_ALL_THIS_CRAP;
01222 }
01223 else {
01224 WC->connected = 1;
01225 serv_getln(buf, sizeof buf);
01233 if ( (!follow_xff) || (strlen(browser_host) == 0) ) {
01234 locate_host(browser_host, WC->http_sock);
01235 }
01236
01237 get_serv_info(browser_host, user_agent);
01238 if (serv_info.serv_rev_level < MINIMUM_CIT_VERSION) {
01239 wprintf(_("You are connected to a Citadel "
01240 "server running Citadel %d.%02d. \n"
01241 "In order to run this version of WebCit "
01242 "you must also have Citadel %d.%02d or"
01243 " newer.\n\n\n"),
01244 serv_info.serv_rev_level / 100,
01245 serv_info.serv_rev_level % 100,
01246 MINIMUM_CIT_VERSION / 100,
01247 MINIMUM_CIT_VERSION % 100
01248 );
01249 end_webcit_session();
01250 goto SKIP_ALL_THIS_CRAP;
01251 }
01252 }
01253 }
01254
01258 if (!strcasecmp(action, "listsub")) {
01259 do_listsub();
01260 goto SKIP_ALL_THIS_CRAP;
01261 }
01262 #ifdef WEBCIT_WITH_CALENDAR_SERVICE
01263 if (!strcasecmp(action, "freebusy")) {
01264 do_freebusy(cmd);
01265 goto SKIP_ALL_THIS_CRAP;
01266 }
01267 #endif
01268
01273 if ((!WC->logged_in)
01274 && (strlen(c_httpauth_user) > 0)
01275 && (strlen(c_httpauth_pass) > 0)) {
01276 serv_printf("USER %s", c_httpauth_user);
01277 serv_getln(buf, sizeof buf);
01278 if (buf[0] == '3') {
01279 serv_printf("PASS %s", c_httpauth_pass);
01280 serv_getln(buf, sizeof buf);
01281 if (buf[0] == '2') {
01282 become_logged_in(c_httpauth_user,
01283 c_httpauth_pass, buf);
01284 safestrncpy(WC->httpauth_user, c_httpauth_user, sizeof WC->httpauth_user);
01285 safestrncpy(WC->httpauth_pass, c_httpauth_pass, sizeof WC->httpauth_pass);
01286 } else {
01288 authorization_required(&buf[4]);
01289 goto SKIP_ALL_THIS_CRAP;
01290 }
01291 }
01292 }
01293
01295 if (!strcasecmp(action, "rss")) {
01296 display_rss(bstr("room"), request_method);
01297 goto SKIP_ALL_THIS_CRAP;
01298 }
01299
01304 if (!strncasecmp(action, "groupdav", 8)) {
01305 groupdav_main(req, ContentType,
01306 ContentLength, content+body_start);
01307 if (!WC->logged_in) {
01308 WC->killthis = 1;
01309 }
01310 goto SKIP_ALL_THIS_CRAP;
01311 }
01312
01313
01318 if ((strcasecmp(request_method, "GET")) && (strcasecmp(request_method, "POST"))) {
01319 groupdav_main(req, ContentType,
01320 ContentLength, content+body_start);
01321 if (!WC->logged_in) {
01322 WC->killthis = 1;
01323 }
01324 goto SKIP_ALL_THIS_CRAP;
01325 }
01326
01331 if ((!WC->logged_in)
01332 && (strlen(c_username) > 0)
01333 && (strlen(c_password) > 0)) {
01334 serv_printf("USER %s", c_username);
01335 serv_getln(buf, sizeof buf);
01336 if (buf[0] == '3') {
01337 serv_printf("PASS %s", c_password);
01338 serv_getln(buf, sizeof buf);
01339 if (buf[0] == '2') {
01340 become_logged_in(c_username, c_password, buf);
01341 }
01342 }
01343 }
01348 if ((strlen(WC->wc_roomname) == 0) && (strlen(c_roomname) > 0)) {
01349 serv_printf("GOTO %s", c_roomname);
01350 serv_getln(buf, sizeof buf);
01351 if (buf[0] == '2') {
01352 safestrncpy(WC->wc_roomname, c_roomname, sizeof WC->wc_roomname);
01353 }
01354 }
01355
01356 if (!strcasecmp(action, "image")) {
01357 output_image();
01358
01363 } else if ((!WC->logged_in) && (!strcasecmp(action, "login"))) {
01364 do_login();
01365 } else if (!WC->logged_in) {
01366 display_login(NULL);
01367 }
01368
01373 else if (!strcasecmp(action, "do_welcome")) {
01374 do_welcome();
01375 } else if (!strcasecmp(action, "blank")) {
01376 blank_page();
01377 } else if (!strcasecmp(action, "do_template")) {
01378 url_do_template();
01379 } else if (!strcasecmp(action, "display_aide_menu")) {
01380 display_aide_menu();
01381 } else if (!strcasecmp(action, "display_main_menu")) {
01382 display_main_menu();
01383 } else if (!strcasecmp(action, "who")) {
01384 who();
01385 } else if (!strcasecmp(action, "sslg")) {
01386 seconds_since_last_gexp();
01387 } else if (!strcasecmp(action, "who_inner_html")) {
01388 begin_ajax_response();
01389 who_inner_div();
01390 end_ajax_response();
01391 } else if (!strcasecmp(action, "wholist_section")) {
01392 begin_ajax_response();
01393 wholist_section();
01394 end_ajax_response();
01395 } else if (!strcasecmp(action, "new_messages_html")) {
01396 begin_ajax_response();
01397 new_messages_section();
01398 end_ajax_response();
01399 } else if (!strcasecmp(action, "tasks_inner_html")) {
01400 begin_ajax_response();
01401 tasks_section();
01402 end_ajax_response();
01403 } else if (!strcasecmp(action, "calendar_inner_html")) {
01404 begin_ajax_response();
01405 calendar_section();
01406 end_ajax_response();
01407 } else if (!strcasecmp(action, "iconbar_ajax_menu")) {
01408 begin_ajax_response();
01409 do_iconbar();
01410 end_ajax_response();
01411 } else if (!strcasecmp(action, "iconbar_ajax_rooms")) {
01412 begin_ajax_response();
01413 do_iconbar_roomlist();
01414 end_ajax_response();
01415 } else if (!strcasecmp(action, "knrooms")) {
01416 knrooms();
01417 } else if (!strcasecmp(action, "gotonext")) {
01418 slrp_highest();
01419 gotonext();
01420 } else if (!strcasecmp(action, "skip")) {
01421 gotonext();
01422 } else if (!strcasecmp(action, "ungoto")) {
01423 ungoto();
01424 } else if (!strcasecmp(action, "dotgoto")) {
01425 if (WC->wc_view != VIEW_MAILBOX) {
01426 slrp_highest();
01427 }
01428 smart_goto(bstr("room"));
01429 } else if (!strcasecmp(action, "dotskip")) {
01430 smart_goto(bstr("room"));
01431 } else if (!strcasecmp(action, "termquit")) {
01432 do_logout();
01433 } else if (!strcasecmp(action, "readnew")) {
01434 readloop("readnew");
01435 } else if (!strcasecmp(action, "readold")) {
01436 readloop("readold");
01437 } else if (!strcasecmp(action, "readfwd")) {
01438 readloop("readfwd");
01439 } else if (!strcasecmp(action, "headers")) {
01440 readloop("headers");
01441 } else if (!strcasecmp(action, "do_search")) {
01442 readloop("do_search");
01443 } else if (!strcasecmp(action, "msg")) {
01444 embed_message(index[1]);
01445 } else if (!strcasecmp(action, "printmsg")) {
01446 print_message(index[1]);
01447 } else if (!strcasecmp(action, "msgheaders")) {
01448 display_headers(index[1]);
01449 } else if (!strcasecmp(action, "wiki")) {
01450 display_wiki_page();
01451 } else if (!strcasecmp(action, "display_enter")) {
01452 display_enter();
01453 } else if (!strcasecmp(action, "post")) {
01454 post_message();
01455 } else if (!strcasecmp(action, "move_msg")) {
01456 move_msg();
01457 } else if (!strcasecmp(action, "delete_msg")) {
01458 delete_msg();
01459 } else if (!strcasecmp(action, "userlist")) {
01460 userlist();
01461 } else if (!strcasecmp(action, "showuser")) {
01462 showuser();
01463 } else if (!strcasecmp(action, "display_page")) {
01464 display_page();
01465 } else if (!strcasecmp(action, "page_user")) {
01466 page_user();
01467 } else if (!strcasecmp(action, "chat")) {
01468 do_chat();
01469 } else if (!strcasecmp(action, "display_private")) {
01470 display_private("", 0);
01471 } else if (!strcasecmp(action, "goto_private")) {
01472 goto_private();
01473 } else if (!strcasecmp(action, "zapped_list")) {
01474 zapped_list();
01475 } else if (!strcasecmp(action, "display_zap")) {
01476 display_zap();
01477 } else if (!strcasecmp(action, "zap")) {
01478 zap();
01479 } else if (!strcasecmp(action, "display_entroom")) {
01480 display_entroom();
01481 } else if (!strcasecmp(action, "entroom")) {
01482 entroom();
01483 } else if (!strcasecmp(action, "display_whok")) {
01484 display_whok();
01485 } else if (!strcasecmp(action, "do_invt_kick")) {
01486 do_invt_kick();
01487 } else if (!strcasecmp(action, "display_editroom")) {
01488 display_editroom();
01489 } else if (!strcasecmp(action, "netedit")) {
01490 netedit();
01491 } else if (!strcasecmp(action, "editroom")) {
01492 editroom();
01493 } else if (!strcasecmp(action, "display_editinfo")) {
01494 display_edit(_("Room info"), "EINF 0", "RINF", "editinfo", 1);
01495 } else if (!strcasecmp(action, "editinfo")) {
01496 save_edit(_("Room info"), "EINF 1", 1);
01497 } else if (!strcasecmp(action, "display_editbio")) {
01498 sprintf(buf, "RBIO %s", WC->wc_fullname);
01499 display_edit(_("Your bio"), "NOOP", buf, "editbio", 3);
01500 } else if (!strcasecmp(action, "editbio")) {
01501 save_edit(_("Your bio"), "EBIO", 0);
01502 } else if (!strcasecmp(action, "confirm_move_msg")) {
01503 confirm_move_msg();
01504 } else if (!strcasecmp(action, "delete_room")) {
01505 delete_room();
01506 } else if (!strcasecmp(action, "validate")) {
01507 validate();
01508 } else if (!strcasecmp(action, "display_editpic")) {
01509 display_graphics_upload(_("your photo"),
01510 "UIMG 0|_userpic_",
01511 "editpic");
01512 } else if (!strcasecmp(action, "editpic")) {
01513 do_graphics_upload("UIMG 1|_userpic_");
01514 } else if (!strcasecmp(action, "display_editroompic")) {
01515 display_graphics_upload(_("the icon for this room"),
01516 "UIMG 0|_roompic_",
01517 "editroompic");
01518 } else if (!strcasecmp(action, "editroompic")) {
01519 do_graphics_upload("UIMG 1|_roompic_");
01520 } else if (!strcasecmp(action, "delete_floor")) {
01521 delete_floor();
01522 } else if (!strcasecmp(action, "rename_floor")) {
01523 rename_floor();
01524 } else if (!strcasecmp(action, "create_floor")) {
01525 create_floor();
01526 } else if (!strcasecmp(action, "display_editfloorpic")) {
01527 sprintf(buf, "UIMG 0|_floorpic_|%s",
01528 bstr("which_floor"));
01529 display_graphics_upload(_("the icon for this floor"),
01530 buf,
01531 "editfloorpic");
01532 } else if (!strcasecmp(action, "editfloorpic")) {
01533 sprintf(buf, "UIMG 1|_floorpic_|%s",
01534 bstr("which_floor"));
01535 do_graphics_upload(buf);
01536 } else if (!strcasecmp(action, "display_reg")) {
01537 display_reg(0);
01538 } else if (!strcasecmp(action, "display_changepw")) {
01539 display_changepw();
01540 } else if (!strcasecmp(action, "changepw")) {
01541 changepw();
01542 } else if (!strcasecmp(action, "display_edit_node")) {
01543 display_edit_node();
01544 } else if (!strcasecmp(action, "edit_node")) {
01545 edit_node();
01546 } else if (!strcasecmp(action, "display_netconf")) {
01547 display_netconf();
01548 } else if (!strcasecmp(action, "display_confirm_delete_node")) {
01549 display_confirm_delete_node();
01550 } else if (!strcasecmp(action, "delete_node")) {
01551 delete_node();
01552 } else if (!strcasecmp(action, "display_add_node")) {
01553 display_add_node();
01554 } else if (!strcasecmp(action, "add_node")) {
01555 add_node();
01556 } else if (!strcasecmp(action, "terminate_session")) {
01557 slrp_highest();
01558 terminate_session();
01559 } else if (!strcasecmp(action, "edit_me")) {
01560 edit_me();
01561 } else if (!strcasecmp(action, "display_siteconfig")) {
01562 display_siteconfig();
01563 } else if (!strcasecmp(action, "chat_recv")) {
01564 chat_recv();
01565 } else if (!strcasecmp(action, "chat_send")) {
01566 chat_send();
01567 } else if (!strcasecmp(action, "siteconfig")) {
01568 siteconfig();
01569 } else if (!strcasecmp(action, "display_generic")) {
01570 display_generic();
01571 } else if (!strcasecmp(action, "do_generic")) {
01572 do_generic();
01573 } else if (!strcasecmp(action, "ajax_servcmd")) {
01574 ajax_servcmd();
01575 } else if (!strcasecmp(action, "display_menubar")) {
01576 display_menubar(1);
01577 } else if (!strcasecmp(action, "mimepart")) {
01578 mimepart(index[1], index[2], 0);
01579 } else if (!strcasecmp(action, "mimepart_download")) {
01580 mimepart(index[1], index[2], 1);
01581 } else if (!strcasecmp(action, "edit_vcard")) {
01582 edit_vcard();
01583 } else if (!strcasecmp(action, "submit_vcard")) {
01584 submit_vcard();
01585 } else if (!strcasecmp(action, "select_user_to_edit")) {
01586 select_user_to_edit(NULL, NULL);
01587 } else if (!strcasecmp(action, "display_edituser")) {
01588 display_edituser(NULL, 0);
01589 } else if (!strcasecmp(action, "edituser")) {
01590 edituser();
01591 } else if (!strcasecmp(action, "create_user")) {
01592 create_user();
01593 } else if (!strcasecmp(action, "changeview")) {
01594 change_view();
01595 } else if (!strcasecmp(action, "change_start_page")) {
01596 change_start_page();
01597 } else if (!strcasecmp(action, "display_floorconfig")) {
01598 display_floorconfig(NULL);
01599 } else if (!strcasecmp(action, "toggle_self_service")) {
01600 toggle_self_service();
01601 #ifdef WEBCIT_WITH_CALENDAR_SERVICE
01602 } else if (!strcasecmp(action, "display_edit_task")) {
01603 display_edit_task();
01604 } else if (!strcasecmp(action, "save_task")) {
01605 save_task();
01606 } else if (!strcasecmp(action, "display_edit_event")) {
01607 display_edit_event();
01608 } else if (!strcasecmp(action, "save_event")) {
01609 save_event();
01610 } else if (!strcasecmp(action, "respond_to_request")) {
01611 respond_to_request();
01612 } else if (!strcasecmp(action, "handle_rsvp")) {
01613 handle_rsvp();
01614 #endif
01615 } else if (!strcasecmp(action, "summary")) {
01616 summary();
01617 } else if (!strcasecmp(action, "summary_inner_div")) {
01618 begin_ajax_response();
01619 summary_inner_div();
01620 end_ajax_response();
01621 } else if (!strcasecmp(action, "display_customize_iconbar")) {
01622 display_customize_iconbar();
01623 } else if (!strcasecmp(action, "commit_iconbar")) {
01624 commit_iconbar();
01625 } else if (!strcasecmp(action, "set_room_policy")) {
01626 set_room_policy();
01627 } else if (!strcasecmp(action, "display_inetconf")) {
01628 display_inetconf();
01629 } else if (!strcasecmp(action, "save_inetconf")) {
01630 save_inetconf();
01631 } else if (!strcasecmp(action, "display_smtpqueue")) {
01632 display_smtpqueue();
01633 } else if (!strcasecmp(action, "display_smtpqueue_inner_div")) {
01634 display_smtpqueue_inner_div();
01635 } else if (!strcasecmp(action, "display_sieve")) {
01636 display_sieve();
01637 } else if (!strcasecmp(action, "save_sieve")) {
01638 save_sieve();
01639 } else if (!strcasecmp(action, "display_add_remove_scripts")) {
01640 display_add_remove_scripts(NULL);
01641 } else if (!strcasecmp(action, "create_script")) {
01642 create_script();
01643 } else if (!strcasecmp(action, "delete_script")) {
01644 delete_script();
01645 } else if (!strcasecmp(action, "setup_wizard")) {
01646 do_setup_wizard();
01647 } else if (!strcasecmp(action, "display_preferences")) {
01648 display_preferences();
01649 } else if (!strcasecmp(action, "set_preferences")) {
01650 set_preferences();
01651 } else if (!strcasecmp(action, "recp_autocomplete")) {
01652 recp_autocomplete(bstr("recp"));
01653 } else if (!strcasecmp(action, "cc_autocomplete")) {
01654 recp_autocomplete(bstr("cc"));
01655 } else if (!strcasecmp(action, "bcc_autocomplete")) {
01656 recp_autocomplete(bstr("bcc"));
01657 } else if (!strcasecmp(action, "display_address_book_middle_div")) {
01658 display_address_book_middle_div();
01659 } else if (!strcasecmp(action, "display_address_book_inner_div")) {
01660 display_address_book_inner_div();
01661 } else if (!strcasecmp(action, "set_floordiv_expanded")) {
01662 set_floordiv_expanded(index[1]);
01663 } else if (!strcasecmp(action, "diagnostics")) {
01664 output_headers(1, 1, 1, 0, 0, 0);
01665 wprintf("Session: %d<hr />\n", WC->wc_session);
01666 wprintf("Command: <br /><PRE>\n");
01667 escputs(cmd);
01668 wprintf("</PRE><hr />\n");
01669 wprintf("Variables: <br /><PRE>\n");
01670 dump_vars();
01671 wprintf("</PRE><hr />\n");
01672 wDumpContent(1);
01673 } else if (!strcasecmp(action, "updatenote")) {
01674 updatenote();
01675 } else if (!strcasecmp(action, "display_room_directory")) {
01676 display_room_directory();
01677 } else if (!strcasecmp(action, "download_file")) {
01678 download_file(index[1]);
01679 } else if (!strcasecmp(action, "upload_file")) {
01680 upload_file();
01681 }
01682
01684 else {
01685 display_main_menu();
01686 }
01687
01688 SKIP_ALL_THIS_CRAP:
01689 fflush(stdout);
01690 if (content != NULL) {
01691 free(content);
01692 content = NULL;
01693 }
01694 free_urls();
01695 if (WC->upload_length > 0) {
01696 free(WC->upload);
01697 WC->upload_length = 0;
01698 }
01699 }
01700
01701