30 lines
734 B
PHP
30 lines
734 B
PHP
|
|
<?php
|
||
|
|
// 임시 이미지 파일 정리 스크립트
|
||
|
|
// 24시간이 지난 파일들을 삭제
|
||
|
|
|
||
|
|
$tmpDir = $_SERVER['DOCUMENT_ROOT'] . '/tmpimg';
|
||
|
|
$maxAge = 24 * 60 * 60; // 24시간 (초)
|
||
|
|
|
||
|
|
if (!is_dir($tmpDir)) {
|
||
|
|
exit('임시 디렉토리가 존재하지 않습니다.');
|
||
|
|
}
|
||
|
|
|
||
|
|
$files = glob($tmpDir . '/*');
|
||
|
|
$deletedCount = 0;
|
||
|
|
|
||
|
|
foreach ($files as $file) {
|
||
|
|
if (is_file($file)) {
|
||
|
|
$fileTime = filemtime($file);
|
||
|
|
$age = time() - $fileTime;
|
||
|
|
|
||
|
|
if ($age > $maxAge) {
|
||
|
|
if (unlink($file)) {
|
||
|
|
$deletedCount++;
|
||
|
|
echo "삭제됨: " . basename($file) . "\n";
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
echo "총 {$deletedCount}개의 임시 파일이 삭제되었습니다.\n";
|
||
|
|
?>
|