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


PHP Archive_Tar::addString方法代码示例

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


在下文中一共展示了Archive_Tar::addString方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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

示例2: 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

示例3: 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

示例4: validate

 /**
  * Validate the preconditions required for this release task.
  *
  * @param array $options Additional options.
  *
  * @return array An empty array if all preconditions are met and a list of
  *               error messages otherwise.
  */
 public function validate($options)
 {
     $errors = array();
     $testpkg = Horde_Util::getTempFile();
     $archive = new Archive_Tar($testpkg, 'gz');
     $archive->addString('a', 'a');
     $archive->addString('b', 'b');
     $results = exec('tar tzvf ' . $testpkg . ' 2>&1');
     // MacOS tar doesn't error out, but only returns the first string (ending in 'a');
     if (strpos($results, 'lone zero block') !== false || substr($results, -1, 1) == 'a') {
         $errors[] = 'Broken Archive_Tar, upgrade first.';
     }
     $remote = new Horde_Pear_Remote();
     try {
         $exists = $remote->releaseExists($this->getComponent()->getName(), $this->getComponent()->getVersion());
         if ($exists) {
             $errors[] = sprintf('The remote server already has version "%s" for component "%s".', $this->getComponent()->getVersion(), $this->getComponent()->getName());
         }
     } catch (Horde_Http_Exception $e) {
         $errors[] = 'Failed accessing the remote PEAR server.';
     }
     try {
         Components_Helper_Version::validateReleaseStability($this->getComponent()->getVersion(), $this->getComponent()->getState('release'));
     } catch (Components_Exception $e) {
         $errors[] = $e->getMessage();
     }
     try {
         Components_Helper_Version::validateApiStability($this->getComponent()->getVersion(), $this->getComponent()->getState('api'));
     } catch (Components_Exception $e) {
         $errors[] = $e->getMessage();
     }
     if (empty($options['releaseserver'])) {
         $errors[] = 'The "releaseserver" option has no value. Where should the release be uploaded?';
     }
     if (empty($options['releasedir'])) {
         $errors[] = 'The "releasedir" option has no value. Where is the remote pirum install located?';
     }
     return $errors;
 }
开发者ID:raz0rsdge,项目名称:horde,代码行数:47,代码来源:Package.php

示例5: execute

 protected function execute($arguments = array(), $options = array())
 {
     // Remove E_STRICT and E_DEPRECATED from error_reporting
     error_reporting(error_reporting() & ~(E_STRICT | E_DEPRECATED));
     require_once 'Archive/Tar.php';
     $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));
     }
     $content = file_get_contents($packagePath . '/package.xml');
     $infoXml = opToolkit::loadXmlString($content, array('return' => 'SimpleXMLElement'));
     $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:te-koyama,项目名称:openpne,代码行数:22,代码来源:opPluginArchiveTask.class.php

示例6: make_tarball_and_emit

function make_tarball_and_emit($fobj, $file_list, $tarName, $compress = NULL)
{
    if ($compress == 'gz') {
        $tarName .= '.gz';
    } elseif ($compress == 'bz2') {
        $tarName .= '.bz2';
    }
    header("Content-type: application/tarball");
    header("Content-Disposition: attachment; filename={$tarName}");
    $tar = new Archive_Tar($tarName, $compress);
    file_put_contents("php://stdout", "Tarball Created ({$tarName})\n");
    foreach ($file_list as $name => $handle) {
        file_put_contents("php://stdout", "\t{$name} added to tarball\n");
        $tar->addString($name, stream_get_contents($handle)) or die("Error adding {$name} to tarball");
    }
    header("Content-Length: " . filesize($tarName));
    $f = fopen($tarName, 'r');
    while (!feof($f)) {
        fwrite($fobj, fgets($f));
    }
    fclose($f);
    unlink($tarName);
    //no caching... which should be done as we scale
}
开发者ID:shivamndave,项目名称:greenwharf-php-api,代码行数:24,代码来源:download.php

