Inform the user about invalid remote installation request.

@param moodle_url $continueurl
@return string
353625
public function remote_request_invalid_page(moodle_url $continueurl) {

        $out = $this->output->header();
        $out .= $this->output->heading(get_string('installfromrepo', 'tool_installaddon'));
        $out .= $this->output->box(get_string('remoterequestinvalid', 'tool_installaddon'), 'generalbox', 'notice');
        $out .= $this->output->continue_button($continueurl, 'get');
        $out .= $this->output->footer();

        return $out;
    }
1199994
protected function get_user_oauth_client($overrideurl = false) {
        if ($this->client) {
            return $this->client;
        }
        if ($overrideurl) {
            $returnurl = $overrideurl;
        } else {
            $returnurl = new moodle_url('/repository/repository_callback.php');
            $returnurl->param('callback', 'yes');
            $returnurl->param('repo_id', $this->id);
            $returnurl->param('sesskey', sesskey());
        }
        $this->client = \core\oauth2\api::get_user_oauth_client($this->issuer, $returnurl, self::SCOPES);
        return $this->client;
    }
1106277
protected function _get_zip_url( $remote ) {
		$url = false;

		if ( ! empty( $remote->assets ) && is_array( $remote->assets ) ) {
			if ( ! empty( $remote->assets[0] ) && is_object( $remote->assets[0] ) ) {
				if ( ! empty( $remote->assets[0]->browser_download_url ) ) {
					$url = $remote->assets[0]->browser_download_url;
				}
			}
		}

		$tag_name = isset( $remote->tag_name ) ? $remote->tag_name : null;

		if ( ! $url && $tag_name ) {
			$url = sprintf(
				'https://github.com/%1$s/%2$s/archive/%3$s.zip',
				$this->user_name,
				$this->repository,
				$tag_name
			);
		}

		return apply_filters(
			sprintf(
				'inc2734_github_theme_updater_zip_url_%1$s/%2$s',
				$this->user_name,
				$this->repository
			),
			$url,
			$this->user_name,
			$this->repository,
			$tag_name
		);
	}
991018
protected function fetchUrl(string $url): string
    {
        $curl = curl_init($url);
        curl_setopt_array($curl, [
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_TIMEOUT => $this->timeOut
        ]);
        $data = curl_exec($curl);
        $statusCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
        $error = curl_error($curl);
        curl_close($curl);

        if ($error) {
            throw new FetchFailedException(sprintf("A cURL error occurred for \"%s\": %s", $url, $error));
        }

        if ($statusCode !== 200) {
            throw new FetchFailedException(sprintf("URL \"%s\" responded with status code %d.", $url, $statusCode));
        }

        if (!$data) {
            throw new FetchFailedException(sprintf("URL \"%s\" returned no data.", $url));
        }

        return $data;
    }
857725
function buildSecureNginxServer($url)
    {
        $path = $this->certificatesPath();

        return str_replace(
            ['VALET_HOME_PATH', 'VALET_SERVER_PATH', 'VALET_STATIC_PREFIX', 'VALET_SITE', 'VALET_CERT', 'VALET_KEY'],
            [VALET_HOME_PATH, VALET_SERVER_PATH, VALET_STATIC_PREFIX, $url, $path.'/'.$url.'.crt', $path.'/'.$url.'.key'],
            $this->files->get(__DIR__.'/../stubs/secure.valet.conf')
        );
    }
437750
public function diffCommand($url = 'http://www.baidu.com')
    {
        $remote_ts = $this->_getRemoteTimestamp($url);
        $local_ts = time();
        if ($remote_ts === false) {
            return $this->console->error(['fetch remote timestamp failed: `:url`', 'url' => $url]);
        } else {
            $this->console->writeLn(' local: ' . date('Y-m-d H:i:s', $local_ts));
            $this->console->writeLn('remote: ' . date('Y-m-d H:i:s', $remote_ts));
            $this->console->writeLn('  diff: ' . ($local_ts - $remote_ts));
            return 0;
        }
    }
927757
public static function getRequestClientIP($url='')
    {
        if (!$url || !is_string($url)){
            if (isset($_SERVER['REMOTE_ADDR']))
                $url = $_SERVER['REMOTE_ADDR'];
        }
        return (filter_var($url, FILTER_VALIDATE_IP)) ? $url : '';
    }
466854
public function refreshOverseaUrl($url)
    {
        $urls = is_array($url) ? $url : func_get_args();

        return $this->request($urls, 'urls', 'RefreshCdnOverSeaUrl');
    }
113322
public function verifyProtocol($url, $append = 'http://')
    {
        if (strpos($url, 'http://') === false && strpos($url, 'https://') === false) {
            $url = $append.$url;
        }
        
        return $url;
    }
