function brilliant_gallery_rmdir_recursive in Brilliant Gallery 7
Same name and namespace in other branches
- 6.4 cron.inc \brilliant_gallery_rmdir_recursive()
- 6.3 brilliant_gallery.module \brilliant_gallery_rmdir_recursive()
@todo Please document this function.
See also
1 call to brilliant_gallery_rmdir_recursive()
- brilliant_gallery_cleantmpdir in ./
brilliant_gallery_cron.inc - @todo Please document this function.
File
- ./
brilliant_gallery_cron.inc, line 62
Code
function brilliant_gallery_rmdir_recursive($dir, $timestampexpired) {
// Remove '/' at the end, if any
$slash = '/';
if (substr($dir, -1) == '/') {
$slash = '';
}
$files = scandir($dir);
array_shift($files);
// remove '.' from array
array_shift($files);
// remove '..' from array
foreach ($files as $file) {
$filename = $file;
$file = $dir . $slash . $file;
if (is_dir($file)) {
if (substr(strtolower($filename), 0, strlen('bg_picasa_orig_')) == 'bg_picasa_orig_') {
// Only delete files that start 'bg_picasa_orig_' OR 'bg_cached_resized_'
@rmdir($file);
}
}
else {
$suffix = strtolower(brilliant_gallery_get_extension($filename));
if ($suffix == 'jpg' or $suffix == 'jpeg' or $suffix == 'png' or $suffix == 'gif') {
# It is a file in the specified BG cache directory
if (@filemtime($file) < $timestampexpired) {
$unlinked = unlink($file);
if ($unlinked) {
$GLOBALS['bg_removedcnt']++;
}
}
}
}
}
}