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


PHP Phar::isValidPharFilename方法代码示例

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


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

示例1: __construct

 /**
  * @param string $package path to package file
  */
 function __construct($package, \Pyrus\Package $parent)
 {
     $package = realpath($package);
     if (!$package) {
         throw new Phar\Exception('Phar package ' . $package . ' does not exist');
     }
     $pxml = false;
     $this->archive = $package;
     try {
         if (\Phar::isValidPharFilename($package, 1)) {
             $phar = new \Phar($package, \RecursiveDirectoryIterator::KEY_AS_FILENAME);
             $pxml = 'phar://' . $package . '/' . $phar->getMetaData();
         } else {
             $phar = new \PharData($package, \RecursiveDirectoryIterator::KEY_AS_FILENAME);
             if ($phar->getMetaData()) {
                 $pxml = 'phar://' . $package . '/' . $phar->getMetaData();
             }
         }
     } catch (\Exception $e) {
         throw new Phar\Exception('Could not open Phar archive ' . $package, $e);
     }
     $package = str_replace('\\', '/', $package);
     try {
         if ($pxml === false) {
             $info = pathinfo($package);
             $internal = $info['filename'];
             if (isset($phar[$internal . '/.xmlregistry'])) {
                 if ($phar instanceof \PharData) {
                     $iterate = new \PharData('phar://' . $package . '/' . $internal . '/.xmlregistry');
                 } else {
                     $iterate = new \Phar('phar://' . $package . '/' . $internal . '/.xmlregistry');
                 }
                 foreach (new \RecursiveIteratorIterator($iterate, \RecursiveIteratorIterator::LEAVES_ONLY) as $file) {
                     $filename = $file->getFileName();
                     // default to new package.xml
                     if (preg_match('@^(.+)\\-package.xml$@', $filename)) {
                         $pxml = $file->getPathName();
                         break;
                     }
                 }
             } else {
                 foreach (array('package2.xml', $internal . '/' . 'package2.xml', 'package.xml', $internal . '/' . 'package.xml') as $checkfile) {
                     if (isset($phar[$checkfile])) {
                         $this->_BCpackage = true;
                         $pxml = $phar[$checkfile]->getPathName();
                         break;
                     }
                 }
             }
         }
         if ($pxml === false) {
             throw new Phar\Exception('No package.xml in archive');
         }
     } catch (\Exception $e) {
         throw new Phar\Exception('Could not extract Phar archive ' . $package, $e);
     }
     parent::__construct(new \Pyrus\PackageFile($pxml, 'Pyrus\\PackageFile\\v2'), $parent);
 }
开发者ID:peopleplan,项目名称:Pyrus,代码行数:61,代码来源:Phar.php

示例2: __construct

 /**
  * Archive creator for phar, tar, tgz and zip archives.
  *
  * @param string path to primary archive
  * @param string|false stub or false to use default stub of phar archives
  * @param int one of Phar::TAR, Phar::PHAR, or Phar::ZIP
  * @param int if the archive can be compressed (phar and tar), one of Phar::GZ, Phar::BZ2 or Phar::NONE
  *            for no compression
  * @param array an array of arrays containing information on additional archives to create.  The indices are:
  *
  *               0. extension (tar/tgz/zip)
  *               1. format (Phar::TAR, Phar::ZIP, Phar::PHAR)
  *               2. compression (Phar::GZ, Phar::BZ2, Phar::NONE)
  */
 function __construct($path, $stub = false, $fileformat = Phar::TAR, $compression = Phar::GZ, array $others = null)
 {
     if (!class_exists('Phar')) {
         throw new \Pyrus\Developer\Creator\Exception('Phar extension is not available');
     }
     if (!Phar::canWrite() || !Phar::isValidPharFilename($path, true)) {
         $this->_classname = 'PharData';
     }
     $this->path = $path;
     $this->compression = $compression;
     $this->format = $fileformat;
     $this->others = $others;
     $this->stub = $stub;
 }
开发者ID:peopleplan,项目名称:Pyrus,代码行数:28,代码来源:Phar.php

