Created
June 14, 2014 15:23
-
-
Save t0mtaylor/9a450f3eb80c0d1c9b4d to your computer and use it in GitHub Desktop.
image scrubber, use with https://github.com/t0mtaylor/phpimageresize/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
chdir( dirname ( realpath(__DIR__) ) ); | |
chdir( 'tmp/' ); | |
$days = 0; | |
$hours = 3; | |
$root = getcwd()."/cache/"; | |
$paths = array($root."",$root."remote/"); | |
$filetypes_to_delete = array("gif","jpg","jpeg","png","bmp"); | |
foreach ($paths as $path) | |
{ | |
print $path . "\n"; | |
if ($handle = opendir($path)) | |
{ | |
if($handle) | |
{ | |
while (false !== ($file = readdir($handle))) | |
{ | |
// Check the file we're doing is actually a file | |
if (is_file($path.$file)) | |
{ | |
$file_info = pathinfo($path.$file); | |
if (isset($file_info['extension']) && in_array(strtolower($file_info['extension']), $filetypes_to_delete)) | |
{ | |
// Check if the file is older than X days X hours old | |
if (filemtime($path.$file) < ( time() - ( $days * $hours * 60 * 60 ) ) ) | |
{ | |
// Do the deletion | |
unlink($path.$file); | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment