diff options
author | Meik Sievertsen <acydburn@phpbb.com> | 2005-11-30 17:48:06 +0000 |
---|---|---|
committer | Meik Sievertsen <acydburn@phpbb.com> | 2005-11-30 17:48:06 +0000 |
commit | 1bf18e23edb13b2d3014c4509e4d1b15ddc274fe (patch) | |
tree | dfbf1798248969f0ac79842d4f0dc449a36f6cd2 /phpBB/includes/functions_compress.php | |
parent | ba6f40ce2542b87c7110dd9e38e4c0386b22da81 (diff) | |
download | forums-1bf18e23edb13b2d3014c4509e4d1b15ddc274fe.tar forums-1bf18e23edb13b2d3014c4509e4d1b15ddc274fe.tar.gz forums-1bf18e23edb13b2d3014c4509e4d1b15ddc274fe.tar.bz2 forums-1bf18e23edb13b2d3014c4509e4d1b15ddc274fe.tar.xz forums-1bf18e23edb13b2d3014c4509e4d1b15ddc274fe.zip |
- added acp_language (language pack management)
- minor adjustments to cope with PHP5.x
git-svn-id: file:///svn/phpbb/trunk@5315 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes/functions_compress.php')
-rw-r--r-- | phpBB/includes/functions_compress.php | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/phpBB/includes/functions_compress.php b/phpBB/includes/functions_compress.php index b159adf53d..4c5d37f68e 100644 --- a/phpBB/includes/functions_compress.php +++ b/phpBB/includes/functions_compress.php @@ -15,14 +15,14 @@ class compress { var $fp = 0; - + function add_file($src, $src_rm_prefix = '', $src_add_prefix = '', $skip_files = '') { global $phpbb_root_path; $skip_files = explode(',', $skip_files); - // Remove rm prefix from src path + // Remove rm prefix from src path $src_path = ($src_rm_prefix) ? preg_replace('#^(' . preg_quote($src_rm_prefix) . ')#', '', $src) : $src; // Add src prefix $src_path = ($src_add_prefix) ? ($src_add_prefix . ((substr($src_add_prefix, -1) != '/') ? '/' : '') . $src_path) : $src_path; @@ -82,6 +82,12 @@ class compress return true; } + function add_custom_file($src, $filename) + { + $this->data($filename, implode('', file($src))); + return true; + } + function add_data($src, $name) { $this->data($name, $src); @@ -91,12 +97,13 @@ class compress function methods() { $methods = array('tar'); + $available_methods = array('tar.gz' => 'zlib', 'tar.bz2' => 'bz2', 'zip' => 'zlib'); - foreach (array('tar.gz' => 'zlib', 'tar.bz2' => 'bz2', 'zip' => 'zlib') as $type => $module) + foreach ($available_methods as $type => $module) { if (!@extension_loaded($module)) { - break; + continue; } $methods[] = $type; } @@ -312,7 +319,7 @@ class compress_zip extends compress unset($data); // If we didn't compress set method to store, else deflate - $c_method = ($c_len == $unc_len) ? "\x00\x00" : "\x08\x00"; + $c_method = ($c_len == $unc_len) ? "\x00\x00" : "\x08\x00"; // Are we a file or a directory? Set archive for file $attrib = ($is_dir) ? 16 : 32; @@ -348,7 +355,7 @@ class compress_zip extends compress $cdrec .= "\x00\x00"; // version made by $cdrec .= "$var_ext\x00"; // version needed to extract $cdrec .= "\x00\x00"; // gen purpose bit flag - $cdrec .= $c_method; // compression method + $cdrec .= $c_method; // compression method $cdrec .= $hexdtime; // last mod time & date $cdrec .= pack('V', $crc); // crc32 $cdrec .= pack('V', $c_len); // compressed filesize @@ -372,7 +379,7 @@ class compress_zip extends compress { $ctrldir = implode('', $this->ctrl_dir); - return $ctrldir . $this->eof_cdh . + return $ctrldir . $this->eof_cdh . pack('v', sizeof($this->ctrl_dir)) . // total # of entries "on this disk" pack('v', sizeof($this->ctrl_dir)) . // total # of entries overall pack('V', strlen($ctrldir)) . // size of central dir @@ -548,7 +555,7 @@ class compress_tar extends compress $header .= pack("a8", sprintf("%07o", 0)); $header .= pack("a8", sprintf("%07o", 0)); $header .= pack("a12", sprintf("%011o", $filesize)); - $header .= pack("a12", sprintf("%011o", $mtime)); + $header .= pack("A12", sprintf("%011o", $mtime)); // From a12 to A12 $header .= ' '; $header .= pack("a", $typeflag); $header .= pack("a100", ''); @@ -581,7 +588,12 @@ class compress_tar extends compress function open() { $fzopen = ($this->isbz && function_exists('bzopen')) ? 'bzopen' : (($this->isgz && extension_loaded('zlib')) ? 'gzopen' : 'fopen'); - return $this->fp = @$fzopen($this->file, $this->mode . 'b'); + $this->fp = @$fzopen($this->file, $this->mode . 'b' . (($fzopen == 'gzopen') ? '9' : '')); + + if (!$this->fp) + { + trigger_error('Unable to open file ' . $this->file . ' [' . $fzopen . ' - ' . $this->mode . 'b]'); + } } function download($filename) @@ -601,7 +613,7 @@ class compress_tar extends compress case 'tar.bz2': $mimetype = 'application/x-bzip2'; break; - + default: $mimetype = 'application/octet-stream'; break; |