aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/functions_compress.php
diff options
context:
space:
mode:
authorIgor Wiedler <igor@wiedler.ch>2012-08-25 17:00:40 +0200
committerIgor Wiedler <igor@wiedler.ch>2012-08-25 17:00:40 +0200
commitae85d43757463e743917f43ee3e014a8b1af85d6 (patch)
treee4c2b7188baadd74cbf968a4174cd5257ccdfb0e /phpBB/includes/functions_compress.php
parentfd9fd71a88fad2b33d75722587dbfc0bd100ae50 (diff)
parentbfdba90a34ad95c7cb9e0bc187cb464c83f8ba59 (diff)
downloadforums-ae85d43757463e743917f43ee3e014a8b1af85d6.tar
forums-ae85d43757463e743917f43ee3e014a8b1af85d6.tar.gz
forums-ae85d43757463e743917f43ee3e014a8b1af85d6.tar.bz2
forums-ae85d43757463e743917f43ee3e014a8b1af85d6.tar.xz
forums-ae85d43757463e743917f43ee3e014a8b1af85d6.zip
Merge remote-tracking branch 'upstream/develop' into feature/dic
* upstream/develop: (259 commits) [prep-release-3.0.11] Bumping version number for 3.0.11 final. [feature/php-events] Fix doc of core.viewonline_overwrite_location [feature/php-events] Fix doc of core.user_set_default_group [feature/php-events] Fix doc of core.generate_smilies_after [feature/php-events] Fix doc of core.delete_user_after [feature/php-events] Fix doc of core.delete_user_before [feature/php-events] Fix doc of core.update_username [feature/php-events] Fix doc of core.memberlist_prepare_profile_data [feature/php-events] Fix doc and position of viewonline_overwrite_location [feature/php-events] Fix doc of core.viewtopic_get_post_data [feature/php-events] Fix doc of core.viewtopic_cache_guest_data [ticket/11061] Add the --dev flag to the composer instructions in README [ticket/11060] Make sure pyrus can install everything on travis [ticket/11059] Use https for the README logo [feature/php-events] Fix acp_manage_forums_update_data_before and is_new_forum [feature/php-events] Fix core.acp_manage_forums_update_data_after vars [ticket/11032] fix language of error displayed [ticket/11052] update search backend constructor everywhere [ticket/11052] pass parametes to search construct while posting [ticket/11054] Fixed $config var description ... Conflicts: phpBB/includes/cron/task/core/tidy_cache.php phpBB/includes/cron/task/core/tidy_search.php
Diffstat (limited to 'phpBB/includes/functions_compress.php')
-rw-r--r--phpBB/includes/functions_compress.php37
1 files changed, 37 insertions, 0 deletions
diff --git a/phpBB/includes/functions_compress.php b/phpBB/includes/functions_compress.php
index 72d8eabe76..8e07e6d1b8 100644
--- a/phpBB/includes/functions_compress.php
+++ b/phpBB/includes/functions_compress.php
@@ -24,6 +24,11 @@ class compress
var $fp = 0;
/**
+ * @var array
+ */
+ protected $filelist = array();
+
+ /**
* Add file to archive
*/
function add_file($src, $src_rm_prefix = '', $src_add_prefix = '', $skip_files = '')
@@ -123,6 +128,36 @@ 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 filename
+ */
+ protected function unique_filename($name)
+ {
+ if (isset($this->filelist[$name]))
+ {
+ $start = $name;
+ $ext = '';
+ $this->filelist[$name]++;
+
+ // Separate the extension off the end of the filename to preserve it
+ $pos = strrpos($name, '.');
+ if ($pos !== false)
+ {
+ $start = substr($name, 0, $pos);
+ $ext = substr($name, $pos);
+ }
+
+ return $start . '_' . $this->filelist[$name] . $ext;
+ }
+
+ $this->filelist[$name] = 0;
+ return $name;
+ }
+
+ /**
* Return available methods
*/
function methods()
@@ -361,6 +396,7 @@ class compress_zip extends compress
function data($name, $data, $is_dir = false, $stat)
{
$name = str_replace('\\', '/', $name);
+ $name = $this->unique_filename($name);
$hexdtime = pack('V', $this->unix_to_dos_time($stat[9]));
@@ -633,6 +669,7 @@ class compress_tar extends compress
*/
function data($name, $data, $is_dir = false, $stat)
{
+ $name = $this->unique_filename($name);
$this->wrote = true;
$fzwrite = ($this->isbz && function_exists('bzwrite')) ? 'bzwrite' : (($this->isgz && @extension_loaded('zlib')) ? 'gzwrite' : 'fwrite');