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; + } }