From 4bdef6fd21a5dcab455b0cd1ee2652de606929c3 Mon Sep 17 00:00:00 2001 From: MateBartus Date: Thu, 12 Mar 2015 00:25:00 +0100 Subject: [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 --- phpBB/includes/functions_compress.php | 69 ++++++++++++++++++++++++++++++++--- 1 file changed, 63 insertions(+), 6 deletions(-) (limited to 'phpBB/includes/functions_compress.php') diff --git a/phpBB/includes/functions_compress.php b/phpBB/includes/functions_compress.php index a7ee29dd91..e768a0f47b 100644 --- a/phpBB/includes/functions_compress.php +++ b/phpBB/includes/functions_compress.php @@ -184,7 +184,7 @@ class compress } /** -* Zip creation class from phpMyAdmin 2.3.0 (c) Tobias Ratschiller, Olivier Müller, Loï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); -- cgit v1.2.1 From 73e6e5b77faadbb7676961bf38122d669de111db Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 3 Dec 2015 17:50:29 +0100 Subject: [ticket/13454] Remove unused variables This is the first part of the changes. More to come. PHPBB3-13454 --- phpBB/includes/functions_compress.php | 1 - 1 file changed, 1 deletion(-) (limited to 'phpBB/includes/functions_compress.php') diff --git a/phpBB/includes/functions_compress.php b/phpBB/includes/functions_compress.php index e768a0f47b..910708f502 100644 --- a/phpBB/includes/functions_compress.php +++ b/phpBB/includes/functions_compress.php @@ -56,7 +56,6 @@ class compress // Clean up path, add closing / if not present $src_path = ($src_path && substr($src_path, -1) != '/') ? $src_path . '/' : $src_path; - $filelist = array(); $filelist = filelist("$phpbb_root_path$src", '', '*'); krsort($filelist); -- cgit v1.2.1 From f8fbe3793680af1dae2db2829cfc84068831c52f Mon Sep 17 00:00:00 2001 From: rxu Date: Wed, 28 Jun 2017 00:58:03 +0700 Subject: [ticket/14972] replace all occurrences of sizeof() with the count() PHPBB3-14972 --- phpBB/includes/functions_compress.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'phpBB/includes/functions_compress.php') diff --git a/phpBB/includes/functions_compress.php b/phpBB/includes/functions_compress.php index 910708f502..77e03ee449 100644 --- a/phpBB/includes/functions_compress.php +++ b/phpBB/includes/functions_compress.php @@ -409,7 +409,7 @@ class compress_zip extends compress function close() { // Write out central file directory and footer ... if it exists - if (sizeof($this->ctrl_dir)) + if (count($this->ctrl_dir)) { fwrite($this->fp, $this->file()); } @@ -511,8 +511,8 @@ class compress_zip extends compress $ctrldir = implode('', $this->ctrl_dir); return $ctrldir . $this->eof_cdh . - pack('v', sizeof($this->ctrl_dir)) . // total # of entries "on this disk" - pack('v', sizeof($this->ctrl_dir)) . // total # of entries overall + pack('v', count($this->ctrl_dir)) . // total # of entries "on this disk" + pack('v', count($this->ctrl_dir)) . // total # of entries overall pack('V', strlen($ctrldir)) . // size of central dir pack('V', $this->datasec_len) . // offset to start of central dir "\x00\x00"; // .zip file comment length -- cgit v1.2.1 From b148bb5d707d739e92b66205866a764a9aa133b5 Mon Sep 17 00:00:00 2001 From: Ruben Calvo Date: Sun, 21 Oct 2018 05:56:29 +0000 Subject: [ticket/15849] Stop using php4 constructors PHPBB3-15849 --- phpBB/includes/functions_compress.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/functions_compress.php') diff --git a/phpBB/includes/functions_compress.php b/phpBB/includes/functions_compress.php index 77e03ee449..e86da77b38 100644 --- a/phpBB/includes/functions_compress.php +++ b/phpBB/includes/functions_compress.php @@ -210,7 +210,7 @@ class compress_zip extends compress /** * Constructor */ - function compress_zip($mode, $file) + function __construct($mode, $file) { global $phpbb_filesystem; @@ -569,7 +569,7 @@ class compress_tar extends compress /** * Constructor */ - function compress_tar($mode, $file, $type = '') + function __construct($mode, $file, $type = '') { global $phpbb_filesystem; -- cgit v1.2.1