Exemple #1
0
 protected function act_thumb()
 {
     $this->getDir($this->get['dir'], true);
     if (!isset($this->get['file']) || !isset($this->get['dir'])) {
         $this->sendDefaultThumb();
     }
     $file = $this->get['file'];
     if (basename($file) != $file) {
         $this->sendDefaultThumb();
     }
     $file = "{$this->thumbsDir}/{$this->type}/{$this->get['dir']}/{$file}";
     if (!is_file($file) || !is_readable($file)) {
         $file = "{$this->config['uploadDir']}/{$this->type}/{$this->get['dir']}/" . basename($file);
         if (!is_file($file) || !is_readable($file)) {
             $this->sendDefaultThumb($file);
         }
         $image = image::factory($this->imageDriver, $file);
         if ($image->initError) {
             $this->sendDefaultThumb($file);
         }
         list($tmp, $tmp, $type) = getimagesize($file);
         if (in_array($type, array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG)) && $image->width <= $this->config['thumbWidth'] && $image->height <= $this->config['thumbHeight']) {
             $mime = $type == IMAGETYPE_GIF ? "gif" : ($type == IMAGETYPE_PNG ? "png" : "jpeg");
             $mime = "image/{$mime}";
             httpCache::file($file, $mime);
         } else {
             $this->sendDefaultThumb($file);
         }
     }
     httpCache::file($file, "image/jpeg");
 }
Exemple #2
0
 protected function act_thumb()
 {
     $this->getDir($this->get['dir'], true);
     if (!isset($this->get['file']) || !isset($this->get['dir'])) {
         $this->sendDefaultThumb();
     }
     $file = $this->get['file'];
     if (basename($file) != $file) {
         $this->sendDefaultThumb();
     }
     $file = "{$this->thumbsDir}/{$this->type}/{$this->get['dir']}/{$file}";
     if (!is_file($file) || !is_readable($file)) {
         $file = "{$this->config['uploadDir']}/{$this->type}/{$this->get['dir']}/" . basename($file);
         if (!is_file($file) || !is_readable($file)) {
             $this->sendDefaultThumb($file);
         }
         $image = new gd($file);
         if ($image->init_error) {
             $this->sendDefaultThumb($file);
         }
         $browsable = array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG);
         if (in_array($image->type, $browsable) && $image->get_width() <= $this->config['thumbWidth'] && $image->get_height() <= $this->config['thumbHeight']) {
             $type = $image->type == IMAGETYPE_GIF ? "gif" : ($image->type == IMAGETYPE_PNG ? "png" : "jpeg");
             $type = "image/{$type}";
             httpCache::file($file, $type);
         } else {
             $this->sendDefaultThumb($file);
         }
     }
     httpCache::file($file, "image/jpeg");
 }
Exemple #3
0
 protected function act_thumb()
 {
     if (!isset($_GET['file']) || !isset($_GET['dir']) || !$this->checkFilename($_GET['file'])) {
         $this->sendDefaultThumb();
     }
     $dir = $this->getDir();
     $file = "{$this->thumbsTypeDir}/{$_GET['dir']}/{$_GET['file']}";
     // Create thumbnail
     if (!is_file($file) || !is_readable($file)) {
         $file = "{$dir}/{$_GET['file']}";
         if (!is_file($file) || !is_readable($file)) {
             $this->sendDefaultThumb($file);
         }
         $image = image::factory($this->imageDriver, $file);
         if ($image->initError) {
             $this->sendDefaultThumb($file);
         }
         $img = new fastImage($file);
         $type = $img->getType();
         $img->close();
         if (in_array($type, array("gif", "jpeg", "png")) && $image->width <= $this->config['thumbWidth'] && $image->height <= $this->config['thumbHeight']) {
             $mime = "image/{$type}";
             httpCache::file($file, $mime);
         } else {
             $this->sendDefaultThumb($file);
         }
         // Get type from already-existing thumbnail
     } else {
         $img = new fastImage($file);
         $type = $img->getType();
         $img->close();
     }
     httpCache::file($file, "image/{$type}");
 }