示例3: DataTemplate

 /**
  * Searches for the files matching the template in the order of the
  * received languages. Once matched, the language is captured so that
  * template itself does not have to keep track of the language for which
  * it is defined.
  */
 function DataTemplate($path, $langs = array('en_US'))
 {
     foreach ($langs as $l) {
         if (file_exists("{$this->base}/{$l}/{$path}")) {
             $this->lang = $l;
             $this->filepath = Misc::realpath("{$this->base}/{$l}/{$path}");
             break;
         } elseif (class_exists('Phar') && Phar::isValidPharFilename("{$this->base}/{$l}.phar") && file_exists("phar://{$this->base}/{$l}.phar/{$path}")) {
             $this->lang = $l;
             $this->filepath = "phar://{$this->base}/{$l}.phar/{$path}";
             break;
         }
     }
 }
开发者ID:iHunt101,项目名称:phlite,代码行数:20,代码来源:DataTemplate.php

示例4: __construct

 /**
  * Archive creator for phar, tar, tgz and zip archives.
  *
  * @param string path to primary archive
  * @param string|false stub or false to use default stub of phar archives
  * @param int one of Phar::TAR, Phar::PHAR, or Phar::ZIP
  * @param int if the archive can be compressed (phar and tar), one of Phar::GZ, Phar::BZ2 or Phar::NONE
  *            for no compression
  * @param array an array of arrays containing information on additional archives to create.  The indices are:
  *
  *               0. extension (tar/tgz/zip)
  *               1. format (Phar::TAR, Phar::ZIP, Phar::PHAR)
  *               2. compression (Phar::GZ, Phar::BZ2, Phar::NONE)
  * @param string PKCS12 certificate to be used to sign the archive.  This must be a certificate issued
  *               by a certificate authority, self-signed certs will not be accepted by Pyrus
  * @param string passphrase, if any, for the PKCS12 certificate.
  */
 function __construct($path, $stub = false, $fileformat = \Phar::TAR, $compression = \Phar::GZ, array $others = null, $releaser = null, \PEAR2\Pyrus\Package $new = null, $pkcs12 = null, $passphrase = '')
 {
     if (!class_exists('Phar')) {
         throw new \PEAR2\Pyrus\Developer\Creator\Exception('Phar extension is not available');
     }
     if (!\Phar::canWrite() || !\Phar::isValidPharFilename($path, true)) {
         $this->_classname = 'PharData';
     }
     $this->path = $path;
     $this->compression = $compression;
     $this->format = $fileformat;
     $this->others = $others;
     $this->stub = $stub;
     if ($pkcs12 && !extension_loaded('openssl')) {
         throw new \PEAR2\Pyrus\Developer\Creator\Exception('Unable to use ' . 'OpenSSL signing of phars, enable the openssl PHP extension');
     }
     $this->pkcs12 = $pkcs12;
     $this->passphrase = $passphrase;
     if (null !== $this->pkcs12) {
         $cert = array();
         $pkcs = openssl_pkcs12_read(file_get_contents($this->pkcs12), $cert, $this->passphrase);
         if (!$pkcs) {
             throw new \PEAR2\Pyrus\Developer\Creator\Exception('Unable to process openssl key');
         }
         $private = openssl_pkey_get_private($cert['pkey']);
         if (!$private) {
             throw new \PEAR2\Pyrus\Developer\Creator\Exception('Unable to extract private openssl key');
         }
         $pub = openssl_pkey_get_public($cert['cert']);
         $info = openssl_x509_parse($cert['cert']);
         $details = openssl_pkey_get_details($pub);
         if (true !== openssl_x509_checkpurpose($cert['cert'], X509_PURPOSE_SSL_SERVER, \PEAR2\Pyrus\Channel\RemotePackage::authorities())) {
             throw new \PEAR2\Pyrus\Developer\Creator\Exception('releasing maintainer\'s certificate is invalid');
         }
         // now verify that this cert is in fact the releasing maintainer's certificate
         // by verifying that alternate name is the releaser's email address
         if (!isset($info['subject']) || !isset($info['subject']['emailAddress'])) {
             throw new \PEAR2\Pyrus\Developer\Creator\Exception('releasing maintainer\'s certificate does not contain' . ' an alternate name corresponding to the releaser\'s email address');
         }
         if ($info['subject']['emailAddress'] != $new->maintainer[$releaser]->email) {
             throw new \PEAR2\Pyrus\Developer\Creator\Exception('releasing maintainer\'s certificate ' . 'alternate name does not match the releaser\'s email address ' . $new->maintainer[$releaser]->email);
         }
         $pkey = '';
         openssl_pkey_export($private, $pkey);
         $this->x509cert = $cert['cert'];
         $this->publickey = $details['key'];
         $this->privatekey = $pkey;
     }
 }
