本文整理汇总了PHP中stream_get_transports函数的典型用法代码示例。如果您正苦于以下问题:PHP stream_get_transports函数的具体用法?PHP stream_get_transports怎么用?PHP stream_get_transports使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了stream_get_transports函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkOpenSSLSupport
function checkOpenSSLSupport()
{
if (!in_array('ssl', stream_get_transports())) {
return FALSE;
}
return TRUE;
}
示例2: supportSSL
/**
* Detect SSL stream transport
* @return boolean|string If returns string has an problem, returns true if ok
*/
function supportSSL()
{
if (defined('SOCKET_SSL_STREAM')) {
return true;
}
if (function_exists('stream_get_transports')) {
/* PHP 5 */
$ok = in_array('ssl', stream_get_transports());
if ($ok) {
defined('SOCKET_SSL_STREAM', '1');
return true;
}
} else {
/* PHP 4 */
ob_start();
phpinfo(1);
$info = strtolower(ob_get_clean());
if (preg_match('/socket\\stransports/', $info) !== 0) {
if (preg_match('/(ssl[,]|ssl [,]|[,] ssl|[,]ssl)/', $info) !== 0) {
defined('SOCKET_SSL_STREAM', '1');
return true;
} else {
return 'No SSL stream support detected';
}
}
}
return 'Don\'t detected streams (finder error), no SSL stream support';
}
示例3: prepare
/**
* Setup archive directory and internal migrate data struct.
*
* @param array $environment
* Environment to migrate to, from NSPI acquia_agent_cloud_migration_environments()
* @return array $migration
*/
public function prepare($environment)
{
// Internal migration store is an array because objects cannot be stored
// by Drupal's Batch API.
$local_env = $this->checkEnv();
if ($local_env['error'] !== FALSE) {
return $local_env;
}
// Modify environment URL if SSL is available for use.
if (in_array('ssl', stream_get_transports(), TRUE) && !defined('ACQUIA_DEVELOPMENT_NOSSL')) {
$uri = parse_url($environment['url']);
if (isset($uri['host'])) {
$environment['url'] = $uri['host'];
}
$environment['url'] .= isset($uri['port']) ? ':' . $uri['port'] : '';
$environment['url'] .= isset($uri['path']) && isset($uri['host']) ? $uri['path'] : '';
$environment['url'] = 'https://' . $environment['url'];
}
$time = REQUEST_TIME;
$date = gmdate('Ymd_his', $time);
$migration = array('error' => FALSE, 'id' => uniqid() . '_' . $date, 'date' => $date, 'time' => $time, 'compression_ext' => $local_env['compression_ext'], 'request_params' => array('r' => Url::FromRoute('acquia_connector.settings', array(), array('absolute' => TRUE))->toString(), 'y' => 'sar', 'stage' => $environment['stage'], 'nonce' => $environment['nonce']), 'env' => $environment, 'no_data_tables' => array());
// Set up local storage of archive.
$this->destination($migration);
return $migration;
}
示例4: skip
public function skip()
{
$streams = stream_get_transports();
$this->skipIf(!in_array('ssl', $streams), 'SSL is not configured for your system. It is not possible to run this test');
$this->skipIf(!SWIFT_SSL_HOST, 'Cannot run test without an SSL enabled SMTP host to connect to (define ' . 'SWIFT_SSL_HOST in tests/acceptance.conf.php if you wish to run this test)');
parent::skip();
}
示例5: get
/**
* Get all enable transports.
*
* @return array
*/
public static function get()
{
static $_ = null;
if (null === $_) {
$_ = stream_get_transports();
}
return $_;
}
示例6: setUp
public function setUp()
{
// skip tests when this PHP has no SSL support
$transports = stream_get_transports();
if (!in_array('ssl', $transports)) {
$this->markTestSkipped('No SSL support available.');
}
parent::setUp();
}
示例7: validate
/**
* Validate data.
*
* This ensures that unix socket transport is supported by this system.
*
* @param string $data
* @return mixed True on success, else error message.
*/
public function validate($data)
{
if ($data === 'unixsocket') {
$supportedtransports = stream_get_transports();
if (!array_search('unix', $supportedtransports)) {
return get_string('errornounixsocketssupported', 'antivirus_clamav');
}
}
return true;
}
示例8: __construct
/**
* Constructor to initialize instance properties.
*
* @param int $port Port on which the daemon will listen or NULL
* to select a port automatically, defaults to NULL
* @param string $transport Socket transport for the daemon to use,
* defaults to 'tcp'
*
* @return void
*/
public function __construct($port = null, $transport = 'tcp')
{
if (in_array($transport, stream_get_transports())) {
$this->transport = $transport;
} else {
$this->transport = 'tcp';
}
$this->port = $port ? $port : $this->findPort();
$this->commands = array();
$this->input = array();
}
示例9: setUp
public function setUp()
{
$streams = stream_get_transports();
if (!in_array('ssl', $streams)) {
$this->markTestSkipped('SSL is not configured for your system. It is not possible to run this test');
}
if (!defined('SWIFT_SSL_HOST')) {
$this->markTestSkipped('Cannot run test without an SSL enabled SMTP host to connect to (define ' . 'SWIFT_SSL_HOST in tests/acceptance.conf.php if you wish to run this test)');
}
parent::setUp();
}
示例10: IsSupported
/**
* Check to make sure all the critical dependencies are available
*
* @return boolean
**/
public function IsSupported()
{
if (function_exists('curl_exec') && defined('CURL_VERSION_SSL')) {
return true;
} else {
if (in_array('ssl', stream_get_transports())) {
return true;
} else {
$this->SetError(GetLang('AuthorizeNetSSLNotAvailable'));
return false;
}
}
}
示例11: getSwiftMailerFromConfig
/**
* Returns an instance of Swift_Mailer based on the config.s
* @return \Swift_Mailer
*/
public function getSwiftMailerFromConfig()
{
$encryptionType = $this->getMailConfig('smtp_encryption');
// Workaround issue where smtp_encryption could == 1 in the past by
// checking it is a valid transport
if ($encryptionType && !in_array($encryptionType, stream_get_transports())) {
$encryptionType = null;
}
/** @var \Swift_SmtpTransport $transport */
$transport = \Swift_SmtpTransport::newInstance($this->getMailConfig('smtp_address'), $this->getMailConfig('smtp_port'), $encryptionType);
$transport->setUsername($this->getMailConfig('smtp_username'));
$transport->setPassword($this->getMailConfig('smtp_password'));
return \Swift_Mailer::newInstance($transport);
}
示例12: buildSmtpEncryptSelector
/**
* Render a selector element that allows to select the encryption method for SMTP
*
* @param array $params Field information to be rendered
*
* @return string The HTML selector
*/
public function buildSmtpEncryptSelector(array $params)
{
$extConf = GeneralUtility::removeDotsFromTS(unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['mailcopy']));
$transports = stream_get_transports();
if (empty($transports)) {
return '';
}
$markup = '<select class="valid" name="' . $params['fieldName'] . '" id=em-' . $params['propertyName'] . '">';
$active = (string) self::extract($extConf, explode('.', $params['propertyName']));
foreach ($transports as $transport) {
$markup .= '<option value="' . $transport . '"' . ($transport === $active ? ' selected="selected"' : '') . '>' . $transport . '</option>';
}
$markup .= '</select>';
return $markup;
}
示例13: __construct
public function __construct()
{
if (function_exists('fsockopen')) {
$this->socketExtension = true;
$this->xportlist = stream_get_transports();
if (in_array('ssl', $this->xportlist)) {
$this->sslAvailable = true;
} else {
if (in_array('ss', $this->xportlist)) {
array_push($this->xportlist, 'ssl');
$this->sslAvailable = true;
}
}
} else {
$this->setError("This class need 'Sockets' extension!");
}
}
示例14: establish
private function establish()
{
$unix = in_array("unix", \stream_get_transports(), true);
if ($unix) {
$promise = \Amp\Socket\connect("unix://{$this->path}.sock");
} else {
$promise = \Amp\pipe(\Amp\file\get($this->path), 'Amp\\Socket\\connect');
}
$promise->when(function ($e, $sock) {
if ($e) {
$this->failAll();
return;
}
$this->sock = $sock;
$this->writeWatcher = \Amp\onWritable($sock, $this->writer);
});
}
示例15: is_supported
/**
* Checks if minimum system requirements are met for vivvo_ga to function properly
*
* @param &string $missing If function returns false passed variable will hold info about missing component
* @return bool
*/
public static function is_supported(&$missing = null)
{
$missing = 'php';
if (version_compare(PHP_VERSION, '5.1.4', '>=') !== false) {
$missing = 'curl';
if (extension_loaded('curl')) {
return !($missing = false);
}
$missing = 'socket';
if (function_exists('stream_socket_client')) {
$missing = 'ssl';
if (in_array('ssl', stream_get_transports())) {
return !($missing = false);
}
}
}
return false;
}