Example #1
0
 /**
  * timthumb::start()
  * 
  * @return
  */
 public static function start()
 {
     $tim = new timthumb();
     $tim->handleErrors();
     $tim->securityChecks();
     if ($tim->tryBrowserCache()) {
         exit(0);
     }
     $tim->handleErrors();
     if (FILE_CACHE_ENABLED && $tim->tryServerCache()) {
         exit(0);
     }
     $tim->handleErrors();
     $tim->run();
     $tim->handleErrors();
     exit(0);
 }
Example #2
0
 public static function start($param_array)
 {
     self::$param_array = $param_array;
     $tim = new timthumb();
     $tim->handleErrors();
     $tim->securityChecks();
     if ($tim->tryBrowserCache()) {
         return $tim->cachefile;
         //exit(0);
     }
     $tim->handleErrors();
     if (FILE_CACHE_ENABLED && $tim->tryServerCache()) {
         return $tim->cachefile;
         //exit(0);
     }
     $tim->handleErrors();
     $tim->run();
     $tim->handleErrors();
     return $tim->cachefile;
     //exit(0);
 }
Example #3
0
 /**
  * @param array $options
  */
 public static function start(array $options = null)
 {
     //Image fetching and caching
     if (!defined('FILE_CACHE_TIME_BETWEEN_CLEANS')) {
         define('FILE_CACHE_TIME_BETWEEN_CLEANS', 86400);
     }
     // How often the cache is cleaned
     if (!defined('FILE_CACHE_MAX_FILE_AGE')) {
         define('FILE_CACHE_MAX_FILE_AGE', 86400);
     }
     // How old does a file have to be to be deleted from the cache
     if (!defined('FILE_CACHE_SUFFIX')) {
         define('FILE_CACHE_SUFFIX', '.timthumb.txt');
     }
     // What to put at the end of all files in the cache directory so we can identify them
     if (!defined('FILE_CACHE_PREFIX')) {
         define('FILE_CACHE_PREFIX', 'timthumb');
     }
     // What to put at the beg of all files in the cache directory so we can identify them
     if (!defined('MAX_FILE_SIZE')) {
         define('MAX_FILE_SIZE', 10485760);
     }
     // 10 Megs is 10485760. This is the max internal or external file size that we'll process.
     if (!defined('CURL_TIMEOUT')) {
         define('CURL_TIMEOUT', 20);
     }
     // Timeout duration for Curl. This only applies if you have Curl installed and aren't using PHP's default URL fetching mechanism.
     if (!defined('WAIT_BETWEEN_FETCH_ERRORS')) {
         define('WAIT_BETWEEN_FETCH_ERRORS', 3600);
     }
     // Time to wait between errors fetching remote file
     //Browser caching
     if (!defined('BROWSER_CACHE_MAX_AGE')) {
         define('BROWSER_CACHE_MAX_AGE', 864000);
     }
     // Time to cache in the browser
     if (!defined('BROWSER_CACHE_DISABLE')) {
         define('BROWSER_CACHE_DISABLE', false);
     }
     // Use for testing if you want to disable all browser caching
     //Image size and defaults
     if (!defined('NOT_FOUND_IMAGE')) {
         define('NOT_FOUND_IMAGE', '');
     }
     // Image to serve if any 404 occurs
     if (!defined('ERROR_IMAGE')) {
         define('ERROR_IMAGE', '');
     }
     // Image to serve if an error occurs instead of showing error message
     if (!defined('PNG_IS_TRANSPARENT')) {
         define('PNG_IS_TRANSPARENT', FALSE);
     }
     // Define if a png image should have a transparent background color. Use False value if you want to display a custom coloured canvas_colour
     //Image compression is enabled if either of these point to valid paths
     //These are now disabled by default because the file sizes of PNGs (and GIFs) are much smaller than we used to generate.
     //They only work for PNGs. GIFs and JPEGs are not affected.
     if (!defined('OPTIPNG_ENABLED')) {
         define('OPTIPNG_ENABLED', false);
     }
     if (!defined('OPTIPNG_PATH')) {
         define('OPTIPNG_PATH', '/usr/bin/optipng');
     }
     //This will run first because it gives better compression than pngcrush.
     if (!defined('PNGCRUSH_ENABLED')) {
         define('PNGCRUSH_ENABLED', false);
     }
     if (!defined('PNGCRUSH_PATH')) {
         define('PNGCRUSH_PATH', '/usr/bin/pngcrush');
     }
     //This will only run if OPTIPNG_PATH is not set or is not valid
     $tim = new timthumb($options);
     $tim->handleErrors();
     $tim->securityChecks();
     if ($tim->tryBrowserCache()) {
         exit(0);
     }
     $tim->handleErrors();
     if (static::$options['file_cache_enabled'] && $tim->tryServerCache()) {
         exit(0);
     }
     $tim->handleErrors();
     $tim->run();
     $tim->handleErrors();
     exit(0);
 }
Example #4
0
 public static function start()
 {
     if (LIMIT_ON) {
         if (count($_GET) > 1 || !$_GET['src'] || $_POST) {
             return;
         }
     }
     $tim = new timthumb();
     $tim->handleErrors();
     $tim->securityChecks();
     if ($tim->tryBrowserCache()) {
         exit(0);
     }
     $tim->handleErrors();
     if (FILE_CACHE_ENABLED && $tim->tryServerCache()) {
         exit(0);
     }
     $tim->handleErrors();
     $tim->run();
     $tim->handleErrors();
     exit(0);
 }