864063
public function check(string $url): LinkState
    {
        $response = null;

        try {
            $requests = $this->createRequestSet($url);

            foreach ($requests as $request) {
                $response = $this->getHttpResponse($request);

                if ($response->getStatusCode() === self::HTTP_STATUS_CODE_OK) {
                    return new LinkState(LinkState::TYPE_HTTP, $response->getStatusCode());
                }
            }
        } catch (\InvalidArgumentException $invalidArgumentException) {
            if (substr_count($invalidArgumentException->getMessage(), 'Unable to parse URI')) {
                return new LinkState(LinkState::TYPE_CURL, Configuration::CURL_MALFORMED_URL_CODE);
            }
        } catch (HttpConnectException $connectException) {
            $curlExceptionFactory = new CurlExceptionFactory();

            if ($curlExceptionFactory::isCurlException($connectException)) {
                $curlException = $curlExceptionFactory::fromConnectException($connectException);
                return new LinkState(LinkState::TYPE_CURL, $curlException->getCurlCode());
            }
        } catch (GuzzleException $guzzleException) {
            // Cannot happen
            return new LinkState(LinkState::TYPE_CURL, 0);
        }

        return new LinkState(LinkState::TYPE_HTTP, $response->getStatusCode());
    }
1145880
public static function UrlExsist ($url, $timeout = 30, $protocol_version = self::VERSION_1_1) {
		$result = static::HeadRequest($url, $timeout, $protocol_version);
		return isset($result['http']['status']['code']) && $result['http']['status']['code'] !== '404';
	}
1049919
public function site_url($sUrl = '', $bForceSecure = false)
    {
        //  If an explicit URL is passed in, then leave it be
        if (preg_match('/^(http|https|ftp|mailto)\:/', $sUrl)) {
            return $sUrl;
        }

        $sUrl = parent::site_url($sUrl);

        //  If the URL begins with a slash then attempt to guess the host using $_SERVER
        if (preg_match('/^\//', $sUrl) && !empty($_SERVER['HTTP_HOST'])) {
            $sProtocol = !empty($_SERVER['REQUEST_SCHEME']) ? $_SERVER['REQUEST_SCHEME'] : 'http';
            $sUrl      = $sProtocol . '://' . $_SERVER['HTTP_HOST'] . $sUrl;
        }

        if ($bForceSecure || Functions::isPageSecure()) {
            $sUrl = preg_replace('#^' . BASE_URL . '#', SECURE_BASE_URL, $sUrl);
        }

        return $sUrl;
    }
1357252
public function getRealUrl($url)
	{
		if (config('services.cdn.base_url')) {
			$s3_url = self::$s3_base_url . config('filesystems.disks.s3.bucket') . '/';

			return str_replace($s3_url, config('services.cdn.base_url'), $url);
		} else {
			return $url;
		}
	}
865368
static public function getRootUrl($url=null)
	{
	    if (!$url || strpos($url, '://') === false) {
            $schema = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https://' : 'http://';
            $domain = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : getenv('HTTP_HOST');
            $domain = static::GetRootDomain($domain);
            $baseUrl = $domain ? $schema . $domain : '';
            $port = isset($_SERVER['SERVER_PORT']) ? $_SERVER['SERVER_PORT'] : null;
	    } else {
	        $parts = parse_url($url);
	        $domain = static::GetRootDomain($parts['host']);
	        $baseUrl = $parts['scheme'] . '://' . $domain;
	        $port = isset($parts['port']) ? $parts['port'] : '';
	    }
	    if ($port && $port != 80 && $port != 443) {
	        $baseUrl .= ':'.$port;
	    }
	    
	    return $baseUrl;
	}
741312
public static function getInstanceByRemote($url)
    {
        $validator = new UrlValidator();
        if ($validator->validate($url, $error)) {
            $url = str_replace("&amp;", "&", $url);
            $http = new Client();
            $response = $http->get($url)->send();
            if (!$response->isOk) {
                return null;
            } else {
                $baseName = basename($url);
                $tempPath = FileHelper::getTempFilePath($baseName);
                file_put_contents($tempPath, $response->content);
                return new static([
                    'isUploadedFile' => false,
                    'name' => $baseName,
                    'tempName' => $tempPath,
                    'type' => FileHelper::getMimeType($tempPath),
                    'size' => strlen($response->content),
                    'error' => UPLOAD_ERR_OK,
                ]);
            }
        } else {
            return null;
        }
    }
200458
public function validateUrl($url)
    {
        if (empty($url)) {
            throw new \InvalidArgumentException('The field cannot be empty.');
        }

        if (!filter_var($url, FILTER_VALIDATE_URL)) {
            throw new \InvalidArgumentException('The field requires a valid URL.');
        }

        return $url;
    }
947181
protected function getMessage(string $url): ?string
    {
        $response = wp_remote_get($url);
        $responseCode = wp_remote_retrieve_response_code($response);

        if (! is_int($responseCode)) {
            return 'Unable to reach ' . $url;
        }

        return ($this->expectedStatusCode === $responseCode)
            ? null
            : $url . ' returns ' . $responseCode;
    }