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; }
/** * * Compress theme into archive file * @param string $path target archive path * @param string $name archive filename * @return string arcive path */ public function compress($path, $name = null) { if (!$name) { $name = "webasyst.{$this->app}.theme.{$this->id}.tar.gz"; } $target_file = "{$path}/{$this->app}/{$name}"; $autoload = waAutoload::getInstance(); $autoload->add('Archive_Tar', 'wa-installer/lib/vendors/PEAR/Tar.php'); $autoload->add('PEAR', 'wa-installer/lib/vendors/PEAR/PEAR.php'); if (file_exists($this->path) && class_exists('Archive_Tar', true)) { waFiles::create($target_file); $tar_object = new Archive_Tar($target_file, true); $tar_object->setIgnoreRegexp('@(\\.(php\\d?|svn|git|fw_|files\\.md5$))@'); $path = getcwd(); chdir(dirname($this->path)); if (!$tar_object->create('./' . basename($this->path))) { waFiles::delete($target_file); } chdir($path); } return $target_file; }
function plug_download($idplug, $idclient, $_zip = false, $_name = false, $_ext = false) { global $rep, $cfg_cms, $sess, $cms_log; $plugin = $rep->plug_data($idplug, $idclient); // todo:zlib abfrage + popup if (is_array($plugin)) { // Event $zip = false; require_once "Archive/Tar.php"; $xmlstring = $rep->plug_generate($plugin); $name = $_name == '' ? $plugin['root_name'] : trim($_name); $zip = $cfg_cms['gzip_enabled'] == true && $_zip == true ? true : false; if ($zip === true && ($_ext == 'tar' || $_ext == 'tgz')) { $_ext = 'tgz'; } elseif ($zip === false && ($_ext == 'tar' || $_ext == 'tgz')) { $_ext = 'tar'; } else { $_ext = 'cmsplugin'; } $_mtype = $zip === true ? 'application/x-compressed' : 'application/x-tar'; $file = $cfg_cms['path_base'] . $cfg_cms['path_backend_rel'] . 'upload/' . 'out/' . $name . '.' . $_ext; $download = $cfg_cms['path_base_http'] . $cfg_cms['path_backend_rel'] . 'upload/' . 'out/' . $name . '.' . $_ext; lib_write_file($cfg_cms['path_base'] . $cfg_cms['path_backend_rel'] . 'plugins/' . $name . '/' . $name . '.cmsplug', $xmlstring); if (false == ($tar = new Archive_Tar($file, $zip))) { return '1615'; } elseif ($tar == '-1' && $zip == true) { return plug_download($idplug, $idclient, false, $_name, $_ext); } $old_working_dir = getcwd(); chdir($cfg_cms['path_base'] . $cfg_cms['path_backend_rel'] . 'plugins/'); $tar->setIgnoreRegexp("#CVS|\\.svn#"); $tar->create(trim($name)); chdir($old_working_dir); ob_end_clean(); header('Content-Type: ' . $_mtype); header('Content-Transfer-Encoding: binary'); header('Content-Description: Download Data'); header('Content-Length: ' . filesize($file)); header('Content-Disposition: attachment; filename="' . basename($file) . '"'); header('Expires: 0'); header('Cache-Control: no-cache, must-revalidate'); header('Pragma: no-cache'); //old function: header('Location:' . $download); readfile($file); //Log $cms_log->info('user', 'plug_download', array('idplug' => $idplug, 'name' => $name)); //Event fire_event('plug_download', array('idplug' => $idplug, 'name' => $name, 'idclient' => $idclient)); lib_delete_file($file); exit; } }