[ Index ]
 

Code source de CMS made simple 1.0.5

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/lib/filemanager/ImageManager/ -> thumbs.php (source)

   1  <?php
   2  /**
   3   * On the fly Thumbnail generation.
   4   * Creates thumbnails given by thumbs.php?img=/relative/path/to/image.jpg
   5   * relative to the base_dir given in config.inc.php
   6   * @author $Author: Wei Zhuo $
   7   * @version $Id: thumbs.php 2755 2006-05-10 00:51:46Z wishy $
   8   * @package ImageManager
   9   */
  10  
  11  require_once(dirname(dirname(dirname(dirname(__FILE__)))) . '/include.php');
  12  check_login();
  13  
  14  $userid = get_userid();
  15  if (!check_permission($userid, 'Modify Files')) die();
  16  
  17  require_once ('config.inc.php');
  18  require_once ('Classes/ImageManager.php');
  19  require_once ('Classes/Thumbnail.php');
  20  
  21  //check for img parameter in the url
  22  if(!isset($_GET['img']))
  23      exit();
  24  
  25  
  26  $manager = new ImageManager($IMConfig);
  27  
  28  //get the image and the full path to the image
  29  $image = rawurldecode($_GET['img']);
  30  $fullpath = Files::makeFile($manager->getBaseDir(),$image);
  31  
  32  //not a file, so exit
  33  if(!is_file($fullpath))
  34      exit();
  35  
  36  $imgInfo = @getImageSize($fullpath);
  37  
  38  //Not an image, send default thumbnail
  39  if(!is_array($imgInfo))
  40  {
  41      //show the default image, otherwise we quit!
  42      $default = $manager->getDefaultThumb();
  43      if($default)
  44      {
  45          header('Location: '.$default);
  46          exit();
  47      }
  48  }
  49  
  50  //Check for thumbnails
  51  $thumbnail = $manager->getThumbName($fullpath);
  52  if(is_file($thumbnail))
  53  {
  54      //if the thumbnail is newer, send it
  55      if(filemtime($thumbnail) >= filemtime($fullpath))
  56      {
  57          header('Location: '.$manager->getThumbURL($image));
  58          exit();
  59      }
  60  }
  61  
  62  //creating thumbnails
  63  // if image smaller than config size for thumbs
  64      if ($imgInfo[0] <= $IMConfig['thumbnail_width'] && $imgInfo[1] <= $IMConfig['thumbnail_height'])
  65      {
  66          $thumbnailer = new Thumbnail($imgInfo[0],$imgInfo[1]);
  67          $thumbnailer->createThumbnail($fullpath, $thumbnail);
  68      }
  69   
  70  // if image bigger than config size for thumbs
  71      else {
  72          $thumbnailer = new Thumbnail($IMConfig['thumbnail_width'],$IMConfig['thumbnail_height']);
  73          $thumbnailer->createThumbnail($fullpath, $thumbnail);
  74      }
  75  
  76  //Check for NEW thumbnails
  77  if(is_file($thumbnail))
  78  {
  79      //send the new thumbnail
  80      header('Location: '.$manager->getThumbURL($image));
  81      exit();
  82  }
  83  else
  84  {
  85      //show the default image, otherwise we quit!
  86      $default = $manager->getDefaultThumb();
  87      if($default)
  88          header('Location: '.$default);
  89  }
  90  ?>


Généré le : Tue Apr 3 18:50:37 2007 par Balluche grâce à PHPXref 0.7