From 5dfb96ebe1d40b85f3fe23922aa967690a5c8544 Mon Sep 17 00:00:00 2001 From: filesite Date: Sat, 28 Sep 2024 21:43:38 +0800 Subject: [PATCH] add image cache clean --- themes/beauty/controller/SiteController.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/themes/beauty/controller/SiteController.php b/themes/beauty/controller/SiteController.php index 4c2185f..967ad0b 100644 --- a/themes/beauty/controller/SiteController.php +++ b/themes/beauty/controller/SiteController.php @@ -283,6 +283,19 @@ Class SiteController extends Controller { unlink("{$cacheDir}{$file}"); } + + //删除图片缓存: image/ + $imgCacheDir = "{$cacheDir}image/"; + if (is_dir($imgCacheDir)) { + $files = scandir($imgCacheDir); + foreach($files as $file) { + if (!preg_match('/\.json$/i', $file)) {continue;} + + unlink("{$imgCacheDir}{$file}"); + } + + rmdir($imgCacheDir); + } } }catch(Exception $e) { $code = 0;