httpdate(httpnow, time(NULL));
if (do_httpheaders) {
- wprintf("Content-type: text/html\r\n"
+ wprintf("Content-type: text/html; charset=utf-8\r\n"
"Server: %s / %s\n"
"Connection: close\r\n",
SERVER, serv_info.serv_software
wprintf("HTTP/1.0 302 Moved Temporarily\n");
wprintf("Location: %s\r\n", whichpage);
wprintf("URI: %s\r\n", whichpage);
- wprintf("Content-type: text/html\r\n\r\n");
+ wprintf("Content-type: text/html; charset=utf-8\r\n\r\n");
wprintf("<html><body>\n");
wprintf("you really want to be <A HREF=\"%s\">here</A> now\n",
whichpage);
-void extract_action(char *actbuf, char *cmdbuf)
-{
- int i;
-
- strcpy(actbuf, cmdbuf);
-
- /*
- * First strip out the http method
- */
- remove_token(actbuf, 0, ' ');
- if (actbuf[0] == ' ') strcpy(actbuf, &actbuf[1]);
- if (actbuf[0] == '/') strcpy(actbuf, &actbuf[1]);
-
- /*
- * Now kill invalid (for webcit) characters
- */
- for (i = 0; i < strlen(actbuf); ++i) {
- if (actbuf[i] == ' ') {
- actbuf[i] = 0;
- i = 0;
- }
- if (actbuf[i] == '/') {
- actbuf[i] = 0;
- i = 0;
- }
- if (actbuf[i] == '?') {
- actbuf[i] = 0;
- i = 0;
- }
- if (actbuf[i] == '&') {
- actbuf[i] = 0;
- i = 0;
- }
- }
-}
-
-
void upload_handler(char *name, char *filename, char *partnum, char *disp,
- void *content, char *cbtype, size_t length,
- char *encoding, void *userdata)
+ void *content, char *cbtype, char *cbcharset,
+ size_t length, char *encoding, void *userdata)
{
struct urlcontent *u;
+ lprintf(9, "upload_handler() name=%s, type=%s, len=%d\n",
+ name, cbtype, length);
+
/* Form fields */
if ( (length > 0) && (strlen(cbtype) == 0) ) {
u = (struct urlcontent *) malloc(sizeof(struct urlcontent));
*/
void session_loop(struct httprequest *req)
{
- char cmd[SIZ];
- char method[SIZ];
- char action[SIZ];
+ char cmd[1024];
+ char method[128];
+ char action[128];
+ char arg1[128];
+ char arg2[128];
+ char arg3[128];
char buf[SIZ];
int a, b;
int ContentLength = 0;
safestrncpy(cmd, hptr->line, sizeof cmd);
hptr = hptr->next;
extract_token(method, cmd, 0, ' ', sizeof method);
- extract_action(action, cmd);
+
+ /* Figure out the action */
+ extract_token(action, cmd, 1, '/', sizeof action);
+ if (strstr(action, "?")) *strstr(action, "?") = 0;
+ if (strstr(action, "&")) *strstr(action, "&") = 0;
+ if (strstr(action, " ")) *strstr(action, " ") = 0;
+
+ extract_token(arg1, cmd, 2, '/', sizeof arg1);
+ if (strstr(arg1, "?")) *strstr(arg1, "?") = 0;
+ if (strstr(arg1, "&")) *strstr(arg1, "&") = 0;
+ if (strstr(arg1, " ")) *strstr(arg1, " ") = 0;
+
+ extract_token(arg2, cmd, 3, '/', sizeof arg2);
+ if (strstr(arg2, "?")) *strstr(arg2, "?") = 0;
+ if (strstr(arg2, "&")) *strstr(arg2, "&") = 0;
+ if (strstr(arg2, " ")) *strstr(arg2, " ") = 0;
+
+ extract_token(arg3, cmd, 4, '/', sizeof arg3);
+ if (strstr(arg3, "?")) *strstr(arg3, "?") = 0;
+ if (strstr(arg3, "&")) *strstr(arg3, "&") = 0;
+ if (strstr(arg3, " ")) *strstr(arg3, " ") = 0;
while (hptr != NULL) {
safestrncpy(buf, hptr->line, sizeof buf);
}
}
+
/* Static content can be sent without connecting to Citadel. */
if (!strcasecmp(action, "static")) {
- safestrncpy(buf, &cmd[12], sizeof buf);
+ safestrncpy(buf, arg1, sizeof buf);
for (a = 0; a < strlen(buf); ++a)
if (isspace(buf[a]))
buf[a] = 0;
/*
- * If this isn't a GroupDAV session, it's an ordinary browser
- * connecting to the user interface. Only allow GET and POST
- * methods.
+ * Automatically send requests with any method other than GET or
+ * POST to the GroupDAV code as well.
*/
if ((strcasecmp(method, "GET")) && (strcasecmp(method, "POST"))) {
- wprintf("HTTP/1.1 405 Method Not Allowed\r\n");
- groupdav_common_headers();
- wprintf("Content-Length: 0\r\n\r\n");
+ groupdav_main(req, ContentType, /* do GroupDAV methods */
+ ContentLength, content+body_start);
+ if (!WC->logged_in) {
+ WC->killthis = 1; /* If not logged in, don't */
+ } /* keep the session active */
goto SKIP_ALL_THIS_CRAP;
}
display_aide_menu();
} else if (!strcasecmp(action, "display_main_menu")) {
display_main_menu();
- } else if (!strcasecmp(action, "whobbs")) {
- whobbs();
+ } else if (!strcasecmp(action, "who")) {
+ who();
+ } else if (!strcasecmp(action, "who_inner_html")) {
+ who_inner_html();
} else if (!strcasecmp(action, "knrooms")) {
knrooms();
} else if (!strcasecmp(action, "gotonext")) {