本文整理汇总了PHP中stream_context_get_options函数的典型用法代码示例。如果您正苦于以下问题:PHP stream_context_get_options函数的具体用法?PHP stream_context_get_options怎么用?PHP stream_context_get_options使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了stream_context_get_options函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: get_raw_chain
function get_raw_chain($host, $port = 443)
{
global $timeout;
$data = [];
$stream = stream_context_create(array("ssl" => array("capture_peer_cert" => true, "capture_peer_cert_chain" => true, "verify_peer" => false, "peer_name" => $host, "verify_peer_name" => false, "allow_self_signed" => true, "capture_session_meta" => true, "sni_enabled" => true)));
$read_stream = stream_socket_client("ssl://{$host}:{$port}", $errno, $errstr, $timeout, STREAM_CLIENT_CONNECT, $stream);
if ($read_stream === false) {
return false;
} else {
$context = stream_context_get_params($read_stream);
$context_meta = stream_context_get_options($read_stream)['ssl']['session_meta'];
$cert_data = openssl_x509_parse($context["options"]["ssl"]["peer_certificate"]);
$chain_data = $context["options"]["ssl"]["peer_certificate_chain"];
$chain_length = count($chain_data);
if (isset($chain_data) && $chain_length < 10) {
foreach ($chain_data as $key => $value) {
$data["chain"][$key] = $value;
}
} else {
$data["error"] = ["Chain too long."];
return $data;
}
}
return $data;
}
开发者ID:Lennie,项目名称:certificate-expiry-monitor,代码行数:25,代码来源:certs.php
示例2: getOptions
function getOptions()
{
if (empty($this->_options)) {
$this->_options->merge(stream_context_get_options($this->_resource));
}
return $this->_options;
}
开发者ID:Kinetical,项目名称:Kinesis,代码行数:7,代码来源:Context.php
示例3: getIncomingStream
/**
* {@inheritDoc}
*/
public function getIncomingStream()
{
$options = stream_context_get_options($this->context);
$method = 'GET';
if (isset($options['http']['method'])) {
$method = $options['http']['method'];
}
$headers = [];
if (isset($options['http']['header'])) {
$headerLines = explode("\r\n", $options['http']['header']);
foreach ($headerLines as $headerLine) {
list($header, $value) = explode(': ', $headerLine, 2);
$headers[$header][] = $value;
}
}
$body = null;
if (isset($options['http']['content'])) {
$body = $options['http']['content'];
}
$protocolVersion = 1.1;
if (isset($options['http']['protocol_version'])) {
$protocolVersion = $options['http']['protocol_version'];
}
$request = new Request($method, $this->path, $headers, $body, $protocolVersion);
return \GuzzleHttp\Psr7\stream_for(\GuzzleHttp\Psr7\str($request));
}
开发者ID:cvo-technologies,项目名称:stream-emulation,代码行数:29,代码来源:HttpEmulator.php
示例4: stream_open
public function stream_open($path, $mode, $options, &$opened_path)
{
$context = stream_context_get_options($this->context);
$this->state = $context['nativesmb']['state'];
$this->handle = $context['nativesmb']['handle'];
return true;
}
开发者ID:isklv,项目名称:smb-bundle,代码行数:7,代码来源:NativeStream.php
示例5: __construct
/**
* {@inheritDoc}
*/
public function __construct()
{
$defaults = stream_context_get_options(stream_context_get_default());
$this->adapter = $defaults[Filesystem::PROTOCOL]['adapter'];
$this->logger = $defaults[Filesystem::PROTOCOL]['logger'];
$this->logger->debug(__METHOD__);
}
开发者ID:dspacelabs,项目名称:filesystem,代码行数:10,代码来源:StreamWrapper.php
示例6: applyInitPathHook
public static function applyInitPathHook($url, $context = 'core')
{
$params = [];
$parts = AJXP_Utils::safeParseUrl($url);
if (!($params = self::getLocalParams(self::CACHE_KEY . $url))) {
// Nothing in cache
$repositoryId = $parts["host"];
$repository = ConfService::getRepositoryById($parts["host"]);
if ($repository == null) {
throw new \Exception("Cannot find repository");
}
$configHost = $repository->getOption('HOST');
$configPath = $repository->getOption('PATH');
$params['path'] = $parts['path'];
$params['basepath'] = $configPath;
$params['itemname'] = basename($params['path']);
// Special case for root dir
if (empty($params['path']) || $params['path'] == '/') {
$params['path'] = '/';
}
$params['path'] = dirname($params['path']);
$params['fullpath'] = rtrim($params['path'], '/') . '/' . $params['itemname'];
$params['base_url'] = $configHost;
$params['keybase'] = $repositoryId . $params['fullpath'];
$params['key'] = md5($params['keybase']);
self::addLocalParams(self::CACHE_KEY . $url, $params);
}
$repoData = self::actualRepositoryWrapperData($parts["host"]);
$repoProtocol = $repoData['protocol'];
$default = stream_context_get_options(stream_context_get_default());
$default[$repoProtocol]['path'] = $params;
$default[$repoProtocol]['client']->setDefaultUrl($configHost);
stream_context_set_default($default);
}
开发者ID:Nanomani,项目名称:pydio-core,代码行数:34,代码来源:PathWrapper.php
示例7: checkoutExistingSocket
private function checkoutExistingSocket($uri, $options)
{
if (empty($this->sockets[$uri])) {
return null;
}
$needsRebind = false;
foreach ($this->sockets[$uri] as $socketId => $poolStruct) {
if (!$poolStruct->isAvailable) {
continue;
} elseif ($this->isSocketDead($poolStruct->resource)) {
unset($this->sockets[$uri][$socketId]);
} elseif (($bindToIp = @stream_context_get_options($poolStruct->resource)['socket']['bindto']) && $bindToIp == $options[self::OP_BINDTO]) {
$poolStruct->isAvailable = false;
$this->reactor->disable($poolStruct->idleWatcher);
return $poolStruct->resource;
} elseif ($bindToIp) {
$needsRebind = true;
} else {
$poolStruct->isAvailable = false;
$this->reactor->disable($poolStruct->idleWatcher);
return $poolStruct->resource;
}
}
$this->needsRebind = $needsRebind;
return null;
}
开发者ID:lt,项目名称:artax,代码行数:26,代码来源:SocketPool.php
示例8: stream_open
function stream_open($path, $mode, $options, &$opened_path)
{
if ($this->context) {
print_r(stream_context_get_options($this->context));
}
return false;
}
开发者ID:badlamer,项目名称:hhvm,代码行数:7,代码来源:bug54440.php
示例9: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->rfs = new RemoteFilesystem($this->getIO());
$output->write('Checking platform settings: ');
$this->outputResult($output, $this->checkPlatform());
$output->write('Checking http connectivity: ');
$this->outputResult($output, $this->checkHttp());
$opts = stream_context_get_options(StreamContextFactory::getContext());
if (!empty($opts['http']['proxy'])) {
$output->write('Checking HTTP proxy: ');
$this->outputResult($output, $this->checkHttpProxy());
$output->write('Checking HTTPS proxy support for request_fulluri: ');
$this->outputResult($output, $this->checkHttpsProxyFullUriRequestParam());
}
$composer = $this->getComposer(false);
if ($composer) {
$output->write('Checking composer.json: ');
$this->outputResult($output, $this->checkComposerSchema());
}
if ($composer) {
$config = $composer->getConfig();
} else {
$config = Factory::createConfig();
}
if ($oauth = $config->get('github-oauth')) {
foreach ($oauth as $domain => $token) {
$output->write('Checking ' . $domain . ' oauth access: ');
$this->outputResult($output, $this->checkGithubOauth($domain, $token));
}
}
$output->write('Checking composer version: ');
$this->outputResult($output, $this->checkVersion());
return $this->failures;
}
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:34,代码来源:DiagnoseCommand.php
示例10: create
/**
* Creates a stream context based on the provided configuration.
*
* @param ConfigInterface $config The configuration.
*
* @return resource A stream context based on the provided configuration.
*/
public function create(ConfigInterface $config)
{
$options = array();
$headers = array();
$proxy = $config->get('proxy');
if (is_array($proxy)) {
$options = array('http' => array('proxy' => $proxy['proxy_host'] . ':' . $proxy['proxy_port']));
if (isset($proxy['proxy_login']) && isset($proxy['proxy_password'])) {
// Support for proxy authentication is untested. The current implementation is based on
// http://php.net/manual/en/function.stream-context-create.php#74431.
$headers[] = 'Proxy-Authorization: Basic ' . base64_encode($proxy['proxy_login'] . ':' . $proxy['proxy_password']);
}
}
$soapOptions = $config->get('soapClientOptions');
if ((!isset($soapOptions['authentication']) || $soapOptions['authentication'] === SOAP_AUTHENTICATION_BASIC) && isset($soapOptions['login']) && isset($soapOptions['password'])) {
$headers[] = 'Authorization: Basic ' . base64_encode($soapOptions['login'] . ':' . $soapOptions['password']);
}
if (count($headers) > 0) {
$options['http']['header'] = $headers;
}
// If we already created a stream context, make sure we use the same options.
if (isset($soapOptions['stream_context'])) {
$options = array_merge($options, stream_context_get_options($soapOptions['stream_context']));
}
return stream_context_create($options);
}
开发者ID:parabolicinteractive,项目名称:wsdl2phpgenerator,代码行数:33,代码来源:StreamContextFactory.php
示例11: testStreamContext
public function testStreamContext()
{
$context = stream_context_get_options($this->context)['swiftfs'];
$this->assertNotEmpty($context['token']);
$this->assertNotEmpty($context['swift_endpoint']);
$this->assertEquals(self::FTYPE, $context['content_type']);
}
开发者ID:ktroach,项目名称:openstack-sdk-php,代码行数:7,代码来源:StreamWrapperFSTest.php
示例12: php_compat_file_get_contents
/**
* Replace file_get_contents()
*
* @category PHP
* @package PHP_Compat
* @license LGPL - http://www.gnu.org/licenses/lgpl.html
* @copyright 2004-2007 Aidan Lister <[email protected]>, Arpad Ray <[email protected]>
* @link http://php.net/function.file_get_contents
* @author Aidan Lister <[email protected]>
* @author Arpad Ray <[email protected]>
* @version $Revision: 280045 $
* @internal resource_context is only supported for PHP 4.3.0+ (stream_context_get_options)
* @since PHP 4.3.0
* @require PHP 4.0.0 (user_error)
*/
function php_compat_file_get_contents($filename, $incpath = false, $resource_context = null, $offset = -1, $maxlen = -1)
{
if (is_resource($resource_context) && function_exists('stream_context_get_options')) {
$opts = stream_context_get_options($resource_context);
}
$colon_pos = strpos($filename, '://');
$wrapper = $colon_pos === false ? 'file' : substr($filename, 0, $colon_pos);
$opts = empty($opts) || empty($opts[$wrapper]) ? array() : $opts[$wrapper];
$data = false;
switch ($wrapper) {
case 'http':
$max_redirects = isset($opts[$wrapper]['max_redirects']) ? $opts[$proto]['max_redirects'] : PHP_COMPAT_FILE_GET_CONTENTS_MAX_REDIRECTS;
for ($i = 0; $i < $max_redirects; $i++) {
$data = php_compat_http_get_contents_helper($filename, $opts);
if (is_array($contents)) {
// redirected
$filename = rtrim($contents[1]);
$data = '';
continue;
}
break 2;
}
user_error('redirect limit exceeded', E_USER_WARNING);
return;
case 'ftp':
case 'https':
case 'ftps':
case 'socket':
// tbc
}
if (false === $data) {
if (is_resource($resource_context) && version_compare(PHP_VERSION, '4.3.0', 'ge')) {
$fh = fopen($filename, 'rb', $incpath, $resource_context);
} else {
$fh = fopen($filename, 'rb', $incpath);
}
if (false === $fh) {
user_error('failed to open stream: No such file or directory', E_USER_WARNING);
return false;
}
clearstatcache();
if ($fsize = @filesize($filename)) {
$data = fread($fh, $fsize);
} else {
$data = '';
while (!feof($fh)) {
$data .= fread($fh, 8192);
}
}
fclose($fh);
}
if ($offset != -1) {
$data = substr($data, $offset);
}
if ($maxlen != -1) {
$data = substr($data, 0, $maxlen);
}
return $data;
}
开发者ID:manishkhanchandani,项目名称:mkgxy,代码行数:74,代码来源:file_get_contents_helper.php
示例13: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$composer = $this->getComposer(false);
if ($composer) {
$commandEvent = new CommandEvent(PluginEvents::COMMAND, 'diagnose', $input, $output);
$composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
$this->getIO()->write('Checking composer.json: ', false);
$this->outputResult($this->checkComposerSchema());
}
if ($composer) {
$config = $composer->getConfig();
} else {
$config = Factory::createConfig();
}
$this->rfs = new RemoteFilesystem($this->getIO(), $config);
$this->process = new ProcessExecutor($this->getIO());
$this->getIO()->write('Checking platform settings: ', false);
$this->outputResult($this->checkPlatform());
$this->getIO()->write('Checking git settings: ', false);
$this->outputResult($this->checkGit());
$this->getIO()->write('Checking http connectivity: ', false);
$this->outputResult($this->checkHttp());
$opts = stream_context_get_options(StreamContextFactory::getContext('http://example.org'));
if (!empty($opts['http']['proxy'])) {
$this->getIO()->write('Checking HTTP proxy: ', false);
$this->outputResult($this->checkHttpProxy());
$this->getIO()->write('Checking HTTP proxy support for request_fulluri: ', false);
$this->outputResult($this->checkHttpProxyFullUriRequestParam());
$this->getIO()->write('Checking HTTPS proxy support for request_fulluri: ', false);
$this->outputResult($this->checkHttpsProxyFullUriRequestParam());
}
if ($oauth = $config->get('github-oauth')) {
foreach ($oauth as $domain => $token) {
$this->getIO()->write('Checking ' . $domain . ' oauth access: ', false);
$this->outputResult($this->checkGithubOauth($domain, $token));
}
} else {
$this->getIO()->write('Checking github.com rate limit: ', false);
try {
$rate = $this->getGithubRateLimit('github.com');
$this->outputResult(true);
if (10 > $rate['remaining']) {
$this->getIO()->write('<warning>WARNING</warning>');
$this->getIO()->write(sprintf('<comment>Github has a rate limit on their API. ' . 'You currently have <options=bold>%u</options=bold> ' . 'out of <options=bold>%u</options=bold> requests left.' . PHP_EOL . 'See https://developer.github.com/v3/#rate-limiting and also' . PHP_EOL . ' https://getcomposer.org/doc/articles/troubleshooting.md#api-rate-limit-and-oauth-tokens</comment>', $rate['remaining'], $rate['limit']));
}
} catch (\Exception $e) {
if ($e instanceof TransportException && $e->getCode() === 401) {
$this->outputResult('<comment>The oauth token for github.com seems invalid, run "composer config --global --unset github-oauth.github.com" to remove it</comment>');
} else {
$this->outputResult($e);
}
}
}
$this->getIO()->write('Checking disk free space: ', false);
$this->outputResult($this->checkDiskSpace($config));
$this->getIO()->write('Checking composer version: ', false);
$this->outputResult($this->checkVersion());
return $this->failures;
}
开发者ID:mothership-ec,项目名称:composer,代码行数:62,代码来源:DiagnoseCommand.php
示例14: getHttpOptionsFromContext
/**
* Returns HTTP options from current stream context.
*
* @see http://php.net/manual/en/context.http.php
* @return array HTTP options.
*/
protected static function getHttpOptionsFromContext($context)
{
if (!$context) {
return array();
}
$options = stream_context_get_options($context);
return !empty($options['http']) ? $options['http'] : array();
}
开发者ID:php-vcr,项目名称:php-vcr,代码行数:14,代码来源:StreamHelper.php
示例15: file_get_contents
public static function file_get_contents($url, $flags = null, $context = null, $offset = null, $maxlen = null)
{
// Not a URL? Do not handle.
if (strpos($url, '://') === false) {
return file_get_contents($url, $flags, $context, $offset, $maxlen);
}
if ($url != static::$url) {
self::$httpstatus = 404;
}
global $http_response_header_test;
if (self::$setHeaders && self::$httpstatus != 404) {
$http_response_header_test = array('HTTP/1.1 ' . self::$httpstatus);
} else {
$http_response_header_test = null;
}
if (self::$httpstatus != 200) {
return '';
}
// Get the from/to from the context
$from = 0;
$to = 0;
if (is_resource($context)) {
$contextOptions = stream_context_get_options($context);
if (isset($contextOptions['http']) && isset($contextOptions['http']['header'])) {
$headers = $contextOptions['http']['header'];
$headers = explode("\r\n", $headers);
foreach ($headers as $line) {
if (substr($line, 0, 13) != 'Range: bytes=') {
continue;
}
$line = substr($line, 13);
$line = trim($line, "\r\n=");
list($from, $to) = explode('-', $line);
}
}
}
if (empty($from) && empty($to)) {
return self::returnBytes(self::$returnSize);
}
$buffer = '';
if (empty($from)) {
$from = 0;
}
if ($from > self::$returnSize - 1) {
return '';
}
if ($from < 0) {
$from = 0;
}
if (empty($to)) {
$to = self::$returnSize - 1;
}
if ($to > self::$returnSize - 1) {
$to = self::$returnSize - 1;
}
$bytes = 1 + $to - $from;
return self::returnBytes($bytes);
}
开发者ID:Joal01,项目名称:fof,代码行数:58,代码来源:FakeFopen.php
示例16: get_CN
function get_CN($context)
{
$ary = stream_context_get_options($context);
assert($ary);
$cert = $ary['ssl']['peer_certificate'];
assert($cert);
$cert_ary = openssl_x509_parse($cert);
return $cert_ary['subject']['CN'];
}
开发者ID:gleamingthecube,项目名称:php,代码行数:9,代码来源:ext_openssl_tests_sni_001.php
示例17: stream_open
public function stream_open($path, $mode, $options, &$opened_path)
{
$options = stream_context_get_options($this->context);
if (!isset($options['guzzle']['stream'])) {
return false;
}
$this->mode = $mode;
$this->stream = $options['guzzle']['stream'];
return true;
}
开发者ID:mahersafadi,项目名称:joindin-api,代码行数:10,代码来源:GuzzleStreamWrapper.php
示例18: testContextOptionsAreSecureDefaults
public function testContextOptionsAreSecureDefaults()
{
$context = $this->mozCertData->getStreamContext();
$opts = stream_context_get_options($context);
$this->assertSame(true, $opts['ssl']['capture_peer_cert']);
$this->assertSame(true, $opts['ssl']['verify_peer']);
$this->assertSame(false, $opts['ssl']['allow_self_signed']);
$this->assertRegExp('/^.+\\.(pem|crt)$/', $opts['ssl']['cafile']);
$this->assertSame('mxr.mozilla.org', $opts['ssl']['CN_match']);
}
开发者ID:evandotpro,项目名称:sslurp,代码行数:10,代码来源:MozillaCertDataTest.php
示例19: createConnection
public function createConnection($socket)
{
$context = stream_context_get_options($socket);
if (array_key_exists('ssl', $context)) {
$conn = new SecureConnection($socket, $this->loop);
} else {
$conn = new Connection($socket, $this->loop);
}
return $conn;
}
开发者ID:Rudi9719,项目名称:stein-syn,代码行数:10,代码来源:Server.php
示例20: stream_open
public final function stream_open($path, $mode, $options, &$opened_path)
{
$params = stream_context_get_options($this->context);
if (!isset($params['mock']['object']) || !is_object($params['mock']['object']) || $mode != 'a+t') {
return false;
}
$opened_path = $path;
$this->mock =& $params['mock']['object'];
return true;
}
开发者ID:erebot,项目名称:plop,代码行数:10,代码来源:Socket.php
注:本文中的stream_context_get_options函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论