當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。