diff --git a/lib/DirScanner.php b/lib/DirScanner.php index b0edec3..916162d 100644 --- a/lib/DirScanner.php +++ b/lib/DirScanner.php @@ -69,7 +69,18 @@ Class DirScanner { //解析描述文件内容 - private function parseDescriptionFiles($realpath) { + private function parseDescriptionFiles($realpath, $extension) { + if (!in_array($extension, $this->allowReadContentFileExtensions)) { + return false; + } + + $field = preg_replace('/^.+_([a-z0-9]+)\.txt$/i', "$1", $realpath); + if ($field == $realpath) {return false;} + $content = file_get_contents($realpath); + $data = []; + $data[$field] = $content; + + return $data; } //解析快捷方式文件内容 diff --git a/test/DirScannerTest.php b/test/DirScannerTest.php index d895511..aa34f8b 100644 --- a/test/DirScannerTest.php +++ b/test/DirScannerTest.php @@ -48,6 +48,7 @@ class DirScannerTest extends DirScanner { echo "\n"; } + } @@ -57,8 +58,8 @@ $scanner = new DirScannerTest(); //$scanner->secureLinkTest('/default/', 'foo=bar', '127.0.0.1', ''); //$scanner->secureLinkTest('/default/', 'foo=bar', '127.0.0.1', '{secret} {secure_link_expires}{uri}{remote_addr}'); -$scanner->getFilePathTest('/content/小说/金庸/', '书剑恩仇录', 'md'); -$scanner->getFilePathTest('/content/小说/金庸/', '封面图', 'jpg'); -$scanner->getFilePathTest('/content/视频/游戏/', 'demo', 'm3u8'); -$scanner->getFilePathTest('/content/视频/游戏/', '推荐', 'url'); -$scanner->getFilePathTest('/content/视频/游戏/', '测试', 'mp4'); +//$scanner->getFilePathTest('/content/小说/金庸/', '书剑恩仇录', 'md'); +//$scanner->getFilePathTest('/content/小说/金庸/', '封面图', 'jpg'); +//$scanner->getFilePathTest('/content/视频/游戏/', 'demo', 'm3u8'); +//$scanner->getFilePathTest('/content/视频/游戏/', '推荐', 'url'); +//$scanner->getFilePathTest('/content/视频/游戏/', '测试', 'mp4');