phpBB

Code Changes

File: includes/functions_compress.php

  Unmodified   Added   Modified   Removed
Line 53Line 53
			$filelist = filelist("$phpbb_root_path$src", '', '*');
krsort($filelist);


			$filelist = filelist("$phpbb_root_path$src", '', '*');
krsort($filelist);


 
			/**
* Commented out, as adding the folders produces corrupted archives

			if ($src_path)
{
$this->data($src_path, '', true, stat("$phpbb_root_path$src"));
}

			if ($src_path)
{
$this->data($src_path, '', true, stat("$phpbb_root_path$src"));
}

 
			*/


foreach ($filelist as $path => $file_ary)
{


foreach ($filelist as $path => $file_ary)
{

 
				/**
* Commented out, as adding the folders produces corrupted archives

				if ($path)
{
// Same as for src_path

				if ($path)
{
// Same as for src_path

Line 68Line 73

$this->data("$src_path$path", '', true, stat("$phpbb_root_path$src$path"));
}


$this->data("$src_path$path", '', true, stat("$phpbb_root_path$src$path"));
}

 
				*/


foreach ($file_ary as $file)
{


foreach ($file_ary as $file)
{

Line 79Line 85
					$this->data("$src_path$path$file", file_get_contents("$phpbb_root_path$src$path$file"), false, stat("$phpbb_root_path$src$path$file"));
}
}

					$this->data("$src_path$path$file", file_get_contents("$phpbb_root_path$src$path$file"), false, stat("$phpbb_root_path$src$path$file"));
}
}

 
		}
else
{
// $src does not exist
return false;

		}

return true;

		}

return true;

Line 89Line 100
	*/
function add_custom_file($src, $filename)
{

	*/
function add_custom_file($src, $filename)
{

 
		if (!file_exists($src))
{
return false;
}


		$this->data($filename, file_get_contents($src), false, stat($src));
return true;
}

		$this->data($filename, file_get_contents($src), false, stat($src));
return true;
}

Line 155Line 171
	*/
