diff --git a/bl-kernel/admin/themes/gris b/bl-kernel/admin/themes/gris index 09138280..c97e1681 160000 --- a/bl-kernel/admin/themes/gris +++ b/bl-kernel/admin/themes/gris @@ -1 +1 @@ -Subproject commit 09138280134ec8014982f260c1ebb6a5b0091fdc +Subproject commit c97e1681dda9576128298d299e42973646df2475 diff --git a/bl-kernel/ajax/logo-upload.php b/bl-kernel/ajax/logo-upload.php index c334ca09..f1f0d4e8 100644 --- a/bl-kernel/ajax/logo-upload.php +++ b/bl-kernel/ajax/logo-upload.php @@ -32,10 +32,12 @@ if (!in_array($fileExtension, $GLOBALS['ALLOWED_IMG_EXTENSION'])) { // File MIME Type $fileMimeType = Filesystem::mimeType($_FILES['inputFile']['tmp_name']); -if (!in_array($fileMimeType, $GLOBALS['ALLOWED_IMG_MIMETYPES'])) { - $message = $L->g('File mime type is not supported. Allowed types:').' '.implode(', ',$GLOBALS['ALLOWED_IMG_MIMETYPES']); - Log::set($message, LOG_TYPE_ERROR); - ajaxResponse(1, $message); +if ($fileMimeType!==false) { + if (!in_array($fileMimeType, $GLOBALS['ALLOWED_IMG_MIMETYPES'])) { + $message = $L->g('File mime type is not supported. Allowed types:').' '.implode(', ',$GLOBALS['ALLOWED_IMG_MIMETYPES']); + Log::set($message, LOG_TYPE_ERROR); + ajaxResponse(1, $message); + } } // Final filename diff --git a/bl-kernel/ajax/profile-picture-upload.php b/bl-kernel/ajax/profile-picture-upload.php index 22a9dc9f..cbdd7295 100644 --- a/bl-kernel/ajax/profile-picture-upload.php +++ b/bl-kernel/ajax/profile-picture-upload.php @@ -37,10 +37,12 @@ if (!in_array($fileExtension, $GLOBALS['ALLOWED_IMG_EXTENSION']) ) { // Check file MIME Type $fileMimeType = Filesystem::mimeType($_FILES['profilePictureInputFile']['tmp_name']); -if (!in_array($fileMimeType, $GLOBALS['ALLOWED_IMG_MIMETYPES'])) { - $message = $L->g('File mime type is not supported. Allowed types:').' '.implode(', ',$GLOBALS['ALLOWED_IMG_MIMETYPES']); - Log::set($message, LOG_TYPE_ERROR); - ajaxResponse(1, $message); +if ($fileMimeType!==false) { + if (!in_array($fileMimeType, $GLOBALS['ALLOWED_IMG_MIMETYPES'])) { + $message = $L->g('File mime type is not supported. Allowed types:').' '.implode(', ',$GLOBALS['ALLOWED_IMG_MIMETYPES']); + Log::set($message, LOG_TYPE_ERROR); + ajaxResponse(1, $message); + } } // Tmp filename diff --git a/bl-kernel/ajax/upload-images.php b/bl-kernel/ajax/upload-images.php index a7b190db..1ca8c406 100644 --- a/bl-kernel/ajax/upload-images.php +++ b/bl-kernel/ajax/upload-images.php @@ -65,10 +65,12 @@ foreach ($_FILES['images']['name'] as $uuid=>$filename) { // Check file MIME Type $fileMimeType = Filesystem::mimeType($_FILES['images']['tmp_name'][$uuid]); - if (!in_array($fileMimeType, $GLOBALS['ALLOWED_IMG_MIMETYPES'])) { - $message = $L->g('File mime type is not supported. Allowed types:').' '.implode(', ',$GLOBALS['ALLOWED_IMG_MIMETYPES']); - Log::set($message, LOG_TYPE_ERROR); - ajaxResponse(1, $message); + if ($fileMimeType!==false) { + if (!in_array($fileMimeType, $GLOBALS['ALLOWED_IMG_MIMETYPES'])) { + $message = $L->g('File mime type is not supported. Allowed types:').' '.implode(', ',$GLOBALS['ALLOWED_IMG_MIMETYPES']); + Log::set($message, LOG_TYPE_ERROR); + ajaxResponse(1, $message); + } } // Move from PHP tmp file to Bludit tmp directory diff --git a/bl-kernel/helpers/filesystem.class.php b/bl-kernel/helpers/filesystem.class.php index 347f15c6..1ff4a6eb 100644 --- a/bl-kernel/helpers/filesystem.class.php +++ b/bl-kernel/helpers/filesystem.class.php @@ -303,12 +303,23 @@ class Filesystem { | @file /home/diego/dog.jpg | @return image/jpeg | - | @file string Full path of the file + | @file [string] Full path of the file | - | @return string + | @return [string|bool] Mime type as string or FALSE if not possible to get the mime type */ public static function mimeType($file) { - return mime_content_type($file); + if (function_exists('mime_content_type')) { + return mime_content_type($file); + } + + if (function_exists('finfo_file')) { + $fileinfo = finfo_open(FILEINFO_MIME_TYPE); + $mimeType = finfo_file($fileinfo, $file); + finfo_close($fileinfo); + return $mimeType; + } + + return false; } }