Esempio n. 1
0
 function run()
 {
     //$mimeIcon=getMimeIcon($mime);
     $fullfile = $this->real_cwd . '/' . $this->filename;
     $thumbfile = $this->real_cwd . '/.thumb_' . $this->filename;
     $icon = false;
     if (file_exists($thumbfile)) {
         $icon = $thumbfile;
     } else {
         $mime = $this->getMIME($fullfile);
         $ext = strtolower($this->getExtension($this->filename));
         if ($this->isImage($mime, $ext)) {
             //Try and find a thumbnail, else try to generate one
             //	else send generic picture icon.
             if ($this->isJPEG($mime, $ext)) {
                 $result = $this->resizeFromJPEG($fullfile);
             } elseif ($this->isGIF($mime, $ext)) {
                 $result = $this->resizeFromGIF($fullfile);
             } elseif ($this->isPNG($mime, $ext)) {
                 $result = $this->resizeFromPNG($fullfile);
             }
             if ($result !== false) {
                 if (function_exists("imagejpeg")) {
                     imagejpeg($result, $thumbfile, 70);
                     @chmod($thumbfile, $this->fckphp_config['modx']['file_permissions']);
                     //modified for MODx
                     $icon = $thumbfile;
                 } elseif (function_exists("imagepng")) {
                     imagepng($result, $thumbfile);
                     @chmod($thumbfile, $this->fckphp_config['modx']['file_permissions']);
                     //modified for MODx
                     $icon = $thumbfile;
                 } elseif (function_exists("imagegif")) {
                     imagegif($result, $thumbfile);
                     @chmod($thumbfile, $this->fckphp_config['modx']['file_permissions']);
                     //modified for MODx
                     $icon = $thumbfile;
                 } else {
                     $icon = iconLookup($mime, $ext);
                 }
             } else {
                 $icon = iconLookup($mime, $ext);
             }
         } else {
             $icon = iconLookup($mime, $ext);
         }
     }
     $iconMime = $this->image2MIME($icon);
     if ($iconMime == false) {
         $iconMime = "image/jpeg";
     }
     header("Content-type: {$iconMime}", true);
     readfile($icon);
 }
Esempio n. 2
0
 function run()
 {
     //$mimeIcon=getMimeIcon($mime);
     $fullfile = $this->real_cwd . '/' . $this->filename;
     $thumbfile = $this->real_cwd . '/.thumb/' . $this->filename;
     $icon = false;
     if (is_file($thumbfile)) {
         $icon = $thumbfile;
     } else {
         $thumbdir = dirname($thumbfile);
         $finfo = getimagesize($fullfile);
         $mime = $finfo['mime'];
         $ext = strtolower($this->getExtension($this->filename));
         if ($this->isImage($mime, $ext)) {
             if (!is_dir($thumbdir)) {
                 $rs = mkdir($thumbdir, $this->fckphp_config['modx']['folder_permissions'], true);
             }
             if ($rs) {
                 chmod($thumbdir, $this->fckphp_config['modx']['folder_permissions']);
             }
             //Try and find a thumbnail, else try to generate one
             //	else send generic picture icon.
             if ($this->isJPEG($mime, $ext)) {
                 $result = $this->resizeFromJPEG($fullfile);
             } elseif ($this->isGIF($mime, $ext)) {
                 $result = $this->resizeFromGIF($fullfile);
             } elseif ($this->isPNG($mime, $ext)) {
                 $result = $this->resizeFromPNG($fullfile);
             }
             if ($result !== false) {
                 if (function_exists("imagejpeg")) {
                     imagejpeg($result, $thumbfile, 80);
                     @chmod($thumbfile, $this->fckphp_config['modx']['file_permissions']);
                     $icon = $thumbfile;
                 } elseif (function_exists("imagepng")) {
                     imagepng($result, $thumbfile);
                     @chmod($thumbfile, $this->fckphp_config['modx']['file_permissions']);
                     $icon = $thumbfile;
                 } elseif (function_exists("imagegif")) {
                     imagegif($result, $thumbfile);
                     @chmod($thumbfile, $this->fckphp_config['modx']['file_permissions']);
                     $icon = $thumbfile;
                 } else {
                     $icon = iconLookup($mime, $ext);
                 }
             } else {
                 $icon = iconLookup($mime, $ext);
             }
         } else {
             $icon = iconLookup($mime, $ext);
         }
     }
     $finfo = getimagesize($icon);
     $iconMime = $finfo['mime'];
     if ($iconMime == false) {
         $iconMime = 'image/jpeg';
     }
     header("Content-type: {$iconMime}", true);
     readfile($icon);
 }