From cc637e72f02f73f5ec8545aad9877ab7b55ea09a Mon Sep 17 00:00:00 2001 From: "Paul S. Owen" Date: Mon, 21 Jul 2003 16:10:07 +0000 Subject: [PATCH] concanetate rather than substr_replace git-svn-id: file:///svn/phpbb/trunk@4306 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_compress.php | 79 +++++++++++++++------------ 1 file changed, 45 insertions(+), 34 deletions(-) diff --git a/phpBB/includes/functions_compress.php b/phpBB/includes/functions_compress.php index 71efca7ece..e0ab1fc64e 100644 --- a/phpBB/includes/functions_compress.php +++ b/phpBB/includes/functions_compress.php @@ -1,15 +1,24 @@ isgz = (strpos($file, '.tar.gz') !== false || strpos($file, '.tgz') !== false) ? true : false; $this->isbz = (strpos($file, '.tar.bz2') !== false) ? true : false; - $this->fzopen = ($this->isbz && function_exists('bzopen')) ? 'bzopen' : (($this->isgz && extension_loaded('zlib')) ? 'gzopen' : 'fopen'); - $this->fzclose = ($this->isbz && function_exists('bzclose')) ? 'bzclose' : (($this->isgz && extension_loaded('zlib')) ? 'gzclose' : 'fclose'); - $this->fzread = ($this->isbz && function_exists('bzread')) ? 'bzread' : (($this->isgz && extension_loaded('zlib')) ? 'gzread' : 'fread'); - $this->fzwrite = ($this->isbz && function_exists('bzwrite')) ? 'bzwrite' : (($this->isgz && extension_loaded('zlib')) ? 'gzwrite' : 'fwrite'); - - $fzopen = $this->fzopen; + $fzopen = ($this->isbz && function_exists('bzopen')) ? 'bzopen' : (($this->isgz && extension_loaded('zlib')) ? 'gzopen' : 'fopen'); return $this->fp = @$fzopen($phpbb_root_path . $file, $mode . 'b'); } function extract($dst) { + $fzread = ($this->isbz && function_exists('bzread')) ? 'bzread' : (($this->isgz && extension_loaded('zlib')) ? 'gzread' : 'fread'); } function close() { - $fzclose = $this->fzclose; + $fzclose = ($this->isbz && function_exists('bzclose')) ? 'bzclose' : (($this->isgz && extension_loaded('zlib')) ? 'gzclose' : 'fclose'); $fzclose($this->fp); } function data($name, $data, $mtime = false, $is_dir = false) { - $fzwrite = $this->fzwrite; - $fzread = $this->fzread; + $fzwrite = ($this->isbz && function_exists('bzwrite')) ? 'bzwrite' : (($this->isgz && extension_loaded('zlib')) ? 'gzwrite' : 'fwrite'); $mode = ($is_dir) ? '493' : '436'; $mtime = (!$mtime) ? time() : $mtime; $filesize = ($is_dir) ? 0 : strlen($data); $typeflag = ($is_dir) ? '5' : ''; - $header = pack("x512", 0); - $header = substr_replace($header, pack("a100", $name), 0, 100); - $header = substr_replace($header, pack("a8", sprintf("%07o", $mode)), 100, 8); -// $header = substr_replace($header, pack("a8", sprintf("%07o", 0)), 108, 8); -// $header = substr_replace($header, pack("a8", sprintf("%07o", 0)), 116, 8); - $header = substr_replace($header, pack("a12", sprintf("%011o", $filesize)), 124, 12); - $header = substr_replace($header, pack("a12", sprintf("%011o", $mtime)), 136, 12); - $header = substr_replace($header, pack("a", $typeflag), 156, 1); - - $header = substr_replace($header, 'ustar', 257, 5); - $header = substr_replace($header, '00', 263, 2); - - // Space padded for checksum - $header = substr_replace($header, ' ', 148, 8); + $header = ''; + $header .= pack("a100", $name); + $header .= pack("a8", sprintf("%07o", $mode)); + $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 .= ' '; + $header .= pack("a", $typeflag); + $header .= pack("a100", ''); + $header .= 'ustar'; + $header .= pack("x"); + $header .= '00'; + $header .= pack("x247"); + // Checksum for ($i = 0; $i < 512; $i++) { $b = unpack("c1char", substr($header, $i, 1));