[ Index ]

PHP Cross Reference of Mambo 4.6.5

[ Variables ]     [ Functions ]     [ Classes ]     [ Constants ]     [ Statistics ]

title

Body

[close]

/mambots/editors/mostlyce/jscripts/tiny_mce/imagemanager/ -> thumbs.php (source)

   1  <?php
   2  //Custom MOStlyCE code

   3  require('../../../../../../configuration.php');
   4  require ($mosConfig_absolute_path.'mambots/editors/mostlyce/jscripts/tiny_mce/auth_check.php');
   5  $result = externalCallCheck($mosConfig_absolute_path, $mosConfig_secret);
   6  if (!$result) {
   7      die('Direct Access to this location is not allowed.');
   8  }
   9  require ($mosConfig_absolute_path.'/mambots/editors/mostlyce/jscripts/tiny_mce/mostlyce_config.php');
  10  //If the Image Manager is not enabled stop them here

  11  if ($editor_plugin_img_mgr!=='true') {
  12      die('Direct Access to this location is not allowed.');
  13  }
  14  //End custom MOStlyCE code

  15  ?>
  16  <?php
  17  /**

  18   * On the fly Thumbnail generation.

  19   * Creates thumbnails given by thumbs.php?img=/relative/path/to/image.jpg

  20   * relative to the base_dir given in config.inc.php

  21   * @author $Author$

  22   * @version $Id$

  23   * @package ImageManager

  24   */
  25  
  26  require_once ('config.inc.php');
  27  require_once ('Classes/ImageManager.php');
  28  require_once ('Classes/Thumbnail.php');
  29  
  30  //check for img parameter in the url

  31  if(!isset($_GET['img']))
  32      exit();
  33  
  34  
  35  $manager = new ImageManager($IMConfig);
  36  
  37  //get the image and the full path to the image

  38  $image = rawurldecode($_GET['img']);
  39  $fullpath = Files::makeFile($manager->getBaseDir(),$image);
  40  
  41  //not a file, so exit

  42  if(!is_file($fullpath))
  43      exit();
  44  
  45  $imgInfo = @getImageSize($fullpath);
  46  
  47  //Not an image, send default thumbnail

  48  if(!is_array($imgInfo))
  49  {
  50      //show the default image, otherwise we quit!

  51      $default = $manager->getDefaultThumb();
  52      if($default)
  53      {
  54          header('Location: '.$default);
  55          exit();
  56      }
  57  }
  58  //if the image is less than the thumbnail dimensions

  59  //send the original image as thumbnail

  60  if ($imgInfo[0] <= $IMConfig['thumbnail_width']
  61   && $imgInfo[1] <= $IMConfig['thumbnail_height'])
  62   {
  63       header('Location: '.$manager->getFileURL($image));
  64       exit();
  65   }
  66  
  67  //Check for thumbnails

  68  $thumbnail = $manager->getThumbName($fullpath);
  69  if(is_file($thumbnail))
  70  {
  71      //if the thumbnail is newer, send it

  72      if(filemtime($thumbnail) >= filemtime($fullpath))
  73      {
  74          header('Location: '.$manager->getThumbURL($image));
  75          exit();
  76      }
  77  }
  78  
  79  //creating thumbnails

  80  $thumbnailer = new Thumbnail($IMConfig['thumbnail_width'],$IMConfig['thumbnail_height']);
  81  $thumbnailer->createThumbnail($fullpath, $thumbnail);
  82  
  83  //Check for NEW thumbnails

  84  if(is_file($thumbnail))
  85  {
  86      //send the new thumbnail

  87      header('Location: '.$manager->getThumbURL($image));
  88      exit();
  89  }
  90  else
  91  {
  92      //show the default image, otherwise we quit!

  93      $default = $manager->getDefaultThumb();
  94      if($default)
  95          header('Location: '.$default);
  96  }
  97  ?>