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 the & sign */
98 for (a = 0; a < strlen(up); ++a) {
99 if (!strncmp(ptr, "&", 1)) {
106 for (a = 0; a < b; ++a)
110 u->url_data = malloc(strlen(up) + 1);
111 strcpy(u->url_data, up);
113 unescape_input(u->url_data);
121 struct urlcontent *u;
123 while (WC->urlstrings != NULL) {
124 free(WC->urlstrings->url_data);
125 u = WC->urlstrings->next;
126 free(WC->urlstrings);
132 * Diagnostic function to display the contents of all variables
136 struct urlcontent *u;
138 for (u = WC->urlstrings; u != NULL; u = u->next) {
139 wprintf("%38s = %s\n", u->url_key, u->url_data);
143 char *bstr(char *key)
145 struct urlcontent *u;
147 for (u = WC->urlstrings; u != NULL; u = u->next) {
148 if (!strcasecmp(u->url_key, key))
149 return (u->url_data);
155 void wprintf(const char *format,...)
160 va_start(arg_ptr, format);
161 vsprintf(wbuf, format, arg_ptr);
164 write(WC->http_sock, 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)
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, " ");
214 strncat(target, &strbuf[a], 1);
219 void escputs1(char *strbuf, int nbsp)
222 stresc(buf, strbuf, nbsp);
226 void escputs(char *strbuf)
232 * Escape a string for feeding out as a URL.
233 * Returns a pointer to a buffer that must be freed by the caller!
235 void urlesc(char *outbuf, char *strbuf)
238 char *ec = " #&;`'|*?-~<>^()[]{}$\\";
242 for (a = 0; a < strlen(strbuf); ++a) {
244 for (b = 0; b < strlen(ec); ++b) {
245 if (strbuf[a] == ec[b])
250 sprintf(&outbuf[b], "%%%02x", strbuf[a]);
252 sprintf(&outbuf[b], "%c", strbuf[a]);
256 void urlescputs(char *strbuf)
260 urlesc(outbuf, strbuf);
261 wprintf("%s", outbuf);
268 * Output all that important stuff that the browser will want to see
273 * 0 = Nothing. Do not display any leading HTTP or HTML.
274 * 1 = HTTP headers plus the room banner
275 * 2 = HTTP headers required to terminate the session (unset cookies)
276 * 3 = HTTP and HTML headers, but no room banner
278 * Bit 2: Set to 1 to auto-refresh page every 30 seconds
280 * Bit 3: suppress check for express messages
282 void output_headers(int controlcode)
285 int print_standard_html_head = 0;
287 int suppress_check = 0;
289 static int pageseq = 0;
290 print_standard_html_head = controlcode & 0x03;
291 refresh30 = ((controlcode & 0x04) >> 2);
292 suppress_check = ((controlcode & 0x08) >> 3);
294 wprintf("HTTP/1.0 200 OK\n");
296 httpdate(httpnow, time(NULL));
298 if (print_standard_html_head > 0) {
299 wprintf("Content-type: text/html\n"
300 "Server: %s\n", SERVER
302 wprintf("Connection: close\n"
304 "Cache-Control: no-store\n"
308 stuff_to_cookie(cookie, WC->wc_session, WC->wc_username,
309 WC->wc_password, WC->wc_roomname);
311 if (print_standard_html_head == 2) {
312 wprintf("Set-cookie: webcit=%s\n", unset);
314 wprintf("Set-cookie: webcit=%s\n", cookie);
315 if (server_cookie != NULL) {
316 wprintf("%s\n", server_cookie);
320 if (print_standard_html_head > 0) {
323 if (refresh30) svprintf("REFRESHTAG", WCS_STRING,
324 "<META HTTP-EQUIV=\"refresh\" CONTENT=\"30\">\n");
325 else svprintf("REFRESHTAG", WCS_STRING,
326 "<META HTTP-EQUIV=\"refresh\" CONTENT=\"500363689;\">\n");
327 /* script for checking for pages (not always launched) */
328 svprintf("PAGERSCRIPT", WCS_STRING,
329 "<SCRIPT LANGUAGE=\"JavaScript\">\n"
330 "function launch_page_popup() {\n"
331 "pwin = window.open('/page_popup', 'CitaPage%d', "
332 "'toolbar=no,location=no,copyhistory=no,status=no,"
333 "scrollbars=yes,resizable=no,height=250,width=400');\n"
341 clear_local_substs();
343 if (!suppress_check) if (WC->HaveExpressMessages) {
344 svprintf("extrabodyparms", WCS_STRING, "%s",
345 "onload=\"launch_page_popup()\" ");
346 WC->HaveExpressMessages = 0;
349 do_template("background");
350 clear_local_substs();
353 if (print_standard_html_head == 1) {
354 wprintf("<A NAME=\"TheTop\"></A>");
355 embed_room_banner(NULL);
358 if (strlen(WC->ImportantMessage) > 0) {
359 do_template("beginbox_nt");
360 wprintf("<SPAN CLASS=\"errormsg\">"
361 "%s</SPAN><BR>\n", WC->ImportantMessage);
362 do_template("endbox");
363 strcpy(WC->ImportantMessage, "");
371 void http_redirect(char *whichpage) {
372 wprintf("HTTP/1.0 302 Moved Temporarily\n");
373 wprintf("Location: %s\n", whichpage);
374 wprintf("URI: %s\n", whichpage);
375 wprintf("Content-type: text/html\n\n");
376 wprintf("<html><body>\n");
377 wprintf("you really want to be <A HREF=\"%s\">here</A> now\n",
379 wprintf("</body></html>\n");
384 void check_for_express_messages()
390 if (buf[3] == '*') WC->HaveExpressMessages = 1;
397 * Output a piece of content to the web browser
399 void http_transmit_thing(char *thing, size_t length, char *content_type) {
401 wprintf("Content-type: %s\n"
402 "Content-length: %ld\n"
404 "Connection: close\n"
410 write(WC->http_sock, thing, (size_t)length);
416 void output_static(char *what)
423 char content_type[SIZ];
425 lprintf(9, "output_static(%s)\n", what);
426 sprintf(buf, "static/%s", what);
427 fp = fopen(buf, "rb");
429 wprintf("HTTP/1.0 404 %s\n", strerror(errno));
430 wprintf("Content-Type: text/plain\n");
432 wprintf("Cannot open %s: %s\n", what, strerror(errno));
434 if (!strncasecmp(&what[strlen(what) - 4], ".gif", 4))
435 strcpy(content_type, "image/gif");
436 else if (!strncasecmp(&what[strlen(what) - 4], ".txt", 4))
437 strcpy(content_type, "text/plain");
438 else if (!strncasecmp(&what[strlen(what) - 4], ".css", 4))
439 strcpy(content_type, "text/css");
440 else if (!strncasecmp(&what[strlen(what) - 4], ".jpg", 4))
441 strcpy(content_type, "image/jpeg");
442 else if (!strncasecmp(&what[strlen(what) - 4], ".png", 4))
443 strcpy(content_type, "image/png");
444 else if (!strncasecmp(&what[strlen(what) - 5], ".html", 5))
445 strcpy(content_type, "text/html");
446 else if (!strncasecmp(&what[strlen(what) - 4], ".wml", 4))
447 strcpy(content_type, "text/vnd.wap.wml");
448 else if (!strncasecmp(&what[strlen(what) - 5], ".wmls", 5))
449 strcpy(content_type, "text/vnd.wap.wmlscript");
450 else if (!strncasecmp(&what[strlen(what) - 5], ".wmlc", 5))
451 strcpy(content_type, "application/vnd.wap.wmlc");
452 else if (!strncasecmp(&what[strlen(what) - 6], ".wmlsc", 6))
453 strcpy(content_type, "application/vnd.wap.wmlscriptc");
454 else if (!strncasecmp(&what[strlen(what) - 5], ".wbmp", 5))
455 wprintf("Content-type: image/vnd.wap.wbmp");
457 wprintf("Content-type: application/octet-stream");
459 fstat(fileno(fp), &statbuf);
460 bytes = statbuf.st_size;
461 lprintf(3, "Static: %s, %ld bytes\n", what, bytes);
462 bigbuffer = malloc(bytes);
463 fread(bigbuffer, bytes, 1, fp);
466 http_transmit_thing(bigbuffer, (size_t)bytes, content_type);
469 if (!strcasecmp(bstr("force_close_session"), "yes")) {
470 end_webcit_session();
476 * When the browser requests an image file from the Citadel server,
477 * this function is called to transmit it.
482 char *xferbuf = NULL;
485 serv_printf("OIMG %s|%s", bstr("name"), bstr("parm"));
488 bytes = extract_long(&buf[4], 0);
489 xferbuf = malloc(bytes);
491 /* Read it from the server */
492 read_server_binary(xferbuf, bytes);
496 /* Write it to the browser */
497 http_transmit_thing(xferbuf, (size_t)bytes, "image/gif");
502 /* Instead of an ugly 404, send a 1x1 transparent GIF
503 * when there's no such image on the server.
505 output_static("blank.gif");
508 wprintf("HTTP/1.0 404 %s\n", &buf[4]);
510 wprintf("Content-Type: text/plain\n"
512 "Error retrieving image: %s\n",
525 void output_mimepart()
529 char content_type[SIZ];
530 char *content = NULL;
532 serv_printf("OPNA %s|%s", bstr("msgnum"), bstr("partnum"));
535 bytes = extract_long(&buf[4], 0);
536 content = malloc(bytes);
537 extract(content_type, &buf[4], 3);
539 read_server_binary(content, bytes);
542 http_transmit_thing(content, bytes, content_type);
545 wprintf("HTTP/1.0 404 %s\n", &buf[4]);
547 wprintf("Content-Type: text/plain\n");
549 wprintf("Error retrieving part: %s\n", &buf[4]);
557 char *load_mimepart(long msgnum, char *partnum)
561 char content_type[SIZ];
564 serv_printf("OPNA %ld|%s", msgnum, partnum);
567 bytes = extract_long(&buf[4], 0);
568 extract(content_type, &buf[4], 3);
570 content = malloc(bytes + 1);
571 read_server_binary(content, bytes);
575 content[bytes] = 0; /* null terminate for good measure */
586 * Convenience functions to display a page containing only a string
588 void convenience_page(char *titlebarcolor, char *titlebarmsg, char *messagetext)
590 wprintf("HTTP/1.0 200 OK\n");
592 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#%s\"><TR><TD>", titlebarcolor);
593 wprintf("<SPAN CLASS=\"titlebar\">%s</SPAN>\n", titlebarmsg);
594 wprintf("</TD></TR></TABLE><BR>\n");
595 escputs(messagetext);
603 * Display a blank page.
605 void blank_page(void) {
612 * A template has been requested
614 void url_do_template(void) {
615 do_template(bstr("template"));
621 * Offer to make any page the user's "start page."
623 void offer_start_page(void) {
624 wprintf("<A HREF=\"/change_start_page?startpage=");
625 urlescputs(WC->this_page);
627 "<FONT SIZE=-2 COLOR=\"#AAAAAA\">Make this my start page</FONT>"
634 * Change the user's start page
636 void change_start_page(void) {
638 if (bstr("startpage") == NULL) {
639 strcpy(WC->ImportantMessage,
640 "startpage set to null");
645 set_preference("startpage", bstr("startpage"));
648 do_template("newstartpage");
655 void display_success(char *successmessage)
657 convenience_page("007700", "OK", successmessage);
662 void extract_action(char *actbuf, char *cmdbuf)
666 strcpy(actbuf, cmdbuf);
667 if (!strncasecmp(actbuf, "GET /", 5))
668 strcpy(actbuf, &actbuf[5]);
669 if (!strncasecmp(actbuf, "PUT /", 5))
670 strcpy(actbuf, &actbuf[5]);
671 if (!strncasecmp(actbuf, "POST /", 6))
672 strcpy(actbuf, &actbuf[6]);
674 for (i = 0; i < strlen(actbuf); ++i) {
675 if (actbuf[i] == ' ') {
679 if (actbuf[i] == '/') {
683 if (actbuf[i] == '?') {
687 if (actbuf[i] == '&') {
695 void upload_handler(char *name, char *filename, char *partnum, char *disp,
696 void *content, char *cbtype, size_t length,
697 char *encoding, void *userdata)
699 struct urlcontent *u;
702 if ( (length > 0) && (strlen(cbtype) == 0) ) {
703 u = (struct urlcontent *) malloc(sizeof(struct urlcontent));
704 u->next = WC->urlstrings;
706 safestrncpy(u->url_key, name, sizeof(u->url_key));
707 u->url_data = malloc(length + 1);
708 memcpy(u->url_data, content, length);
709 u->url_data[length] = 0;
713 if ( (length > 0) && (strlen(cbtype) > 0) ) {
714 WC->upload = malloc(length);
715 if (WC->upload != NULL) {
716 WC->upload_length = length;
717 safestrncpy(WC->upload_filename, filename,
718 sizeof(WC->upload_filename));
719 safestrncpy(WC->upload_content_type, cbtype,
720 sizeof(WC->upload_content_type));
721 memcpy(WC->upload, content, length);
724 lprintf(3, "malloc() failed: %s\n", strerror(errno));
734 * Entry point for WebCit transaction
736 void session_loop(struct httprequest *req)
742 int ContentLength = 0;
744 char ContentType[512];
747 struct httprequest *hptr;
748 char browser_host[SIZ];
749 char user_agent[SIZ];
752 /* We stuff these with the values coming from the client cookies,
753 * so we can use them to reconnect a timed out session if we have to.
755 char c_username[SIZ];
756 char c_password[SIZ];
757 char c_roomname[SIZ];
760 strcpy(c_username, "");
761 strcpy(c_password, "");
762 strcpy(c_roomname, "");
764 WC->upload_length = 0;
770 if (hptr == NULL) return;
772 strcpy(cmd, hptr->line);
774 extract_action(action, cmd);
776 while (hptr != NULL) {
777 strcpy(buf, hptr->line);
780 if (!strncasecmp(buf, "Cookie: webcit=", 15)) {
781 strcpy(cookie, &buf[15]);
782 cookie_to_stuff(cookie, NULL,
783 c_username, c_password, c_roomname);
785 else if (!strncasecmp(buf, "Content-length: ", 16)) {
786 ContentLength = atoi(&buf[16]);
788 else if (!strncasecmp(buf, "Content-type: ", 14)) {
789 safestrncpy(ContentType, &buf[14], sizeof ContentType);
791 else if (!strncasecmp(buf, "User-agent: ", 12)) {
792 safestrncpy(user_agent, &buf[12], sizeof user_agent);
794 else if (!strncasecmp(buf, "Host: ", 6)) {
795 safestrncpy(WC->http_host, &buf[6], sizeof WC->http_host);
797 /* Only WAP gateways explicitly name this content-type */
798 else if (strstr(buf, "text/vnd.wap.wml")) {
803 if (ContentLength > 0) {
804 content = malloc(ContentLength + SIZ);
805 memset(content, 0, ContentLength + SIZ);
806 sprintf(content, "Content-type: %s\n"
807 "Content-length: %d\n\n",
808 ContentType, ContentLength);
809 body_start = strlen(content);
812 while (BytesRead < ContentLength) {
813 a=read(WC->http_sock, &content[BytesRead+body_start],
814 ContentLength - BytesRead);
815 if (a <= 0) BytesRead = ContentLength;
819 if (!strncasecmp(ContentType,
820 "application/x-www-form-urlencoded", 33)) {
821 addurls(&content[body_start]);
822 } else if (!strncasecmp(ContentType, "multipart", 9)) {
823 content_end = content + ContentLength + body_start;
824 mime_parser(content, content_end, *upload_handler,
825 NULL, NULL, NULL, 0);
831 /* make a note of where we are in case the user wants to save it */
832 safestrncpy(WC->this_page, cmd, sizeof(WC->this_page));
833 remove_token(WC->this_page, 2, ' ');
834 remove_token(WC->this_page, 0, ' ');
836 /* If there are variables in the URL, we must grab them now */
837 for (a = 0; a < strlen(cmd); ++a) {
838 if ((cmd[a] == '?') || (cmd[a] == '&')) {
839 for (b = a; b < strlen(cmd); ++b)
842 addurls(&cmd[a + 1]);
847 /* Static content can be sent without connecting to Citadel. */
848 if (!strcasecmp(action, "static")) {
849 strcpy(buf, &cmd[12]);
850 for (a = 0; a < strlen(buf); ++a)
854 goto SKIP_ALL_THIS_CRAP; /* Don't try to connect */
858 * If we're not connected to a Citadel server, try to hook up the
861 if (!WC->connected) {
862 if (!strcasecmp(ctdlhost, "uds")) {
863 /* unix domain socket */
864 sprintf(buf, "%s/citadel.socket", ctdlport);
865 WC->serv_sock = uds_connectsock(buf);
869 WC->serv_sock = tcp_connectsock(ctdlhost, ctdlport);
872 if (WC->serv_sock < 0) {
874 goto SKIP_ALL_THIS_CRAP;
878 serv_gets(buf); /* get the server welcome message */
879 locate_host(browser_host, WC->http_sock);
880 get_serv_info(browser_host, user_agent);
881 if (serv_info.serv_rev_level < MINIMUM_CIT_VERSION) {
882 wprintf("You are connected to a Citadel "
883 "server running Citadel %d.%02d;\nin "
884 "order to run this version of WebCit "
885 "you must also have Citadel %d.%02d or"
887 serv_info.serv_rev_level / 100,
888 serv_info.serv_rev_level % 100,
889 MINIMUM_CIT_VERSION / 100,
890 MINIMUM_CIT_VERSION % 100
892 end_webcit_session();
893 goto SKIP_ALL_THIS_CRAP;
899 * Functions which can be performed without logging in
901 if (!strcasecmp(action, "listsub")) {
903 goto SKIP_ALL_THIS_CRAP;
905 #ifdef WEBCIT_WITH_CALENDAR_SERVICE
906 if (!strcasecmp(action, "freebusy")) {
908 goto SKIP_ALL_THIS_CRAP;
912 check_for_express_messages();
915 * If we're not logged in, but we have username and password cookies
916 * supplied by the browser, try using them to log in.
918 if ((!WC->logged_in) && (strlen(c_username) > 0) && (strlen(c_password) > 0)) {
919 serv_printf("USER %s", c_username);
922 serv_printf("PASS %s", c_password);
925 become_logged_in(c_username, c_password, buf);
930 * If we don't have a current room, but a cookie specifying the
931 * current room is supplied, make an effort to go there.
933 if ((strlen(WC->wc_roomname) == 0) && (strlen(c_roomname) > 0)) {
934 serv_printf("GOTO %s", c_roomname);
937 strcpy(WC->wc_roomname, c_roomname);
941 if (!strcasecmp(action, "image")) {
945 * All functions handled below this point ... make sure we log in
946 * before doing anything else!
948 } else if ((!WC->logged_in) && (!strcasecmp(action, "login"))) {
950 } else if (!WC->logged_in) {
955 * Various commands...
958 else if (!strcasecmp(action, "do_welcome")) {
960 } else if (!strcasecmp(action, "blank")) {
962 } else if (!strcasecmp(action, "do_template")) {
964 } else if (!strcasecmp(action, "display_main_menu")) {
966 } else if (!strcasecmp(action, "whobbs")) {
968 } else if (!strcasecmp(action, "knrooms")) {
970 } else if (!strcasecmp(action, "gotonext")) {
973 } else if (!strcasecmp(action, "skip")) {
975 } else if (!strcasecmp(action, "ungoto")) {
977 } else if (!strcasecmp(action, "dotgoto")) {
979 smart_goto(bstr("room"));
980 } else if (!strcasecmp(action, "dotskip")) {
981 smart_goto(bstr("room"));
982 } else if (!strcasecmp(action, "termquit")) {
984 } else if (!strcasecmp(action, "readnew")) {
986 } else if (!strcasecmp(action, "readold")) {
988 } else if (!strcasecmp(action, "readfwd")) {
990 } else if (!strcasecmp(action, "headers")) {
992 } else if (!strcasecmp(action, "display_enter")) {
994 } else if (!strcasecmp(action, "post")) {
996 } else if (!strcasecmp(action, "delete_msg")) {
998 } else if (!strcasecmp(action, "confirm_move_msg")) {
1000 } else if (!strcasecmp(action, "move_msg")) {
1002 } else if (!strcasecmp(action, "userlist")) {
1004 } else if (!strcasecmp(action, "showuser")) {
1006 } else if (!strcasecmp(action, "display_page")) {
1008 } else if (!strcasecmp(action, "page_user")) {
1010 } else if (!strcasecmp(action, "chat")) {
1012 } else if (!strcasecmp(action, "display_private")) {
1013 display_private("", 0);
1014 } else if (!strcasecmp(action, "goto_private")) {
1016 } else if (!strcasecmp(action, "zapped_list")) {
1018 } else if (!strcasecmp(action, "display_zap")) {
1020 } else if (!strcasecmp(action, "zap")) {
1022 } else if (!strcasecmp(action, "display_entroom")) {
1024 } else if (!strcasecmp(action, "entroom")) {
1026 } else if (!strcasecmp(action, "display_editroom")) {
1028 } else if (!strcasecmp(action, "netedit")) {
1030 } else if (!strcasecmp(action, "editroom")) {
1032 } else if (!strcasecmp(action, "display_whok")) {
1034 } else if (!strcasecmp(action, "display_editinfo")) {
1035 display_edit("Room info", "EINF 0", "RINF", "/editinfo", 1);
1036 } else if (!strcasecmp(action, "editinfo")) {
1037 save_edit("Room info", "EINF 1", 1);
1038 } else if (!strcasecmp(action, "display_editbio")) {
1039 sprintf(buf, "RBIO %s", WC->wc_username);
1040 display_edit("Your bio", "NOOP", buf, "editbio", 3);
1041 } else if (!strcasecmp(action, "editbio")) {
1042 save_edit("Your bio", "EBIO", 0);
1043 } else if (!strcasecmp(action, "confirm_delete_room")) {
1044 confirm_delete_room();
1045 } else if (!strcasecmp(action, "delete_room")) {
1047 } else if (!strcasecmp(action, "validate")) {
1049 } else if (!strcasecmp(action, "display_editpic")) {
1050 display_graphics_upload("your photo",
1053 } else if (!strcasecmp(action, "editpic")) {
1054 do_graphics_upload("UIMG 1|_userpic_");
1055 } else if (!strcasecmp(action, "display_editroompic")) {
1056 display_graphics_upload("the graphic for this room",
1059 } else if (!strcasecmp(action, "editroompic")) {
1060 do_graphics_upload("UIMG 1|_roompic_");
1061 } else if (!strcasecmp(action, "delete_floor")) {
1063 } else if (!strcasecmp(action, "rename_floor")) {
1065 } else if (!strcasecmp(action, "create_floor")) {
1067 } else if (!strcasecmp(action, "display_editfloorpic")) {
1068 sprintf(buf, "UIMG 0|_floorpic_|%s",
1069 bstr("which_floor"));
1070 display_graphics_upload("the graphic for this floor",
1073 } else if (!strcasecmp(action, "editfloorpic")) {
1074 sprintf(buf, "UIMG 1|_floorpic_|%s",
1075 bstr("which_floor"));
1076 do_graphics_upload(buf);
1077 } else if (!strcasecmp(action, "display_reg")) {
1079 } else if (!strcasecmp(action, "display_changepw")) {
1081 } else if (!strcasecmp(action, "changepw")) {
1083 } else if (!strcasecmp(action, "display_edit_node")) {
1084 display_edit_node();
1085 } else if (!strcasecmp(action, "edit_node")) {
1087 } else if (!strcasecmp(action, "display_netconf")) {
1089 } else if (!strcasecmp(action, "display_confirm_delete_node")) {
1090 display_confirm_delete_node();
1091 } else if (!strcasecmp(action, "delete_node")) {
1093 } else if (!strcasecmp(action, "display_add_node")) {
1095 } else if (!strcasecmp(action, "add_node")) {
1097 } else if (!strcasecmp(action, "terminate_session")) {
1099 terminate_session();
1100 } else if (!strcasecmp(action, "edit_me")) {
1102 } else if (!strcasecmp(action, "display_siteconfig")) {
1103 display_siteconfig();
1104 } else if (!strcasecmp(action, "page_popup")) {
1106 } else if (!strcasecmp(action, "siteconfig")) {
1108 } else if (!strcasecmp(action, "display_generic")) {
1110 } else if (!strcasecmp(action, "do_generic")) {
1112 } else if (!strcasecmp(action, "display_menubar")) {
1114 } else if (!strcasecmp(action, "output_mimepart")) {
1116 } else if (!strcasecmp(action, "edit_vcard")) {
1118 } else if (!strcasecmp(action, "submit_vcard")) {
1120 } else if (!strcasecmp(action, "select_user_to_edit")) {
1121 select_user_to_edit(NULL, NULL);
1122 } else if (!strcasecmp(action, "display_edituser")) {
1123 display_edituser(NULL);
1124 } else if (!strcasecmp(action, "edituser")) {
1126 } else if (!strcasecmp(action, "create_user")) {
1128 } else if (!strcasecmp(action, "changeview")) {
1130 } else if (!strcasecmp(action, "do_stuff_to_msgs")) {
1132 } else if (!strcasecmp(action, "change_start_page")) {
1133 change_start_page();
1134 } else if (!strcasecmp(action, "display_floorconfig")) {
1135 display_floorconfig(NULL);
1136 } else if (!strcasecmp(action, "toggle_self_service")) {
1137 toggle_self_service();
1138 #ifdef WEBCIT_WITH_CALENDAR_SERVICE
1139 } else if (!strcasecmp(action, "display_edit_task")) {
1140 display_edit_task();
1141 } else if (!strcasecmp(action, "save_task")) {
1143 } else if (!strcasecmp(action, "display_edit_event")) {
1144 display_edit_event();
1145 } else if (!strcasecmp(action, "save_event")) {
1147 } else if (!strcasecmp(action, "respond_to_request")) {
1148 respond_to_request();
1149 } else if (!strcasecmp(action, "handle_rsvp")) {
1152 } else if (!strcasecmp(action, "summary")) {
1154 } else if (!strcasecmp(action, "diagnostics")) {
1157 wprintf("You're in session %d<HR>\n", WC->wc_session);
1158 wprintf("Command: <BR><PRE>\n");
1160 wprintf("</PRE><HR>\n");
1161 wprintf("Variables: <BR><PRE>\n");
1163 wprintf("</PRE><HR>\n");
1166 /* When all else fais, display the main menu. */
1168 display_main_menu();
1173 if (content != NULL) {
1178 if (WC->upload_length > 0) {
1180 WC->upload_length = 0;