function brilliant_gallery_cleantmpdir in Brilliant Gallery 6.3
Same name and namespace in other branches
- 6.4 cron.inc \brilliant_gallery_cleantmpdir()
- 7 brilliant_gallery_cron.inc \brilliant_gallery_cleantmpdir()
1 call to brilliant_gallery_cleantmpdir()
File
- ./
brilliant_gallery.module, line 1105
Code
function brilliant_gallery_cleantmpdir() {
// Delete files and directories from the file cache directory if their time is up!
$timenow = time();
$bgcachexpire = variable_get('brilliant_gallery_cache_duration', 90) * 24 * 3600;
// Cache expiration time in days.
$timestampexpired = time() - $bgcachexpire;
$cachetempdirectory = trim(variable_get('brilliant_gallery_pcache', file_directory_temp()));
if ($cachetempdirectory == '') {
// If there is no cache directory in the files folder, then we need to use the default temp dir
$cachetempdirectory = file_directory_temp();
}
else {
$cachetempdirectory = realpath(file_directory_path()) . '/' . $cachetempdirectory;
}
$GLOBALS['bg_removedcnt'] = 0;
#watchdog('Brilliant Gal','sakr2: '.$cachetempdirectory);
#watchdog('Brilliant Gal Cron','in');
brilliant_gallery_rmdir_recursive($cachetempdirectory, $timestampexpired);
// Also clear the Drupal cache - otherwise there might be some cached HTML pointing to files that are no longer in the file cache.
cache_clear_all();
watchdog('Brilliant Gal', 'Cleared ' . $GLOBALS['bg_removedcnt'] . ' files from the temp directory ' . $cachetempdirectory . ' after ' . variable_get('brilliant_gallery_cache_duration', 90) . ' days. Elapsed time: ' . (time() - $timenow) . ' seconds.');
}