diff --git a/lib/DirScanner.php b/lib/DirScanner.php index 461db07..b9a903f 100644 --- a/lib/DirScanner.php +++ b/lib/DirScanner.php @@ -77,6 +77,12 @@ Class DirScanner { public $scanTimeCost = 0; //上一次目录扫描耗时,单位:毫秒 + //判断目录名或文件名是否合法 + //不允许包含斜杠/,反斜杠\,单引号',双引号",空格字符 + private function isValid($name) { + return str_replace(['/', '\\', "'", '"', ' '], '', $name) == $name; + } + //解析描述文件内容 //snapshot相对路径完善,支持secure_link private function parseDescriptionFiles($realpath) { @@ -474,7 +480,7 @@ Class DirScanner { $files = scandir($dir); foreach($files as $file) { - if (in_array($file, $ignore_files)) {continue;} + if (in_array($file, $ignore_files) || !$this->isValid($file)) {continue;} $branch = []; $realpath = realpath("{$dir}{$file}"); diff --git a/themes/googleimage/controller/SiteController.php b/themes/googleimage/controller/SiteController.php index 630cd06..5d5f58f 100644 --- a/themes/googleimage/controller/SiteController.php +++ b/themes/googleimage/controller/SiteController.php @@ -12,6 +12,7 @@ Class SiteController extends Controller { $scanner = new DirScanner(); $scanner->setWebRoot(FSC::$app['config']['content_directory']); $dirTree = $scanner->scan(__DIR__ . '/../../../www/' . FSC::$app['config']['content_directory'], 4); + $scanResults = $scanner->getScanResults(); //获取目录 $menus = $scanner->getMenus(); @@ -30,7 +31,7 @@ Class SiteController extends Controller { $pageTitle = !empty($titles) ? $titles[0]['name'] : "FileSite.io - 无数据库、基于文件和目录的Markdown文档、网址导航、图书、图片、视频网站PHP开源系统"; $viewName = 'index'; - $params = compact('menus', 'html'); + $params = compact('dirTree', 'scanResults', 'menus', 'html'); return $this->render($viewName, $params, $pageTitle); } diff --git a/themes/googleimage/views/layout/main.php b/themes/googleimage/views/layout/main.php index 72f5a62..7fdbee6 100644 --- a/themes/googleimage/views/layout/main.php +++ b/themes/googleimage/views/layout/main.php @@ -18,7 +18,7 @@ FileSite.io
- +
@@ -38,6 +38,7 @@ include_once $viewFile; ©FSC 2022 - execute time: {page_time_cost} ms + diff --git a/themes/googleimage/views/site/index.php b/themes/googleimage/views/site/index.php index 1a2331e..e685336 100644 --- a/themes/googleimage/views/site/index.php +++ b/themes/googleimage/views/site/index.php @@ -1,8 +1,9 @@