Files
sam-kd/filedrive/cleanup_tmpimg.php
hskwon aca1767eb9 초기 커밋: 5130 레거시 시스템
- URL 하드코딩 → .env APP_URL 기반 동적 URL로 변경
- DB 연결 하드코딩 → .env 기반으로 변경
- MySQL strict mode DATE 오류 수정
2025-12-10 20:14:31 +09:00

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";
?>