From 0e2dcd269d928ec4a286ec78782bcd0d5112e84b Mon Sep 17 00:00:00 2001 From: Fahad Abbas Date: Wed, 21 Feb 2018 15:59:36 +0500 Subject: [PATCH] modified : secuirity fixes of file uploading has been applied --- upload/actions/beats_uploader.php | 4 ++-- upload/actions/photo_uploader.php | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/upload/actions/beats_uploader.php b/upload/actions/beats_uploader.php index c8e17a78..7450be0f 100755 --- a/upload/actions/beats_uploader.php +++ b/upload/actions/beats_uploader.php @@ -46,7 +46,7 @@ switch($mode) echo json_encode($updateResponse); } break; - case "uploadPhoto": + /* case "uploadPhoto": { $exts = $cbphoto->exts; $max_size = 1048576; // 2MB in bytes @@ -126,7 +126,7 @@ switch($mode) exit(0); } } - break; + break;*/ case 'plupload': { diff --git a/upload/actions/photo_uploader.php b/upload/actions/photo_uploader.php index b7d4224e..2679f09d 100644 --- a/upload/actions/photo_uploader.php +++ b/upload/actions/photo_uploader.php @@ -161,6 +161,14 @@ switch($mode) upload_error("Invalid file extension"); exit(0); } + + #checking for if the right file is uploaded + $content_type = get_mime_type($_FILES[$form]['tmp_name']); + if ( $content_type != 'image') { + upload_error("Invalid file type"); + exit(); + } + $filename = $cbphoto->create_filename(); @@ -178,7 +186,7 @@ switch($mode) break; - case 'plupload': { + /* case 'plupload': { $status_array = array(); // HTTP headers for no cache etc header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); @@ -193,6 +201,7 @@ switch($mode) echo json_encode(array("status"=>"400","err"=>"Invalid Content")); exit(); } + $extension = getExt( $_FILES['file']['name']); $types = strtolower(config('allowed_types')); $supported_extensions = explode(',', $types); @@ -201,6 +210,7 @@ switch($mode) echo json_encode(array("status"=>"504","msg"=>"Invalid extension")); exit(); } + //pr($_REQUEST); $targetDir = PHOTOS_DIR; $directory = create_dated_folder( PHOTOS_DIR ); @@ -325,7 +335,7 @@ switch($mode) rename($filePath, $targetFile); echo json_encode( array("success"=>"yes","file_name"=>$filename, "extension" => getExt( $filePath ), "file_directory" => $directory ) ); - } + }*/ break; }