]> code.citadel.org Git - citadel.git/blobdiff - webcit/webcit.c
* Final cvs commit for 1998 (an awful year, I'm glad to see it over).
[citadel.git] / webcit / webcit.c
index f5f1faa69a71955223dbf5b60b3b12df5b71d7cd..5f6703083ad67a2f6c905aa142c94d6fed024b3d 100644 (file)
@@ -41,6 +41,9 @@ struct urlcontent *urlstrings = NULL;
 static const char *defaulthost = DEFAULT_HOST;
 static const char *defaultport = DEFAULT_PORT;
 
+int upload_length = 0;
+char *upload;
+
 
 void unescape_input(char *buf)
 {
@@ -247,6 +250,7 @@ void urlescputs(char *strbuf)
 
 
 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])))
@@ -285,7 +289,7 @@ void output_headers(int print_standard_html_head) {
 
        if (print_standard_html_head) {
                wprintf("<HTML><HEAD><TITLE>");
-               escputs("WebCit");
+               escputs("WebCit");       /* FIX -- add BBS name here */
                wprintf("</TITLE></HEAD>");
                if (ExpressMessages != NULL) {
                        wprintf("<SCRIPT language=\"javascript\">\n");
@@ -356,6 +360,8 @@ void output_static(char *what) {
 
                if (!strncasecmp(&what[strlen(what)-4], ".gif", 4))
                        printf("Content-type: image/gif\n");
+               else if (!strncasecmp(&what[strlen(what)-4], ".jpg", 4))
+                       printf("Content-type: image/jpeg\n");
                else if (!strncasecmp(&what[strlen(what)-5], ".html", 5))
                        printf("Content-type: text/html\n");
                else
@@ -418,6 +424,25 @@ void output_image() {
 
        }
 
+
+/*
+ * Convenience function to display a page containing only an error string
+ */
+void display_error(char *errormessage) {
+        printf("HTTP/1.0 200 OK\n");
+        output_headers(1);
+        wprintf("<TABLE WIDTH=100% BORDER=0 BGCOLOR=770000><TR><TD>");
+        wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
+        wprintf("<B>Error</B>\n");
+        wprintf("</FONT></TD></TR></TABLE><BR>\n");
+       escputs(errormessage);
+        wprintf("</BODY></HTML>\n");
+        wDumpContent();
+       }
+
+
+
+
 void extract_action(char *actbuf, char *cmdbuf) {
        int i;
 
@@ -441,8 +466,8 @@ void session_loop(void) {
        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.
@@ -459,6 +484,9 @@ FILE *fp;
        strcpy(c_password, "");
        strcpy(c_roomname, "");
 
+       upload_length = 0;
+       upload = NULL;
+
        getz(cmd);
        extract_action(action, cmd);
 
@@ -475,11 +503,12 @@ FILE *fp;
                        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;
@@ -487,11 +516,16 @@ FILE *fp;
        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;
@@ -603,7 +637,7 @@ fclose(fp);
 
        else if (!strcasecmp(action, "dotgoto")) {
                slrp_highest();
-               dotgoto();
+               gotoroom(bstr("room"), 1);
                }
 
        else if (!strcasecmp(action, "termquit")) {
@@ -654,6 +688,93 @@ fclose(fp);
                showuser();
                }
 
+       else if (!strcasecmp(action, "display_page")) {
+               display_page();
+               }
+
+       else if (!strcasecmp(action, "page_user")) {
+               page_user();
+               }
+
+       else if (!strcasecmp(action, "chat")) {
+               do_chat();
+               }
+
+       else if (!strcasecmp(action, "display_private")) {
+               display_private("", 0);
+               }
+
+       else if (!strcasecmp(action, "goto_private")) {
+               goto_private();
+               }
+
+       else if (!strcasecmp(action, "zapped_list")) {
+               zapped_list();
+               }
+
+       else if (!strcasecmp(action, "display_zap")) {
+               display_zap();
+               }
+
+       else if (!strcasecmp(action, "zap")) {
+               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");
@@ -677,6 +798,10 @@ fclose(fp);
                content = NULL;
                }
        free_urls();
+       if (upload_length > 0) {
+               free(upload);
+               upload_length = 0;
+               }
        }
 
 int main(int argc, char *argv[]) {