From 4a0829b07ee8e6a0d78bff7c5614ef5c0ec54bd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=B5=A9=E6=96=8C?= Date: Fri, 22 Nov 2024 08:05:31 +0800 Subject: [PATCH] Update submit.php --- trunk/web/submit.php | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/trunk/web/submit.php b/trunk/web/submit.php index 18e13f29a48..98b5c0f5d83 100644 --- a/trunk/web/submit.php +++ b/trunk/web/submit.php @@ -207,9 +207,14 @@ } $tempfile = $_FILES ["answer"] ["tmp_name"]; +$len=$_FILES['answer']['size']; if($tempfile!=""){ if($language!=23){ - + if ($len > 65536) { + $view_errors = $MSG_TOO_LONG."
"; + require "template/" . $OJ_TEMPLATE . "/error.php"; + exit(0); + } $source=file_get_contents($tempfile); $len = strlen($source); unlink($tempfile); @@ -255,8 +260,18 @@ $id = 0; } -if($language!=23) $len = strlen($source);else $len = $_FILES['answer']['size']; -//echo $source; +if($language!=23) $len = strlen($source); else $len = $_FILES['answer']['size']; +if ($len < 2) { + $view_errors = $MSG_TOO_SHORT.$tempfile."
"; + require "template/".$OJ_TEMPLATE."/error.php"; + exit(0); +} +if ($len > 65536) { + $view_errors = $MSG_TOO_LONG."
"; + require "template/" . $OJ_TEMPLATE . "/error.php"; + exit(0); +} + setcookie('lastlang', $language, time()+360000); @@ -269,17 +284,6 @@ } -if ($len < 2) { - $view_errors = $MSG_TOO_SHORT.$tempfile."
"; - require "template/".$OJ_TEMPLATE."/error.php"; - exit(0); -} - -if ($len > 65536) { - $view_errors = $MSG_TOO_LONG."
"; - require "template/" . $OJ_TEMPLATE . "/error.php"; - exit(0); -} if (!$OJ_BENCHMARK_MODE) { // last submit