/*
* Extract variables from the URL.
*/
-void addurls(char *url)
+void addurls(char *url, long ulen)
{
char *aptr, *bptr, *eptr;
char *up;
- char buf[SIZ] = "";
- int len, n, keylen;
+ char *buf;
+ int len, keylen;
urlcontent *u;
struct wcsession *WCC = WC;
if (WCC->urlstrings == NULL)
WCC->urlstrings = NewHash(1, NULL);
- eptr = buf + sizeof (buf);
- up = url;
- /** locate the = sign */
- n = safestrncpy(buf, up, sizeof buf);
- if (n < 0) /* hm, we exceeded the buffer... hmmm what to do now? */
- n = -n;
+ buf = (char*) malloc (ulen + 1);
+ memcpy(buf, url, ulen);
+ buf[ulen] = '\0';
+ eptr = buf + ulen;
up = buf;
while (!IsEmptyStr(up)) {
aptr = up;
u->url_data[u->url_data_size] = '\0';
up = bptr;
++up;
-/* uncomment the following line to see each parameter in the log
+#ifdef DEBUG_URLSTRINGS
lprintf(9, "%s = [%ld] %s\n", u->url_key, u->url_data_size, u->url_data);
-*/
+#endif
}
}
}
if (cache) {
+ char httpTomorow[128];
+
+ http_datestring(httpTomorow, sizeof httpTomorow,
+ time(NULL) + 60 * 60 * 24 * 2);
+
wprintf("Pragma: public\r\n"
"Cache-Control: max-age=3600, must-revalidate\r\n"
- "Last-modified: %s\r\n",
- httpnow
+ "Last-modified: %s\r\n"
+ "Expires: %s\r\n",
+ httpnow,
+ httpTomorow
);
}
else {
char pathname[1024];
int a, b, nBackDots, nEmpty;
int ContentLength = 0;
- int BytesRead = 0;
char ContentType[512];
char *content = NULL;
char *content_end = NULL;
}
if (ContentLength > 0) {
- content = malloc(ContentLength + SIZ);
- memset(content, 0, ContentLength + SIZ);
- snprintf(content, ContentLength + SIZ, "Content-type: %s\n"
+ int BuffSize;
+
+ BuffSize = ContentLength + SIZ;
+ content = malloc(BuffSize);
+ memset(content, 0, BuffSize);
+ snprintf(content, BuffSize, "Content-type: %s\n"
"Content-length: %d\n\n",
ContentType, ContentLength);
body_start = strlen(content);
/** Read the entire input data at once. */
- client_read(WC->http_sock, &content[BytesRead+body_start], ContentLength);
+ client_read(WC->http_sock, &content[body_start], ContentLength);
if (!strncasecmp(ContentType, "application/x-www-form-urlencoded", 33)) {
- addurls(&content[body_start]);
+ addurls(&content[body_start], ContentLength);
} else if (!strncasecmp(ContentType, "multipart", 9)) {
content_end = content + ContentLength + body_start;
mime_parser(content, content_end, *upload_handler, NULL, NULL, NULL, 0);
len = b - 1;
}
}
- addurls(&cmd[a + 1]);
+ addurls(&cmd[a + 1], len - a);
cmd[a] = 0;
len = a - 1;
}
} else if (!strcasecmp(action, "display_mime_icon")) {
display_mime_icon();
- /**
- * All functions handled below this point ... make sure we log in
- * before doing anything else!
- */
+ /*
+ * All functions handled below this point ... make sure we log in
+ * before doing anything else!
+ */
} else if ((!WC->logged_in) && (!strcasecmp(action, "login"))) {
do_login();
+ } else if ((!WC->logged_in) && (!strcasecmp(action, "display_openid_login"))) {
+ display_openid_login(NULL);
+ } else if ((!WC->logged_in) && (!strcasecmp(action, "openid_login"))) {
+ do_openid_login();
+ } else if (!strcasecmp(action, "finalize_openid_login")) {
+ finalize_openid_login();
} else if (!WC->logged_in) {
display_login(NULL);
}
- /**
+ /*
* Various commands...
*/
dump_vars();
wprintf("</PRE><hr />\n");
wDumpContent(1);
+ } else if (!strcasecmp(action, "add_new_note")) {
+ add_new_note();
} else if (!strcasecmp(action, "ajax_update_note")) {
ajax_update_note();
} else if (!strcasecmp(action, "display_room_directory")) {
download_file(index[1]);
} else if (!strcasecmp(action, "upload_file")) {
upload_file();
+ } else if (!strcasecmp(action, "display_openids")) {
+ display_openids();
+ } else if (!strcasecmp(action, "openid_attach")) {
+ openid_attach();
}
/** When all else fais, display the main menu. */