#include "webserver.h"
#include "mime_parser.h"
-/**
- * Subdirectories from which the client may request static content
- */
-char *static_content_dirs[] = {
- "static", /** static templates */
- "tiny_mce" /** the JS editor */
-};
-
/**
* String to unset the cookie.
* Any date "in the past" will work, so I chose my birthday, right down to
/** check for ImportantMessages (these display in a div overlaying the main screen) */
if (strlen(WC->ImportantMessage) > 0) {
wprintf("<div id=\"important_message\">\n");
- wprintf("<SPAN CLASS=\"imsg\">"
- "%s</SPAN><br />\n", WC->ImportantMessage);
+ wprintf("<span class=\"imsg\">"
+ "%s</span><br />\n", WC->ImportantMessage);
wprintf("</div>\n");
wprintf("<script type=\"text/javascript\">\n"
" setTimeout('hide_imsg_popup()', 3000); \n"
/**
* \brief Generic function to output an arbitrary MIME part from an arbitrary
- * message number on the server.
- * \param msgnum number of the item on the citadel server
- * \param partnum the MIME part to be output
+ * message number on the server.
+ *
+ * \param msgnum Number of the item on the citadel server
+ * \param partnum The MIME part to be output
+ * \param force_download Nonzero to force set the Content-Type: header
+ * to "application/octet-stream"
*/
-void mimepart(char *msgnum, char *partnum)
+void mimepart(char *msgnum, char *partnum, int force_download)
{
- char buf[SIZ];
+ char buf[256];
off_t bytes;
- char content_type[SIZ];
+ char content_type[256];
char *content = NULL;
serv_printf("OPNA %s|%s", msgnum, partnum);
if (buf[0] == '2') {
bytes = extract_long(&buf[4], 0);
content = malloc(bytes + 2);
- extract_token(content_type, &buf[4], 3, '|', sizeof content_type);
+ if (force_download) {
+ strcpy(content_type, "application/octet-stream");
+ }
+ else {
+ extract_token(content_type, &buf[4], 3, '|', sizeof content_type);
+ }
output_headers(0, 0, 0, 0, 0, 0);
read_server_binary(content, bytes);
serv_puts("CLOS");
char content_type[SIZ];
char *content;
- serv_printf("OPNA %ld|%s", msgnum, partnum);
+ serv_printf("DLAT %ld|%s", msgnum, partnum);
serv_getln(buf, sizeof buf);
- if (buf[0] == '2') {
+ if (buf[0] == '6') {
bytes = extract_long(&buf[4], 0);
extract_token(content_type, &buf[4], 3, '|', sizeof content_type);
content = malloc(bytes + 2);
- read_server_binary(content, bytes);
+ serv_read(content, bytes);
- serv_puts("CLOS");
- serv_getln(buf, sizeof buf);
content[bytes] = 0; /* null terminate for good measure */
return(content);
}
wprintf("HTTP/1.1 200 OK\n");
output_headers(1, 1, 2, 0, 0, 0);
wprintf("<div id=\"banner\">\n");
- wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#%s\"><TR><TD>", titlebarcolor);
- wprintf("<SPAN CLASS=\"titlebar\">%s</SPAN>\n", titlebarmsg);
- wprintf("</TD></TR></TABLE>\n");
+ wprintf("<table width=100%% border=0 bgcolor=\"#%s\"><tr><td>", titlebarcolor);
+ wprintf("<span class=\"titlebar\">%s</span>\n", titlebarmsg);
+ wprintf("</td></tr></table>\n");
wprintf("</div>\n<div id=\"content\">\n");
escputs(messagetext);
void offer_start_page(void) {
wprintf("<a href=\"change_start_page?startpage=");
urlescputs(WC->this_page);
- wprintf("\"><FONT SIZE=-2 COLOR=\"#AAAAAA\">");
+ wprintf("\"><font size=-2 color=\"#AAAAAA\">");
wprintf(_("Make this my start page"));
- wprintf("</FONT></A>");
+ wprintf("</font></a>");
/*
wprintf("<br/><a href=\"rss?room=");
urlescputs(WC->wc_roomname);
}
}
+ /** If it's a "force 404" situation then display the error and bail. */
+ if (!strcmp(action, "404")) {
+ wprintf("HTTP/1.1 404 Not found\r\n");
+ wprintf("Content-Type: text/plain\r\n");
+ wprintf("\r\n");
+ wprintf("Not found\r\n");
+ goto SKIP_ALL_THIS_CRAP;
+ }
/** Static content can be sent without connecting to Citadel. */
is_static = 0;
- for (a=0; a<(sizeof(static_content_dirs) / sizeof(char *)); ++a) {
- if (!strcasecmp(action, static_content_dirs[a])) {
+ for (a=0; a<ndirs; ++a) {
+ if (!strcasecmp(action, (char*)static_content_dirs[a])) { /* map web to disk location */
is_static = 1;
}
}
readloop("readfwd");
} else if (!strcasecmp(action, "headers")) {
readloop("headers");
+ } else if (!strcasecmp(action, "do_search")) {
+ readloop("do_search");
} else if (!strcasecmp(action, "msg")) {
embed_message(arg1);
} else if (!strcasecmp(action, "printmsg")) {
} else if (!strcasecmp(action, "display_menubar")) {
display_menubar(1);
} else if (!strcasecmp(action, "mimepart")) {
- mimepart(arg1, arg2);
+ mimepart(arg1, arg2, 0);
+ } else if (!strcasecmp(action, "mimepart_download")) {
+ mimepart(arg1, arg2, 1);
} else if (!strcasecmp(action, "edit_vcard")) {
edit_vcard();
} else if (!strcasecmp(action, "submit_vcard")) {
display_inetconf();
} else if (!strcasecmp(action, "save_inetconf")) {
save_inetconf();
+ } else if (!strcasecmp(action, "display_smtpqueue")) {
+ display_smtpqueue();
+ } else if (!strcasecmp(action, "display_smtpqueue_inner_div")) {
+ display_smtpqueue_inner_div();
+ } else if (!strcasecmp(action, "display_sieve")) {
+ display_sieve();
+ } else if (!strcasecmp(action, "save_sieve")) {
+ save_sieve();
} else if (!strcasecmp(action, "setup_wizard")) {
do_setup_wizard();
} else if (!strcasecmp(action, "display_preferences")) {