mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-30 21:40:43 +02:00
[ticket/15253] Use path from adapter
PHPBB3-15253
This commit is contained in:
@@ -25,16 +25,21 @@ class local implements adapter_interface
|
||||
*/
|
||||
protected $filesystem;
|
||||
|
||||
/** @var string phpBB root path */
|
||||
protected $phpbb_root_path;
|
||||
/** @var string path */
|
||||
protected $root_path;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct($filesystem, $phpbb_root_path)
|
||||
public function __construct(\phpbb\config\config $config, \phpbb\filesystem\filesystem $filesystem, $root_path, $path_key)
|
||||
{
|
||||
$this->filesystem = $filesystem;
|
||||
$this->phpbb_root_path = $phpbb_root_path;
|
||||
$this->root_path = $root_path.$config[$path_key];
|
||||
|
||||
if(substr($this->root_path, -1, 1) != DIRECTORY_SEPARATOR)
|
||||
{
|
||||
$this->root_path = $this->root_path.DIRECTORY_SEPARATOR;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -42,14 +47,14 @@ class local implements adapter_interface
|
||||
*/
|
||||
public function put_contents($path, $content)
|
||||
{
|
||||
if ($this->exists($this->phpbb_root_path.$path))
|
||||
if ($this->exists($this->root_path.$path))
|
||||
{
|
||||
throw new exception('', $path); // FILE_EXISTS
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
$this->filesystem->dump_file($this->phpbb_root_path.$path, $content);
|
||||
$this->filesystem->dump_file($this->root_path.$path, $content);
|
||||
}
|
||||
catch (filesystem_exception $e)
|
||||
{
|
||||
@@ -62,12 +67,12 @@ class local implements adapter_interface
|
||||
*/
|
||||
public function get_contents($path)
|
||||
{
|
||||
if (!$this->exists($this->phpbb_root_path.$path))
|
||||
if (!$this->exists($this->root_path.$path))
|
||||
{
|
||||
throw new exception('', $path); // FILE_DONT_EXIST
|
||||
}
|
||||
|
||||
if (($content = @file_get_contents($this->phpbb_root_path.$path)) === false)
|
||||
if (($content = @file_get_contents($this->root_path.$path)) === false)
|
||||
{
|
||||
throw new exception('', $path); // CANNOT READ FILE
|
||||
}
|
||||
@@ -80,7 +85,7 @@ class local implements adapter_interface
|
||||
*/
|
||||
public function exists($path)
|
||||
{
|
||||
return $this->filesystem->exists($this->phpbb_root_path.$path);
|
||||
return $this->filesystem->exists($this->root_path.$path);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -90,7 +95,7 @@ class local implements adapter_interface
|
||||
{
|
||||
try
|
||||
{
|
||||
$this->filesystem->remove($this->phpbb_root_path.$path);
|
||||
$this->filesystem->remove($this->root_path.$path);
|
||||
}
|
||||
catch (filesystem_exception $e)
|
||||
{
|
||||
@@ -105,7 +110,7 @@ class local implements adapter_interface
|
||||
{
|
||||
try
|
||||
{
|
||||
$this->filesystem->rename($this->phpbb_root_path.$path_orig, $this->phpbb_root_path.$path_dest, false);
|
||||
$this->filesystem->rename($this->root_path.$path_orig, $this->root_path.$path_dest, false);
|
||||
}
|
||||
catch (filesystem_exception $e)
|
||||
{
|
||||
@@ -120,7 +125,7 @@ class local implements adapter_interface
|
||||
{
|
||||
try
|
||||
{
|
||||
$this->filesystem->copy($this->phpbb_root_path.$path_orig, $this->phpbb_root_path.$path_dest, false);
|
||||
$this->filesystem->copy($this->root_path.$path_orig, $this->root_path.$path_dest, false);
|
||||
}
|
||||
catch (filesystem_exception $e)
|
||||
{
|
||||
@@ -135,7 +140,7 @@ class local implements adapter_interface
|
||||
{
|
||||
try
|
||||
{
|
||||
$this->filesystem->mkdir($this->phpbb_root_path.$path);
|
||||
$this->filesystem->mkdir($this->root_path.$path);
|
||||
}
|
||||
catch (filesystem_exception $e)
|
||||
{
|
||||
|
Reference in New Issue
Block a user