fallback if exif_imagetype is not available
Foaly* [Fri, 18 Oct 2013 00:33:55 +0000 (02:33 +0200)]
action.defaultadmin.php
lib/class.imagecompressor_utils.php

index 893709e..7815ba6 100644 (file)
@@ -40,15 +40,11 @@ else
        $tab = '';
 }
 
-$tab_header = $this->StartTabHeaders() .
-$this->SetTabHeader('imagelist', $this->Lang('title_imagelist'),('imagelist' == $tab)?true:false);
-
-/*$tab_header .= $this->SetTabHeader('prefs', $this->Lang('title_mod_prefs'),('prefs' == $tab)?true:false);
-$this->smarty->assign('start_prefs_tab', $this->StartTab('prefs', $params));*/
-
-echo $tab_header.$this->EndTabHeaders().$this->StartTabContent();
+echo $this->StartTabHeaders();
+echo $this->SetTabHeader('imagelist', $this->Lang('title_imagelist'), ('imagelist' == $tab)?true:false);
+echo $this->EndTabHeaders();
+echo $this->StartTabContent();
 echo $this->StartTab('imagelist', $params);
 require_once('function.admin_imagelist_tab.php');
 echo $this->EndTab();
-
 echo $this->EndTabContent();
\ No newline at end of file
index 9f3cb3a..11bd714 100644 (file)
@@ -31,6 +31,8 @@ class imagecompressor_utils {
        const SMUSHIT_API_URL = 'http://www.smushit.com/ysmush.it/ws.php?img=%s';
        const SMUSHIT_UA = 'CMS made simple Image Compressor/0.10.2';
 
+       static protected $mime;
+
        private function __construct() {}
 
        static final public function format_bytes($size)
@@ -102,15 +104,28 @@ class imagecompressor_utils {
 
        static final public function is_image($path)
        {
-               $info = @exif_imagetype($path);
-               if($info & (IMAGETYPE_GIF | IMAGETYPE_JPEG | IMAGETYPE_PNG))
+               if(function_exists('exif_imagetype'))
                {
-                       return true;
+                       $info = @exif_imagetype($path);
+                       if($info & (IMAGETYPE_GIF | IMAGETYPE_JPEG | IMAGETYPE_PNG))
+                       {
+                               return true;
+                       }
+                       else
+                       {
+                               return false;
+                       }
                }
-               else
+               elseif(function_exists('finfo_open'))
                {
-                       return false;
+                       if(!self::$mime)
+                       {
+                               self::$mime = finfo_open(FILEINFO_MIME);
+                       }
+                       $filetype = finfo_file(self::$mime, $path);
+                       return strpos($filetype, 'image') === 0;
                }
+               return true;
        }
 
        static final public function sort_files_by_date($a, $b)