15if (!defined(
'XOOPS_ROOT_PATH')) {
22include_once XOOPS_ROOT_PATH.
'/class/downloader.php';
26include_once XOOPS_ROOT_PATH.
'/class/class.tar.php';
38 public function __construct($ext =
'.tar.gz', $mimyType =
'application/x-gzip')
40 $this->archiver =
new tar();
41 $this->ext = trim($ext);
42 $this->mimeType = trim($mimyType);
51 public function addFile($filepath, $newfilename=
null)
53 $this->archiver->addFile($filepath);
54 if (isset($newfilename)) {
56 for ($i = 0; $i < $this->archiver->numFiles; $i++) {
57 if ($this->archiver->files[$i][
'name'] == $filepath) {
58 $this->archiver->files[$i][
'name'] = trim($newfilename);
73 $this->archiver->addFile($filepath,
true);
74 if (isset($newfilename)) {
76 for ($i = 0; $i < $this->archiver->numFiles; $i++) {
77 if ($this->archiver->files[$i][
'name'] == $filepath) {
78 $this->archiver->files[$i][
'name'] = trim($newfilename);
94 $dummyfile = XOOPS_CACHE_PATH.
'/dummy_'.time().
'.html';
95 $fp = fopen($dummyfile,
'w');
98 $this->archiver->addFile($dummyfile);
102 for ($i = 0; $i < $this->archiver->numFiles; $i++) {
103 if ($this->archiver->files[$i][
'name'] == $dummyfile) {
104 $this->archiver->files[$i][
'name'] = $filename;
106 $this->archiver->files[$i][
'time'] = $time;
122 $dummyfile = XOOPS_CACHE_PATH.
'/dummy_'.time().
'.html';
123 $fp = fopen($dummyfile,
'wb');
126 $this->archiver->addFile($dummyfile,
true);
130 for ($i = 0; $i < $this->archiver->numFiles; $i++) {
131 if ($this->archiver->files[$i][
'name'] == $dummyfile) {
132 $this->archiver->files[$i][
'name'] = $filename;
134 $this->archiver->files[$i][
'time'] = $time;
149 $file = $this->archiver->toTarOutput($name.$this->ext, $gzip);
150 $this->
_header($name.$this->ext);
151 header(
'Content-Type: application/x-tar') ;
152 header(
'Content-Length: ' . (
float)@strlen($file)) ;
addBinaryFileData(&$data, $filename, $time=0)
addFileData(&$data, $filename, $time=0)
download($name, $gzip=true)
addFile($filepath, $newfilename=null)
addBinaryFile($filepath, $newfilename=null)
__construct($ext='.tar.gz', $mimyType='application/x-gzip')