diff --git a/data/CRMEntity.php b/data/CRMEntity.php index 5ecd152625d5e9d79ebd5afe240dac1283a4a1d4..10a83cad5ae53f85c93a6e1ee39b488eeda84cad 100755 --- a/data/CRMEntity.php +++ b/data/CRMEntity.php @@ -139,7 +139,7 @@ class CRMEntity { $save_file = 'true'; //only images are allowed for Image Attachmenttype - $mimeType = mime_content_type($file_details['tmp_name']); + $mimeType = vtlib_mime_content_type($file_details['tmp_name']); $mimeTypeContents = explode('/', $mimeType); // For contacts and products we are sending attachmentType as value if ($attachmentType == 'Image' || ($file_details['size'] && $mimeTypeContents[0] == 'image')) { @@ -2696,4 +2696,4 @@ class CRMEntity { return $query; } } -?> \ No newline at end of file +?> diff --git a/include/utils/VtlibUtils.php b/include/utils/VtlibUtils.php index 096ba474210760be2577fe73dc161d56f193df0a..24a0bfc9e6165c14ece3e86ed1c56bd01cfd20a2 100644 --- a/include/utils/VtlibUtils.php +++ b/include/utils/VtlibUtils.php @@ -704,4 +704,8 @@ function vtlib_module_icon($modulename){ return "modules/Vtiger/Vtiger.png"; } +function vtlib_mime_content_type($filename) { + return Vtiger_Functions::mime_content_type($filename); +} + ?> diff --git a/modules/Settings/Vtiger/actions/CompanyDetailsSave.php b/modules/Settings/Vtiger/actions/CompanyDetailsSave.php index 28da624cc75c58349141428d84bb1a25f6a6d9b2..676e22bc2ab7c94fe9f984e377f77893abf80c33 100644 --- a/modules/Settings/Vtiger/actions/CompanyDetailsSave.php +++ b/modules/Settings/Vtiger/actions/CompanyDetailsSave.php @@ -28,7 +28,7 @@ class Settings_Vtiger_CompanyDetailsSave_Action extends Settings_Vtiger_Basic_Ac } //mime type check - $mimeType = mime_content_type($logoDetails['tmp_name']); + $mimeType = vtlib_mime_content_type($logoDetails['tmp_name']); $mimeTypeContents = explode('/', $mimeType); if (!$logoDetails['size'] || $mimeTypeContents[0] != 'image' || !in_array($mimeTypeContents[1], Settings_Vtiger_CompanyDetails_Model::$logoSupportedFormats)) { $saveLogo = false; @@ -73,4 +73,4 @@ class Settings_Vtiger_CompanyDetailsSave_Action extends Settings_Vtiger_Basic_Ac public function validateRequest(Vtiger_Request $request) { $request->validateWriteAccess(); } -} \ No newline at end of file +} diff --git a/vtlib/Vtiger/Functions.php b/vtlib/Vtiger/Functions.php index 7b7c2abf60713c4526696ea78925af080181995a..e0c3aaced61f282bae64911a7c8845ffe95c1e8f 100644 --- a/vtlib/Vtiger/Functions.php +++ b/vtlib/Vtiger/Functions.php @@ -938,7 +938,24 @@ class Vtiger_Functions { $noof_group_rows = $adb->num_rows($result); return $result; } - + + /** + * Function to determine mime type of file. + * Compatible with mime_magic or fileinfo php extension. + */ + static function mime_content_type($filename) { + $type = null; + if (function_exists('mime_content_type')) { + $type = mime_content_type($filename); + } else if (function_exists('finfo_open')) { + $finfo = finfo_open(FILEINFO_MIME_TYPE); + $type = finfo_file($finfo, $filename); + finfo_close($finfo); + } else { + throw new Exception('mime_magic or fileinfo extension required.'); + } + return $type; + } /** * Check the file MIME Type @@ -946,7 +963,7 @@ class Vtiger_Functions { * @param $claimedMime Array of bad file extenstions */ static function verifyClaimedMIME($targetFile,$claimedMime) { - $fileMimeContentType= mime_content_type($targetFile); + $fileMimeContentType= self::mime_content_type($targetFile); if (in_array(strtolower($fileMimeContentType), $claimedMime)) { return false; }