mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-30 21:40:43 +02:00
[ticket/13697] Moving filesystem related functions to filesystem service
* Moving filesystem service to \phpbb\filesystem namespace * Wraping Symfony's Filesystem component * Moving filesystem related functions from includes/functions.php into \phpbb\filesystem\filesystem Functions moved (and deprecated): - phpbb_chmod - phpbb_is_writable - phpbb_is_absolute - phpbb_own_realpath - phpbb_realpath * Adding interface for filesystem service PHPBB3-13697
This commit is contained in:
@@ -184,7 +184,7 @@ class compress
|
||||
}
|
||||
|
||||
/**
|
||||
* Zip creation class from phpMyAdmin 2.3.0 (c) Tobias Ratschiller, Olivier M<EFBFBD>ller, Lo<EFBFBD>c Chapeaux,
|
||||
* Zip creation class from phpMyAdmin 2.3.0 (c) Tobias Ratschiller, Olivier Müller, Loïc Chapeaux,
|
||||
* Marc Delisle, http://www.phpmyadmin.net/
|
||||
*
|
||||
* Zip extraction function by Alexandre Tedeschi, alexandrebr at gmail dot com
|
||||
@@ -203,12 +203,20 @@ class compress_zip extends compress
|
||||
var $old_offset = 0;
|
||||
var $datasec_len = 0;
|
||||
|
||||
/**
|
||||
* @var \phpbb\filesystem\filesystem_interface
|
||||
*/
|
||||
protected $filesystem;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
function compress_zip($mode, $file)
|
||||
{
|
||||
global $phpbb_filesystem;
|
||||
|
||||
$this->fp = @fopen($file, $mode . 'b');
|
||||
$this->filesystem = ($phpbb_filesystem instanceof \phpbb\filesystem\filesystem_interface) ? $phpbb_filesystem : new \phpbb\filesystem\filesystem();
|
||||
|
||||
if (!$this->fp)
|
||||
{
|
||||
@@ -286,7 +294,15 @@ class compress_zip extends compress
|
||||
{
|
||||
trigger_error("Could not create directory $folder");
|
||||
}
|
||||
phpbb_chmod($str, CHMOD_READ | CHMOD_WRITE);
|
||||
|
||||
try
|
||||
{
|
||||
$this->filesystem->phpbb_chmod($str, CHMOD_READ | CHMOD_WRITE);
|
||||
}
|
||||
catch (\phpbb\filesystem\exception\filesystem_exception $e)
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -315,7 +331,15 @@ class compress_zip extends compress
|
||||
{
|
||||
trigger_error("Could not create directory $folder");
|
||||
}
|
||||
phpbb_chmod($str, CHMOD_READ | CHMOD_WRITE);
|
||||
|
||||
try
|
||||
{
|
||||
$this->filesystem->phpbb_chmod($str, CHMOD_READ | CHMOD_WRITE);
|
||||
}
|
||||
catch (\phpbb\filesystem\exception\filesystem_exception $e)
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -538,11 +562,18 @@ class compress_tar extends compress
|
||||
var $type = '';
|
||||
var $wrote = false;
|
||||
|
||||
/**
|
||||
* @var \phpbb\filesystem\filesystem_interface
|
||||
*/
|
||||
protected $filesystem;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
function compress_tar($mode, $file, $type = '')
|
||||
{
|
||||
global $phpbb_filesystem;
|
||||
|
||||
$type = (!$type) ? $file : $type;
|
||||
$this->isgz = preg_match('#(\.tar\.gz|\.tgz)$#', $type);
|
||||
$this->isbz = preg_match('#\.tar\.bz2$#', $type);
|
||||
@@ -551,6 +582,8 @@ class compress_tar extends compress
|
||||
$this->file = &$file;
|
||||
$this->type = &$type;
|
||||
$this->open();
|
||||
|
||||
$this->filesystem = ($phpbb_filesystem instanceof \phpbb\filesystem\filesystem_interface) ? $phpbb_filesystem : new \phpbb\filesystem\filesystem();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -601,7 +634,15 @@ class compress_tar extends compress
|
||||
{
|
||||
trigger_error("Could not create directory $folder");
|
||||
}
|
||||
phpbb_chmod($str, CHMOD_READ | CHMOD_WRITE);
|
||||
|
||||
try
|
||||
{
|
||||
$this->filesystem->phpbb_chmod($str, CHMOD_READ | CHMOD_WRITE);
|
||||
}
|
||||
catch (\phpbb\filesystem\exception\filesystem_exception $e)
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -628,7 +669,15 @@ class compress_tar extends compress
|
||||
{
|
||||
trigger_error("Could not create directory $folder");
|
||||
}
|
||||
phpbb_chmod($str, CHMOD_READ | CHMOD_WRITE);
|
||||
|
||||
try
|
||||
{
|
||||
$this->filesystem->phpbb_chmod($str, CHMOD_READ | CHMOD_WRITE);
|
||||
}
|
||||
catch (\phpbb\filesystem\exception\filesystem_exception $e)
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -637,7 +686,15 @@ class compress_tar extends compress
|
||||
{
|
||||
trigger_error("Couldn't create file $filename");
|
||||
}
|
||||
phpbb_chmod($target_filename, CHMOD_READ);
|
||||
|
||||
try
|
||||
{
|
||||
$this->filesystem->phpbb_chmod($target_filename, CHMOD_READ);
|
||||
}
|
||||
catch (\phpbb\filesystem\exception\filesystem_exception $e)
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
// Grab the file contents
|
||||
fwrite($fp, ($filesize) ? $fzread($this->fp, ($filesize + 511) &~ 511) : '', $filesize);
|
||||
|
Reference in New Issue
Block a user