diff --git a/app/FileManagerFile.php b/app/FileManagerFile.php index 0f3102c4..6d479e7c 100644 --- a/app/FileManagerFile.php +++ b/app/FileManagerFile.php @@ -67,6 +67,10 @@ class FileManagerFile extends Model 'file_url' ]; + protected $casts = [ + 'meta_data' => 'array', + ]; + /** * Set routes with public access * diff --git a/app/Http/Helpers/helpers.php b/app/Http/Helpers/helpers.php index 5bbfac13..299daa83 100644 --- a/app/Http/Helpers/helpers.php +++ b/app/Http/Helpers/helpers.php @@ -528,4 +528,10 @@ function get_pretty_name($basename, $name, $mimetype) } return $name . '.' . $mimetype; -} \ No newline at end of file +} +function get_image_meta_data($file) +{ + if(get_file_type($file->getMimeType()) === 'image') { + return exif_read_data($file); + } +} diff --git a/app/Http/Requests/FileFunctions/UploadRequest.php b/app/Http/Requests/FileFunctions/UploadRequest.php index da425a6a..18859927 100644 --- a/app/Http/Requests/FileFunctions/UploadRequest.php +++ b/app/Http/Requests/FileFunctions/UploadRequest.php @@ -2,6 +2,7 @@ namespace App\Http\Requests\FileFunctions; +use App\Rules\MimetypeBlacklistValidation; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Support\Facades\Auth; @@ -26,7 +27,7 @@ class UploadRequest extends FormRequest { return [ 'parent_id' => 'required|integer', - 'file' => 'required|file', + 'file' => ['required','file' , new MimetypeBlacklistValidation] ]; } } diff --git a/app/Http/Tools/Editor.php b/app/Http/Tools/Editor.php index f7456cfa..11b05154 100644 --- a/app/Http/Tools/Editor.php +++ b/app/Http/Tools/Editor.php @@ -257,6 +257,8 @@ class Editor // If last then process file if ($request->boolean('is_last')) { + $meta_data = get_image_meta_data($file); + $disk_local = Storage::disk('local'); $unique_id = get_unique_id(); @@ -292,6 +294,7 @@ class Editor 'mimetype' => get_file_type_from_mimetype($file_mimetype), 'type' => get_file_type($file_mimetype), 'folder_id' => $request->parent_id, + 'meta_data' => $meta_data, 'name' => $user_file_name, 'unique_id' => $unique_id, 'basename' => $disk_file_name, diff --git a/app/Rules/MimetypeBlacklistValidation.php b/app/Rules/MimetypeBlacklistValidation.php new file mode 100644 index 00000000..ab71a82d --- /dev/null +++ b/app/Rules/MimetypeBlacklistValidation.php @@ -0,0 +1,42 @@ +getMimeType()); + + return !array_intersect($fileMimetype , $mimetype_blacklist); + } + + /** + * Get the validation error message. + * + * @return string + */ + public function message() + { + abort (415,'Type of this mime type is not allowed.'); + } +} diff --git a/database/migrations/2020_09_04_085714_add_exif_data_to_file_manager_files_table.php b/database/migrations/2020_09_04_085714_add_exif_data_to_file_manager_files_table.php new file mode 100644 index 00000000..a99ef2c9 --- /dev/null +++ b/database/migrations/2020_09_04_085714_add_exif_data_to_file_manager_files_table.php @@ -0,0 +1,32 @@ +longText('meta_data')->after('type')->nullable(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('file_manager_files', function (Blueprint $table) { + // + }); + } +} diff --git a/resources/js/components/FilesView/FileInfoPanel.vue b/resources/js/components/FilesView/FileInfoPanel.vue index 5cc484b1..4a0a7e0d 100644 --- a/resources/js/components/FilesView/FileInfoPanel.vue +++ b/resources/js/components/FilesView/FileInfoPanel.vue @@ -56,12 +56,21 @@ + +
+ +
+ + \ No newline at end of file diff --git a/resources/js/helpers.js b/resources/js/helpers.js index d1543870..178a0d85 100644 --- a/resources/js/helpers.js +++ b/resources/js/helpers.js @@ -145,6 +145,10 @@ const Helpers = { if (error.response.status === 500) isNotGeneralError = false + //Break if mimetype of file is in blacklist + if(error.response.status === 415) + isNotGeneralError = false + // Show Error if (attempts === 3) this.$isSomethingWrong() diff --git a/resources/js/i18n/lang/cn.json b/resources/js/i18n/lang/cn.json index 89d3ca1d..676be008 100644 --- a/resources/js/i18n/lang/cn.json +++ b/resources/js/i18n/lang/cn.json @@ -208,6 +208,9 @@ "username_plac": "输入您的邮件用户名" }, "others": { + "mimetypes_blacklist": "Mimetypes Blacklist", + "mimetypes_blacklist_plac":"Add mimetypes to Blacklist" , + "mimetypes_blacklist_help" :"If you want ban some type of files to upload just add them to blacklist like this: php,mp3,jpeg
Use a comma between each mime type. Don't use a dot before mimetypes." , "section_cache": "Application Cache", "cache_disclaimer": "Did you change anything in your .env file or change your stripe credentials? Then clear your cache.", "cache_clear": "Clear Cache", @@ -295,6 +298,19 @@ "size": "大小", "where": "地址" }, + "file_detail_meta": { + "meta_data": "Metadata", + "author": "Author", + "time_data": "Original time data", + "make": "Camera", + "model": "Model", + "camera_lens": "Camera lens", + "aperature": "Aperture F Number", + "iso": "ISO", + "focal": "Focal length", + "exposure": "Exposure time", + "not_avaible": "Metadata not avaible" + }, "folder": { "empty": "空的", "item_counts": "{count} 个文件 | {count} 个文件" @@ -473,6 +489,10 @@ }, "title": "选择付款方式" }, + "popup_mimetypes_blacklist": { + "title": "Sorry", + "message": "File of this type is not allowed to upload." + }, "popup_create_folder": { "folder_default_name": "新文件夹", "title": "请填入新文件夹名称" diff --git a/resources/js/i18n/lang/en.json b/resources/js/i18n/lang/en.json index 966b41ae..77f842c5 100644 --- a/resources/js/i18n/lang/en.json +++ b/resources/js/i18n/lang/en.json @@ -210,6 +210,9 @@ "username_plac": "Type your mail username" }, "others": { + "mimetypes_blacklist": "Mimetypes Blacklist", + "mimetypes_blacklist_plac":"Add mimetypes to Blacklist" , + "mimetypes_blacklist_help" :"If you want ban some type of files to upload just add them to blacklist like this: php,mp3,jpeg
Use a comma between each mime type. Don't use a dot before mimetypes." , "section_cache": "Application Cache", "cache_disclaimer": "Did you change anything in your .env file or change your Stripe credentials? Then clear your cache.", "cache_clear": "Clear Cache", @@ -297,6 +300,19 @@ "size": "Size", "where": "Where" }, + "file_detail_meta": { + "meta_data": "Metadata", + "author": "Author", + "time_data": "Original time data", + "make": "Camera", + "model": "Model", + "camera_lens": "Camera lens", + "aperature": "Aperture F Number", + "iso": "ISO", + "focal": "Focal length", + "exposure": "Exposure time", + "not_avaible": "Metadata not avaible" + }, "folder": { "empty": "Empty", "item_counts": "{count} Item | {count} Items" @@ -475,6 +491,10 @@ }, "title": "Choose Payment Method" }, + "popup_mimetypes_blacklist": { + "title": "Sorry", + "message": "File of this type is not allowed to upload." + }, "popup_create_folder": { "folder_default_name": "New Folder", "title": "Please enter your new folder name" diff --git a/resources/js/i18n/lang/sk.json b/resources/js/i18n/lang/sk.json index 63b7d541..ebf4a943 100644 --- a/resources/js/i18n/lang/sk.json +++ b/resources/js/i18n/lang/sk.json @@ -210,6 +210,9 @@ "username_plac": "Zadajte svoje používateľské meno pre poštu" }, "others": { + "mimetypes_blacklist": "Čierna listina mimetypov", + "mimetypes_blacklist_plac":"Pridajte mimetypy do Čiernej listiny", + "mimetypes_blacklist_help" :"Ak chcete zakázať nahrávanie niektorých typov súborov, jednoducho ich pridajte na čiernu listinu, príklad: php, mp3, jpeg
Medzi mimetypmi použite čiarku. Nevkladajte bodku pred mimetyp." , "section_cache": "Aplikačná pamäť", "cache_disclaimer": "Zmenili ste niečo v .env súbore alebo ste zmenili Stripe poverenia? Vymažte aplikačnú pamäť.", "cache_clear": "Vymazať aplikačnú pamäť", @@ -297,6 +300,19 @@ "size": "Veľkosť", "where": "Umiestnenie" }, + "file_detail_meta": { + "meta_data": "Metadata", + "author": "Autor", + "time_data": "Pôvodných časový údaj", + "make": "Fotoaparát", + "model": "Model", + "camera_lens": "Objektív fotoaparátu", + "aperature": "Clona", + "iso": "ISO", + "focal": "Ohnisková vzdialenosť", + "exposure": "Doba expozície", + "not_avaible": "Metadáta nie sú k dispozícii" + }, "folder": { "empty": "Prázdne", "item_counts": "{count} Položka | {count} Položky" @@ -475,6 +491,10 @@ }, "title": "Vyberte si metódu platby" }, + "popup_mimetypes_blacklist": { + "title": "Ospravelnujume sa", + "message": "Nieje povolené nahrávať tento typ súboru." + }, "popup_create_folder": { "folder_default_name": "Nový priečinok", "title": "Prosím, vložte názov nového priečinka" diff --git a/resources/js/store/modules/fileFunctions.js b/resources/js/store/modules/fileFunctions.js index 705ec53a..c4c67d37 100644 --- a/resources/js/store/modules/fileFunctions.js +++ b/resources/js/store/modules/fileFunctions.js @@ -122,6 +122,13 @@ const actions = { message: i18n.t('popup_exceed_limit.message') }) break; + case 415: + events.$emit('alert:open', { + emoji: '😬', + title: i18n.t('popup_mimetypes_blacklist.title'), + message: i18n.t('popup_mimetypes_blacklist.message') + }) + break; case 413: events.$emit('alert:open', { emoji: '😟', diff --git a/resources/js/views/Admin/AppSettings/AppSettingsTabs/Others.vue b/resources/js/views/Admin/AppSettings/AppSettingsTabs/Others.vue index f36c020e..a8642cda 100644 --- a/resources/js/views/Admin/AppSettings/AppSettingsTabs/Others.vue +++ b/resources/js/views/Admin/AppSettings/AppSettingsTabs/Others.vue @@ -80,6 +80,21 @@ + +
+ + +
+
+ +