From b61df2d1ea5b19bba164abae83d79876226fb693 Mon Sep 17 00:00:00 2001 From: lutranf Date: Tue, 23 Dec 2014 14:28:16 +0100 Subject: [PATCH] fix getMimeType --- inc/toolbox.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/inc/toolbox.php b/inc/toolbox.php index 40211fb..3e5b6ee 100644 --- a/inc/toolbox.php +++ b/inc/toolbox.php @@ -145,8 +145,11 @@ class ToolBox curl_setopt($oCurl, CURLOPT_FOLLOWLOCATION, true); curl_setopt($oCurl, CURLOPT_HEADER, true); curl_setopt($oCurl, CURLOPT_NOBODY, true); + curl_setopt($oCurl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); + curl_setopt($oCurl, CURLOPT_SSL_VERIFYPEER, false); curl_exec($oCurl); $sMimetype = curl_getinfo($oCurl, CURLINFO_CONTENT_TYPE); + curl_close($oCurl); } //Only sub type (after /) @@ -174,7 +177,8 @@ class ToolBox elseif(!array_key_exists('extension', $asOutInfo)) $sOutPath .= '.'.$sImageExt; //folder + filename, but getting ext from file info //New sizes - if(in_array($sImageExt, $asImageExts)) + if(!in_array($sImageExt, $asImageExts)) $asResult['error'] = 'Wrong file type'; + else { list($iWidth, $iHeight) = getimagesize($sInPath); if($iWidth > $iMaxWidth || $iHeight > $iMaxHeight) @@ -241,7 +245,6 @@ class ToolBox $asResult['height'] = $iResizedHeight; $asResult['out'] = $sOutPath; } - else $asResult['error'] = 'Wrong file type'; if($bDeleteIn && $asResult['error']=='' && $sInPath != $sOutPath) unlink($sInPath);