From 5fcc897c5566454140e0ecf882333db263d0cf30 Mon Sep 17 00:00:00 2001 From: AL BOROM WARD <3279308836@qq.com> Date: Tue, 16 Nov 2021 06:21:39 +0800 Subject: [PATCH] Updated Script.php In this commit, I fixed the bug200 which was the incorrect encoding of Chinese characters in the uploaded assignment files --- Script.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Script.php b/Script.php index 92a14fa..553ab63 100644 --- a/Script.php +++ b/Script.php @@ -75,7 +75,6 @@ if (!empty($_POST["frm_signup_2"])) { $_SESSION['user_fullname'] = $fullname; $_SESSION['user_type'] = "Student"; $_SESSION['user_email'] = $email; - $_SESSION['user_student_id'] = $student_id; // check confirmed password if (strcasecmp($password, $confirmpassword) != 0) { @@ -302,7 +301,7 @@ function is_valid_file_format($file) 'cvc', 'c', 'class', 'cpp', 'h', 'java', 'sh', 'swift', 'zip', 'rar', 'ods', 'xlr', 'bak', 'ico', 'swf' ); - $filename = $_FILES[$file]['name']; + utf8_encode($filename = $_FILES[$file]['name']); $ext = pathinfo($filename, PATHINFO_EXTENSION); $result = in_array($ext, $allowed); return $result; @@ -454,8 +453,10 @@ function checksize($file) } // ############################### Submit Assignment ################################## + if (!empty($_POST["frm_submitlab"])) { + /* Posting values to database */ $lab_id = mysqli_real_escape_string($con, $_POST["lab_id"]); $student_id = $_POST["student_id"]; $group_id = $_POST["group_id"]; @@ -552,19 +553,19 @@ if (!empty($_POST["frm_submitlab"])) { $targetfile4 = ""; if (strlen($_FILES['attachment1']['name']) > 2) { // why greater than 2??? - $targetfile = "/" . $student_id . "/" . $url . "/" . $lab_name . "/" . rawurlencode($_FILES['attachment1']['name']); + $targetfile = "/" . $student_id . "/" . $url . "/" . $lab_name . "/" . $_FILES['attachment1']['name']; } if (strlen($_FILES['attachment2']['name']) > 2) { - $targetfile2 = "/" . $student_id . "/" . $url . "/" . $lab_name . "/" . rawurlencode($_FILES['attachment2']['name']); + $targetfile2 = "/" . $student_id . "/" . $url . "/" . $lab_name . "/" . $_FILES['attachment2']['name']; } if (strlen($_FILES['attachment3']['name']) > 2) { - $targetfile3 = "/" . $student_id . "/" . $url . "/" . $lab_name . "/" . rawurlencode($_FILES['attachment3']['name']); + $targetfile3 = "/" . $student_id . "/" . $url . "/" . $lab_name . "/" . $_FILES['attachment3']['name']; } if (strlen($_FILES['attachment4']['name']) > 2) { - $targetfile4 = "/" . $student_id . "/" . $url . "/" . $lab_name . "/" . rawurlencode($_FILES['attachment4']['name']); + $targetfile4 = "/" . $student_id . "/" . $url . "/" . $lab_name . "/" . $_FILES['attachment4']['name']; } // When $group_id is not properly initialized, use integer 0 as its value. -- 2.17.1