It *was* working but stopped about a week ago, nothing has changed on the hosting account to my knowledge
Quote:
<?php
$directories = [
'/path/to/directory1',
'/path/to/directory2',
'/path/to/directory3'
'etc...'
'etc...'
];
$threshold = 30 * 24 * 60 * 60; // 30 days
foreach ($directories as $directory) {
if (is_dir($directory)) {
$dir = opendir($directory);
while (($file = readdir($dir)) !== false) {
if (pathinfo($file, PATHINFO_EXTENSION) === 'jpg') {
$filePath = $directory . DIRECTORY_SEPARATOR . $file;
if (file_exists($filePath) && time() - filemtime($filePath) > $threshold) {
unlink($filePath);
echo "Deleted: $filePath\n";
}
}
}
closedir($dir);
} else {
echo "Directory does not exist: $directory\n";
}
}
echo "Cleanup complete.\n";
?>
|