示例7: tempnam

    function db2app__process($values)
    {
        require_once 'Archive/Tar.php';
        $tarpath = tempnam('/tmp', strval($values['database_name']));
        //echo $tarpath;
        $compression = 'gz';
        $archive = new Archive_Tar($tarpath, $compression);
        $path = strval($values['database_name']);
        $archive->addString($path . '/.htaccess', '<FilesMatch "\\.ini$">
Deny from all
</FilesMatch>');
        $archive->addString($path . '/Web.config', file_get_contents(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'site_skeleton' . DIRECTORY_SEPARATOR . 'Web.config'));
        mysql_select_db($values['database_name'], db());
        $res = mysql_query('show tables', db());
        if (!$res) {
            trigger_error(mysql_error(db()), E_USER_ERROR);
        }
        $tables = array();
        while ($row = mysql_fetch_row($res)) {
            if ($row[0][0] == '_') {
                continue;
            }
            if (strpos($row[0], 'dataface_') === 0) {
                continue;
            }
            if (preg_match('/__history$/', $row[0])) {
                continue;
            }
            $tables[] = $row[0] . ' = "' . ucwords(str_replace('_', ' ', $row[0])) . '"';
        }
        $archive->addString($path . '/conf.ini', ';;Configuration settings for application
title="' . addslashes($values['database_name']) . '"

[_database]
	host="' . DB_HOST . '"
	name="' . addslashes($values['database_name']) . '"
	user="' . addslashes($values['mysql_user']) . '"
	password="' . addslashes($values['mysql_password']) . '"
	
[_tables]
' . implode("\n", $tables) . '
');
        $archive->addString($path . '/index.php', '<?php //Main Application access point
require_once "' . addslashes(dirname(__FILE__) . '/dataface-public-api.php') . '";
df_init(__FILE__, "' . addslashes(dirname($_SERVER['PHP_SELF'])) . '");
$app =& Dataface_Application::getInstance();
$app->display();
');
        switch ($values['install_type']) {
            case 'ftp_install':
                //echo 'here';
                require_once 'install/FTPExtractor.class.php';
                $extractor = new FTPExtractor($archive);
                $res = $extractor->connect($values['ftp_host'], $values['ftp_username'], $values['ftp_password']);
                if (PEAR::isError($res)) {
                    die($res->getMessage());
                }
                $res = $extractor->extract($values['ftp_path'], '/');
                //if ( PEAR::isError($res) ){
                //	die($res->getMessage());
                //}
                $context = array();
                if (PEAR::isError($res)) {
                    $context['result'] = 'Error: ' . $res->getMessage();
                } else {
                    $context = $res;
                }
                include 'install' . DIRECTORY_SEPARATOR . 'archive2app-results.inc.php';
                exit;
            default:
                // download_tarball
                //$tarpath =  $_FILES['archive']['tmp_name'];
                if ($compression == 'gz') {
                    $mimetype = 'application/x-gzip';
                } else {
                    $mimetype = 'application/x-tar';
                }
                header('Content-type: ' . $mimetype);
                header('Content-Disposition: attachment; filename="' . basename($tarpath) . '.tar.gz"');
                echo file_get_contents($tarpath);
                exit;
        }
        //return $tarpath;
    }
开发者ID:promoso,项目名称:HVAC,代码行数:84,代码来源:installer.php

示例8: addToArchive

 public function addToArchive(Archive_Tar $archive)
 {
     // Add package file
     $rval = $archive->addString('application' . DIRECTORY_SEPARATOR . 'packages' . DIRECTORY_SEPARATOR . $this->getKey() . '.json', $this->toString('json'));
     if ($archive->isError($rval)) {
         throw new Engine_Package_Manifest_Exception('Error in archive: ' . $rval->getMessage());
     }
     // Add internal structure
     if ($this->getAddDirectoryToArchive()) {
         $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());
         }
     } else {
         foreach ($this->getStructure() as $key => $value) {
             if ($this->_jitInstantiation && is_array($value) && !empty($value['type'])) {
                 $class = 'Engine_Package_Manifest_Entity_' . ucfirst($value['type']);
                 Engine_Loader::loadClass($class);
                 $value = new $class($value);
                 $value->setBasePath($this->getBasePath());
             } else {
                 if (!$value instanceof Engine_Package_Manifest_Entity_Abstract) {
                     throw new Engine_Package_Manifest_Exception('Not a package entity');
                 }
             }
             if (method_exists($value, 'setAddDirectoryToArchive')) {
                 $value->setAddDirectoryToArchive($this->getAddDirectoryToArchive());
             }
             $value->addToArchive($archive);
         }
     }
 }
开发者ID:febryantosulistyo,项目名称:ClassicSocial,代码行数:32,代码来源:Package.php

示例9: createPatch

function createPatch($updatecache = false)
{
    include_once "Lib/Archive/Tar.php";
    include_once 'Lib/Text/Diff.php';
    include_once 'Lib/Text/Diff/Renderer/unified.php';
    $start = microtime(true);
    $tar_object = new Archive_Tar(_bmoddir . "Data/Cache.tar");
    $tar_object->setErrorHandling(PEAR_ERROR_PRINT);
    $tardata = $tar_object->listContent();
    $working = checkDir2("");
    $fmerged = array_merge($tardata, $working);
    $tarf_db = reIndexByFile($tardata);
    $work_db = reIndexByFile($working);
    $workidx = indexFilename($working);
    $tar_idx = indexFilename($tardata);
    $f_names = array_unique(array_merge($workidx, $tar_idx));
    $out = "";
    foreach ($f_names as $file) {
        //speed optimization
        if ($tarf_db[$file] && $work_db[$file] && $tarf_db[$file]["mtime"] == $work_db[$file]["mtime"] && $updatecache != true) {
            continue;
        }
        if ($tarf_db[$file]) {
            $fts1 = $tarf_db[$file]["mtime"];
            $fdata = $tar_object->extractInString($file);
            $lines1 = explode("\n", $fdata);
            //$lines1 = file("Data/$file");
            if (substr($fdata, -1, 1) == "\n") {
                //$lines1[] = "";
            }
        } else {
            $fts1 = 0;
            $lines1 = array();
        }
        if ($work_db[$file]) {
            $fts2 = $work_db[$file]["mtime"];
            //$lines2 = file(_bpatdir."$file");
            $filetext = file_get_contents(_bmoddir . _bpatdir . "{$file}");
            $lines2 = explode("\n", $filetext);
        } else {
            $fts2 = 0;
            $lines2 = array();
            $filetext = "";
        }
        if (array_search($file, $workidx) === false && array_search($file, $tar_idx) !== false) {
            //delted file
            $out .= renderHeader($file, $fts1, $fts2);
            $out .= "@@ -0,0 @@\n\n";
            continue;
        }
        if (array_search($file, $workidx) !== false && array_search($file, $tar_idx) === false) {
            //added file
        }
        if ($filetext == $fdata) {
            continue;
        }
        $diff = new Text_Diff('auto', array($lines1, $lines2));
        $renderer = new Text_Diff_Renderer_unified();
        $render = $renderer->render($diff);
        if ($render != "") {
            $out .= renderHeader($file, $fts1, $fts2);
            //get ts to work!
            $out .= $render . "\n";
            if (substr($filetext, -1, 1) != "\n") {
                $out .= "\\ No newline at end of file\n\n";
            }
        }
    }
    if ($updatecache == true) {
        $tar_object->create(array());
        foreach ($f_names as $file) {
            $tar_object->addString($file, file_get_contents(_bmoddir . _bpatdir . "{$file}"));
        }
    }
    return array(microtime(true) - $start, $out, count($addlist));
}
开发者ID:antimatter15,项目名称:antimatter15,代码行数:76,代码来源:functions.php

示例10: createAction

 public function createAction()
 {
     // Require
     require_once 'PEAR.php';
     require_once 'Archive/Tar.php';
     // Form
     $this->view->form = $form = new Install_Form_Backup_Create();
     if (!$this->getRequest()->isPost()) {
         return;
     }
     if (!$form->isValid($this->getRequest()->getPost())) {
         return;
     }
     // Process
     set_time_limit(0);
     $values = $form->getValues();
     // Make filename
     $archiveFileName = $values['name'];
     $archiveFileName = preg_replace('/[^a-zA-Z0-9_.-]/', '', $archiveFileName);
     if (strtolower(substr($archiveFileName, -4)) != '.tar') {
         $archiveFileName .= '.tar';
     }
     $archiveFileName = $this->_outputPath . DIRECTORY_SEPARATOR . $archiveFileName;
     // setup paths
     $archiveSourcePath = APPLICATION_PATH;
     $tmpPath = APPLICATION_PATH . DIRECTORY_SEPARATOR . 'temporary';
     // Make archive
     $archive = new Archive_Tar($archiveFileName);
     // Add files
     $path = $archiveSourcePath;
     $files = array();
     $it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path), RecursiveIteratorIterator::SELF_FIRST);
     foreach ($it as $file) {
         $pathname = $file->getPathname();
         if ($file->isFile()) {
             if (substr($pathname, 0, strlen($tmpPath)) == $tmpPath) {
                 continue;
             } else {
                 $files[] = $pathname;
             }
         }
     }
     $ret = $archive->addModify($files, '', $path);
     if (PEAR::isError($ret)) {
         throw new Engine_Exception($ret->getMessage());
     }
     // Add temporary structure only
     /*
         $it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($tmpPath), RecursiveIteratorIterator::SELF_FIRST);
         foreach( $it as $file ) {
      if( $file->isFile() ) {
        continue;
      } else {
        $path = str_replace(APPLICATION_PATH . DIRECTORY_SEPARATOR . 'temporary' . DIRECTORY_SEPARATOR, '', $file->getPathname());
        $path .= DIRECTORY_SEPARATOR . 'index.html';
        $archive->addString($path, '');
      }
         }
     * 
     */
     // Export database
     $dbTempFile = $this->_createTemporaryFile();
     $db = Zend_Registry::get('Zend_Db');
     $export = Engine_Db_Export::factory($db, array());
     $this->_export = $export;
     $export->write($dbTempFile);
     $archive->addString('database.sql', file_get_contents($dbTempFile));
     unlink($dbTempFile);
     return $this->_helper->redirector->gotoRoute(array('action' => 'index'));
 }
