X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=webcit%2Fgraphics.c;h=6949e09fd81b8f0175f5b59c0554f0561acbf351;hb=2362c3d4de86f20822ab81015222a196137fd20e;hp=948dc8905b82d0839eb7b5803f39830d15627f83;hpb=3dda3cda8acb9c1c4eb227f4780630913ffc633a;p=citadel.git diff --git a/webcit/graphics.c b/webcit/graphics.c index 948dc8905..6949e09fd 100644 --- a/webcit/graphics.c +++ b/webcit/graphics.c @@ -2,108 +2,94 @@ * $Id$ * * Handles HTTP upload of graphics files into the system. + * \ingroup WebcitHttpServer */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include "webcit.h" -void display_graphics_upload(char *description, char *check_cmd, char *uplurl) +void display_graphics_upload(char *description, char *filename, char *uplurl) { char buf[SIZ]; - serv_puts(check_cmd); + + snprintf(buf, SIZ, "UIMG 0||%s", filename); + serv_puts(buf); serv_getln(buf, sizeof buf); if (buf[0] != '2') { strcpy(WC->ImportantMessage, &buf[4]); display_main_menu(); return; } - output_headers(1, 1, 0, 0, 0, 0, 0); - - output_headers(1, 1, 2, 0, 0, 0, 0); - wprintf("
\n" - "
" - "Set/change your photo" - "
\n" - "
\n
\n" - ); + output_headers(1, 1, 0, 0, 0, 0); - wprintf("
" - "
\n"); + output_headers(1, 1, 1, 0, 0, 0); - wprintf("
\n"); + svput("BOXTITLE", WCS_STRING, _("Image upload")); + do_template("beginbox"); - wprintf("
\n", uplurl); + wprintf("\n", uplurl); - wprintf("\n", WC->nonce); + wprintf("\n"); - wprintf("You can upload any image directly from your computer,\n"); - wprintf("as long as it is in GIF format (JPEG, PNG, etc. won't\n"); - wprintf("work).

\n"); + wprintf(_("You can upload an image directly from your computer")); + wprintf("

\n"); + + wprintf(_("Please select a file to upload:")); + wprintf("\n"); - wprintf("Please select a file to upload:

\n"); - wprintf("\n"); - wprintf("

"); - wprintf("\n"); + wprintf("
\n", filename); + + wprintf("
"); + wprintf("\n", _("Upload")); wprintf(" "); - wprintf("\n"); + wprintf("\n", _("Reset form")); wprintf(" "); - wprintf("\n"); - wprintf("\n"); - wprintf("
\n"); - wprintf("
\n"); + wprintf("\n", _("Cancel")); + wprintf("
\n"); + wprintf("\n"); + + do_template("endbox"); + wDumpContent(1); } -void do_graphics_upload(char *upl_cmd) +void do_graphics_upload(char *filename) { + const char *MimeType; char buf[SIZ]; int bytes_remaining; int pos = 0; int thisblock; + bytes_remaining = WC->upload_length; - if (!strcasecmp(bstr("sc"), "Cancel")) { + if (havebstr("cancel_button")) { strcpy(WC->ImportantMessage, - "Graphics upload cancelled."); + _("Graphics upload has been cancelled.")); display_main_menu(); return; } if (WC->upload_length == 0) { strcpy(WC->ImportantMessage, - "You didn't upload a file."); + _("You didn't upload a file.")); display_main_menu(); return; } - serv_puts(upl_cmd); + + MimeType = GuessMimeType(&WC->upload[0], bytes_remaining); + snprintf(buf, SIZ, "UIMG 1|%s|%s", MimeType, filename); + serv_puts(buf); + serv_getln(buf, sizeof buf); if (buf[0] != '2') { strcpy(WC->ImportantMessage, &buf[4]); display_main_menu(); return; } - bytes_remaining = WC->upload_length; while (bytes_remaining) { thisblock = ((bytes_remaining > 4096) ? 4096 : bytes_remaining); serv_printf("WRIT %d", thisblock);