static const char *defaulthost = DEFAULT_HOST;
static const char *defaultport = DEFAULT_PORT;
+int upload_length = 0;
+char *upload;
+
void unescape_input(char *buf)
{
void getz(char *buf) {
+ bzero(buf, 256);
if (fgets(buf, 256, stdin) == NULL) strcpy(buf, "");
else {
while ((strlen(buf)>0)&&(!isprint(buf[strlen(buf)-1])))
char buf[256];
int a, b;
int ContentLength = 0;
+ char ContentType[512];
char *content;
-FILE *fp;
/* We stuff these with the values coming from the client cookies,
* so we can use them to reconnect a timed out session if we have to.
strcpy(c_password, "");
strcpy(c_roomname, "");
+ upload_length = 0;
+ upload = NULL;
+
getz(cmd);
extract_action(action, cmd);
strcpy(c_password, &buf[20]);
if (!strncasecmp(buf, "Cookie: wc_roomname=", 20))
strcpy(c_roomname, &buf[20]);
-
if (!strncasecmp(buf, "Content-length: ", 16)) {
ContentLength = atoi(&buf[16]);
}
-
+ if (!strncasecmp(buf, "Content-type: ", 14)) {
+ strcpy(ContentType, &buf[14]);
+ }
} while(strlen(buf)>0);
++TransactionCount;
if (ContentLength > 0) {
content = malloc(ContentLength+1);
fread(content, ContentLength, 1, stdin);
-fp = fopen("content", "wb");
-fwrite(content, ContentLength, 1, fp);
-fclose(fp);
+
content[ContentLength] = 0;
- addurls(content);
+
+ if (!strncasecmp(ContentType,
+ "application/x-www-form-urlencoded", 33)) {
+ addurls(content);
+ }
+ else if (!strncasecmp(ContentType, "multipart", 9)) {
+ mime_parser(content, ContentLength, ContentType);
+ }
}
else {
content = NULL;
else if (!strcasecmp(action, "dotgoto")) {
slrp_highest();
- dotgoto();
+ gotoroom(bstr("room"), 1);
}
else if (!strcasecmp(action, "termquit")) {
zap();
}
+ else if (!strcasecmp(action, "display_entroom")) {
+ display_entroom();
+ }
+
+ else if (!strcasecmp(action, "entroom")) {
+ entroom();
+ }
+
+ else if (!strcasecmp(action, "display_editroom")) {
+ display_editroom();
+ }
+
+ else if (!strcasecmp(action, "editroom")) {
+ editroom();
+ }
+
+ else if (!strcasecmp(action, "display_editinfo")) {
+ display_edit("Room info", "EINF 0", "RINF", "/editinfo");
+ }
+
+ else if (!strcasecmp(action, "editinfo")) {
+ save_edit("Room info", "EINF 1", 1);
+ }
+
+ else if (!strcasecmp(action, "display_editbio")) {
+ sprintf(buf, "RBIO %s", wc_username);
+ display_edit("Your bio", "NOOP", buf, "editbio");
+ }
+
+ else if (!strcasecmp(action, "editbio")) {
+ save_edit("Your bio", "EBIO", 0);
+ }
+
+ else if (!strcasecmp(action, "confirm_delete_room")) {
+ confirm_delete_room();
+ }
+
+ else if (!strcasecmp(action, "delete_room")) {
+ delete_room();
+ }
+
+ else if (!strcasecmp(action, "validate")) {
+ validate();
+ }
+
+ else if (!strcasecmp(action, "display_editpic")) {
+ display_graphics_upload("your photo",
+ "UIMG 0|_userpic_",
+ "/editpic");
+ }
+
+ else if (!strcasecmp(action, "editpic")) {
+ do_graphics_upload("UIMG 1|_userpic_");
+ }
+
/* When all else fails... */
else {
printf("HTTP/1.0 200 OK\n");
content = NULL;
}
free_urls();
+ if (upload_length > 0) {
+ free(upload);
+ upload_length = 0;
+ }
}
int main(int argc, char *argv[]) {