Nearly all <FORM> blocks now contain a hidden input
[citadel.git] / webcit / graphics.c
index fdcf30ce8d533f431a5074afa7c2544c7f07180b..daeff6d349c32c9adbe5f91e032fed979be48ca2 100644 (file)
@@ -2,27 +2,9 @@
  * $Id$
  *
  * Handles HTTP upload of graphics files into the system.
+ * \ingroup WebcitHttpServer
  */
 
-#include <ctype.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <sys/socket.h>
-#include <sys/time.h>
-#include <limits.h>
-#include <netinet/in.h>
-#include <netdb.h>
-#include <string.h>
-#include <pwd.h>
-#include <errno.h>
-#include <stdarg.h>
-#include <pthread.h>
-#include <signal.h>
 #include "webcit.h"
 
 void display_graphics_upload(char *description, char *check_cmd, char *uplurl)
@@ -30,46 +12,51 @@ void display_graphics_upload(char *description, char *check_cmd, char *uplurl)
        char buf[SIZ];
 
        serv_puts(check_cmd);
-       serv_gets(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, 0, 0, 0, 0);
 
-       output_headers(1, 1, 2, 0, 0, 0, 0);
+       output_headers(1, 1, 2, 0, 0, 0);
        wprintf("<div id=\"banner\">\n"
-               "<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>"
-               "<SPAN CLASS=\"titlebar\">Set/change your photo</SPAN>"
+               "<TABLE class=\"graphics_banner\"><TR><TD>"
+               "<SPAN CLASS=\"titlebar\">");
+       wprintf(_("Image upload"));
+       wprintf("</SPAN>"
                "</TD></TR></TABLE>\n"
                "</div>\n<div id=\"content\">\n"
        );
 
-       wprintf("<div style=\"margin-right:1px\">"
-               "<table border=0 width=100%% bgcolor=\"#ffffff\"><tr><td>\n");
+       wprintf("<div class=\"fix_scrollbar_bug\">"
+               "<table class=\"graphics_background\"><tr><td>\n");
 
        wprintf("<CENTER>\n");
 
-       wprintf("<FORM ENCTYPE=\"multipart/form-data\" ACTION=\"%s\" "
+       wprintf("<FORM ENCTYPE=\"multipart/form-data\" action=\"%s\" "
                "METHOD=\"POST\" NAME=\"graphicsupload\">\n", uplurl);
 
+       wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
        wprintf("<INPUT TYPE=\"hidden\" NAME=\"which_room\" VALUE=\"");
        urlescputs(bstr("which_room"));
        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).<br /><br />\n");
+       wprintf(_("You can upload any image directly from your computer, "
+               "as long as it is in GIF format (JPEG, PNG, etc. won't "
+               "work)."));
+       wprintf("<br /><br />\n");
 
-       wprintf("Please select a file to upload:<br /><br />\n");
+       wprintf(_("Please select a file to upload:"));
+       wprintf("<br /><br />\n");
        wprintf("<INPUT TYPE=\"FILE\" NAME=\"filename\" SIZE=\"35\">\n");
        wprintf("<br /><br />");
-       wprintf("<INPUT TYPE=\"SUBMIT\" NAME=\"sc\" VALUE=\"Upload\">\n");
+       wprintf("<INPUT TYPE=\"SUBMIT\" NAME=\"upload_button\" VALUE=\"%s\">\n", _("Upload"));
        wprintf("&nbsp;");
-       wprintf("<INPUT TYPE=\"RESET\" VALUE=\"Reset Form\">\n");
+       wprintf("<INPUT TYPE=\"RESET\" VALUE=\"%s\">\n", _("Reset form"));
        wprintf("&nbsp;");
-       wprintf("<INPUT TYPE=\"SUBMIT\" NAME=\"sc\" VALUE=\"Cancel\">\n");
+       wprintf("<INPUT TYPE=\"SUBMIT\" NAME=\"cancel_button\" VALUE=\"%s\">\n", _("Cancel"));
        wprintf("</FORM>\n");
        wprintf("</CENTER>\n");
        wprintf("</td></tr></table></div>\n");
@@ -83,21 +70,21 @@ void do_graphics_upload(char *upl_cmd)
        int pos = 0;
        int thisblock;
 
-       if (!strcasecmp(bstr("sc"), "Cancel")) {
+       if (strlen(bstr("cancel_button")) > 0) {
                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);
-       serv_gets(buf);
+       serv_getln(buf, sizeof buf);
        if (buf[0] != '2') {
                strcpy(WC->ImportantMessage, &buf[4]);
                display_main_menu();
@@ -107,11 +94,11 @@ void do_graphics_upload(char *upl_cmd)
        while (bytes_remaining) {
                thisblock = ((bytes_remaining > 4096) ? 4096 : bytes_remaining);
                serv_printf("WRIT %d", thisblock);
-               serv_gets(buf);
+               serv_getln(buf, sizeof buf);
                if (buf[0] != '7') {
                        strcpy(WC->ImportantMessage, &buf[4]);
                        serv_puts("UCLS 0");
-                       serv_gets(buf);
+                       serv_getln(buf, sizeof buf);
                        display_main_menu();
                        return;
                }
@@ -122,7 +109,7 @@ void do_graphics_upload(char *upl_cmd)
        }
 
        serv_puts("UCLS 1");
-       serv_gets(buf);
+       serv_getln(buf, sizeof buf);
        if (buf[0] != 'x') {
                display_success(&buf[4]);
                return;