19 defined(
'XOOPS_ROOT_PATH') or die('Restricted access');
24 include_once XOOPS_ROOT_PATH . '/class/downloader.php';
28 include_once XOOPS_ROOT_PATH . '/class/class.
tar.php';
40 $this->archiver =
new tar();
41 $this->ext = trim(
$ext);
42 $this->mimeType = trim($mimyType);
51 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);
71 function addBinaryFile($filepath, $newfilename = null)
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);
92 function addFileData(&$data, $filename,
$time = 0)
95 $fp = fopen($dummyfile,
'w');
98 $this->archiver->addFile($dummyfile);
101 for(
$i = 0;
$i < $this->archiver->numFiles;
$i ++) {
102 if ($this->archiver->files[
$i][
'name'] == $dummyfile) {
103 $this->archiver->files[
$i][
'name'] = $filename;
105 $this->archiver->files[
$i][
'time'] =
$time;
119 function addBinaryFileData(&$data, $filename,
$time = 0)
122 $fp = fopen($dummyfile,
'wb');
125 $this->archiver->addFile($dummyfile,
true);
128 for(
$i = 0;
$i < $this->archiver->numFiles;
$i ++) {
129 if ($this->archiver->files[
$i][
'name'] == $dummyfile) {
130 $this->archiver->files[
$i][
'name'] = $filename;
132 $this->archiver->files[
$i][
'time'] =
$time;
145 function download($name, $gzip =
true)
147 $this->_header($name . $this->ext);
148 echo $this->archiver->toTarOutput($name . $this->ext, $gzip);