瀏覽代碼

Update config.php to delete all, including dirs

Belle Aerni 2 年之前
父節點
當前提交
cdee7c8a04
共有 1 個文件被更改,包括 5 次插入6 次删除
  1. 5 6
      src/cron.php

+ 5 - 6
src/cron.php

@@ -1,8 +1,7 @@
 <?php
 <?php
-$cacheFiles = glob(__DIR__ . DIRECTORY_SEPARATOR . 'Cache' . DIRECTORY_SEPARATOR . '*.*');
-foreach($cacheFiles as $cacheFile){
-  if(is_file($cacheFile)) {
-    unlink($cacheFile);
-  }
+$cacheDir = __DIR__ . DIRECTORY_SEPARATOR . 'Cache' . DIRECTORY_SEPARATOR;
+$di = new RecursiveDirectoryIterator($cacheDir, FilesystemIterator::SKIP_DOTS);
+$ri = new RecursiveIteratorIterator($di, RecursiveIteratorIterator::CHILD_FIRST);
+foreach ($ri as $file) {
+  $file->isDir() ?  rmdir($file->getRealPath()) : unlink($file->getRealPath());
 }
 }
-?>