开发者ID:robeendey,项目名称:ce,代码行数:70,代码来源:BackupController.php

示例11: implode

            if ($sections[0] == 'work') {
                $tar->addString('jxlib' . DS . implode(DS, $sections), file_get_contents($file));
            }
        }
        break;
    case 'bz2':
        require_once 'includes/Tar.php';
        $fileName = "jxlib.tar.bz2";
        $archiveSubPath .= DS . $fileName;
        $archiveName = $work_dir . $archiveSubPath;
        $tar = new Archive_Tar($archiveName, 'bz2');
        $includedPic = false;
        foreach ($filesToArchive as $file) {
            $sections = explode(DS, $file);
            if ($sections[0] == 'work') {
                $tar->addString('jxlib' . DS . implode(DS, $sections), file_get_contents($file));
            }
        }
        break;
}
/**
//remove the files from the server
foreach ($filesToArchive as $file){
	$sections = explode(DS,$file);
	if ($sections[0] == 'work'){
		unlink($file);
	}
}
*/
//setup the return object to send via JSON
$obj = new stdClass();
开发者ID:JxLib,项目名称:JxLib,代码行数:31,代码来源:builder.php

示例12: archiveNodes


//.........这里部分代码省略.........
         if ($ext == 'rar') {
             $atype = self::RAR;
         } else {
             if ($ext == 'tar' || preg_match('~\\.tar\\.(gz|bz2|xz|Z)$~', $aname)) {
                 $atype = self::TAR;
             } else {
                 if ($ext == 'gz') {
                     $atype = self::GZIP;
                 } else {
                     return false;
                 }
             }
         }
     }
     switch ($atype) {
         case self::ZIP:
             $zip = new \ZipArchive();
             $result = $zip->open($aname, \ZIPARCHIVE::CREATE);
             if ($result !== true) {
                 throw new \Exception('ZipArchive error: ' . $result);
             }
             foreach ($files as $localname => $filename) {
                 /*echo "added ".$filename.PHP_EOL;
                   echo number_format(filesize($filename)).PHP_EOL;
                   */
                 if (is_null($filename)) {
                     if ($zip->addEmptyDir($localname) === false) {
                         return false;
                     }
                 } else {
                     if ($zip->addFile($filename, $localname) === false) {
                         return false;
                     }
                 }
             }
             $zip->close();
             return count($files);
             break;
         case self::RAR:
             return false;
             break;
         case self::TAR:
             $compression = null;
             switch (strtolower(pathinfo($aname, PATHINFO_EXTENSION))) {
                 case 'gz':
                     $compression = 'gz';
                     break;
                 case 'bz2':
                     $compression = 'bz2';
                     break;
                 case 'xz':
                     $compression = 'lzma2';
                     break;
                 case 'Z':
                     $tar_aname = 'compress.lzw://' . $aname;
                     break;
             }
             if (isset($tar_aname)) {
                 $tar = new \Archive_Tar($tar_aname, $compression);
             } else {
                 $tar = new \Archive_Tar($aname, $compression);
             }
             foreach ($files as $localname => $filename) {
                 $remove_dir = dirname($filename);
                 $add_dir = dirname($localname);
                 /*echo "added ".$filename.PHP_EOL;
                   echo number_format(filesize($filename)).PHP_EOL;
                   */
                 if (is_null($filename)) {
                     if ($tar->addString($localname, "") === false) {
                         return false;
                     }
                 } else {
                     if ($tar->addModify($filename, $add_dir, $remove_dir) === false) {
                         return false;
                     }
                 }
             }
             $tar = null;
             return count($files);
             break;
         case self::GZIP:
             if (count($files) > 1) {
                 return false;
             }
             /*if ($localname != basename($aname, '.gz')) return false;
              */
             $filename = array_shift($files);
             if (is_null($filename)) {
                 return false;
             }
             // invalid list
             if (file_put_contents($aname, gzencode(file_get_contents($filename))) !== false) {
                 return 1;
             } else {
                 return false;
             }
             break;
     }
 }
