Esempio n. 1
0
/**
 * Remove image from cache
 *
 * @author Andreas Goetz <*****@*****.**>
 */
function removeCacheFile($url)
{
    // get extension
    if (preg_match("/\\.(jpe?g|gif|png)\$/i", $url, $matches)) {
        // check if file exists
        if (cache_file_exists($url, $cache_file, CACHE_IMG, $matches[1])) {
            @unlink($cache_file);
        }
    }
}
Esempio n. 2
0
/**
 * amazon workaround for 1 pixel transparent images
 */
function checkAmazonSmallImage($url, $ext, $file)
{
    if (preg_match('/^(.+)L(Z{7,}.+)$/', $url, $m)) {
        if (list($width, $height, $type, $attr) = getimagesize($file)) {
            if ($width <= 1) {
                $smallurl = $m[1] . 'M' . $m[2];
                if (cache_file_exists($smallurl, $cache_file, CACHE_IMG, $ext) || download($smallurl, $cache_file)) {
                    copy($cache_file, $file);
                }
            }
        }
    }
}
Esempio n. 3
0
function cache_get($url, $cache_folder, $cache_max_age, $serialize = false)
{
    $data = false;
    if ($cache_max_age > 0) {
        if (cache_file_exists($url, $cache_file, $cache_folder)) {
            if (time() - filemtime($cache_file) < $cache_max_age) {
                $data = file_get_contents($cache_file);
                if ($data !== false && $serialize) {
                    $data = unserialize($data);
                }
            } else {
                @unlink($cache_file);
            }
        }
    }
    return $data;
}
Esempio n. 4
0
/**
 * get Thumbnail for a movie
 *
 * @param  string   URL
 * @return string   the URL to the cached image if exists or a link to img.php
 */
function getThumbnail($imgurl, $name = '')
{
    // cover url not set? try local path instead
    if (!$imgurl && $name) {
        // be careful with the filename here- so clean it
        $localname = CACHE . '/' . CACHE_LOCAL . '/' . cleanFilename($name) . '.jpg';
        //      Small performance fix
        //      if (file_exists($localname) && filesize($localname)) return($localname);
        if (@filesize($localname) > 0) {
            return $localname;
        }
    }
    // really an image?
    if (preg_match('/\\.(jpe?g|gif|png)$/i', $imgurl, $matches)) {
        // local file? - keep it!
        if (!preg_match('/^http/i', $imgurl)) {
            return $imgurl;
        }
        // file in cache?
        if (cache_file_exists($imgurl, $cache_file, CACHE_IMG, $matches[1])) {
            // double-check this is really an image
            if (@exif_imagetype($cache_file)) {
                return $cache_file;
            }
        } else {
            // add cache_ignore=1& to suppress additional cache lookup in img.php
            return 'img.php?url=' . urlencode($imgurl);
        }
    }
    // no image url given -> nopic
    return img();
}
Esempio n. 5
0
        } else {
            cache_file_exists($url, $cache_file, CACHE_IMG, $matches[1]);
        }
        $covers[] = $cache_file;
        $images[] = $cache_file;
    }
}
// find actor images in cache
foreach ($actorResult as $val) {
    $url = $val['imgurl'];
    if (preg_match("/\\.(jpe?g|gif|png)\$/i", $url, $matches)) {
        // get the cache file name, honor manually uploaded files
        if (preg_match('#^cache#i', $url)) {
            $cache_file = $url;
        } else {
            cache_file_exists($url, $cache_file, CACHE_IMG, $matches[1]);
        }
        $actors[] = $cache_file;
        $images[] = $cache_file;
    }
}
$size = 0;
$coverSize = 0;
$actorSize = 0;
$unused = 0;
$coverNum = 0;
$actorNum = 0;
// get list of all images currently in cache
list($total, $foo, $files) = analyzeCacheFolder('cache/img', true);
if ($submit) {
    dump('Deleting:');