本文整理汇总了PHP中Archive_Tar类的典型用法代码示例。如果您正苦于以下问题:PHP Archive_Tar类的具体用法?PHP Archive_Tar怎么用?PHP Archive_Tar使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Archive_Tar类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: addToArchive
public function addToArchive(Archive_Tar $archive)
{
$rval = $archive->addModify($this->getBasePath() . DIRECTORY_SEPARATOR . $this->getPath(), null, $this->getBasePath());
if ($archive->isError($rval)) {
throw new Engine_Package_Manifest_Exception('Error in archive: ' . $rval->getMessage());
}
}
开发者ID:febryantosulistyo,项目名称:ClassicSocial,代码行数:7,代码来源:File.php
示例2: archive
public static function archive($name = false, $listFilesAndFolders, $export_files_dir, $export_files_dir_name, $backupName, $move = false, $identifier, $type)
{
if (empty($export_files_dir)) {
return;
}
$dir_separator = DIRECTORY_SEPARATOR;
$backupName = 'backup' . $dir_separator . $backupName;
$installFilePath = 'system' . $dir_separator . 'admin-scripts' . $dir_separator . 'miscellaneous' . $dir_separator;
$dbSQLFilePath = 'backup' . $dir_separator;
$old_path = getcwd();
chdir($export_files_dir);
$tar = new Archive_Tar($backupName, 'gz');
if (SJB_System::getIfTrialModeIsOn()) {
$tar->setIgnoreList(array('system/plugins/mobile', 'system/plugins/facebook_app', 'templates/mobile', 'templates/Facebook'));
}
SessionStorage::write('backup_' . $identifier, serialize(array('last_time' => time())));
switch ($type) {
case 'full':
$tar->addModify("{$installFilePath}install.php", '', $installFilePath);
$tar->addModify($dbSQLFilePath . $name, '', $dbSQLFilePath);
$tar->addModify($listFilesAndFolders, '');
SJB_Filesystem::delete($export_files_dir . $dbSQLFilePath . $name);
break;
case 'files':
$tar->addModify("{$installFilePath}install.php", '', $installFilePath);
$tar->addModify($listFilesAndFolders, '');
break;
case 'database':
$tar->addModify($dbSQLFilePath . $listFilesAndFolders, '', $dbSQLFilePath);
SJB_Filesystem::delete($export_files_dir . $dbSQLFilePath . $listFilesAndFolders);
break;
}
chdir($old_path);
return true;
}
开发者ID:Maxlander,项目名称:shixi,代码行数:35,代码来源:Backup.php
示例3: create
/**
* @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 = true)
{
$compress = strtolower($compress);
if ($compress == 'tgz' || $compress == 'tbz' || $compress == 'tar') {
require_once _EXT_PATH . '/libraries/Tar.php';
if (is_string($files)) {
$files = array($files);
}
if ($autoExt) {
$archive .= '.' . $compress;
}
if ($compress == 'tgz') {
$compress = 'gz';
}
if ($compress == 'tbz') {
$compress = 'bz2';
}
$tar = new Archive_Tar($archive, $compress);
$tar->setErrorHandling(PEAR_ERROR_PRINT);
$result = $tar->addModify($files, $addPath, $removePath);
return $result;
} elseif ($compress == 'zip') {
$adapter =& xFileArchive::getAdapter('zip');
if ($adapter) {
$result = $adapter->create($archive, $files, $removePath);
}
if ($result == false) {
return PEAR::raiseError('Unrecoverable ZIP Error');
}
}
}
开发者ID:xamiro-dev,项目名称:xamiro,代码行数:40,代码来源:archive.php
示例4: addToArchive
public function addToArchive(Archive_Tar $archive)
{
// Add top level package manifest
$archive->addString('package.json', $this->toString('json'));
// Normal stuff
parent::addToArchive($archive);
}
开发者ID:febryantosulistyo,项目名称:ClassicSocial,代码行数:7,代码来源:Manifest.php
示例5: testBz2
function testBz2()
{
$oTar = new Archive_Tar($this->sFileBz2, 'bz2');
$sExpected = $oTar->extractInString('Beautifier.php');
unset($oTar);
$sActual = file_get_contents('tarz://' . $this->sFileBz2 . "#Beautifier.php");
$this->assertTrue($sExpected == $sActual, 'file_get_contents');
}
开发者ID:rafasashi,项目名称:PHP_Beautifier,代码行数:8,代码来源:StreamWrapperTest.php
示例6: install
function install($file)
{
G::LoadThirdParty("pear/Archive", "Tar");
$result = array();
$status = 1;
try {
//Extract
$tar = new Archive_Tar($file);
$swTar = $tar->extract(PATH_OUTTRUNK);
//true on success, false on error. //directory for extract
//$swTar = $tar->extract(PATH_PLUGINS);
if (!$swTar) {
throw new Exception("Could not extract file.");
}
//Upgrade
$option = array("http" => array("method" => "POST"));
// Proxy settings
$sysConf = System::getSystemConfiguration();
if (isset($sysConf['proxy_host'])) {
if ($sysConf['proxy_host'] != '') {
if (!is_array($option['http'])) {
$option['http'] = array();
}
$option['http']['request_fulluri'] = true;
$option['http']['proxy'] = 'tcp://' . $sysConf['proxy_host'] . ($sysConf['proxy_port'] != '' ? ':' . $sysConf['proxy_port'] : '');
if ($sysConf['proxy_user'] != '') {
if (!isset($option['http']['header'])) {
$option['http']['header'] = '';
}
$option['http']['header'] .= 'Proxy-Authorization: Basic ' . base64_encode($sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : ''));
}
}
}
$context = stream_context_create($option);
///////
$fileData = @fopen(EnterpriseUtils::getUrlServerName() . "/sys" . SYS_SYS . "/" . SYS_LANG . "/" . SYS_SKIN . "/enterprise/services/processMakerUpgrade", "rb", false, $context);
if ($fileData === false) {
throw new Exception("Could not open services url.");
}
$resultAux = G::json_decode(stream_get_contents($fileData));
if ($resultAux->status == "OK") {
$result["status"] = $resultAux->status;
//OK
$result["message"] = $resultAux->message;
} else {
throw new Exception($resultAux->message);
}
} catch (Exception $e) {
$result["message"] = $e->getMessage();
$status = 0;
}
if ($status == 0) {
$result["status"] = "ERROR";
}
return $result;
}
开发者ID:emildev35,项目名称:processmaker,代码行数:56,代码来源:processMakerAjax.php
示例7: expand
public static function expand($path)
{
$path = realpath($path);
$dir = dirname($path);
#print ">> $path\n";
$arch = new Archive_Tar($path, true);
$arch->setErrorHandling(PEAR_ERROR_PRINT);
if (false === $arch->extract($dir)) {
throw new Pfw_Exception_Script(Pfw_Exception_Script::E_ARCHIVE_UNKNOWN);
}
}
开发者ID:seansitter,项目名称:picnicphp,代码行数:11,代码来源:Archive.php
示例8: __construct
/**
* @param string $tar - path to tar file
*/
public function __construct($_tar)
{
$tar = new Archive_Tar($_tar);
$this->package_xml = $tar->extractInString('package.xml');
unset($tar);
$this->parse_package();
$files = $this->files();
// $xml = simplexml_load_string(str_replace('xmlns=', 'xmlns:default=', $this->package_xml));
// $namespaces = $xml->getNamespaces(true);
// $xml->registerXPathNamespace('default', 'default');
}
开发者ID:scottdavis,项目名称:pearfarm_channel_server,代码行数:14,代码来源:package_extractor.php
示例9: getArchive
protected function getArchive()
{
$obj = new Archive_Tar($this->getBackupFile());
if (!is_file($this->getBackupFile())) {
$files = array();
if (!$obj->create($files)) {
echo "can't create archive";
}
}
return $obj;
}
开发者ID:ngocanh,项目名称:pimcore,代码行数:11,代码来源:Backup.php
示例10: generateTarByPluginDir
public static function generateTarByPluginDir(array $info, $filename, $input, $output)
{
$timeLimit = ini_get('max_execution_time');
set_time_limit(0);
require_once 'Archive/Tar.php';
$tar = new Archive_Tar($output . '/' . $filename, true);
foreach ($info['filelist'] as $file => $data) {
$tar->addString($info['name'] . '-' . $info['version'] . '/' . $file, file_get_contents($input . '/' . $file));
}
$tar->addString('package.xml', file_get_contents($input . '/package.xml'));
set_time_limit($timeLimit);
}
开发者ID:balibali,项目名称:opPluginChannelServerPlugin,代码行数:12,代码来源:opPluginChannelServerToolkit.class.php
示例11: archive_extract
function archive_extract($path, $archive_dir, $config = array())
{
$result = FALSE;
if (class_exists('Archive_Tar')) {
if (file_safe(path_concat($archive_dir, 'file.txt'), $config)) {
$tar = new Archive_Tar($path);
$tar->extract($archive_dir);
$result = file_exists($archive_dir);
}
}
return $result;
}
开发者ID:Cinemacloud,项目名称:angular-moviemasher,代码行数:12,代码来源:archiveutils.php
示例12: extract_archive
function extract_archive($path, $archive_dir)
{
$result = FALSE;
if (class_exists('Archive_Tar')) {
if (safe_path($archive_dir)) {
$tar = new Archive_Tar($path);
$tar->extract(dirname($archive_dir));
$result = file_exists($archive_dir);
}
}
return $result;
}
开发者ID:ronniebrito,项目名称:moodle_moviemasher,代码行数:12,代码来源:archiveutils.php
示例13: installFromFile
public function installFromFile($file)
{
require_once "/var/www/localhost/htdocs/papyrine/libraries/PEAR.php";
require_once "/var/www/localhost/htdocs/papyrine/libraries/Archive_Tar.php";
$tar = new Archive_Tar($file, 'bz2');
$about = $tar->extractInString("about.xml");
$xml = simplexml_load_string($about);
$dir = "/var/www/localhost/htdocs/papyrine/data/plugins/tmp/" . $xml->id . "/";
if (!is_dir($dir)) {
$tar->extract($dir);
}
$this->installFromDirectory($dir);
}
开发者ID:BackupTheBerlios,项目名称:papyrine-svn,代码行数:13,代码来源:PapyrinePluginManager.php
示例14: _untarIntoTemp
protected function _untarIntoTemp($path)
{
$original_dir = getcwd();
//create a temp file, turn it into a directory
$dir = tempnam('/tmp', 'mt2c');
unlink($dir);
mkdir($dir);
chdir($dir);
$tar = new Archive_Tar($path);
$tar->extract('.');
chdir($original_dir);
return $dir;
}
开发者ID:drAlberT,项目名称:magento-tar-to-connect,代码行数:13,代码来源:MagentoTarToConnectBaseTest.php
示例15: install
static function install($source, $filename)
{
$target = SIMPLE_EXT . substr($filename, 0, -3);
setup::out("{t}Download{/t}: " . $source . " ...");
if ($fz = gzopen($source, "r") and $fp = fopen($target, "w")) {
$i = 0;
while (!gzeof($fz)) {
$i++;
setup::out(".", false);
if ($i % 160 == 0) {
setup::out();
}
fwrite($fp, gzread($fz, 16384));
}
gzclose($fz);
fclose($fp);
} else {
sys_die("{t}Error{/t}: gzopen [2] " . $source);
}
setup::out();
if (!file_exists($target) or filesize($target) == 0 or filesize($target) % 10240 != 0) {
sys_die("{t}Error{/t}: file-check [3] Filesize: " . filesize($target) . " " . $target);
}
setup::out(sprintf("{t}Processing %s ...{/t}", basename($target)));
$tar_object = new Archive_Tar($target);
$tar_object->setErrorHandling(PEAR_ERROR_PRINT);
$tar_object->extract(SIMPLE_EXT);
$file_list = $tar_object->ListContent();
if (!is_array($file_list) or !isset($file_list[0]["filename"]) or !is_dir(SIMPLE_EXT . $file_list[0]["filename"])) {
sys_die("{t}Error{/t}: tar [4] " . $target);
}
self::update_modules_list();
$ext_folder = db_select_value("simple_sys_tree", "id", "anchor=@anchor@", array("anchor" => "extensions"));
foreach ($file_list as $file) {
sys_chmod(SIMPLE_EXT . $file["filename"]);
setup::out(sprintf("{t}Processing %s ...{/t}", SIMPLE_EXT . $file["filename"]));
if (basename($file["filename"]) == "install.php") {
setup::out("");
require SIMPLE_EXT . $file["filename"];
setup::out("");
}
if (basename($file["filename"]) == "readme.txt") {
$data = file_get_contents(SIMPLE_EXT . $file["filename"]);
setup::out(nl2br("\n" . q($data) . "\n"));
}
if (!empty($ext_folder) and basename($file["filename"]) == "folders.xml") {
setup::out(sprintf("{t}Processing %s ...{/t}", "folder structure"));
folders::create_default_folders(SIMPLE_EXT . $file["filename"], $ext_folder, false);
}
}
}
开发者ID:drognisep,项目名称:Simple-Groupware,代码行数:51,代码来源:extensions.php
示例16: extract
static function extract($target, $folder)
{
setup::out(sprintf("{t}Processing %s ...{/t}", basename($target)));
$tar_object = new Archive_Tar($target);
$tar_object->setErrorHandling(PEAR_ERROR_PRINT);
$tar_object->extract($folder);
$file_list = $tar_object->ListContent();
if (!is_array($file_list) or !isset($file_list[0]["filename"]) or !is_dir($folder . $file_list[0]["filename"])) {
sys_die("{t}Error{/t}: tar [3] " . $target);
}
foreach ($file_list as $file) {
sys_chmod($folder . $file["filename"]);
}
@unlink($target);
return $folder . $file_list[0]["filename"];
}
开发者ID:drognisep,项目名称:Simple-Groupware,代码行数:16,代码来源:updater.php
示例17: readPackageFile
public static function readPackageFile($file)
{
// Sanity
if (!file_exists($file) || !is_file($file) || strtolower(pathinfo($file, PATHINFO_EXTENSION)) != 'tar') {
throw new Engine_Package_Exception('File does not exist or is not a tar file');
}
self::_loadArchiveClass();
// Create archive object
$archive = new Archive_Tar($file);
// List files
$fileList = $archive->listContent();
if (empty($fileList)) {
throw new Engine_Package_Exception('Unable to open archive');
}
// Check for root package file
$rootPackageFile = null;
foreach ($fileList as $arFile) {
if ($arFile['filename'] == 'package.json') {
$rootPackageFile = $arFile['filename'];
break;
}
}
if (null === $rootPackageFile) {
throw new Engine_Package_Exception('Root package file not found.');
}
// Start building package stuff
$packageFileObject = new Engine_Package_Manifest();
$packageFileObject->fromString($archive->extractInString($rootPackageFile), 'json');
return $packageFileObject;
}
开发者ID:febryantosulistyo,项目名称:ClassicSocial,代码行数:30,代码来源:Archive.php
示例18: execute
/**
* 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;
}
开发者ID:adamfranco,项目名称:segue,代码行数:53,代码来源:export.act.php
示例19: execute
protected function execute($arguments = array(), $options = array())
{
$pluginName = $arguments['name'];
$packagePath = sfConfig::get('sf_plugins_dir') . '/' . $pluginName;
if (!is_readable($packagePath . '/package.xml')) {
throw new sfException(sprintf('Plugin "%s" dosen\'t have a definition file.', $pluginName));
}
$infoXml = simplexml_load_file($packagePath . '/package.xml');
$filename = sprintf('%s-%s.tgz', (string) $infoXml->name, (string) $infoXml->version->release);
$dirPath = sfConfig::get('sf_plugins_dir') . '/' . $pluginName;
$tar = new Archive_Tar($arguments['dir'] . '/' . $filename, true);
foreach ($infoXml->contents->dir->file as $file) {
$attributes = $file->attributes();
$name = (string) $attributes['name'];
$tar->addString($pluginName . '-' . (string) $infoXml->version->release . '/' . $name, file_get_contents($dirPath . '/' . $name));
}
$tar->addString('package.xml', file_get_contents($dirPath . '/package.xml'));
}
开发者ID:Kazuhiro-Murota,项目名称:OpenPNE3,代码行数:18,代码来源:opPluginArchiveTask.class.php
示例20: nc_tgz_create
function nc_tgz_create($archive_name, $file_name, $additional_path = '', $exclude_tag = NULL)
{
global $DOCUMENT_ROOT, $SUB_FOLDER;
@set_time_limit(0);
$path = $DOCUMENT_ROOT . $SUB_FOLDER . $additional_path;
if (SYSTEM_TAR) {
$exclude_tag_cmd = '';
if ($exclude_tag) {
$exclude_array_tmp = nc_exclude_tag_to_array($path, $exclude_tag);
$exclude_array = array();
foreach ($exclude_array_tmp as $item) {
$exclude_array[] = '--exclude=' . preg_quote(ltrim(substr($item, strlen($path)), '/'));
}
$exclude_tag_cmd = implode(' ', $exclude_array);
}
exec("cd {$path}; tar -zcf '{$archive_name}' {$exclude_tag_cmd} {$file_name} 2>&1", $output, $err_code);
if ($err_code) {
trigger_error("{$output['0']}", E_USER_WARNING);
return false;
}
return true;
} else {
$tar_object = new Archive_Tar($archive_name, "gz");
$tar_object->setErrorHandling(PEAR_ERROR_PRINT);
if ($exclude_tag) {
$exclude_array_tmp = nc_exclude_tag_to_array($path, $exclude_tag);
$exclude_array = array();
foreach ($exclude_array_tmp as $item) {
$exclude_array[] = ltrim(substr($item, strlen($path)), '/');
}
$tar_object->setIgnoreList($exclude_array);
}
chdir($path);
ob_start();
$file_name_array = explode(' ', $file_name);
$res = $tar_object->create($file_name_array);
if (!$res) {
ob_end_flush();
} else {
ob_end_clean();
}
return $res;
}
}
开发者ID:Blu2z,项目名称:implsk,代码行数:44,代码来源:tar.inc.php
注:本文中的Archive_Tar类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论