protected function setUp() { if (in_array('sfImageSource', stream_get_wrappers())) { stream_wrapper_unregister('sfImageSource'); } stream_wrapper_register('sfImageSource', 'sfImageSourceMock') or die('Failed to register protocol..'); }
/** * Write content to file * @param string $path * @param string $content */ protected function writeFile($path, $content) { if (!in_array(SafeStream::PROTOCOL, stream_get_wrappers())) { SafeStream::register(); } file_put_contents("safe://" . $path, $content); }
/** * Creates an ImportXMLReader drawing from the source provided * @param ImportSource $source * @param Config $config */ function __construct(ImportSource $source, Config $config = null) { $this->reader = new XMLReader(); if (!$config) { wfDeprecated(__METHOD__ . ' without a Config instance', '1.25'); $config = ConfigFactory::getDefaultInstance()->makeConfig('main'); } $this->config = $config; if (!in_array('uploadsource', stream_get_wrappers())) { stream_wrapper_register('uploadsource', 'UploadSourceAdapter'); } $id = UploadSourceAdapter::registerSource($source); if (defined('LIBXML_PARSEHUGE')) { $this->reader->open("uploadsource://{$id}", null, LIBXML_PARSEHUGE); } else { $this->reader->open("uploadsource://{$id}"); } // Default callbacks $this->setPageCallback(array($this, 'beforeImportPage')); $this->setRevisionCallback(array($this, "importRevision")); $this->setUploadCallback(array($this, 'importUpload')); $this->setLogItemCallback(array($this, 'importLogItem')); $this->setPageOutCallback(array($this, 'finishImportPage')); $this->importTitleFactory = new NaiveImportTitleFactory(); }
/** * Constructor * * @param string $streamWrapperClassName */ public function __construct($streamWrapperClassName) { $registered = in_array(self::WRAPPER, stream_get_wrappers()); if (!$registered) { stream_wrapper_register(self::WRAPPER, $streamWrapperClassName); } }
function __construct() { parent::__construct(); $gz = in_array('compress.zlib', stream_get_wrappers()) ? 'ok' : '(disabled; requires PHP zlib module)'; $bz2 = in_array('compress.bzip2', stream_get_wrappers()) ? 'ok' : '(disabled; requires PHP bzip2 module)'; $this->mDescription = <<<TEXT This script reads pages from an XML file as produced from Special:Export or dumpBackup.php, and saves them into the current wiki. Compressed XML files may be read directly: .gz {$gz} .bz2 {$bz2} .7z (if 7za executable is in PATH) Note that for very large data sets, importDump.php may be slow; there are alternate methods which can be much faster for full site restoration: <https://www.mediawiki.org/wiki/Manual:Importing_XML_dumps> TEXT; $this->stderr = fopen("php://stderr", "wt"); $this->addOption('report', 'Report position and speed after every n pages processed', false, true); $this->addOption('namespaces', 'Import only the pages from namespaces belonging to the list of ' . 'pipe-separated namespace names or namespace indexes', false, true); $this->addOption('dry-run', 'Parse dump without actually importing pages'); $this->addOption('debug', 'Output extra verbose debug information'); $this->addOption('uploads', 'Process file upload data if included (experimental)'); $this->addOption('no-updates', 'Disable link table updates. Is faster but leaves the wiki in an inconsistent state'); $this->addOption('image-base-path', 'Import files from a specified path', false, true); $this->addArg('file', 'Dump file to import [else use stdin]', false); }
public static function unregisterWrapper() { $existed = in_array('stack', stream_get_wrappers()); if ($existed) { stream_wrapper_unregister('stack'); } }
/** * unregisters vfsStreamWrapper */ public static function unregister() { if (in_array(vfsStream::SCHEME, stream_get_wrappers()) === true) { stream_wrapper_unregister(vfsStream::SCHEME); } self::$registered = false; }
public static function register() { if (in_array('phpspec', stream_get_wrappers())) { stream_wrapper_unregister('phpspec'); } stream_wrapper_register('phpspec', 'PhpSpec\\Loader\\StreamWrapper'); }
/** * HubUpdater constructor. * @param array|string $option * @throws \Exception */ public function __construct($option) { if (!in_array('https', stream_get_wrappers())) { throw new \Exception("No HTTPS Wrapper Exception"); } $this->setOptions($option); $this->options['save'] = rtrim($this->options['save'], '/'); if ($this->options['save'] !== '') { $this->options['save'] .= '/'; if (!file_exists($this->options['save'])) { mkdir($this->options['save']); } } $this->options['cache'] = $this->options['save'] . rtrim($this->options['cache'], '/'); if ($this->options['cache'] !== '') { $this->options['cache'] .= '/'; if (!file_exists($this->options['cache'])) { mkdir($this->options['cache']); } } $this->cachedInfo = new CacheOneFile($this->options['cache'] . $this->options['cacheFile'], $this->options['holdTime']); $additionalHeader = ''; if ($this->options['auth']) { $additionalHeader .= "Authorization: Basic " . base64_encode($this->options['auth']) . "\r\n"; } $caFilePath = CaBundle::getSystemCaRootBundlePath(); $this->streamContext = stream_context_create(array('http' => array('header' => "User-Agent: Awesome-Update-My-Self-" . $this->options['name'] . "\r\n" . "Accept: application/vnd.github.v3+json\r\n" . $additionalHeader), 'ssl' => array('cafile' => $caFilePath, 'verify_peer' => true))); $this->streamContext2 = stream_context_create(array('http' => array('header' => "User-Agent: Awesome-Update-My-Self-" . $this->options['name'] . "\r\n" . $additionalHeader), 'ssl' => array('cafile' => $caFilePath, 'verify_peer' => true))); $this->allRelease = $this->getRemoteInfo(); }
/** * TODO don't hardcode pool, use params * TODO check rados extensions are available * @param $params */ public function __construct($params) { $this->pool = 'owncloud'; if (!in_array("rados", stream_get_wrappers())) { stream_wrapper_register("rados", '\\OCA\\Rados\\RadosStream'); } }
/** * Register the GridFS stream wrapper. */ public static function register() { if (in_array('gridfs', stream_get_wrappers())) { stream_wrapper_unregister('gridfs'); } stream_wrapper_register('gridfs', get_called_class(), \STREAM_IS_URL); }
/** * Constructs CustomURIResolver from scheme prefix string (e.g. "arg" or "http"). * @param string $scheme Scheme prefix string */ function __construct($scheme) { $this->scheme = $scheme; if (!in_array($scheme, stream_get_wrappers())) { stream_wrapper_register($scheme, "StringStream") or die("Failed to register '" . $scheme . "'"); } }
function get_last_log($path = '') { global $config_logfile_maxsize, $neue_datei, $log_file_number, $config_log_zlib; $name = split_log_name(); $ext = $name['ext']; $name = $name['name']; $i = 0; $neue_datei = false; while (is_file($path . $name . $i . $ext) || is_file($path . $name . $i . $ext . '.gz')) { $i++; } $i--; @($log_size = filesize($path . $name . $i . $ext) / 1000); if (!is_dir(dirname($path . $name))) { return false; } if ($i == -1 || $config_logfile_maxsize !== false && $log_size >= $config_logfile_maxsize) { if ($config_log_zlib && in_array('compress.zlib', stream_get_wrappers())) { // compress old file $fh_compressed = fopen('compress.zlib://' . $path . $name . $i . $ext . '.gz', 'w'); fwrite($fh_compressed, file_get_contents($path . $name . $i . $ext)); fclose($fh_compressed); unlink($path . $name . $i . $ext); } $i++; $neue_log = fopen($path . $name . $i . $ext, 'w'); fclose($neue_log); $neue_datei = true; } $log_file_number = $i; return $path . $name . $i . $ext; }
/** * Register a stream wrapper according to its scheme and class. * Must called prior the opening of first stream under this scheme */ public static function registerStreamWrapper() { if (in_array(static::SCHEME, stream_get_wrappers())) { stream_wrapper_unregister(static::SCHEME); } stream_register_wrapper(static::SCHEME, get_called_class()); }
/** * Unregistering while not registers won't fail. * * @test */ public function unregisterWhenNotRegistered() { // Unregister possible registered URL wrapper. vfsStreamWrapper::unregister(); $this->assertNotContains(vfsStream::SCHEME, stream_get_wrappers()); vfsStreamWrapper::unregister(); }
/** * Install this stream wrapper. */ public static function install() { $wrappers = stream_get_wrappers(); if (!in_array('madmodel', $wrappers)) { stream_wrapper_register('madmodel', 'Mad_Model_Stream'); } }
public function testRegistersStreamWrapper() { StreamWrapper::register($this->client); $this->assertContains('s3', stream_get_wrappers()); // Ensure no error is thrown for registering twice StreamWrapper::register($this->client); }
static function registerStream() { if (!in_array("efile", stream_get_wrappers())) { stream_wrapper_register("efile", "ExtendedFileStream"); } }
/** * create a traditional php client */ public function __construct() { $wrappers = stream_get_wrappers(); if (in_array("https", $wrappers)) { $this->https_support = TRUE; } }
public function testRegisterWrapper() { StreamWrapper::registerWrapper('http'); $this->assertContains('http-emulation', stream_get_wrappers()); StreamWrapper::unregisterWrapper('http'); $this->assertNotContains('http-emulation', stream_get_wrappers()); }
private function sendGeoCodingRequest($value) { $url = 'https://maps.googleapis.com/maps/api/geocode/json'; $params = array('address' => $this->format($value, 'forMap'), 'sensor' => 'false'); $url = $url . '?' . http_build_query($params); $timeout = 25; if (function_exists('curl_init')) { $ch = curl_init($url); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); $content = curl_exec($ch); $status = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); if ($status == 200) { return $content; } } else { if (ini_get('allow_url_fopen')) { $wrappers = stream_get_wrappers(); if (in_array('https', $wrappers)) { $old_timeout = @ini_set('default_socket_timeout', $timeout); $response = @file_get_contents($url); @ini_set('default_socket_timeout', $old_timeout); return $response; } } } return null; }
public function register() { $this->registered = stream_get_wrappers(); foreach ($this->schemes as $scheme => $type) { $this->doRegister($scheme, $type); } }
public function testRegisterWithArgument() { $protocol = 'sftptest'; $this->assertTrue(Stream::register($protocol)); $this->assertContains($protocol, stream_get_wrappers()); $this->assertTrue(stream_wrapper_unregister($protocol)); }
public static function initialize() { if (in_array("file", stream_get_wrappers())) { stream_wrapper_unregister("file"); } stream_wrapper_register("file", __CLASS__); }
/** * Create a traditional php client. */ public function __construct() { $wrappers = stream_get_wrappers(); if (in_array('https', $wrappers)) { $this->httpsSupport = true; } }
protected function init(Container $container, ResourceLocator $locator) { $schemes = $container['config']->get('streams.schemes'); if (!$schemes) { return; } // Set locator to both streams. Stream::setLocator($locator); ReadOnlyStream::setLocator($locator); $registered = stream_get_wrappers(); foreach ($schemes as $scheme => $config) { if (isset($config['paths'])) { $locator->addPath($scheme, '', $config['paths']); } if (isset($config['prefixes'])) { foreach ($config['prefixes'] as $prefix => $paths) { $locator->addPath($scheme, $prefix, $paths); } } if (in_array($scheme, $registered)) { stream_wrapper_unregister($scheme); } $type = !empty($config['type']) ? $config['type'] : 'ReadOnlyStream'; if ($type[0] != '\\') { $type = '\\Grav\\Component\\Filesystem\\StreamWrapper\\' . $type; } if (!stream_wrapper_register($scheme, $type)) { throw new \InvalidArgumentException("Stream '{$type}' could not be initialized."); } } }
/** * * Constructor for HiEngine * * Sets up the stream protocol handler */ public function __construct() { $streams = stream_get_wrappers(); if (!in_array('hi', $streams)) { stream_wrapper_register("hi", "HiEngineParser") or die(_t("Failed to register HiEngine stream protocol")); } }
public function testUnregisteringTheStreamWrapper() { $result = StreamWrapper::unregister(); $this->assertTrue($result); $this->assertNotContains('webdav', stream_get_wrappers()); $this->assertNotContains('webdavs', stream_get_wrappers()); }
/** * Factory fuction which produces a configuration based on a policy and based * on local system resources. * * @param $policy array: * - enable_ssl: bool; default: TRUE * - verify_peer: bool; default: TRUE * - cafile: string, path to aggregated PEM; overrides any system defaults * - fallback_cafile: string, path to aggregated PEM; used on systems which lack default; set FALSE to disable * - fallback_ttl: int, seconds, the max age of the fallback cafile before it's regarded as stale; default: 5 years * @return CA_Config_Stream */ public static function probe($policy = array()) { if (isset($policy['enable_ssl']) && $policy['enable_ssl'] === FALSE) { return new CA_Config_Stream(FALSE, FALSE, NULL); } $sw = stream_get_wrappers(); if (!extension_loaded('openssl') || !in_array('https', $sw)) { return new CA_Config_Stream(FALSE, FALSE, NULL); } if (isset($policy['verify_peer']) && $policy['verify_peer'] === FALSE) { return new CA_Config_Stream(TRUE, FALSE, NULL); } if (isset($policy['cafile'])) { if (file_exists($policy['cafile']) && is_readable($policy['cafile'])) { return new CA_Config_Stream(TRUE, TRUE, $policy['cafile']); } else { throw new Exception("Certificate Authority file is missing. Please contact the system administrator. See also: " . $policy['cafile']); } } if (!isset($policy['fallback_ttl'])) { $policy['fallback_ttl'] = 5 * 364 * 24 * 60 * 60; } if (!isset($policy['fallback_cafile'])) { $policy['fallback_cafile'] = dirname(__FILE__) . '/cacert.pem'; } if (empty($policy['fallback_cafile']) || !file_exists($policy['fallback_cafile'])) { throw new Exception("Certificate Authority file is required for SSL. Please contact the system administrator."); } elseif (time() > filemtime($policy['fallback_cafile']) + $policy['fallback_ttl']) { throw new Exception("Certificate Authority file is too old. Please contact the system administrator. See also: " . $policy['fallback_cafile']); } else { return new CA_Config_Stream(TRUE, TRUE, $policy['fallback_cafile']); } }
public function setUp() { if (!array_search('string', stream_get_wrappers())) { stream_wrapper_register('string', 'phpillowToolStringStream'); } phpillowTestEnvironmentSetup::resetDatabase(array('database' => 'test')); }