4 * Handles HTTP upload of graphics files into the system.
13 #include <sys/types.h>
15 #include <sys/socket.h>
18 #include <netinet/in.h>
28 void display_graphics_upload(char *description, char *check_cmd, char *uplurl)
35 strcpy(WC->ImportantMessage, &buf[4]);
39 output_headers(1, 1, 0, 0, 0, 0, 0);
41 output_headers(1, 1, 2, 0, 0, 0, 0);
42 wprintf("<div id=\"banner\">\n"
43 "<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>"
44 "<SPAN CLASS=\"titlebar\">Set/change your photo</SPAN>"
45 "</TD></TR></TABLE>\n"
46 "</div>\n<div id=\"content\">\n"
49 wprintf("<center><table border=0 width=99%% bgcolor=\"#ffffff\"><tr><td>\n");
51 wprintf("<CENTER>\n");
53 wprintf("<FORM ENCTYPE=\"multipart/form-data\" ACTION=\"%s\" "
54 "METHOD=\"POST\" NAME=\"graphicsupload\">\n", uplurl);
56 wprintf("<INPUT TYPE=\"hidden\" NAME=\"which_room\" VALUE=\"");
57 urlescputs(bstr("which_room"));
60 wprintf("You can upload any image directly from your computer,\n");
61 wprintf("as long as it is in GIF format (JPEG, PNG, etc. won't\n");
62 wprintf("work).<br /><br />\n");
64 wprintf("Please select a file to upload:<br /><br />\n");
65 wprintf("<INPUT TYPE=\"FILE\" NAME=\"filename\" SIZE=\"35\">\n");
66 wprintf("<br /><br />");
67 wprintf("<INPUT TYPE=\"SUBMIT\" NAME=\"sc\" VALUE=\"Upload\">\n");
69 wprintf("<INPUT TYPE=\"RESET\" VALUE=\"Reset Form\">\n");
71 wprintf("<INPUT TYPE=\"SUBMIT\" NAME=\"sc\" VALUE=\"Cancel\">\n");
73 wprintf("</CENTER>\n");
74 wprintf("</td></tr></table></center>\n");
78 void do_graphics_upload(char *upl_cmd)
85 if (!strcasecmp(bstr("sc"), "Cancel")) {
86 strcpy(WC->ImportantMessage,
87 "Graphics upload cancelled.");
92 if (WC->upload_length == 0) {
93 strcpy(WC->ImportantMessage,
94 "You didn't upload a file.");
101 strcpy(WC->ImportantMessage, &buf[4]);
105 bytes_remaining = WC->upload_length;
106 while (bytes_remaining) {
107 thisblock = ((bytes_remaining > 4096) ? 4096 : bytes_remaining);
108 serv_printf("WRIT %d", thisblock);
111 strcpy(WC->ImportantMessage, &buf[4]);
117 thisblock = extract_int(&buf[4], 0);
118 serv_write(&WC->upload[pos], thisblock);
119 pos = pos + thisblock;
120 bytes_remaining = bytes_remaining - thisblock;
126 display_success(&buf[4]);