@param string $url URL path to access to the file to read.

@return resource

@final since 1.1.0
511758
protected function getStreamContext($url)
    {
        $host = parse_url($url, PHP_URL_HOST);

        if (PHP_VERSION_ID < 50600) {
            $this->options['ssl']['CN_match'] = $host;
            $this->options['ssl']['SNI_server_name'] = $host;
        }

        return $this->getMergedStreamContext($url);
    }
1193931
private function buildUrl($url)
    {
        $url = $this->protocol . '://' . $url . '/';

        if ($this->date) {
            $url .= $this->date;
        } else {
            $url .= 'latest';
        }

        $url .= '?base=' . $this->base;

        if ($this->key) {
            $url .= '&access_key=' . $this->key;
        }

        if ($symbols = $this->symbols) {
            $url .= '&symbols=' . implode(',', $symbols);
        }

        return $url;
    }
219084
public function get($url) {
        // Ensure we have the allow_url_fopen directive enabled
        if (!$this->isSupported()) {
            $this->logger->error("allow_url_fopen is disabled.");
            throw new UnsupportedException('allow_url_fopen disabled.');
        }
        $this->logger->info("allow_url_fopen is enabled.");

        $context = stream_context_create(array(
            'http' => array(
                'user_agent'          => 'xsist10-PHP-client'
            ),
            'ssl' => array(
                'method'              => 'GET',
                'verify_peer'         => true,
                'verify_depth'        => 5,
                // Manually specify CA certificate store and CN_match requirement
                'cafile'              => __DIR__ . '/../../cacert.pem',
                'CN_match'            => 'www.haveibeenpwned.com',
                // Disabled to prevent CRIME/BEAST attacks
                // https://en.wikipedia.org/wiki/BEAST_attack#CRIME_and_BREACH_attacks
                'disable_compression' => true
            )
        ));
        
        return @file_get_contents($url, false, $context);
    }
347777
public static function getDomainFromURL($url)
	{
		$url = str_replace(self::getProtocolFromURL($url) . '://', '', $url);
		
		return explode('/', $url)[0];
	}
279701
private function getPath($url)
    {
        $url = trim($url);
        $parsed = $this->parseURL($url);
        if ($parsed !== false) {
            $this->url = $url;
            return $parsed['custom'];
        }
        return $url;
    }
976110
public function loadUrl($url)
    {
        // Fetch HTTP content using Guzzle
        $response = $this->client->get($url);

        return $this->loadHtml($response->getBody()->__toString(), $url);
    }
981514
public function parseUrl($url)
    {
        $scheme   = parse_url($url, PHP_URL_SCHEME);
        $domain   = parse_url($url, PHP_URL_HOST);
        $basename = pathinfo($url, PATHINFO_BASENAME);

        $parts = explode('.', $basename);

        if(count($parts) == 3)
        {
            $type  =  array_pop($parts);
            $format = array_pop($parts);
            $file   = array_pop($parts);
        }
        else
        {
            $type   = '*';
            $format = array_pop($parts);
            $file   = array_pop($parts);
        }

        $path = str_replace(array($scheme.'://', $scheme.':'), '', dirname($url));

        if (strpos($path, $domain.'/') === 0) {
            $path = substr($path, strlen($domain)+1);
        }

        $parts = explode('/', $path);

        $info = array(
            'type'    => $type,
            'domain'  => $domain,
            'package' => array_shift($parts),
            'path'    => implode('/', $parts),
            'file'    => $file,
            'format'  => $format ?: '*',
        );

        return $info;
    }
1031325
public function root($url = null)
    {
        if (!is_null($url) && true !== $url) {
            $this->root = $url;
            return $this;
        } elseif (!$this->root) {
            $file = $this->baseFile();
            if ($file && 0 !== strpos($this->url(), $file)) {
                $file = str_replace('\\', '/', dirname($file));
            }
            $this->root = rtrim($file, '/');
        }
        return true === $url ? $this->domain() . $this->root : $this->root;
    }
1039702
public function initURL($url)
    {
        $contents = file_get_contents($url);

        $lines = explode("\n", $contents);

        return $this->initLines($lines);
    }
817822
protected function getImageByUrl($url)
    {
        $cacheFolder = MUNEE_CACHE . DS . 'placeholders';
        Utils::createDir($cacheFolder);
        $requestOptions = serialize($this->request->options);
        $originalFile = array_shift($this->request->files);

        $fileName = $cacheFolder . DS . md5($url) . '-' . md5($requestOptions . $originalFile);
        if (! file_exists($fileName)) {
            file_put_contents($fileName, file_get_contents($url));
        }

        return $fileName;
    }
