Updated current uploader code to state endpoint version used in logs to identify between this one and the new uploader.

Also pointed error page towards the revamped one.
migrationdev
YandolsZX 7 years ago
parent c0aea99dff
commit bf9135ebfc
  1. 17
      upload.php

@ -1,5 +1,6 @@
<?php <?php
//Imeji Uploader Core Code -- Version 1.2a //Imeji Uploader Core Code -- Version 1.2b
$imejicoreversion = "imeji_v1.2b";
$target_dir = "public/"; $target_dir = "public/";
$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]); $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
$target_filenameonly = basename($_FILES["fileToUpload"]["name"]); $target_filenameonly = basename($_FILES["fileToUpload"]["name"]);
@ -14,20 +15,20 @@ if(isset($_POST["submit"])) {
} else { } else {
echo "File is not an image."; echo "File is not an image.";
$uploadOk = 0; $uploadOk = 0;
header('Location: ./uploadfailed.php'); header('Location: ./failed.php');
} }
} }
// Check if file already exists // Check if file already exists
if (file_exists($target_file)) { if (file_exists($target_file)) {
echo "Sorry, file already exists."; echo "Sorry, file already exists.";
$uploadOk = 0; $uploadOk = 0;
header('Location: ./uploadfailed.php'); header('Location: ./failed.php');
} }
// Check file size (Currently Max 6MB) // Check file size (Currently Max 6MB)
if ($_FILES["fileToUpload"]["size"] > 6291456) { if ($_FILES["fileToUpload"]["size"] > 6291456) {
echo "Sorry, your file is too large. (Max is 6MB)"; echo "Sorry, your file is too large. (Max is 6MB)";
$uploadOk = 0; $uploadOk = 0;
header('Location: ./uploadfailed.php'); header('Location: ./failed.php');
} }
// Allow certain file formats // Allow certain file formats
// Fixed uppercase rejection bug in 1.1a // Fixed uppercase rejection bug in 1.1a
@ -37,12 +38,12 @@ if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg
&& $imageFileType != "GIF" && $imageFileType != "SVG" ) { && $imageFileType != "GIF" && $imageFileType != "SVG" ) {
echo "Sorry, only JPG, JPEG, PNG & GIF files are allowed."; echo "Sorry, only JPG, JPEG, PNG & GIF files are allowed.";
$uploadOk = 0; $uploadOk = 0;
header('Location: ./uploadfailed.php'); header('Location: ./failed.php');
} }
// Check if $uploadOk is set to 0 by an error // Check if $uploadOk is set to 0 by an error
if ($uploadOk == 0) { if ($uploadOk == 0) {
echo "Sorry, your file could not be uploaded."; echo "Sorry, your file could not be uploaded.";
header('Location: ./uploadfailed.php'); header('Location: ./failed.php');
// if everything is ok, try to upload file // if everything is ok, try to upload file
} else { } else {
// 1.2a -- Changed some case-confusing characters such as I and O to web safe symbols. // 1.2a -- Changed some case-confusing characters such as I and O to web safe symbols.
@ -60,7 +61,7 @@ if ($uploadOk == 0) {
if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $newtarget)) { if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $newtarget)) {
chmod("$newtarget", 0775); // Set read and write permissions if file chmod("$newtarget", 0775); // Set read and write permissions if file
echo "The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded."; echo "The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded.";
$uploaderlog = "" . date('U') . ", ". date('Y-m-d H:i:s e') . ", $_SERVER[REMOTE_ADDR], $newfilename" . ", $_SERVER[HTTP_USER_AGENT]"; $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 //$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); file_put_contents('uploads.log', $uploaderlog . PHP_EOL, FILE_APPEND);
header('Location: https://i.zxicar.us/' . $newfilename); header('Location: https://i.zxicar.us/' . $newfilename);
@ -69,7 +70,7 @@ if ($uploadOk == 0) {
//header('Location: http://zxicar.us/imeji/'.basename( $_FILES["fileToUpload"]["name"])); --changed as of v0.2 //header('Location: http://zxicar.us/imeji/'.basename( $_FILES["fileToUpload"]["name"])); --changed as of v0.2
} else { } else {
echo "Sorry, there was a problem uploading your file."; echo "Sorry, there was a problem uploading your file.";
header('Location: ./uploadfailed.php'); header('Location: ./failed.php');
} }
} }
?> ?>

Loading…
Cancel
Save