From a09e25d7943879409b3d258042cda3a4ac05c915 Mon Sep 17 00:00:00 2001 From: Yandols ZeonX Date: Fri, 12 Apr 2019 22:26:07 +0800 Subject: [PATCH] Cleanup. --- dropload.php | 37 +------------------------------------ 1 file changed, 1 insertion(+), 36 deletions(-) diff --git a/dropload.php b/dropload.php index 2e92d25..0b0518a 100644 --- a/dropload.php +++ b/dropload.php @@ -12,36 +12,26 @@ $imageFileType = pathinfo($target_file,PATHINFO_EXTENSION); if(isset($_POST["submit"])) { $check = getimagesize($_FILES["fileToUpload"]["tmp_name"]); if($check !== false) { - //echo "File is an image - " . $check["mime"] . "."; $uploadOk = 1; } else { - //echo "File is not an image."; $uploadOk = 0; - //header('Location: ./failed.php'); header('HTTP/1.1 400 Bad Request', true, 400); http_response_code(400); - //echo 400; return; } } // Check whether a file with the same name already exists on server or not for security reasons. if (file_exists($target_file)) { - //echo "Sorry, file already exists."; $uploadOk = 0; - //header('Location: ./failed.php'); header('HTTP/1.1 400 Bad Request', true, 400); http_response_code(400); - //echo 400; return; } // Check file size. (Imeji Standard Max is 6MB) if ($_FILES["fileToUpload"]["size"] > 6291456) { - //echo "Sorry, your file is too large. (Max is 6MB)"; $uploadOk = 0; - //header('Location: ./failed.php'); header('HTTP/1.1 400 Bad Request', true, 400); http_response_code(400); - //echo 400; return; } // Allow only certain file formats. @@ -50,21 +40,15 @@ if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg && $imageFileType != "JPG" && $imageFileType != "PNG" && $imageFileType != "JPEG" && $imageFileType != "gif" && $imageFileType != "svg" && $imageFileType != "GIF" && $imageFileType != "SVG" ) { - //echo "Sorry, only JPG, JPEG, PNG & GIF files are allowed."; $uploadOk = 0; - //header('Location: ./failed.php'); header('HTTP/1.1 400 Bad Request', true, 400); http_response_code(400); - //echo 400; return; } // Check if $uploadOk is set to 0 by an error, if so go to failure condition. if ($uploadOk == 0) { - //echo "Sorry, your file could not be uploaded."; - //header('Location: ./failed.php'); header('HTTP/1.1 400 Bad Request', true, 400); http_response_code(400); - //echo 400; return; // If everything is ok, try to upload file. } else { @@ -116,36 +100,17 @@ if ($uploadOk == 0) { $newfilename = $dayId . $hourId . $randomFilename . '.' . end(explode(".",$_FILES["fileToUpload"]["name"])); $newtarget = $target_dir . $newfilename; if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $newtarget)) { - chmod("$newtarget", 0775); // Set read and write permissions if file - //echo "The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded."; + chmod("$newtarget", 0775); // Set read and write permissions on file $uploaderlog = "" . date('U') . ", ". date('Y-m-d H:i:s e') . ", $_SERVER[REMOTE_ADDR], $newfilename" . ", " . $imejicoreversion . ", $_SERVER[HTTP_USER_AGENT]"; - //$uploaderlog = "Unix Time: " . date('U') . ", Logical Time: ". date('Y-m-d H:i:s e') . ", IP Address: $_SERVER[REMOTE_ADDR], Filename: $newfilename" . ", User Agent: $_SERVER[HTTP_USER_AGENT], Referer: $_SERVER[HTTP_REFERER]"; --simplified in v0.9e file_put_contents('uploads.log', $uploaderlog . PHP_EOL, FILE_APPEND); - //$respondingcode = http_response_code(); - //return $respondingcode; - - //$droploaddata = header('Location: https://i.zxicar.us/' . $newfilename); - //$droploaddata = '{ "Location": "https://i.zxicar.us/' . $newfilename . '" }'; - //header('Content-type: application/json'); - //echo $droploaddata; - //return; - header('Content-type: application/json'); echo json_encode([ "location" => "https://i.yandols.xyz/{$newfilename}" ]); return; - //header('Location: https://i.zxicar.us/' . $newfilename); - //return; - //header('Location: http://i.zxicar.us/' . $newfilename); --switched to HTTPS as of v0.9d - //header('Location: ../imeji/' . $newtarget); --changed as of v0.7 - //header('Location: http://zxicar.us/imeji/'.basename( $_FILES["fileToUpload"]["name"])); --changed as of v0.2 } else { - //echo "Sorry, there was a problem uploading your file."; - //header('Location: ./failed.php'); header('HTTP/1.1 400 Bad Request', true, 400); http_response_code(400); - //echo 400; return; } }