I've got a thumbnailing script I'm using which uses phpThumb(), but as an object which means I'm having to handle my own cache.
What I've got in a folder is: -
[phpthumb]
.htaccess
index.php
When used, the script will create additional files / folders in here, which are cached versions of images pulled from elsewhere, so for example I might end up with: -
[holidaysnaps]
[phpthumb]
[work-images]
.htaccess
dsc123467.jpg
index.php
lolcat.gif
etc. etc.
My script is at index.php and I want to add a CleanUpCacheDirectory() function to it so that it manages the cache as well. I've tried taking phpThumb's CleanUpCacheDirectory() function and modifying to suit but the first major problem is that it requires a folder to point at and deals with everything inside that, which I can't do here as that would include the phpthumb folder itself, as well as my index.php script and the .htaccess file. And for various reasons, I really don't want to add a "cache" folder in here.
Ideally I'd like the same options as phpThumb, i.e.: -
//$PHPTHUMB_CONFIG['cache_maxage'] = null; // never delete cached thumbnails based on last-access time
$PHPTHUMB_CONFIG['cache_maxage'] = 86400 * 30; // delete cached thumbnails that haven't been accessed in more than [30 days] (value is maximum time since last access in seconds to avoid deletion)//$PHPTHUMB_CONFIG['cache_maxsize'] = null; // never delete cached thumbnails based on byte size of cache directory
$PHPTHUMB_CONFIG['cache_maxsize'] = 10 * 1024 * 1024; // delete least-recently-accessed cached thumbnails when more than [10MB] of cached files are present (value is maximum bytesize of all cached files)//$PHPTHUMB_CONFIG['cache_maxfiles'] = null; // never delete cached thumbnails based on number of cached files
$PHPTHUMB_CONFIG['cache_maxfiles'] = 200; // delete least-recently-accessed cached thumbnails when more than [200] cached files are present (value is maximum number of cached files to keep)
With these set, I'd want to loop through all folders / files in the current folder, but excluding the phpthumb folder (and everything in it), and also ignoring the .htaccess and index.php files.
If it helps, the phpThumb CleanUpCacheDirectory() function is about 1/5th of the way down here: http://phpthumb.sourceforge.net/index.php?source=phpthumb.class.php
Any help would be greatly appreciated!