开发者ID:Epo123,项目名称:UnifiedArchive,代码行数:101,代码来源:UnifiedArchive.php

示例13: usage

        usage("Could not create tar {$archive} in {$archive_dir}");
    }
    foreach ($existing as $l_mod => $file) {
        if (!array_key_exists($l_mod, $launchpad_modules)) {
            I2CE::raiseError("The module {$l_mod} has a .pot files but is not a module in the system -- skipping");
            continue;
        }
        if (!$tar->addModify($file, $l_mod, dirname($file))) {
            usage("Could not add {$file}");
        }
        unset($launchpad_modules[$l_mod]);
    }
    if (count($launchpad_modules) > 0) {
        I2CE::raiseError("The following:\n\t" . implode(",", array_keys($launchpad_modules)) . "\ndid not have an existing .po file.  Creating a blank one");
    }
    foreach ($launchpad_modules as $l_mod => $top_mod) {
        $po = loadPOT(getcwd() . DIRECTORY_SEPARATOR . $template_dir . DIRECTORY_SEPARATOR . $l_mod . DIRECTORY_SEPARATOR . $l_mod . '.pot');
        if (!is_array($po) || count($po) < 1) {
            //I2CE::raiseError("Problem with .pot for $l_mod.  Skipping");  no translations
            continue;
        }
        $cs = $po['']['comments'][''];
        array_unshift($cs, "{$locale} translation for " . $basename);
        $po['']['comments'][''] = $cs;
        $po = createPOT($top_mod, $l_mod, false, $po);
        if (!$tar->addString($l_mod . DIRECTORY_SEPARATOR . $locale . '.po', $po)) {
            I2CE::raiseError("Could not add untranslated {$l_mod}");
        }
    }
    I2CE::raiseError("Created {$archive} in {$archive_dir}");
}
开发者ID:apelon-ohie,项目名称:ihris-site,代码行数:31,代码来源:translate_create_po.php


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