|
|
@ -30,6 +30,7 @@ Class DirScanner { |
|
|
|
'snapshot' => '快照图片', |
|
|
|
'snapshot' => '快照图片', |
|
|
|
]; |
|
|
|
]; |
|
|
|
private $rootDir; //当前扫描的根目录 |
|
|
|
private $rootDir; //当前扫描的根目录 |
|
|
|
|
|
|
|
private $webRoot = '/content/'; //网站静态文件相对路径的根目录 |
|
|
|
private $scanningDirLevel = 0; //当前扫描的目录深度 |
|
|
|
private $scanningDirLevel = 0; //当前扫描的目录深度 |
|
|
|
private $scanStartTime = 0; //扫描开始时间,单位:秒 |
|
|
|
private $scanStartTime = 0; //扫描开始时间,单位:秒 |
|
|
|
private $scanResults = []; //目录扫描结果 |
|
|
|
private $scanResults = []; //目录扫描结果 |
|
|
@ -101,7 +102,11 @@ Class DirScanner { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//根据文件路径生成唯一编号 |
|
|
|
//根据文件路径生成唯一编号 |
|
|
|
|
|
|
|
//使用相对路径计算md5值 |
|
|
|
private function getId($realpath) { |
|
|
|
private function getId($realpath) { |
|
|
|
|
|
|
|
if (!empty($this->rootDir)) { |
|
|
|
|
|
|
|
$realpath = str_replace($this->rootDir, '', $realpath); |
|
|
|
|
|
|
|
} |
|
|
|
return !empty($realpath) ? md5($realpath) : ''; |
|
|
|
return !empty($realpath) ? md5($realpath) : ''; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -276,17 +281,18 @@ Class DirScanner { |
|
|
|
$directory = "/{$directory}"; |
|
|
|
$directory = "/{$directory}"; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$webRoot = preg_replace('/\/$/', '', $this->webRoot); |
|
|
|
$extensionPathMap = [ //默认每种文件读取内容最大大小 |
|
|
|
$extensionPathMap = [ //默认每种文件读取内容最大大小 |
|
|
|
'txt' => '', |
|
|
|
'txt' => '', |
|
|
|
'md' => '/view/', |
|
|
|
'md' => '/view/', |
|
|
|
'url' => '/link/', |
|
|
|
'url' => '/link/', |
|
|
|
'm3u8' => '/m3u8/', |
|
|
|
'm3u8' => '/m3u8/', |
|
|
|
'jpg' => "{$directory}{$filename}.{$extension}", |
|
|
|
'jpg' => "{$webRoot}{$directory}{$filename}.{$extension}", |
|
|
|
'png' => "{$directory}{$filename}.{$extension}", |
|
|
|
'png' => "{$webRoot}{$directory}{$filename}.{$extension}", |
|
|
|
'gif' => "{$directory}{$filename}.{$extension}", |
|
|
|
'gif' => "{$webRoot}{$directory}{$filename}.{$extension}", |
|
|
|
'ico' => "{$directory}{$filename}.{$extension}", |
|
|
|
'ico' => "{$webRoot}{$directory}{$filename}.{$extension}", |
|
|
|
'mp4' => "{$directory}{$filename}.{$extension}", |
|
|
|
'mp4' => "{$webRoot}{$directory}{$filename}.{$extension}", |
|
|
|
'ts' => "{$directory}{$filename}.{$extension}", |
|
|
|
'ts' => "{$webRoot}{$directory}{$filename}.{$extension}", |
|
|
|
]; |
|
|
|
]; |
|
|
|
|
|
|
|
|
|
|
|
$path = isset($extensionPathMap[$extension]) ? $extensionPathMap[$extension] : ''; |
|
|
|
$path = isset($extensionPathMap[$extension]) ? $extensionPathMap[$extension] : ''; |
|
|
@ -409,6 +415,24 @@ Class DirScanner { |
|
|
|
return $this->nginxSecureTimeout; |
|
|
|
return $this->nginxSecureTimeout; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//设置网站静态文件相对根目录 |
|
|
|
|
|
|
|
public function setWebRoot($webRoot) { |
|
|
|
|
|
|
|
if (!empty($webRoot) && !preg_match('/^\//', $webRoot)) { |
|
|
|
|
|
|
|
$webRoot = "/{$webRoot}"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!empty($webRoot) && !preg_match('/\/$/', $webRoot)) { |
|
|
|
|
|
|
|
$webRoot = "{$webRoot}/"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->webRoot = $webRoot; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//获取网站静态文件相对根目录 |
|
|
|
|
|
|
|
public function getWebRoot() { |
|
|
|
|
|
|
|
return $this->webRoot; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//获取是否开启防盗链 |
|
|
|
//获取是否开启防盗链 |
|
|
|
public function isSecureOn() { |
|
|
|
public function isSecureOn() { |
|
|
|
return $this->nginxSecureOn; |
|
|
|
return $this->nginxSecureOn; |
|
|
|