408880
protected function _getAssetFile($url)
    {
        $parts = explode('/', ltrim($url, '/'));
        $pluginPart = [];
        for ($i = 0; $i < 2; $i++) {
            if (!isset($parts[$i])) {
                break;
            }
            $pluginPart[] = Inflector::camelize($parts[$i]);
            $plugin = implode('/', $pluginPart);
            if ($plugin && Plugin::isLoaded($plugin)) {
                $parts = array_slice($parts, $i + 1);
                $fileFragment = implode(DIRECTORY_SEPARATOR, $parts);
                $pluginWebroot = Plugin::path($plugin) . 'webroot' . DIRECTORY_SEPARATOR;

                return $pluginWebroot . $fileFragment;
            }
        }
    }
657345
public function get(string $url): string
    {
        $ch = curl_init($url);

        if ( ! ini_get('open_basedir')) {
            curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
        }

        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_VERBOSE, true);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36');
        curl_setopt($ch, CURLOPT_URL, $url);

        $content = curl_exec($ch);
        if ($content === false) {
            // there was a problem
            $error = curl_error($ch);
            throw new CurlException('Error retrieving "'.$url.'" ('.$error.')');
        }

        return $content;
    }
488319
protected function _getRemoteData($url)
    {
        ini_set('user_agent', $this->_getUserAgent());

        switch ($this->_getUpdateMethod()) {
            case self::UPDATE_LOCAL:
                $file = file_get_contents($url);

                if ($file !== false) {
                    return $file;
                } else {
                    throw new Exception('Cannot open the local file');
                }
            case self::UPDATE_FOPEN:
                // include proxy settings in the file_get_contents() call
                $context = $this->_getStreamContext();
                $file = file_get_contents($url, false, $context);

                if ($file !== false) {
                    return $file;
                } // else try with the next possibility (break omitted)
            case self::UPDATE_FSOCKOPEN:
                $remote_url = parse_url($url);
                $remote_handler = fsockopen($remote_url['host'], 80, $c, $e, $this->timeout);

                if ($remote_handler) {
                    stream_set_timeout($remote_handler, $this->timeout);

                    if (isset($remote_url['query'])) {
                        $remote_url['path'] .= '?' . $remote_url['query'];
                    }

                    $out = sprintf(
                        self::REQUEST_HEADERS,
                        $remote_url['path'],
                        $remote_url['host'],
                        $this->_getUserAgent()
                    );

                    fwrite($remote_handler, $out);

                    $response = fgets($remote_handler);
                    if (strpos($response, '200 OK') !== false) {
                        $file = '';
                        while (!feof($remote_handler)) {
                            $file .= fgets($remote_handler);
                        }

                        $file = str_replace("\r\n", "\n", $file);
                        $file = explode("\n\n", $file);
                        array_shift($file);

                        $file = implode("\n\n", $file);

                        fclose($remote_handler);

                        return $file;
                    }
                } // else try with the next possibility
            case self::UPDATE_CURL:
                $ch = curl_init($url);

                curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
                curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $this->timeout);
                curl_setopt($ch, CURLOPT_USERAGENT, $this->_getUserAgent());

                $file = curl_exec($ch);

                curl_close($ch);

                if ($file !== false) {
                    return $file;
                } // else try with the next possibility
            case false:
                throw new Exception('Your server can\'t connect to external resources. Please update the file manually.');
        }
        
        return '';
    }
210937
public function loadFile($file, $url = null)
    {
        $this->_sourceUrl = $file;
        $str = $this->filesystem->fileGet($file);

        return $this->loadString($str, $url);
    }
287817
public function downloadAttachment($url)
	{
		$result = $this->client->sendRequest(
			self::REQUEST_GET,
			$url,
			array(),
			null,
			$this->authentication,
			true,
			false
		);

		return $result;
	}
1348129
private function parseUrl($url)
    {
        $parsed = parse_url($url);

        if ((count($parsed) === 1)
            && isset($parsed['path'])
            && (0 === strpos($parsed['path'], '?') || false !== strpos($parsed['path'], '&'))
        ) {
            $parsed = array(
                'query' => $parsed['path']
            );

            return $parsed;
        }

        return $parsed;
    }
890547
public static function createFromUrl($url)
    {
        $instance = new static();

        if (self::$generic_file->fetchUrl($url, null, $instance)) {
            return $instance;
        }

        return;
    }