开发者ID:rosstuck,项目名称:PEAR2_Pyrus,代码行数:66,代码来源:Phar.php

示例5: __construct

 /**
  * Create a new instance.
  *
  * @param ConfigurationValues $configuration The configuration.
  *
  * @param Filter              $filters       The filters.
  *
  * @param ComposerInformation $composer      The composer information.
  *
  * @throws \RuntimeException When the configured phar file name is invalid.
  */
 public function __construct(ConfigurationValues $configuration, Filter $filters, ComposerInformation $composer)
 {
     $pharFile = $configuration->get('phar');
     if (!\Phar::isValidPharFilename($pharFile)) {
         throw new \RuntimeException('Phar file name is invalid ' . $pharFile);
     }
     if (file_exists($pharFile)) {
         unlink($pharFile);
     }
     $this->composer = $composer;
     $this->configuration = $configuration;
     $this->filters = $filters;
     $this->phar = new Phar($pharFile, $filters);
     $this->phar->getPharchive()->setSignatureFlags(\Phar::MD5);
     $this->phar->getPharchive()->setMetadata(array('license' => file_get_contents(dirname($pharFile) . '/LICENSE')));
 }
开发者ID:cyberspectrum,项目名称:pharpiler,代码行数:27,代码来源:Project.php

示例6: isValidVideoPackage

 public function isValidVideoPackage($fn)
 {
     if (!Phar::isValidPharFilename($fn)) {
         return false;
     }
     $meta = $this->getVideoMetaFromPackage($fn);
     if ($meta && isset($meta['title'])) {
         if (isset($meta['resolutions']) && is_array($meta['resolutions']) && count($meta['resolutions'])) {
             return self::FINAL_PKG;
         } else {
             if (isset($meta['video_file']) && !empty($meta['video_file'])) {
                 return self::ORGIN_PKG;
             }
         }
     }
     return false;
 }
开发者ID:zhaoshengloveqingqing,项目名称:MediaStorageSystem,代码行数:17,代码来源:mediastore.php

示例7: show

 public function show()
 {
     $args = func_get_args();
     $id = array_shift($args);
     $path = implode('/', $args);
     $phar_path = $this->store->get($id);
     if (!$phar_path || !Phar::isValidPharFilename($phar_path)) {
         show_404();
         return;
     }
     $phar_path = realpath($phar_path);
     if (strpos($path, 'm3u8')) {
         header('Content-Type: application/x-mpegurl');
     }
     if (strpos($path, '.ts')) {
         header('Content-Type: video/mp2t');
     }
     $p = 'phar://' . $phar_path . '/' . $path;
     echo file_get_contents($p);
 }
开发者ID:zhaoshengloveqingqing,项目名称:MediaStorageSystem,代码行数:20,代码来源:media.php

示例8: var_dump

var_dump(Phar::isValidPharFilename('.phar/boo.tar', true));
var_dump(Phar::isValidPharFilename('.phar/boo.tar', false));
echo "\n.phar.tar\n";
var_dump(Phar::isValidPharFilename('.phar.tar'));
var_dump(Phar::isValidPharFilename('.phar.tar', true));
var_dump(Phar::isValidPharFilename('.phar.tar', false));
echo "\n.phar.phar\n";
var_dump(Phar::isValidPharFilename('.phar.phar'));
var_dump(Phar::isValidPharFilename('.phar.phar', true));
var_dump(Phar::isValidPharFilename('.phar.phar', false));
echo "\n.phar.phart\n";
var_dump(Phar::isValidPharFilename('.phar.phart'));
var_dump(Phar::isValidPharFilename('.phar.phart', true));
var_dump(Phar::isValidPharFilename('.phar.phart', false));
echo "\nmy.pharmy\n";
var_dump(Phar::isValidPharFilename('my.pharmy'));
var_dump(Phar::isValidPharFilename('my.pharmy', true));
var_dump(Phar::isValidPharFilename('my.pharmy', false));
echo "\nphar.zip\n";
var_dump(Phar::isValidPharFilename('phar.zip'));
var_dump(Phar::isValidPharFilename('phar.zip', true));
var_dump(Phar::isValidPharFilename('phar.zip', false));
echo "\nphar.zip.phar\n";
var_dump(Phar::isValidPharFilename('phar.zip.phar'));
var_dump(Phar::isValidPharFilename('phar.zip.phar', true));
var_dump(Phar::isValidPharFilename('phar.zip.phar', false));
echo "\ndir.phar.php\n";
var_dump(Phar::isValidPharFilename('dir.phar.php'));
var_dump(Phar::isValidPharFilename('dir.phar.php', true));
var_dump(Phar::isValidPharFilename('dir.phar.php', false));
rmdir(__DIR__ . '/.phar');
开发者ID:sskblr,项目名称:hhvm,代码行数:31,代码来源:is_valid_phar_filename.php

