当前位置: 首页>>代码示例>>PHP>>正文


PHP Archive_Tar类代码示例

本文整理汇总了PHP中Archive_Tar的典型用法代码示例。如果您正苦于以下问题:PHP Archive_Tar类的具体用法?PHP Archive_Tar怎么用?PHP Archive_Tar使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Archive_Tar类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的Archive_Tar类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。