Checks if given URL is accessible (HTTP-Code: 200)

@param string $sLink given link

@return boolean
558504
public function urlValidate($sLink)
    {
        $aUrlParts = @parse_url($sLink);
        $sHost = (isset($aUrlParts["host"]) && $aUrlParts["host"]) ? $aUrlParts["host"] : null;

        if ($sHost) {
            $sDocumentPath = (isset($aUrlParts["path"]) && $aUrlParts["path"]) ? $aUrlParts["path"] : '/';
            $sDocumentPath .= (isset($aUrlParts["query"]) && $aUrlParts["query"]) ? '?' . $aUrlParts["query"] : '';

            $sPort = (isset($aUrlParts["port"]) && $aUrlParts["port"]) ? $aUrlParts["port"] : '80';

            // Now (HTTP-)GET $documentpath at $sHost";
            if (($oConn = @fsockopen($sHost, $sPort, $iErrNo, $sErrStr, 30))) {
                fwrite($oConn, "HEAD {$sDocumentPath} HTTP/1.0\r\nHost: {$sHost}\r\n\r\n");
                $sResponse = fgets($oConn, 22);
                fclose($oConn);

                if (preg_match("/200 OK/", $sResponse)) {
                    return true;
                }
            }
        }

        return false;
    }
875482
public static function isBehindSsl() : bool
  {
      // Check for proxy first
      if (isset($_SERVER['HTTP_X_FORWARDED_PROTO'])) {
          return self::protocolWithActiveSsl($_SERVER['HTTP_X_FORWARDED_PROTO']);
      }

      if (isset($_SERVER['HTTPS'])) {
          return self::protocolWithActiveSsl($_SERVER['HTTPS']);
      }

      return $_SERVER['SERVER_PORT'] == 443;
  }
788581
public function isLinkAllowed(string $link): bool
	{
		if (isset($this->allowedLinks[$link])) {
			return true;
		} else {
			$pos = strrpos($link, ':');
			$link = substr($link, 0, ($pos + 1));
			return isset($this->allowedLinks[$link]);
		}
	}
924283
public function isCurrentProtocol($url)
    {
        // Missing protocol, cannot proceed, assuming true.
        if (!$url || (strpos($url, "http") !== 0)) {
            return true;
        }

        return (strpos($url, "https:") === 0) == $this->isSsl();
    }
298226
public function checkLink($url)
    {
        $url = trim($url);
        if (substr($url, 0, 7 ) == "http://") return $url;

        if (substr($url, 0, 8 ) == "https://") return $url;

        return "http://".$url;
    }
486128
public function isUrl($url)
    {
        $path = parse_url($url, PHP_URL_PATH);
        $encoded_path = array_map('urlencode', explode('/', $path));
        $url = str_replace($path, implode('/', $encoded_path), $url);

        return filter_var($url, FILTER_VALIDATE_URL);
    }
581041
public function has($crawlUrl): bool
    {
        if (! $crawlUrl instanceof CrawlUrl) {
            $crawlUrl = CrawlUrl::create($crawlUrl);
        }

        if ($this->contains($this->urls, $crawlUrl)) {
            return true;
        }

        return false;
    }
484044
public static function isURL(string $url): bool {
        return (boolean) !(filter_var($url, FILTER_SANITIZE_URL | FILTER_VALIDATE_URL) === false);
    }
7847
public function hasAccessToken(string $service):bool{
		return isset($_SESSION[$this->sessionVar], $_SESSION[$this->sessionVar][$service]);
	}
1157870
public static function exists(string $link = ''): bool
    {
        $link = static::normalizePath($link);
        return static::verifyPath($link) && \file_exists($link) && \is_link($link);
    }
369222
public static function href($link) {
        if(isset($link['uri']) || isset($link['fragment'])) {
            return ' href="'.URI::getHref($link).'"';
        }
        return false;
    }
390467
private static function checkUrl($url)
    {
        $headers = get_headers($url);

        if ( ! Str::contains($headers[0], '200 OK')) {
            throw new Exception('Unable to download Maxmind\'s database. ('.substr($headers[0], 13).')');
        }
    }
623959
public function validateLinks($urlLinks = []){
        if(!is_array($urlLinks))
            return false;
        foreach($urlLinks as $keyLink=>$Link){
            if(\SapiStudio\Http\Html::isValidURL($Link)){
                $promises[$keyLink] = $this->headAsync($Link,self::$clientConfig['testConfig']);
            }
        }
        $results = Promise\settle($promises)->wait();
        if($results){
            foreach($results as $promiseIndex=>$promiseResponse){
                $response = $promiseResponse['value'];
                $linkHash = md5($urlLinks[$promiseIndex]);
                $this->validatedLinks[$linkHash]['isAlive']     = ($response) ? true : false;
                $this->validatedLinks[$linkHash]['url']         = $urlLinks[$promiseIndex];
                $this->validatedLinks[$linkHash]['isImage']     = ($response) ? \SapiStudio\Http\Html::urlIsImage($response->getHeaderLine('content-type')) : false;
                $this->validatedLinks[$linkHash]['contentType'] = ($response) ? $response->getHeaderLine('content-type') : false;
            }
        }
        return $this->validatedLinks;
    }
89017
function checkLink(s) {
        return ((s.indexOf("http") === 0) || (s.indexOf(SLASH) === 0)) ? "<a href='" + s + "'>" + s + "</a>" : s;
    }
328119
public function isAccessible($url)
    {
        $context = $this->getContext($url);

        return is_resource(@fopen($url, 'r', null, $context));
    }
139313
protected function urlCheck($url)
    {
        // first check if url has http:// prefix, if not, add it
        $parsed = parse_url($url);

        if (empty($parsed['scheme'])) {
            $url = 'http://' . ltrim($url, '/');
        }

        $file_headers = get_headers($url);

        if (!strpos($file_headers[0], "404 Not Found") > 0) {
            return true;
        }
        
        return false;
    }
329334
public function supports($url)
    {
        $error = $this->validator->validate($url, [new Url()]);

        return 0 === count($error);
    }