示例9: allInfos

 /**
  * allInfos
  *
  * Scans the plugin folders for installed plugins. For each one, the
  * plugin.php file is included and the info array returned in added to
  * the list returned.
  *
  * Returns:
  * Information about all available plugins. The registry will have to be
  * queried to determine if the plugin is installed
  */
 static function allInfos()
 {
     foreach (glob(INCLUDE_DIR . 'plugins/*', GLOB_NOSORT | GLOB_BRACE) as $p) {
         $is_phar = false;
         if (substr($p, strlen($p) - 5) == '.phar' && class_exists('Phar') && Phar::isValidPharFilename($p)) {
             try {
                 // When public key is invalid, openssl throws a
                 // 'supplied key param cannot be coerced into a public key' warning
                 // and phar ignores sig verification.
                 // We need to protect from that by catching the warning
                 // Thanks, https://github.com/koto/phar-util
                 set_error_handler(array('self', 'throwException'));
                 $ph = new Phar($p);
                 restore_error_handler();
                 // Verify the signature
                 $ph->getSignature();
                 $p = 'phar://' . $p;
                 $is_phar = true;
             } catch (UnexpectedValueException $e) {
                 // Cannot find signature file
             } catch (RuntimeException $e) {
                 // Invalid signature file
             }
         }
         if (!is_file($p . '/plugin.php')) {
             // Invalid plugin -- must define "/plugin.php"
             continue;
         }
         // Cache the info into static::$plugin_info
         static::getInfoForPath($p, $is_phar);
     }
     return static::$plugin_info;
 }
开发者ID:KingsleyGU,项目名称:osticket,代码行数:44,代码来源:class.plugin.php

示例10: die

    die('Error: Cannot create Phar. "Phar.readonly" must be set to Off in php.ini' . PHP_EOL);
}
if ($argc < 3) {
    die('Usage : ' . $argv[0] . ' <src> <filename> [<stub>]' . PHP_EOL);
}
$src = $argv[1];
$file = $argv[2];
if (isset($argv[3])) {
    $stub = $argv[3];
} else {
    $stub = __DIR__ . '/../templates/PharStub.php';
}
$stub = realpath($stub);
$dir = realpath(dirname($file));
print 'Creating Phar file "' . $file . '"' . PHP_EOL . 'from directory "' . $src . '"' . PHP_EOL . 'based on stub "' . $stub . '"' . PHP_EOL . PHP_EOL;
if (!Phar::isValidPharFilename($file)) {
    die('Filename "' . $file . '" is not a valid Phar filename' . PHP_EOL);
}
if (!file_exists($dir)) {
    mkdir($dir);
    print 'Created target directory ' . $dir . PHP_EOL;
}
if (file_exists($file)) {
    unlink($file);
    print 'Deleted existing file ' . $file . PHP_EOL;
}
$phar = new Phar($file, 0, 'JobQueue.phar');
$phar->buildFromDirectory($src);
$phar->setStub(file_get_contents($stub));
print 'Wrote Phar file' . PHP_EOL . PHP_EOL;
print 'Done.' . PHP_EOL;
开发者ID:spriebsch,项目名称:JobQueue,代码行数:31,代码来源:createPhar.php


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