If the file already exists and is writable, it is replaced by the
new tar. It is a create and not an add. If the file exists and is
read-only or is a directory it is not replaced. The method return
false and a PEAR error text.
The $p_filelist parameter can be an array of string, each string
representing a filename or a directory name with their path if
needed. It can also be a single string with names separated by a
single blank.
The path indicated in $p_remove_dir will be removed from the
memorized path of each file / directory listed when this path
exists. By default nothing is removed (empty path '')
The path indicated in $p_add_dir will be added at the beginning of
the memorized path of each file / directory listed. However it can
be set to empty ''. The adding of a path is done after the removing
of path.
The path add/remove ability enables the user to prepare an archive
for extraction in a different path than the origin files are.
See also addModify() method for file adding properties.
public createModify ( array $p_filelist, string $p_add_dir, string $p_remove_dir = '' ) : boolean | ||
$p_filelist | array | An array of filenames and directory names, or a single string with names separated by a single blank space. |
$p_add_dir | string | A string which contains a path to be added to the memorized path of each element in the list. |
$p_remove_dir | string | A string which contains a path to be removed from the memorized path of each element in the list, when relevant. |
리턴 | boolean | true on success, false on error. |
/** * Execute the action * * @return mixed * @access public * @since 1/17/08 */ public function execute() { $harmoni = Harmoni::instance(); $component = SiteDispatcher::getCurrentNode(); $site = SiteDispatcher::getCurrentRootNode(); $slotMgr = SlotManager::instance(); $slot = $slotMgr->getSlotBySiteId($site->getId()); $exportDir = DATAPORT_TMP_DIR . "/" . $slot->getShortname() . "-" . str_replace(':', '_', DateAndTime::now()->asString()); mkdir($exportDir); try { // Do the export $visitor = new DomExportSiteVisitor($exportDir); $component->acceptVisitor($visitor); // Validate the result // printpre(htmlentities($visitor->doc->saveXMLWithWhitespace())); // $tmp = new Harmoni_DomDocument; // $tmp->loadXML($visitor->doc->saveXMLWithWhitespace()); // $tmp->schemaValidateWithException(MYDIR."/doc/raw/dtds/segue2-site.xsd"); $visitor->doc->schemaValidateWithException(MYDIR . "/doc/raw/dtds/segue2-site.xsd"); // Write out the XML $visitor->doc->saveWithWhitespace($exportDir . "/site.xml"); $archive = new Archive_Tar($exportDir . ".tar.gz"); $archive->createModify($exportDir, '', DATAPORT_TMP_DIR); // Remove the directory $this->deleteRecursive($exportDir); header("Content-Type: application/x-gzip;"); header('Content-Disposition: attachment; filename="' . basename($exportDir . ".tar.gz") . '"'); print file_get_contents($exportDir . ".tar.gz"); // Clean up the archive unlink($exportDir . ".tar.gz"); } catch (PermissionDeniedException $e) { $this->deleteRecursive($exportDir); if (file_exists($exportDir . ".tar.gz")) { unlink($exportDir . ".tar.gz"); } return new Block(_("You are not authorized to export this component."), ALERT_BLOCK); } catch (Exception $e) { $this->deleteRecursive($exportDir); if (file_exists($exportDir . ".tar.gz")) { unlink($exportDir . ".tar.gz"); } throw $e; } error_reporting(0); exit; }
/** * This compresses the bag into a new file. * * @param string $dirname The directory to compress. * @param string $output The output file. * @param string $method Either 'tgz' or 'zip'. Default is 'tgz'. * * @return string The file name for the file. */ function BagIt_compressBag($dirname, $output, $method = 'tgz') { $base = basename($dirname); $stripLen = strlen($dirname) - strlen($base); if ($method == 'zip') { $zip = new ZipArchive(); $zip->open($output, ZIPARCHIVE::CREATE); foreach (rls($dirname) as $file) { $zip->addFile($file, substr($file, $stripLen)); } $zip->close(); } else { if ($method == 'tgz') { $tar = new Archive_Tar($output, 'gz'); $tar->createModify($dirname, $base, $dirname); } } }
function pack_go() { global $list, $options; $arc_name = basename($_POST["arc_name"] . '.' . $_POST["arc_ext"]); $saveTo = ($options['download_dir_is_changeable'] ? stripslashes($_POST["saveTo"][$i]) : realpath($options['download_dir'])) . '/'; $v_list = array(); if (!$_POST["arc_name"] || !$_POST["arc_ext"]) { echo lang(196) . "<br /><br />"; } elseif (file_exists($saveTo . $arc_name)) { printf(lang(179), $arc_name); echo "<br /><br />"; } else { for ($i = 0; $i < count($_POST["files"]); $i++) { $file = $list[$_POST["files"][$i]]; if (file_exists($file["name"])) { $v_list[] = $file["name"]; } else { printf(lang(145), $file['name']); echo "<br /><br />"; } } if (count($v_list) < 1) { echo lang(137) . "<br /><br />"; } else { $arc_name = $saveTo . $arc_name; require_once CLASS_DIR . "tar.php"; $tar = new Archive_Tar($arc_name); if ($tar->error != '') { echo $tar->error . "<br /><br />"; } else { $remove_path = realpath($options['download_dir']) . '/'; $tar->createModify($v_list, '', $remove_path); if (!file_exists($arc_name)) { echo lang(197) . "<br /><br />"; } else { if (count($v_list = $tar->listContent()) > 0) { for ($i = 0; $i < sizeof($v_list); $i++) { printf(lang(198), $v_list[$i]['filename']); echo " <br />"; } printf(lang(199), $arc_name); echo "<br />"; $stmp = strtolower($arc_name); $arc_method = "Tar"; if (!$options['disable_archive_compression']) { if (strrchr($stmp, "tar.gz") + 5 == strlen($stmp)) { $arc_method = "Tar.gz"; } elseif (strrchr($stmp, "tar.bz2") + 6 == strlen($stmp)) { $arc_method = "Tar.bz2"; } } unset($stmp); $time = explode(" ", microtime()); $time = str_replace("0.", $time[1], $time[0]); $list[$time] = array("name" => $arc_name, "size" => bytesToKbOrMbOrGb(filesize($arc_name)), "date" => $time, "link" => "", "comment" => "archive " . $arc_method); } else { echo lang(200) . "<br /><br />"; } if (!updateListInFile($list)) { echo lang(9) . '<br /><br />'; } } } } } }
public function submitExportLang() { global $currentIndex; $lang = strtolower(Tools::getValue('iso_code')); $theme = strval(Tools::getValue('theme')); if ($lang and $theme) { $items = array_flip(Language::getFilesList($lang, $theme, false, false, false, false, true)); $gz = new Archive_Tar(_PS_TRANSLATIONS_DIR_ . '/export/' . $lang . '.gzip', true); if ($gz->createModify($items, NULL, _PS_ROOT_DIR_)) { } Tools::redirect('translations/export/' . $lang . '.gzip'); $this->_errors[] = Tools::displayError('An error occurred while creating archive.'); } $this->_errors[] = Tools::displayError('Please choose a language and theme.'); }
function Create_Tar($which_exported, $add_dirs) { global $dataDir, $langmessage; if (!$this->NewFile($which_exported, 'tar')) { return; } $this->Init_Tar(); //$tar_object = new Archive_Tar($this->archive_path,'gz'); //didn't always work when compressin $tar_object = new Archive_Tar($this->archive_path); //if( gpdebug ){ // $tar_object->setErrorHandling(PEAR_ERROR_PRINT); //} if (!$tar_object->createModify($add_dirs, 'gpexport', $dataDir)) { message($langmessage['OOPS'] . '(5)'); unlink($this->archive_path); return false; } //add in array so addModify doesn't split the string into an array $temp = array(); $temp[] = $this->export_ini_file; if (!$tar_object->addModify($temp, 'gpexport', $this->temp_dir)) { message($langmessage['OOPS'] . '(6)'); unlink($this->archive_path); return false; } //compression $compression =& $_POST['compression']; if (!isset($this->avail_compress[$compression])) { return true; } $new_path = $this->archive_path . '.' . $compression; $new_name = $this->archive_name . '.' . $compression; switch ($compression) { case 'gz': //gz compress the tar $gz_handle = @gzopen($new_path, 'wb9'); if (!$gz_handle) { return true; } if (!@gzwrite($gz_handle, file_get_contents($this->archive_path))) { return true; } @gzclose($gz_handle); break; case 'bz': //gz compress the tar $bz_handle = @bzopen($new_path, 'w'); if (!$bz_handle) { return true; } if (!@bzwrite($bz_handle, file_get_contents($this->archive_path))) { return true; } @bzclose($bz_handle); break; } unlink($this->archive_path); $this->archive_path = $new_path; $this->archive_name = $new_name; return true; }
/** * Package up both a package.xml and package2.xml for the same release * @param PEAR_Packager * @param PEAR_PackageFile_v1 * @param bool generate a .tgz or a .tar * @param string|null temporary directory to package in */ function toTgz2(&$packager, &$pf1, $compress = true, $where = null) { require_once 'Archive/Tar.php'; if (!$this->_packagefile->isEquivalent($pf1)) { return PEAR::raiseError('PEAR_Packagefile_v2::toTgz: "' . basename($pf1->getPackageFile()) . '" is not equivalent to "' . basename($this->_packagefile->getPackageFile()) . '"'); } if ($where === null) { if (!($where = System::mktemp(array('-d')))) { return PEAR::raiseError('PEAR_Packagefile_v2::toTgz: mktemp failed'); } } elseif (!@System::mkDir(array('-p', $where))) { return PEAR::raiseError('PEAR_Packagefile_v2::toTgz: "' . $where . '" could' . ' not be created'); } $file = $where . DIRECTORY_SEPARATOR . 'package.xml'; if (file_exists($file) && !is_file($file)) { return PEAR::raiseError('PEAR_Packagefile_v2::toTgz: unable to save package.xml as' . ' "' . $file . '"'); } if (!$this->_packagefile->validate(PEAR_VALIDATE_PACKAGING)) { return PEAR::raiseError('PEAR_Packagefile_v2::toTgz: invalid package.xml'); } $ext = $compress ? '.tgz' : '.tar'; $pkgver = $this->_packagefile->getPackage() . '-' . $this->_packagefile->getVersion(); $dest_package = getcwd() . DIRECTORY_SEPARATOR . $pkgver . $ext; if (file_exists($dest_package) && !is_file($dest_package)) { return PEAR::raiseError('PEAR_Packagefile_v2::toTgz: cannot create tgz file "' . $dest_package . '"'); } $pkgfile = $this->_packagefile->getPackageFile(); if (!$pkgfile) { return PEAR::raiseError('PEAR_Packagefile_v2::toTgz: package file object must ' . 'be created from a real file'); } $pkgdir = dirname(realpath($pkgfile)); $pkgfile = basename($pkgfile); // {{{ Create the package file list $filelist = array(); $i = 0; $this->_packagefile->flattenFilelist(); $contents = $this->_packagefile->getContents(); if (isset($contents['bundledpackage'])) { // bundles of packages $contents = $contents['bundledpackage']; if (!isset($contents[0])) { $contents = array($contents); } $packageDir = $where; foreach ($contents as $i => $package) { $fname = $package; $file = $pkgdir . DIRECTORY_SEPARATOR . $fname; if (!file_exists($file)) { return $packager->raiseError("File does not exist: {$fname}"); } $tfile = $packageDir . DIRECTORY_SEPARATOR . $fname; System::mkdir(array('-p', dirname($tfile))); copy($file, $tfile); $filelist[$i++] = $tfile; $packager->log(2, "Adding package {$fname}"); } } else { // normal packages $contents = $contents['dir']['file']; if (!isset($contents[0])) { $contents = array($contents); } $packageDir = $where; foreach ($contents as $i => $file) { $fname = $file['attribs']['name']; $atts = $file['attribs']; $orig = $file; $file = $pkgdir . DIRECTORY_SEPARATOR . $fname; if (!file_exists($file)) { return $packager->raiseError("File does not exist: {$fname}"); } $origperms = fileperms($file); $tfile = $packageDir . DIRECTORY_SEPARATOR . $fname; unset($orig['attribs']); if (count($orig)) { // file with tasks // run any package-time tasks $contents = file_get_contents($file); foreach ($orig as $tag => $raw) { $tag = str_replace(array($this->_packagefile->getTasksNs() . ':', '-'), array('', '_'), $tag); $task = "PEAR_Task_{$tag}"; $task = new $task($this->_packagefile->_config, $this->_packagefile->_logger, PEAR_TASK_PACKAGE); $task->init($raw, $atts, null); $res = $task->startSession($this->_packagefile, $contents, $tfile); if (!$res) { continue; // skip this task } if (PEAR::isError($res)) { return $res; } $contents = $res; // save changes System::mkdir(array('-p', dirname($tfile))); $wp = fopen($tfile, "wb"); fwrite($wp, $contents); fclose($wp); } } if (!file_exists($tfile)) { System::mkdir(array('-p', dirname($tfile))); copy($file, $tfile); } chmod($tfile, $origperms); $filelist[$i++] = $tfile; $this->_packagefile->setFileAttribute($fname, 'md5sum', md5_file($tfile), $i - 1); $packager->log(2, "Adding file {$fname}"); } } // }}} $name = $pf1 !== null ? 'package2.xml' : 'package.xml'; $packagexml = $this->toPackageFile($where, PEAR_VALIDATE_PACKAGING, $name); if ($packagexml) { $tar = new Archive_Tar($dest_package, $compress); $tar->setErrorHandling(PEAR_ERROR_RETURN); // XXX Don't print errors // ----- Creates with the package.xml file $ok = $tar->createModify(array($packagexml), '', $where); if (PEAR::isError($ok)) { return $packager->raiseError($ok); } elseif (!$ok) { return $packager->raiseError('PEAR_Packagefile_v2::toTgz(): adding ' . $name . ' failed'); } // ----- Add the content of the package if (!$tar->addModify($filelist, $pkgver, $where)) { return $packager->raiseError('PEAR_Packagefile_v2::toTgz(): tarball creation failed'); } // add the package.xml version 1.0 if ($pf1 !== null) { $pfgen =& $pf1->getDefaultGenerator(); $packagexml1 = $pfgen->toPackageFile($where, PEAR_VALIDATE_PACKAGING, 'package.xml', true); if (!$tar->addModify(array($packagexml1), '', $where)) { return $packager->raiseError('PEAR_Packagefile_v2::toTgz(): adding package.xml failed'); } } return $dest_package; } }
/** * @param PEAR_Packager * @param bool if true, a .tgz is written, otherwise a .tar is written * @param string|null directory in which to save the .tgz * @return string|PEAR_Error location of package or error object */ function toTgz(&$packager, $compress = true, $where = null) { require_once 'Archive/Tar.php'; if ($where === null) { if (!($where = System::mktemp(array('-d')))) { return PEAR::raiseError('PEAR_Packagefile_v1::toTgz: mktemp failed'); } } elseif (!@System::mkDir(array('-p', $where))) { return PEAR::raiseError('PEAR_Packagefile_v1::toTgz: "' . $where . '" could' . ' not be created'); } if (file_exists($where . DIRECTORY_SEPARATOR . 'package.xml') && !is_file($where . DIRECTORY_SEPARATOR . 'package.xml')) { return PEAR::raiseError('PEAR_Packagefile_v1::toTgz: unable to save package.xml as' . ' "' . $where . DIRECTORY_SEPARATOR . 'package.xml"'); } if (!$this->_packagefile->validate(PEAR_VALIDATE_PACKAGING)) { return PEAR::raiseError('PEAR_Packagefile_v1::toTgz: invalid package file'); } $pkginfo = $this->_packagefile->getArray(); $ext = $compress ? '.tgz' : '.tar'; $pkgver = $pkginfo['package'] . '-' . $pkginfo['version']; $dest_package = getcwd() . DIRECTORY_SEPARATOR . $pkgver . $ext; if (file_exists(getcwd() . DIRECTORY_SEPARATOR . $pkgver . $ext) && !is_file(getcwd() . DIRECTORY_SEPARATOR . $pkgver . $ext)) { return PEAR::raiseError('PEAR_Packagefile_v1::toTgz: cannot create tgz file "' . getcwd() . DIRECTORY_SEPARATOR . $pkgver . $ext . '"'); } if ($pkgfile = $this->_packagefile->getPackageFile()) { $pkgdir = dirname(realpath($pkgfile)); $pkgfile = basename($pkgfile); } else { return PEAR::raiseError('PEAR_Packagefile_v1::toTgz: package file object must ' . 'be created from a real file'); } // {{{ Create the package file list $filelist = array(); $i = 0; foreach ($this->_packagefile->getFilelist() as $fname => $atts) { $file = $pkgdir . DIRECTORY_SEPARATOR . $fname; if (!file_exists($file)) { return PEAR::raiseError("File does not exist: {$fname}"); } else { $filelist[$i++] = $file; if (!isset($atts['md5sum'])) { $this->_packagefile->setFileAttribute($fname, 'md5sum', md5_file($file)); } $packager->log(2, "Adding file {$fname}"); } } // }}} $packagexml = $this->toPackageFile($where, PEAR_VALIDATE_PACKAGING, 'package.xml', true); if ($packagexml) { $tar = new Archive_Tar($dest_package, $compress); $tar->setErrorHandling(PEAR_ERROR_RETURN); // XXX Don't print errors // ----- Creates with the package.xml file $ok = $tar->createModify(array($packagexml), '', $where); if (PEAR::isError($ok)) { return $ok; } elseif (!$ok) { return PEAR::raiseError('PEAR_Packagefile_v1::toTgz: tarball creation failed'); } // ----- Add the content of the package if (!$tar->addModify($filelist, $pkgver, $pkgdir)) { return PEAR::raiseError('PEAR_Packagefile_v1::toTgz: tarball creation failed'); } return $dest_package; } }
$data[$entry->dictionary][$entry->constant] = $entry->value; } foreach ($data as $dictionary => $values) { pathos_files_makeDirectory(dirname($langdir . $dictionary), 0777, true); $fh = fopen($langdir . $dictionary . '.php', 'w'); fwrite($fh, "<?php\r\n\r\n"); foreach ($values as $key => $value) { fwrite($fh, "\tdefine('" . $key . "','" . addslashes($value) . "');\r\n"); } fwrite($fh, "\r\n\r\n?>"); fclose($fh); } include_once BASE . "external/Tar.php"; $fname = tempnam(BASE . '/tmp', 'translation_'); $tar = new Archive_Tar($fname, 'gz'); $tar->createModify($tmpdir, '', $tmpdir); ob_end_clean(); header('Content-Type: application/x-gzip'); header('Content-Disposition: inline; filename="exponent-languagepack-' . $lang->lang . '.tar.gz"'); $fh = fopen($fname, 'rb'); while (!feof($fh)) { echo fread($fh, 8192); } fclose($fh); unlink($fname); pathos_files_removeDirectory($tmpdir); } else { echo 'Could not create default directory.'; } } else { echo SITE_404_HTML;
/** * Create archive using php function and return the path * * @param string $dir target dir * @param array $files files names list * @param string $name archive name * @param array $arc archiver options * @return string|bool */ protected function PhpCompress($dir, $files, $name, $archiver) { @ini_set('memory_limit', '256M'); $path = $this->_joinPath($dir, $name); //format the list $list = array(); foreach ($files as $file) { $list[] = $this->_joinPath($dir, $file); } // create archive object switch ($archiver['ext']) { case 'zip': include 'pclzip.lib.php'; $archive = new PclZip($path); if (!$archive->Create($list, '', $dir)) { return $this->SetError('errArchive'); } break; case 'tgz': case 'tbz': case 'tar': include 'Archive_Tar.php'; $archive = new Archive_Tar($path); if (!$archive->createModify($list, '', $dir)) { return $this->SetError('errArchive'); } break; } return $path; }
/** * Save a compressed copy of the uploaded file * */ function UploadCompressed(&$from, &$fName, &$upload_moved) { global $config, $dataDir, $langmessage; //check file type $file_type = admin_uploaded::GetFileType($fName); if (isset($config['check_uploads']) && $config['check_uploads'] === false) { return true; } if (in_array($file_type, $this->AllowedExtensions)) { return true; } $upload_moved = true; @ini_set('memory_limit', '256M'); includeFile('thirdparty/ArchiveTar/Tar.php'); //first move the file to a temporary folder //some installations don't like working with files in the default tmp folder do { $this->temp_folder = $dataDir . '/data/_temp/' . rand(1000, 9000); } while (file_exists($this->temp_folder)); gpFiles::CheckDir($this->temp_folder, false); $temp_file = $this->temp_folder . '/' . $fName; $this->temp_files[] = $temp_file; if (!move_uploaded_file($from, $temp_file)) { $this->errorMessages[] = sprintf($langmessage['UPLOAD_ERROR'] . ' (UC1)', $fName); return false; } //prepare file names that may be used //replace . with underscore for security $fName = str_replace('.', '_', $fName); $tar_name = $fName . '.tar'; $tgz_name = $fName . '.tgz'; $tbz_name = $fName . '.tar.bz'; //create a .tar archive of the file in the same folder $tar_path = $temp_file . '.tar'; $this->temp_files[] = $tar_path; $tar_object = new Archive_Tar($tar_path); $files = array($temp_file); if (!$tar_object->createModify($files, '', $this->temp_folder)) { $this->errorMessages[] = sprintf($langmessage['UPLOAD_ERROR'] . ' (CM1)', $fName); return false; } $fName = $tar_name; $from = $tar_path; //compress if available, try gz first if (function_exists('gzopen')) { $compress_path = $temp_file . '.tgz'; $this->temp_files[] = $compress_path; //gz compress the tar $gz_handle = @gzopen($compress_path, 'wb9'); if ($gz_handle) { if (@gzwrite($gz_handle, file_get_contents($tar_path))) { @gzclose($gz_handle); $fName = $tgz_name; $from = $compress_path; //return true; } } } //if gz isn't available or doesn't work, try bz if (function_exists('bzopen')) { $compress_path = $temp_file . '.tbz'; $this->temp_files[] = $compress_path; //gz compress the tar $bz_handle = @bzopen($compress_path, 'w'); if ($bz_handle) { if (@bzwrite($bz_handle, file_get_contents($tar_path))) { @bzclose($bz_handle); $fName = $tbz_name; $from = $compress_path; return true; } } } return true; }
switch ($_POST['compression_type']) { case 'zip': if (get_extension($name) != $_POST['compression_type']) { $name .= '.' . $_POST['compression_type']; } require $GO_CONFIG->class_path . 'pclzip.class.inc'; $zip = new PclZip($path . $GO_CONFIG->slash . $name); $zip->create($_POST['archive_files'], PCLZIP_OPT_REMOVE_PATH, $path); break; default: if (get_extension($name) != $_POST['compression_type']) { $name .= '.tar.' . $_POST['compression_type']; } require $GO_CONFIG->class_path . 'pearTar.class.inc'; $tar = new Archive_Tar($path . $GO_CONFIG->slash . $name, $_POST['compression_type']); if (!$tar->createModify($_POST['archive_files'], '', $path . $GO_CONFIG->slash)) { $feedback = '<p class="Error">' . $fb_failed_to_create . '</p>'; $task = 'create_archive'; } break; } } } break; case 'extract': if (isset($_POST['files'])) { require $GO_CONFIG->class_path . 'pearTar.class.inc'; require $GO_CONFIG->class_path . 'pclzip.class.inc'; while ($file = array_shift($_POST['files'])) { if (strtolower(get_extension($file)) == 'zip') { $zip = new PclZip($file);
// avoid timeouts if (!($index++ % 50)) { Safe::set_time_limit(30); SQL::ping(); } } // save the zipfile if ($handle = Safe::fopen($context['path_to_root'] . $file_name . '.zip', 'wb')) { fwrite($handle, $zipfile->get()); fclose($handle); $context['text'] .= BR . Skin::build_link($file_name . '.zip', $file_name . '.zip', 'basic'); } // start the tar file include_once '../included/tar.php'; $tarfile = new Archive_Tar($context['path_to_root'] . $file_name . '.tgz'); // extend the tar file as well if ($tarfile->createModify($all_files, '', $file_path)) { $context['text'] .= BR . Skin::build_link($file_name . '.tgz', $file_name . '.tgz', 'basic'); } $context['text'] .= "</p>\n"; // display the execution time $time = round(get_micro_time() - $context['start_time'], 2); $context['text'] .= '<p>' . sprintf(i18n::s('Script terminated in %.2f seconds.'), $time) . '</p>'; // forward to the index page $menu = array('scripts/' => i18n::s('Server software')); $context['text'] .= Skin::build_list($menu, 'menu_bar'); // remember the built Logger::remember('scripts/build.php: ' . i18n::c('The reference store has been rebuilt')); } // render the skin render_skin();
public function writePackage($article_id, $suffix = '') { error_log('OJS - OJSPackager: writePackage() wird aufgerufen und damit auch Tar.php'); $suppPath = $this->filesPath . "/" . $article_id . "/supp/"; $preprPath = $this->filesPath . "/" . $article_id . "/public/"; $pd = new PackageDescription(); $authors = "c("; $pkgName = ""; // get the handle used by OJS for the journal $article_id was published in #$journal_path = $this->rpositorydao->getJournalPath($article_id); $pd->set("Repository", "OpenScienceRepository"); $pd->set("Depends", "R (>= 2.14)"); // get the date the article was published and its title and description $result_artStmt = $this->rpositorydao->getArtStatement($article_id); $pd->set("Date", $result_artStmt['date_published']); $pd->set("Title", $result_artStmt['sv1']); $pd->set("Description", $result_artStmt['sv2']); // get author details of $article_id and put them into the DESCRIPTION file $result_authorStmt = $this->rpositorydao->getAuthorStatement($article_id); $numberOfAuthors = count($result_authorStmt); error_log('OJS - OJSPackager: Vor der Schleife: Welchen Wert hat number of Authors? ' . $numberOfAuthors . " " . json_encode($this->rpositorydao->getAuthorStatement($article_id))); foreach ($result_authorStmt as $row_authorStmt) { if (strlen($pd->get("Author"))) { $pd->set("Author", $pd->get("Author") . " and "); } $pd->set("Author", $pd->get("Author") . $row_authorStmt['first_name'] . " " . $row_authorStmt['last_name']); if ($this->beginsWith($authors, "c(person(")) { $authors .= ", "; } $authors .= 'person('; $authors .= 'given ="' . $row_authorStmt['first_name'] . '", family = "' . $row_authorStmt['last_name'] . '"'; if ($numberOfAuthors <= 2) { $authorNamePkg = $row_authorStmt['last_name']; $cleanedAuthorName = str_replace(' ', '', $authorNamePkg); $pkgName .= $cleanedAuthorName; error_log('OJS - OJSPackager: Hier kommt was zum Autor dazu? Im Ifzweig kommt ' . $pkgName); } else { error_log('OJS - OJSPackager: Bin im Elsezweig, aber es stimmt etwas mit der naechsten If abfrage nicht...'); if ($row_authorStmt['primary_contact'] == 1) { $authorNamePkg = $row_authorStmt['last_name']; $cleanedAuthorName = str_replace(' ', '', $authorNamePkg); $pkgName .= $cleanedAuthorName; error_log('OJS - OJSPackager wird hier was zum Autor hinzugefuegt? Im Elsezweig kommt ' . $pkgName); } } if ($row_authorStmt['middle_name'] != NULL && strlen($row_authorStmt['middle_name']) > 0) { $authors .= ', middle = "' . $row_authorStmt['middle_name'] . '"'; } if ($row_authorStmt['email'] != NULL && strlen($row_authorStmt['email']) > 0) { $authors .= ', email = "' . $row_authorStmt['email'] . '"'; } $authors .= ', role = c("aut"'; if ($row_authorStmt['primary_contact'] == 1) { // primary_contact $authors .= ', "cre"'; $contMail = ""; if ($row_authorStmt['email'] != NULL && strlen($row_authorStmt['email']) > 0) { $contMail = " <" . $row_authorStmt['email'] . ">"; } $pd->set("Maintainer", $row_authorStmt['first_name'] . " " . $row_authorStmt['last_name'] . $contMail); } $authors .= '))'; } $authors .= ')'; $pd->set("Authors@R", $authors); $temp = explode('-', $pd->get("Date")); $pkgName_and_ver = $this->rpositorydao->getNameNew($article_id, $pkgName); $pkgName = $pkgName_and_ver[0] . "_" . $pkgName_and_ver[1]; #$pkgName = $pkgName. $versnumb['major'] . '.' $versnumb['minor']; unset($temp); $pd->set("Package", $pkgName_and_ver[0]); // path to write the package to $archive = array(); $archive['name'] = sys_get_temp_dir() . '/' . $pkgName; $archive['targz'] = sys_get_temp_dir() . '/' . $pkgName . '.tar'; $archive['zip'] = sys_get_temp_dir() . '/' . $pkgName . '.zip'; error_log('OJS - OJSPackager: welchen Wert hat $archive: ' . $archive); $pd->set("Version", $pkgName_and_ver[1]); $pd->set("License", "CC BY-NC (http://creativecommons.org/licenses/by-nc/3.0/de/)"); // create a directory under the system temp dir for and copy the article and its supplementary files to there $tempDirRoot = $this->tmpDir(); error_log("name and version" . json_encode($pkgName_and_ver)); $tempDir = $tempDirRoot . "/" . $pkgName . "_" . $pkgName_and_ver[1]; mkdir($tempDir); error_log("OJSPackager Tmpdir" . $tempDir); //$pdfile = $pdfile; //error_log("OJS - Rpository: ". $pdfile); rename($pd->toTempFile(), $tempDir . '/' . 'DESCRIPTION'); $pw = new Archive_Tar($archive['targz'], 'gz'); //$pw = new PharData($archive['targz']); $pharData = new PharData($archive['zip']); $result_fileStmt = $this->rpositorydao->getFileStatement($article_id); $submissionPreprintName = ''; $suppCount = 0; foreach ($result_fileStmt as $row_fileStmt) { if ($row_fileStmt['type'] == 'supp') { $suppCount++; } } foreach ($result_fileStmt as $row_fileStmt) { $name = $row_fileStmt['file_name']; $origName = $row_fileStmt['original_file_name']; $type = $row_fileStmt['type']; if ($type == 'supp') { if ($suppCount != 1 || !$this->unpacker->canHandle($suppPath . $name)) { if (!is_dir($tempDir . '/' . 'inst')) { mkdir($tempDir . '/' . 'inst', 0777, TRUE); } if (!copy($suppPath . $name, trim($tempDir) . '/' . 'inst' . '/' . $origName)) { error_log('OJS - rpository: error copying file: ' . $suppPath . $name . ' to: ' . trim($tempDir . '/' . 'inst' . '/' . $origName)); } } elseif ($this->unpacker->canHandle($suppPath . $name)) { if (!is_dir($tempDir . '/' . 'inst')) { mkdir($tempDir . '/' . 'inst', 0777, TRUE); } $unpackDir = $this->tmpDir(); $this->unpacker->unpackInto($suppPath . $name, $unpackDir); $contentDir = get_content_dir($unpackDir); move_dir_contents($contentDir, $tempDir . '/' . 'inst'); $this->deleteDirectory($unpackDir); } } elseif ($type == 'submission/original') { // TODO: pdf name wird nicht ermittelt // verzeichnisstruktur weicht von java version ab $submissionPreprintName = $origName; if (!is_dir($tempDir . '/' . 'inst' . '/' . 'preprint')) { mkdir($tempDir . '/' . 'inst' . '/' . 'preprint', 0777, TRUE); } copy($this->filesPath . "/" . $article_id . "/submission/original/" . $name, trim($tempDir) . '/' . 'inst' . '/' . 'preprint' . '/' . $submissionPreprintName); } elseif ($type == 'public') { $submissionPreprintName = $origName; if (!is_dir($tempDir . '/' . 'inst' . '/' . 'preprint')) { mkdir($tempDir . '/' . 'inst' . '/' . 'preprint', 0777, TRUE); } copy($preprPath . $name, trim($tempDir) . '/' . 'inst' . '/' . 'preprint' . '/' . $submissionPreprintName); } } error_log('OJS - OJSPackager: der Wert von $tempDir ' . $tempDir . ' und von pkgName ' . $pkgName); //PhardataDirectory $pharData->buildFromDirectory($tempDir); //$archive['zip']=$pharData->buildFromDirectory($tempDir); // create the archive with the temp directory we created above //$pw->buildFromDirectory($tempDir); //$pw->compress(Phar::GZ); if (!$pw->createModify($tempDir, "{$pkgName}" . '/', $tempDir)) { error_log("OJS - rpository: error writing archive"); } // delete temp directory $this->deleteDirectory($tempDirRoot); // return the name of created archive error_log('OJS - OJSPackager: Ein Archive wurde erfolgreich zustande gebracht! mit dem archive ' . $archive); return $archive; }
function package($pkgfile = null, $compress = true) { // {{{ validate supplied package.xml file if (empty($pkgfile)) { $pkgfile = 'package.xml'; } // $this->pkginfo gets populated inside $pkginfo = $this->infoFromDescriptionFile($pkgfile); if (PEAR::isError($pkginfo)) { return $this->raiseError($pkginfo); } $pkgdir = dirname(realpath($pkgfile)); $pkgfile = basename($pkgfile); $errors = $warnings = array(); $this->validatePackageInfo($pkginfo, $errors, $warnings, $pkgdir); foreach ($warnings as $w) { $this->log(1, "Warning: {$w}"); } foreach ($errors as $e) { $this->log(0, "Error: {$e}"); } if (sizeof($errors) > 0) { return $this->raiseError('Errors in package'); } // }}} $pkgver = $pkginfo['package'] . '-' . $pkginfo['version']; // {{{ Create the package file list $filelist = array(); $i = 0; foreach ($pkginfo['filelist'] as $fname => $atts) { $file = $pkgdir . DIRECTORY_SEPARATOR . $fname; if (!file_exists($file)) { return $this->raiseError("File does not exist: {$fname}"); } else { $filelist[$i++] = $file; if (empty($pkginfo['filelist'][$fname]['md5sum'])) { $md5sum = md5_file($file); $pkginfo['filelist'][$fname]['md5sum'] = $md5sum; } $this->log(2, "Adding file {$fname}"); } } // }}} // {{{ regenerate package.xml $new_xml = $this->xmlFromInfo($pkginfo); if (PEAR::isError($new_xml)) { return $this->raiseError($new_xml); } if (!($tmpdir = System::mktemp(array('-d')))) { return $this->raiseError("PEAR_Packager: mktemp failed"); } $newpkgfile = $tmpdir . DIRECTORY_SEPARATOR . 'package.xml'; $np = @fopen($newpkgfile, 'wb'); if (!$np) { return $this->raiseError("PEAR_Packager: unable to rewrite {$pkgfile} as {$newpkgfile}"); } fwrite($np, $new_xml); fclose($np); // }}} // {{{ TAR the Package ------------------------------------------- $ext = $compress ? '.tgz' : '.tar'; $dest_package = getcwd() . DIRECTORY_SEPARATOR . $pkgver . $ext; $tar = new Archive_Tar($dest_package, $compress); $tar->setErrorHandling(PEAR_ERROR_RETURN); // XXX Don't print errors // ----- Creates with the package.xml file $ok = $tar->createModify(array($newpkgfile), '', $tmpdir); if (PEAR::isError($ok)) { return $this->raiseError($ok); } elseif (!$ok) { return $this->raiseError('PEAR_Packager: tarball creation failed'); } // ----- Add the content of the package if (!$tar->addModify($filelist, $pkgver, $pkgdir)) { return $this->raiseError('PEAR_Packager: tarball creation failed'); } $this->log(1, "Package {$dest_package} done"); if (file_exists("{$pkgdir}/CVS/Root")) { $cvsversion = preg_replace('/[^a-z0-9]/i', '_', $pkginfo['version']); $cvstag = "RELEASE_{$cvsversion}"; $this->log(1, "Tag the released code with `pear cvstag {$pkgfile}'"); $this->log(1, "(or set the CVS tag {$cvstag} by hand)"); } // }}} return $dest_package; }
function pack_go() { global $list, $options, $L; $arc_name = basename($_POST["arc_name"] . '.' . $_POST["arc_ext"]); $saveTo = ($options['download_dir_is_changeable'] ? stripslashes($_POST["saveTo"][$i]) : realpath($options['download_dir'])) . '/'; $v_list = array(); if (!$_POST["arc_name"] || !$_POST["arc_ext"]) { echo $L->say['enter_arc_name'] . "<br /><br />"; } elseif (file_exists($saveTo . $arc_name)) { echo $L->sprintf($L->say['err_output_file_exist'], $arc_name) . "<br /><br />"; } else { for ($i = 0; $i < count($_POST["files"]); $i++) { $file = $list[$_POST["files"][$i]]; if (file_exists($file["name"])) { $v_list[] = $file["name"]; } else { echo $L->sprintf($L->say['not_found'], $file['name']) . "<br /><br />"; } } if (count($v_list) < 1) { echo "<b class=\"r\">" . $L->say['error_occur'] . "</b><br /><br />"; } else { $arc_name = $saveTo . $arc_name; require_once CLASS_DIR . "tar.php"; $tar = new Archive_Tar($arc_name); if ($tar->error != '') { echo $tar->error . "<br /><br />"; } else { $remove_path = realpath($options['download_dir']) . '/'; $tar->createModify($v_list, '', $remove_path); if (!file_exists($arc_name)) { echo "<b class=\"r\">" . $L->say['_error'] . "</b> " . $L->say['arcv_not_created'] . "<br /><br />"; } else { if (count($v_list = $tar->listContent()) > 0) { for ($i = 0; $i < sizeof($v_list); $i++) { echo $L->sprintf($L->say['was_pack'], $v_list[$i]['filename']) . " <br />"; } echo $L->sprintf($L->say['pack_in_arcv'], $arc_name) . "<br />"; $stmp = strtolower($arc_name); $arc_method = "Tar"; if (!$options['disable_to']['act_archive_compression']) { if (strrchr($stmp, "tar.gz") + 5 == strlen($stmp)) { $arc_method = "Tar.gz"; } elseif (strrchr($stmp, "tar.bz2") + 6 == strlen($stmp)) { $arc_method = "Tar.bz2"; } } unset($stmp); $time = explode(" ", microtime()); $time = str_replace("0.", $time[1], $time[0]); $list[$time] = array("name" => $arc_name, "size" => bytesToKbOrMbOrGb(filesize($arc_name)), "date" => $time, "link" => "", "comment" => "archive " . $arc_method); } else { echo "<b class=\"r\">" . $L->say['_error'] . "</b> " . $L->say['arcv_empty'] . "<br /><br />"; } if (!updateListInFile($list)) { echo $L->say['couldnt_upd'] . '<br /><br />'; } } } } } }
public function submitExportLang() { if ($this->lang_selected->iso_code && $this->theme_selected) { $this->exportTabs(); $items = array_flip(Language::getFilesList($this->lang_selected->iso_code, $this->theme_selected, false, false, false, false, true)); $file_name = _PS_TRANSLATIONS_DIR_ . '/export/' . $this->lang_selected->iso_code . '.gzip'; $gz = new \Archive_Tar($file_name, true); if ($gz->createModify($items, null, _PS_ROOT_DIR_)) { ob_start(); header('Pragma: public'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Cache-Control: public'); header('Content-Description: File Transfer'); header('Content-type: application/octet-stream'); header('Content-Disposition: attachment; filename="' . $this->lang_selected->iso_code . '.gzip' . '"'); header('Content-Transfer-Encoding: binary'); ob_end_flush(); readfile($file_name); @unlink($file_name); exit; } $this->errors[] = $this->trans('An error occurred while creating archive.', array(), 'Admin.International.Notification'); } $this->errors[] = $this->trans('Please select a language and a theme.', array(), 'Admin.International.Notification'); }
function run_pack_plugin($task, $args) { ini_set('display_errors', 'on'); ini_set('error_reporting', E_ERROR); // the environment for poedit always is Development define('G_ENVIRONMENT', G_DEV_ENV); //the plugin name in the first argument if (!isset($args[0])) { printf("Error: %s\n", pakeColor::colorize('you must specify a valid name for the plugin', 'ERROR')); exit(0); } $pluginName = $args[0]; require_once "propel/Propel.php"; G::LoadSystem('templatePower'); $pluginDirectory = PATH_PLUGINS . $pluginName; $pluginOutDirectory = PATH_OUTTRUNK . 'plugins' . PATH_SEP . $pluginName; $pluginHome = PATH_OUTTRUNK . 'plugins' . PATH_SEP . $pluginName; //verify if plugin exists, $pluginClassFilename = PATH_PLUGINS . $pluginName . PATH_SEP . 'class.' . $pluginName . '.php'; $pluginFilename = PATH_PLUGINS . $pluginName . '.php'; if (!is_file($pluginClassFilename)) { printf("The plugin %s does not exist in this file %s \n", pakeColor::colorize($pluginName, 'ERROR'), pakeColor::colorize($pluginClassFilename, 'INFO')); die; } G::LoadClass('plugin'); require_once $pluginFilename; $oPluginRegistry =& PMPluginRegistry::getSingleton(); $pluginDetail = $oPluginRegistry->getPluginDetails($pluginName . '.php'); $fileTar = $pluginHome . PATH_SEP . $pluginName . '-' . $pluginDetail->iVersion . '.tar'; G::LoadThirdParty('pear/Archive', 'Tar'); $tar = new Archive_Tar($fileTar); $tar->_compress = false; $pathBase = $pluginHome . PATH_SEP . $pluginName . PATH_SEP; $tar->createModify($pluginHome . PATH_SEP . $pluginName . '.php', '', $pluginHome); addTarFolder($tar, $pathBase, $pluginHome); $aFiles = $tar->listContent(); foreach ($aFiles as $key => $val) { printf(" %6d %s \n", $val['size'], pakeColor::colorize($val['filename'], 'INFO')); } printf("File created in %s \n", pakeColor::colorize($fileTar, 'INFO')); $filesize = sprintf("%5.2f", filesize($fileTar) / 1024); printf("Filesize %s Kb \n", pakeColor::colorize($filesize, 'INFO')); }
/** * @param string The name of the archive * @param mixed The name of a single file or an array of files * @param string The compression for the archive * @param string Path to add within the archive * @param string Path to remove within the archive * @param boolean Automatically append the extension for the archive * @param boolean Remove for source files */ function create($archive, $files, $compress = 'tar', $addPath = '', $removePath = '', $autoExt = false, $cleanUp = false) { jimport('pear.archive_tar.Archive_Tar'); if (is_string($files)) { $files = array($files); } if ($autoExt) { $archive .= '.' . $compress; } $tar = new Archive_Tar($archive, $compress); $tar->setErrorHandling(PEAR_ERROR_PRINT); $tar->createModify($files, $addPath, $removePath); if ($cleanUp) { JFile::delete($files); } return $tar; }
public function submitExportLang() { if ($this->lang_selected->iso_code && $this->theme_selected) { $this->exportTabs(); $items = array_flip(Language::getFilesList($this->lang_selected->iso_code, $this->theme_selected, false, false, false, false, true)); $gz = new Archive_Tar(_PS_TRANSLATIONS_DIR_ . '/export/' . $this->lang_selected->iso_code . '.gzip', true); $file_name = Tools::getCurrentUrlProtocolPrefix() . Tools::getShopDomain() . __PS_BASE_URI__ . 'translations/export/' . $this->lang_selected->iso_code . '.gzip'; if ($gz->createModify($items, null, _PS_ROOT_DIR_)) { } Tools::redirectLink($file_name); $this->errors[] = Tools::displayError('An error occurred while creating archive.'); } $this->errors[] = Tools::displayError('Please choose a language and a theme.'); }
public function submitExportLang() { if ($this->lang_selected->iso_code && $this->theme_selected) { $this->exportTabs(); $items = array_flip(Language::getFilesList($this->lang_selected->iso_code, $this->theme_selected, false, false, false, false, true)); $gz = new Archive_Tar(_PS_TRANSLATIONS_DIR_ . '/export/' . $this->lang_selected->iso_code . '.gzip', true); $file_name = Tools::getCurrentUrlProtocolPrefix() . Tools::getShopDomain() . __PS_BASE_URI__ . 'translations/export/' . $this->lang_selected->iso_code . '.gzip'; if ($gz->createModify($items, null, _PS_ROOT_DIR_)) { } ob_start(); header('Pragma: public'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Cache-Control: public'); header('Content-Description: File Transfer'); header('Content-type: application/octet-stream'); header('Content-Disposition: attachment; filename="' . $this->lang_selected->iso_code . '.gzip' . '"'); header('Content-Transfer-Encoding: binary'); ob_end_flush(); @readfile($file_name); exit; $this->errors[] = Tools::displayError('An error occurred while creating archive.'); } $this->errors[] = Tools::displayError('Please choose a language and a theme.'); }
$siteDir = $exportpath . '/' . $sitename . '/'; if (file_exists($siteDir)) { deletePath($siteDir); } mkdir($siteDir); // Copy the Media Files to the sitedir. dir_copy($imagepath, $siteDir . 'media/'); // Save the XML to a file. $xmlFile = $siteDir . 'site.xml'; if (!($handle = fopen($xmlFile, 'a'))) { $errorPrinter->doError(500, "Cannot open file ({$xmlFile})"); } // Write $somecontent to our opened file. if (!fwrite($handle, $siteXML)) { $errorPrinter->doError(500, "Cannot write to file ({$xmlFile})"); } fclose($handle); /********************************************************* * Compress the export and send it *********************************************************/ $archiveName = basename(trim($siteDir, '/')) . ".tar.gz"; $archive = new Archive_Tar($exportpath . '/' . $archiveName); $archive->createModify($siteDir, '', DATAPORT_TMP_DIR); // Remove the directory deleteRecursive($siteDir); header("Content-Type: application/x-gzip;"); header('Content-Disposition: attachment; filename="' . $archiveName . '"'); print file_get_contents($exportpath . '/' . $archiveName); // Clean up the archive unlink($exportpath . '/' . $archiveName); exit;
if ($exclude and is_dir($dir)) { if ($d = dir($dir)) { $list = array(); while (false !== ($entry = $d->read())) { if ($entry != '.' and $entry != '..' and array_search($entry, $exclude) === FALSE) { $list[] = "{$dir}/{$entry}"; } } $d->close(); } // if } else { $list = $dir; } // Добавляем данные в архив if ($Tar->createModify($list, '', dirname($dir))) { mail_file($mail_to[$user], $arc_name, $dir); echo "\nРазмер архива: " . filesize($Tar->_tarname); } // if } else { echo ' - Директории/файла не существует!'; } $exclude = array(); // сбрасываем массив break; ////////////////////////////////////////////////// ////////////////////////////////////////////////// case 'save_tar': // добавляет к архиву каталоги, параметр - то же что и к save //////////////////////////////////////////////////
function rscToTar($destination) { global $rsc_dir; if (file_exists($destination . "rsc.tar")) { unlink($destination . "rsc.tar"); } $tarfile = new Archive_Tar($destination . "rsc.tar"); $res = $tarfile->createModify(array($rsc_dir), "", $rsc_dir); if (!$res) { return false; } chmod($destination . "rsc.tar", octdec(0777)); return true; }
public function exportAction() { $themes = Engine_Api::_()->getDbtable('themes', 'core')->fetchAll(); if (!($row = $themes->getRowMatching('name', $this->_getParam('name')))) { throw new Engine_Exception("Theme not found: " . $this->_getParam('name')); } //$targetFilename = APPLICATION_PATH . '/temporary/theme_export.tar'; $target_filename = tempnam(APPLICATION_PATH . '/temporary/', 'theme_'); $template_dir = APPLICATION_PATH . '/application/themes/' . $row->name; $tar = new Archive_Tar($target_filename); $tar->setIgnoreRegexp("#CVS|\\.svn#"); $tar->createModify($template_dir, null, dirname($template_dir)); chmod($target_filename, 0777); header('Content-Type: application/x-tar'); header("Content-disposition: filename={$row->name}.tar"); readfile($target_filename); @unlink($target_filename); exit; }
if (!defined('PATHOS')) { exit(''); } if (!isset($_POST['mods'])) { echo 'You must select at least one module to export files for.'; return; } include_once BASE . 'external/Tar.php'; echo 'Preparing to create Tar archive<Br />'; $files = array(); foreach (array_keys($_POST['mods']) as $mod) { $files[] = BASE . 'files/' . $mod; } $fname = tempnam(BASE . '/tmp', 'exporter_files_'); $tar = new Archive_Tar($fname, 'gz'); $tar->createModify($files, '', BASE); $filename = str_replace(array('__DOMAIN__', '__DB__'), array(str_replace('.', '_', HOSTNAME), DB_NAME), $_POST['filename']); $filename = preg_replace('/[^A-Za-z0-9_.-]/', '-', strftime($filename, time()) . '.tar.gz'); ob_end_clean(); // This code was lifted from phpMyAdmin, but this is Open Source, right? // 'application/octet-stream' is the registered IANA type but // MSIE and Opera seems to prefer 'application/octetstream' $mime_type = PATHOS_USER_BROWSER == 'IE' || PATHOS_USER_BROWSER == 'OPERA' ? 'application/octetstream' : 'application/octet-stream'; header('Content-Type: ' . $mime_type); header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // IE need specific headers if (PATHOS_USER_BROWSER == 'IE') { header('Content-Disposition: inline; filename="' . $filename . '"'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); } else {
protected function runUntrustedAction($action) { switch ($action) { case 'backup': include_once 'HTTP/Download.php'; include_once 'Archive/Tar.php'; if (!$this->data_engine->dump(TIP::buildDataPath('dump'))) { TIP::notifyError('backup'); return false; } $tar_file = TIP::buildCachePath($this->id . '-' . TIP::formatDate('date_sql') . '.tar.gz'); $tar_object = new Archive_Tar($tar_file, 'gz'); $result = $tar_object->createModify(TIP::buildDataPath(), '', TIP::buildPath()); unset($tar_object); if ($result !== true) { return false; } HTTP_Download::staticSend(array('file' => $tar_file, 'contenttype' => 'application/x-gzip', 'contentdisposition' => HTTP_DOWNLOAD_ATTACHMENT)); exit; } return null; }
${$cmd} = $params; break; default: echo ' - ничего не делаем'; } // switch } // switch echo "\n"; } // for // Отправляем всё, что помещено во временную папку if ($dir_size) { echo "Суммарный размер каталога: {$dir_size}\n"; if (!$subject) { // Если html-запросов не было $subject = $params; } if ($compress) { include_once 'Tar.php'; // Используем формат Tar.Gz $arc_name = TEMP_PATH . '/dload.tgz'; $Tar = new Archive_Tar($arc_name, 1); if ($Tar->createModify($dir, '', $dir)) { mail_file($mail_to[$user], $arc_name, $subject); } } else { mail_file($mail_to[$user], $dir, $subject, $report); } } // if