diff options
author | Meik Sievertsen <acydburn@phpbb.com> | 2005-01-23 23:02:10 +0000 |
---|---|---|
committer | Meik Sievertsen <acydburn@phpbb.com> | 2005-01-23 23:02:10 +0000 |
commit | 1613c37d91ab6bf7d6812b889c79f423bf52fda1 (patch) | |
tree | 019d07a37419078341c296f55af67b43750e9837 /phpBB/includes/functions_compress.php | |
parent | 055aef50030304a2a3a50e5a91bdb29a8b76ac64 (diff) | |
download | forums-1613c37d91ab6bf7d6812b889c79f423bf52fda1.tar forums-1613c37d91ab6bf7d6812b889c79f423bf52fda1.tar.gz forums-1613c37d91ab6bf7d6812b889c79f423bf52fda1.tar.bz2 forums-1613c37d91ab6bf7d6812b889c79f423bf52fda1.tar.xz forums-1613c37d91ab6bf7d6812b889c79f423bf52fda1.zip |
- change registration page language on-the-fly
- added download function to functions_compress as well as tiny bugfixes
- added local_name and author to iso.txt file
git-svn-id: file:///svn/phpbb/trunk@5074 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes/functions_compress.php')
-rw-r--r-- | phpBB/includes/functions_compress.php | 64 |
1 files changed, 60 insertions, 4 deletions
diff --git a/phpBB/includes/functions_compress.php b/phpBB/includes/functions_compress.php index 9993b4bb5e..5c55fda67c 100644 --- a/phpBB/includes/functions_compress.php +++ b/phpBB/includes/functions_compress.php @@ -14,7 +14,7 @@ class compress { var $fp = 0; - + function add_file($src, $src_rm_prefix = '', $src_add_prefix = '', $skip_files = '') { global $phpbb_root_path; @@ -63,7 +63,7 @@ class compress $path = (substr($path, 0, 1) == '/') ? substr($path, 1) : $path; $path = ($path && substr($path, -1) != '/') ? $path . '/' : $path; - $this->data("$src_path$path", '', filemtime("$phpbb_root_path$path"), true); + $this->data("$src_path$path", '', filemtime("$phpbb_root_path$src_path$path"), true); } foreach ($file_ary as $file) @@ -73,7 +73,7 @@ class compress continue; } - $this->data("$src_path$path$file", implode('', file("$phpbb_root_path$src$path$file")), filemtime("$phpbb_root_path$src$path$file"), false); + $this->data("$src_path$path$file", implode('', file("$phpbb_root_path$src_path$path$file")), filemtime("$phpbb_root_path$src_path$path$file"), false); } } @@ -374,6 +374,24 @@ class compress_zip extends compress pack('V', $this->datasec_len) . // offset to start of central dir "\x00\x00"; // .zip file comment length } + + function download($filename) + { + global $phpbb_root_path; + + $mimetype = 'application/zip'; + + header('Pragma: no-cache'); + header("Content-Type: $mimetype; name=\"$filename.zip\""); + header("Content-disposition: attachment; filename=$filename.zip"); + + $fp = fopen("{$phpbb_root_path}store/$filename.zip", 'rb'); + while ($buffer = fread($fp, 1024)) + { + echo $buffer; + } + fclose($fp); + } } // Tar/tar.gz compression routine @@ -384,6 +402,7 @@ class compress_tar extends compress var $isbz = false; var $filename = ''; var $mode = ''; + var $type = ''; function compress_tar($mode, $file, $type = '') { @@ -393,6 +412,7 @@ class compress_tar extends compress $this->mode = &$mode; $this->file = &$file; + $this->type = &$type; $this->open(); } @@ -529,6 +549,7 @@ class compress_tar extends compress $header .= pack("x247"); // Checksum + $checksum = 0; for ($i = 0; $i < 512; $i++) { $b = unpack("c1char", substr($header, $i, 1)); @@ -548,11 +569,46 @@ class compress_tar extends compress unset($data); } - function open($mode, $file) + 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'); } + + function download($filename) + { + global $phpbb_root_path; + + switch ($this->type) + { + case 'tar': + $mimetype = 'application/x-tar'; + break; + + case 'tar.gz': + $mimetype = 'application/x-gzip'; + break; + + case 'tar.bz2': + $mimetype = 'application/x-bzip2'; + break; + + default: + $mimetype = 'application/octet-stream'; + break; + } + + header('Pragma: no-cache'); + header("Content-Type: $mimetype; name=\"$filename.$this->type\""); + header("Content-disposition: attachment; filename=$filename.$this->type"); + + $fp = fopen("{$phpbb_root_path}store/$filename.$this->type", 'rb'); + while ($buffer = fread($fp, 1024)) + { + echo $buffer; + } + fclose($fp); + } } ?>
\ No newline at end of file |