aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/functions_compress.php
diff options
context:
space:
mode:
authorDavid M <davidmj@users.sourceforge.net>2008-04-20 04:39:04 +0000
committerDavid M <davidmj@users.sourceforge.net>2008-04-20 04:39:04 +0000
commit79c72890e67dbd0a67bb85466886e4dd7e86a6f5 (patch)
tree7026f754c050e55720581a3c61533ea3d660b465 /phpBB/includes/functions_compress.php
parentc1c3b9f9124b42dd37b5d1da582e23b927cbee44 (diff)
downloadforums-79c72890e67dbd0a67bb85466886e4dd7e86a6f5.tar
forums-79c72890e67dbd0a67bb85466886e4dd7e86a6f5.tar.gz
forums-79c72890e67dbd0a67bb85466886e4dd7e86a6f5.tar.bz2
forums-79c72890e67dbd0a67bb85466886e4dd7e86a6f5.tar.xz
forums-79c72890e67dbd0a67bb85466886e4dd7e86a6f5.zip
#14429
git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8505 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes/functions_compress.php')
-rw-r--r--phpBB/includes/functions_compress.php34
1 files changed, 27 insertions, 7 deletions
diff --git a/phpBB/includes/functions_compress.php b/phpBB/includes/functions_compress.php
index 36b7d575d9..852f1c967a 100644
--- a/phpBB/includes/functions_compress.php
+++ b/phpBB/includes/functions_compress.php
@@ -231,7 +231,7 @@ class compress_zip extends compress
}
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));
@@ -507,12 +507,14 @@ class compress_tar extends compress
$tmp = unpack('A12size', substr($buffer, 124, 12));
$filesize = octdec((int) trim($tmp['size']));
+ $target_filename = "$dst$filename";
+
if ($filetype == 5)
{
- if (!is_dir("$dst$filename"))
+ if (!is_dir($target_filename))
{
$str = '';
- $folders = explode('/', "$dst$filename");
+ $folders = explode('/', $target_filename);
// Create and folders and subfolders if they do not exist
foreach ($folders as $folder)
@@ -529,17 +531,35 @@ class compress_tar extends compress
}
}
}
- 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)
+ {
+ $str = (!empty($str)) ? $str . '/' . $folder : $folder;
+ if (!is_dir($str))
+ {
+ if (!@mkdir($str, 0777))
+ {
+ trigger_error("Could not create directory $folder");
+ }
+ @chmod($str, 0777);
+ }
+ }
+
// Write out the files
- if (!($fp = fopen("$dst$filename", 'wb')))
+ if (!($fp = fopen($target_filename, 'wb')))
{
trigger_error("Couldn't create file $filename");
}
- @chmod("$dst$filename", 0777);
+ @chmod($target_filename, 0777);
// 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);
}
}