Exemplo n.º 1
0
// set PHP memory limit
define('MAX_FILE_SIZE', 3000000);
// file size limit to prevent possible DOS attacks (roughly 1.5 megabytes)
define('CURL_TIMEOUT', 10);
// timeout duration. Tweak as you require (lower = better)
// external domains that are allowed to be displayed on your website
$allowedSites = array('flickr.com', 'picasa.com', 'blogger.com', 'wordpress.com', 'img.youtube.com', 'upload.wikimedia.org', 'harves.net');
// STOP MODIFYING HERE!
// --------------------
// sort out image source
$src = get_request('src', '');
if ($src == '' || strlen($src) <= 3) {
    display_error('no image specified');
}
// clean params before use
$src = clean_source($src);
// get mime type of src
$mime_type = mime_type($src);
// used for external websites only
$external_data_string = '';
// generic file handle for reading and writing to files
$fh = '';
// check to see if this image is in the cache already
// if already cached then display the image and die
check_cache($mime_type);
// cache doesn't exist and then process everything
// check to see if GD function exist
if (!function_exists('imagecreatetruecolor')) {
    display_error('GD Library Error: imagecreatetruecolor does not exist - please contact your webhost and ask them to install the GD library');
}
if (function_exists('imagefilter') && defined('IMG_FILTER_NEGATE')) {
Exemplo n.º 2
0
function get_timthumb_src($src)
{
    $src = clean_source($src);
    // Check if WPMU and set correct path AND that image isn't external
    if (function_exists('get_current_site') && strpos($src, "http://") !== 0) {
        get_current_site();
        //global $blog_id; Breaks with WP3 MS
        if (!$blog_id) {
            global $current_blog;
            $blog_id = $current_blog->blog_id;
        }
        if (isset($blog_id) && $blog_id > 0) {
            $imageParts = explode('files/', $src);
            if (isset($imageParts[1])) {
                $src = '/blogs.dir/' . $blog_id . '/files/' . $imageParts[1];
            }
        }
    }
    return $src;
}
Exemplo n.º 3
0
// TimThumb script created by Tim McDaniels and Darren Hoyt with tweaks by Ben Gillbanks
// http://code.google.com/p/timthumb/
// MIT License: http://www.opensource.org/licenses/mit-license.php
/* Parameters allowed: */
// w: width
// h: height
// zc: zoom crop (0 or 1)
// q: quality (default is 75 and max is 100)
// HTML example: <img src="/scripts/timthumb.php?src=/images/whatever.jpg&w=150&h=200&zc=1" alt="" />
error_reporting(E_ALL);
if (!isset($_REQUEST["src"])) {
    die("no image specified");
}
// clean params before use
$src = clean_source($_REQUEST["src"]);
// set document root
$doc_root = get_document_root($src);
// get path to image on file system
$src = $doc_root . '/' . $src;
$new_width = preg_replace("/[^0-9]+/", "", get_request('w', 100));
$new_height = preg_replace("/[^0-9]+/", "", get_request('h', 100));
$zoom_crop = preg_replace("/[^0-9]+/", "", get_request('zc', 1));
$quality = preg_replace("/[^0-9]+/", "", get_request('9', 80));
// set path to cache directory (default is ./cache)
// this can be changed to a different location
$cache_dir = './cache';
// get mime type of src
$mime_type = mime_type($src);
// check to see if this image is in the cache already
//check_cache($cache_dir, $mime_type);
Exemplo n.º 4
0
    }
    imageinterlace($newImg, 1);
    switch ($ext) {
        case "gif":
            header('Content-Type: image/gif');
            return imagegif($newImg, null, 100);
            break;
        case "jpg":
            header('Content-Type: image/jpeg');
            return imagejpeg($newImg, null, 100);
            break;
        case "png":
            header('Content-Type: image/png');
            return imagepng($newImg, null, 0);
            break;
    }
}
//////////////////////////////////////////////////////////////////////////////////////////////
// return new image
// f = filepath
// w = new width
// h = new height
// a = action, c(rop) or r(esize)
//////////////////////////////////////////////////////////////////////////////////////////////
if (isset($_GET['f']) && isset($_GET['w']) && isset($_GET['h']) && isset($_GET['a'])) {
    if ($_GET['a'] == "c") {
        crop($_GET['w'], $_GET['h'], clean_source($_GET['f']));
    } else {
        resize($_GET['w'], $_GET['h'], clean_source($_GET['f']));
    }
}