function compress_zip($mode, $file)
{

	*/
function compress_zip($mode, $file)
{

		return $this->fp = @fopen($file, $mode . 'b');






		$this->fp = @fopen($file, $mode . 'b');

if (!$this->fp)
{
trigger_error('Unable to open file ' . $file . ' [' . $mode . 'b]');
}

	}

/**

	}

/**

Line 215Line 236
							// Create and folders and subfolders if they do not exist
foreach ($folders as $folder)
{

							// Create and folders and subfolders if they do not exist
foreach ($folders as $folder)
{

 
								$folder = trim($folder);
if (!$folder)
{
continue;
}


								$str = (!empty($str)) ? $str . '/' . $folder : $folder;
if (!is_dir($str))
{

								$str = (!empty($str)) ? $str . '/' . $folder : $folder;
if (!is_dir($str))
{

Line 222Line 249
									{
trigger_error("Could not create directory $folder");
}

									{
trigger_error("Could not create directory $folder");
}

									@chmod($str, 0777);

									phpbb_chmod($str, CHMOD_READ | CHMOD_WRITE);

								}
}
}

								}
}
}

Line 231Line 258
					}
else
{

					}
else
{

						// Some archivers are punks, they don't don't include folders in their archives!

						// Some archivers are punks, they don't include folders in their archives!

						$str = '';
$folders = explode('/', pathinfo($target_filename, PATHINFO_DIRNAME));

// Create and folders and subfolders if they do not exist
foreach ($folders as $folder)
{

						$str = '';
$folders = explode('/', pathinfo($target_filename, PATHINFO_DIRNAME));

// Create and folders and subfolders if they do not exist
foreach ($folders as $folder)
{

 
							$folder = trim($folder);
if (!$folder)
{
continue;
}


							$str = (!empty($str)) ? $str . '/' . $folder : $folder;
if (!is_dir($str))
{

							$str = (!empty($str)) ? $str . '/' . $folder : $folder;
if (!is_dir($str))
{

Line 245Line 278
								{
trigger_error("Could not create directory $folder");
}

								{
trigger_error("Could not create directory $folder");
}

								@chmod($str, 0777);

								phpbb_chmod($str, CHMOD_READ | CHMOD_WRITE);

							}
}
}

							}
}
}

Line 475Line 508
	function compress_tar($mode, $file, $type = '')
{
$type = (!$type) ? $file : $type;

	function compress_tar($mode, $file, $type = '')
{
$type = (!$type) ? $file : $type;

		$this->isgz = (strpos($type, '.tar.gz') !== false || strpos($type, '.tgz') !== false) ? true : false;
$this->isbz = (strpos($type, '.tar.bz2') !== false) ? true : false;

		$this->isgz = preg_match('#(\.tar\.gz|\.tgz)$#', $type);
$this->isbz = preg_match('#\.tar\.bz2$#', $type);


$this->mode = &$mode;
$this->file = &$file;


$this->mode = &$mode;
$this->file = &$file;

Line 506Line 539

$tmp = unpack('A12size', substr($buffer, 124, 12));
$filesize = octdec((int) trim($tmp['size']));


$tmp = unpack('A12size', substr($buffer, 124, 12));
$filesize = octdec((int) trim($tmp['size']));

 

$target_filename = "$dst$filename";


if ($filetype == 5)
{


if ($filetype == 5)
{

					if (!is_dir("$dst$filename"))

					if (!is_dir($target_filename))

					{
$str = '';

					{
$str = '';

						$folders = explode('/', "$dst$filename");

						$folders = explode('/', $target_filename);


// Create and folders and subfolders if they do not exist
foreach ($folders as $folder)
{


// Create and folders and subfolders if they do not exist
foreach ($folders as $folder)
{

 
							$folder = trim($folder);
if (!$folder)
{
continue;
}


							$str = (!empty($str)) ? $str . '/' . $folder : $folder;
if (!is_dir($str))
{

							$str = (!empty($str)) ? $str . '/' . $folder : $folder;
if (!is_dir($str))
{

Line 524Line 565
								{
trigger_error("Could not create directory $folder");
}

								{
trigger_error("Could not create directory $folder");
}

								@chmod($str, 0777);

								phpbb_chmod($str, CHMOD_READ | CHMOD_WRITE);

							}
}
}
}

							}
}
}
}

				else if ($filesize != 0 && ($filetype == 0 || $filetype == "\0"))

				else if ($filesize >= 0 && ($filetype == 0 || $filetype == "\0"))

				{

				{

 
					// Some archivers are punks, they don't properly order the folders in their archives!
$str = '';
$folders = explode('/', pathinfo($target_filename, PATHINFO_DIRNAME));

// Create and folders and subfolders if they do not exist
foreach ($folders as $folder)
{
$folder = trim($folder);
if (!$folder)
{
continue;
}

$str = (!empty($str)) ? $str . '/' . $folder : $folder;
if (!is_dir($str))
{
if (!@mkdir($str, 0777))
{
trigger_error("Could not create directory $folder");
}
phpbb_chmod($str, CHMOD_READ | CHMOD_WRITE);
}
}


					// Write out the files

					// Write out the files

					if (!($fp = fopen("$dst$filename", 'wb')))

					if (!($fp = fopen($target_filename, 'wb')))

					{
trigger_error("Couldn't create file $filename");
}

					{
trigger_error("Couldn't create file $filename");
}

					@chmod("$dst$filename", 0777);

					phpbb_chmod($target_filename, CHMOD_READ);


// Grab the file contents


// Grab the file contents

					fwrite($fp, $fzread($this->fp, ($filesize + 511) &~ 511), $filesize);

					fwrite($fp, ($filesize) ? $fzread($this->fp, ($filesize + 511) &~ 511) : '', $filesize);

					fclose($fp);
}
}

					fclose($fp);
}
}