aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/functions_compress.php
diff options
context:
space:
mode:
authorFyorl <gaelreth@gmail.com>2012-08-04 16:50:03 +0100
committerFyorl <gaelreth@gmail.com>2012-08-04 16:52:41 +0100
commit70d9c02aae2ae357deb5ab415469fbbf965d0177 (patch)
tree700573caaccbc364201ac023ebe0defa1894988f /phpBB/includes/functions_compress.php
parentfa06b779ad7c80d76274ee080db494e9d767ae26 (diff)
downloadforums-70d9c02aae2ae357deb5ab415469fbbf965d0177.tar
forums-70d9c02aae2ae357deb5ab415469fbbf965d0177.tar.gz
forums-70d9c02aae2ae357deb5ab415469fbbf965d0177.tar.bz2
forums-70d9c02aae2ae357deb5ab415469fbbf965d0177.tar.xz
forums-70d9c02aae2ae357deb5ab415469fbbf965d0177.zip
[ticket/11044] Compress class now deals with file conflicts
PHPBB3-11044
Diffstat (limited to 'phpBB/includes/functions_compress.php')
-rw-r--r--phpBB/includes/functions_compress.php25
1 files changed, 25 insertions, 0 deletions
diff --git a/phpBB/includes/functions_compress.php b/phpBB/includes/functions_compress.php
index 72d8eabe76..2d8ad84657 100644
--- a/phpBB/includes/functions_compress.php
+++ b/phpBB/includes/functions_compress.php
@@ -24,6 +24,11 @@ class compress
var $fp = 0;
/**
+ * @var array
+ */
+ private $filelist = array();
+
+ /**
* Add file to archive
*/
function add_file($src, $src_rm_prefix = '', $src_add_prefix = '', $skip_files = '')
@@ -123,6 +128,24 @@ class compress
}
/**
+ * Checks if a file by that name as already been added and, if it has,
+ * returns a new, unique name.
+ *
+ * @param string $name The filename
+ * @return string A unique string
+ */
+ private function check_name($name)
+ {
+ if (isset($this->filelist[$name])) {
+ $this->filelist[$name]++;
+ return $name . '.' . $this->filelist[$name];
+ }
+
+ $this->filelist[$name] = 0;
+ return $name;
+ }
+
+ /**
* Return available methods
*/
function methods()
@@ -361,6 +384,7 @@ class compress_zip extends compress
function data($name, $data, $is_dir = false, $stat)
{
$name = str_replace('\\', '/', $name);
+ $name = $this->check_name($name);
$hexdtime = pack('V', $this->unix_to_dos_time($stat[9]));
@@ -633,6 +657,7 @@ class compress_tar extends compress
*/
function data($name, $data, $is_dir = false, $stat)
{
+ $name = $this->check_name($name);
$this->wrote = true;
$fzwrite = ($this->isbz && function_exists('bzwrite')) ? 'bzwrite' : (($this->isgz && @extension_loaded('zlib')) ? 'gzwrite' : 'fwrite');