aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/functions_compress.php
diff options
context:
space:
mode:
authorIgor Wiedler <igor@wiedler.ch>2012-11-12 10:33:40 +0100
committerIgor Wiedler <igor@wiedler.ch>2012-11-12 10:33:40 +0100
commit5e52216b5e14ced69326813e748fc56be6e28a69 (patch)
tree4e47bd9290da80da48aaf30308e7d03965a904f6 /phpBB/includes/functions_compress.php
parent0971d3f975ebaa8c2874115bd82b308b244783f2 (diff)
parent504158ceaba18bb8bc61d54504a2c870d0eb0407 (diff)
downloadforums-5e52216b5e14ced69326813e748fc56be6e28a69.tar
forums-5e52216b5e14ced69326813e748fc56be6e28a69.tar.gz
forums-5e52216b5e14ced69326813e748fc56be6e28a69.tar.bz2
forums-5e52216b5e14ced69326813e748fc56be6e28a69.tar.xz
forums-5e52216b5e14ced69326813e748fc56be6e28a69.zip
Merge remote-tracking branch 'upstream/develop' into ticket/11015
* upstream/develop: (666 commits) [ticket/11077] Remove code from old global announcements system [ticket/11189] Replace DEBUG_EXTRA with DEBUG [ticket/11189] Always log critical errors when in cron or in image output [ticket/11187] Added a blank array to fix errors in functional tests [ticket/10780] Make L_COLON available in the installer. [ticket/11183] Remove $load_extensions and weird dl() calls [ticket/10970] Added extra documentation to parse_dynamic_path. [ticket/10939] Added documentation for phpbb_request::file [ticket/10865] Use code tags for install/database_update.php. [ticket/10865] Should have been a slash. [ticket/10780] Use L_COLON on LDAP page. [ticket/10780] Use L_COLON on search backend ACP pages. [ticket/10780] Use L_COLON for "download all attachments". [ticket/10780] Use colon from language in ucp_pm_compose.php where possible. [ticket/10780] Replace colons in phpBB/adm/style/acp_ext_details.html. [ticket/10780] Replace colon usage in adm template output with {L_COLON} [ticket/10780] Replace colon usage in template output with {L_COLON} [ticket/11181] Bump PHP requirement to 5.3.3 (from 5.3.2) [develop-olympus] [ticket/11181] Bump PHP requirement to 5.3.3 (from 5.3.2) [ticket/10172] Show prosilver birthday list even if there are no birthdays. ... Conflicts: phpBB/common.php phpBB/download/file.php phpBB/includes/db/dbal.php phpBB/includes/db/firebird.php phpBB/includes/db/mssql.php phpBB/includes/db/mssql_odbc.php phpBB/includes/db/mssqlnative.php phpBB/includes/db/mysql.php phpBB/includes/db/mysqli.php phpBB/includes/db/oracle.php phpBB/includes/db/postgres.php phpBB/includes/db/sqlite.php phpBB/includes/extension/manager.php phpBB/install/database_update.php
Diffstat (limited to 'phpBB/includes/functions_compress.php')
-rw-r--r--phpBB/includes/functions_compress.php41
1 files changed, 40 insertions, 1 deletions
diff --git a/phpBB/includes/functions_compress.php b/phpBB/includes/functions_compress.php
index 72d8eabe76..c79a31930e 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,9 +128,41 @@ 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
+ *
+ * @return array Array of strings of available compression methods (.tar, .tar.gz, .zip, etc.)
*/
- function methods()
+ static public function methods()
{
$methods = array('.tar');
$available_methods = array('.tar.gz' => 'zlib', '.tar.bz2' => 'bz2', '.zip' => 'zlib');
@@ -361,6 +398,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 +671,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');