Browse Source

Description file parse function done

master
filesite 3 years ago
parent
commit
318ddd7671
  1. 13
      lib/DirScanner.php
  2. 11
      test/DirScannerTest.php

13
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;
} }
//解析快捷方式文件内容 //解析快捷方式文件内容

11
test/DirScannerTest.php

@ -48,6 +48,7 @@ class DirScannerTest extends DirScanner {
echo "\n"; 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', '');
//$scanner->secureLinkTest('/default/', 'foo=bar', '127.0.0.1', '{secret} {secure_link_expires}{uri}{remote_addr}'); //$scanner->secureLinkTest('/default/', 'foo=bar', '127.0.0.1', '{secret} {secure_link_expires}{uri}{remote_addr}');
$scanner->getFilePathTest('/content/小说/金庸/', '书剑恩仇录', 'md'); //$scanner->getFilePathTest('/content/小说/金庸/', '书剑恩仇录', 'md');
$scanner->getFilePathTest('/content/小说/金庸/', '封面图', 'jpg'); //$scanner->getFilePathTest('/content/小说/金庸/', '封面图', 'jpg');
$scanner->getFilePathTest('/content/视频/游戏/', 'demo', 'm3u8'); //$scanner->getFilePathTest('/content/视频/游戏/', 'demo', 'm3u8');
$scanner->getFilePathTest('/content/视频/游戏/', '推荐', 'url'); //$scanner->getFilePathTest('/content/视频/游戏/', '推荐', 'url');
$scanner->getFilePathTest('/content/视频/游戏/', '测试', 'mp4'); //$scanner->getFilePathTest('/content/视频/游戏/', '测试', 'mp4');

Loading…
Cancel
Save