mirror of
https://github.com/phpbb/phpbb.git
synced 2025-08-02 14:57:37 +02:00
[ticket/11044] Compress class now deals with file conflicts
PHPBB3-11044
This commit is contained in:
@@ -23,6 +23,11 @@ class compress
|
|||||||
{
|
{
|
||||||
var $fp = 0;
|
var $fp = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
private $filelist = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add file to archive
|
* Add file to archive
|
||||||
*/
|
*/
|
||||||
@@ -122,6 +127,24 @@ class compress
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
* Return available methods
|
||||||
*/
|
*/
|
||||||
@@ -361,6 +384,7 @@ class compress_zip extends compress
|
|||||||
function data($name, $data, $is_dir = false, $stat)
|
function data($name, $data, $is_dir = false, $stat)
|
||||||
{
|
{
|
||||||
$name = str_replace('\\', '/', $name);
|
$name = str_replace('\\', '/', $name);
|
||||||
|
$name = $this->check_name($name);
|
||||||
|
|
||||||
$hexdtime = pack('V', $this->unix_to_dos_time($stat[9]));
|
$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)
|
function data($name, $data, $is_dir = false, $stat)
|
||||||
{
|
{
|
||||||
|
$name = $this->check_name($name);
|
||||||
$this->wrote = true;
|
$this->wrote = true;
|
||||||
$fzwrite = ($this->isbz && function_exists('bzwrite')) ? 'bzwrite' : (($this->isgz && @extension_loaded('zlib')) ? 'gzwrite' : 'fwrite');
|
$fzwrite = ($this->isbz && function_exists('bzwrite')) ? 'bzwrite' : (($this->isgz && @extension_loaded('zlib')) ? 'gzwrite' : 'fwrite');
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user