10 #include <sys/socket.h>
13 #include <netinet/in.h>
23 void display_graphics_upload(char *description, char *check_cmd, char *uplurl)
30 strcpy(WC->ImportantMessage, &buf[4]);
34 output_headers(1, 1, 0, 0, 0, 0, 0);
36 svprintf("BOXTITLE", WCS_STRING, "Set/change your photo");
37 do_template("beginbox");
39 wprintf("<CENTER>\n");
41 wprintf("<FORM ENCTYPE=\"multipart/form-data\" ACTION=\"%s\" "
42 "METHOD=\"POST\" NAME=\"graphicsupload\">\n", uplurl);
44 wprintf("<INPUT TYPE=\"hidden\" NAME=\"which_room\" VALUE=\"");
45 urlescputs(bstr("which_room"));
48 wprintf("You can upload any image directly from your computer,\n");
49 wprintf("as long as it is in GIF format (JPEG, PNG, etc. won't\n");
50 wprintf("work).<br /><br />\n");
52 wprintf("Please select a file to upload:<br /><br />\n");
53 wprintf("<INPUT TYPE=\"FILE\" NAME=\"filename\" SIZE=\"35\">\n");
54 wprintf("<br /><br />");
55 wprintf("<INPUT TYPE=\"SUBMIT\" NAME=\"sc\" VALUE=\"Upload\">\n");
57 wprintf("<INPUT TYPE=\"RESET\" VALUE=\"Reset Form\">\n");
59 wprintf("<INPUT TYPE=\"SUBMIT\" NAME=\"sc\" VALUE=\"Cancel\">\n");
61 wprintf("</CENTER>\n");
62 do_template("endbox");
66 void do_graphics_upload(char *upl_cmd)
73 if (!strcasecmp(bstr("sc"), "Cancel")) {
74 strcpy(WC->ImportantMessage,
75 "Graphics upload cancelled.");
80 if (WC->upload_length == 0) {
81 strcpy(WC->ImportantMessage,
82 "You didn't upload a file.");
89 strcpy(WC->ImportantMessage, &buf[4]);
93 bytes_remaining = WC->upload_length;
94 while (bytes_remaining) {
95 thisblock = ((bytes_remaining > 4096) ? 4096 : bytes_remaining);
96 serv_printf("WRIT %d", thisblock);
99 strcpy(WC->ImportantMessage, &buf[4]);
105 thisblock = extract_int(&buf[4], 0);
106 serv_write(&WC->upload[pos], thisblock);
107 pos = pos + thisblock;
108 bytes_remaining = bytes_remaining - thisblock;
114 display_success(&buf[4]);