From d72fcede103cfd934442b3a92f05c85197cc31e9 Mon Sep 17 00:00:00 2001 From: elf <360197197@qq.com> Date: Sun, 7 May 2023 22:01:18 +0800 Subject: [PATCH] yh --- .../Controller/ConsoleController.class.php | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/Application/Admin/Controller/ConsoleController.class.php b/Application/Admin/Controller/ConsoleController.class.php index d7a65ba49..578b078a9 100644 --- a/Application/Admin/Controller/ConsoleController.class.php +++ b/Application/Admin/Controller/ConsoleController.class.php @@ -913,4 +913,39 @@ class ConsoleController extends Think { $extra ); } + + public function unlinkSourceFile() { + $records = M('game_source', 'tab_')->select(); + $sourceFiles = array_column($records, 'file_name'); + $originalDir = ROOTTT . 'Uploads/Ios/original'; + $files = $this->getFiles($originalDir); + foreach ($files as $file) { + if (!in_array($file, $sourceFiles)) { + echo 'move [' . $originalDir . '/' . $file . '] to [' . '/data/backup/sourceFile/original/' . $file . ']' . PHP_EOL; + // rename($originalDir . '/' . $file, '/data/backup/sourceFile/original/' . $file); + } + } + $sourceDir = ROOTTT . 'Uploads/SourcePack'; + $files = $this->getFiles($sourceDir); + foreach ($files as $file) { + if (!in_array($file, $sourceFiles)) { + echo 'move [' . $sourceDir . '/' . $file . '] to [' . '/data/backup/sourceFile/' . $file . ']' . PHP_EOL; + // rename($sourceDir . '/' . $file, '/data/backup/sourceFile/' . $file); + } + } + } + + private function getFiles($dir){ + $mydir = dir($dir); + $files = []; + while($file = $mydir->read()){ + if((is_dir("$dir/$file"))) { + + } elseif($file !== "." && $file !== "..") { + $files[] = $file; + } + } + $mydir->close(); + return $files; + } }