兼容软连接目录设置
This commit is contained in:
parent
d65ff46fef
commit
9f9bf0af6c
|
@ -73,12 +73,29 @@ class LogViewer
|
|||
*/
|
||||
public function __construct($basePath, $dir, $file = null)
|
||||
{
|
||||
$this->basePath = rtrim($basePath, '/');
|
||||
$this->basePath = $this->getRealPath(rtrim($basePath, '/'));
|
||||
$this->currentDirectory = $this->formatPath(rtrim($dir, '/'));
|
||||
$this->file = $this->formatPath($file);
|
||||
$this->files = new Filesystem();
|
||||
}
|
||||
|
||||
protected function getRealPath($path)
|
||||
{
|
||||
$paths = explode('/', $path);
|
||||
|
||||
$result = '';
|
||||
foreach ($paths as $v) {
|
||||
$result .= $v.'/';
|
||||
|
||||
$current = rtrim($result, '/');
|
||||
if (is_link($current)) {
|
||||
$result = readlink($current).'/';
|
||||
}
|
||||
}
|
||||
|
||||
return rtrim($result, '/');
|
||||
}
|
||||
|
||||
protected function formatPath($path)
|
||||
{
|
||||
return str_replace(['../'], '', $path);
|
||||
|
@ -165,7 +182,7 @@ class LogViewer
|
|||
return $this->getLogBasePath();
|
||||
}
|
||||
|
||||
return $this->getLogBasePath() . '/' . $this->currentDirectory;
|
||||
return $this->getLogBasePath().'/'.$this->currentDirectory;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue
Block a user