Validates a url.  Also checks to make sure the page is reachable and has HTML Tag
@author paul.visco@roswellpark.org
@version 1.2 13/18/2008

@param string $url The url to validate should

@return \sb\Validate_Results
493701
public static function url($url, $check_url = true) {

        $result = new \sb\Validate\Results();
        $result->value = $url;
        $result->is_valid = false;
        $result->data = new stdClass();

        //  /(\s|\n)([a-z]+?):\/\/([a-z0-9\-\.,\?!%\*_\#:;~\\&$@\/=\+]+)/i

        if (preg_match("/^http:\/\/([a-z0-9\-\.,\?!%\*_\#:;~\\&$@\/=\+]+)$/i", $url)) {

            $result->message = "Valid url format";
            $result->is_valid = true;

            if ($check_url) {
                $page = @file_get_contents($url);
                if (!$page) {

                    $result->is_valid = false;
                    $result->message .= ' but page not loaded';
                    $result->data->header = $http_response_header[0];
                } else {

                    if (!preg_match("/<html/", $page)) {
                        $result->is_valid = false;
                        $result->message .= " page reachable but no html tag found";
                    } else {
                        $result->message .= " and page loaded";
                    }
                }
            }
        } else {
            $result->message = "Invalid url format";
        }

        return $result;
    }
791663
public function matchUrl($url)
    {
        $url = '/' . ltrim($url, '/');
        $url = $this->sanitizeUrl($url);

        if ($url && $route = $this->matchUrlDirectly($url)) {
            return $route;
        }
        if ($url && $route = $this->matchUrlWithParameters($url)) {
            return $route;
        }
        return null;
    }
523427
function validateUrl (url) {
  if (!url) {
    return option.some('Url is not specified')
  }
  if (typeof url !== 'string') {
    return option.some('Url should be type of string')
  }
  return option.none
}
1101114
protected function _validate_url($value)
    {
        $value = trim($value);

        if ($value === '') {
            return '';
        }

        if (filter_var($value, FILTER_VALIDATE_URL) !== false) {
            $parts = explode('://', $value, 2);
            $scheme = strtolower($parts[0]);
            $path = $parts[1];
            if ($scheme !== 'http' && $scheme !== 'https') {
                return null;
            } else {
                return $scheme . '://' . $path;
            }
        } else {
            return null;
        }
    }
933660
public function validateFragment($html)
    {
        $query = http_build_query(array_merge(
            $this->getOptions()->buildOptions(),
            array('fragment' => $html)
        ));

        $context = stream_context_create(array(
            'http' => array(
                'method' => 'POST',
                'header' => "Content-Type: application/x-www-form-urlencoded\r\nUser-Agent: HTMLValidator",
                'content' => $query,
            )
        ));

        $data = $this->sendRequest($this->validatorUri, $context);

        return $this->parseSOAP12Response($data);
    }
1168696
static public function submit( $url )
	{
		if( $url instanceof ADT_URL )
			$url	= (string) $url;
		if( !is_string( $url ) )
			throw new InvalidArgumentException( 'URL must be string or instance of ADT_URL' );
		try
		{
			Net_Reader::readUrl( self::$baseUrl.urlencode( $url ) );
		}
		catch( Exception $e )
		{
			self::$lastError	= $e->getMessage();
			return FALSE;
		}
		return TRUE;
	}
329334
public function supports($url)
    {
        $error = $this->validator->validate($url, [new Url()]);

        return 0 === count($error);
    }
1120521
private function validateUrl($url)
    {
        if ($url === false)
            return $url;
        $resolver = new OptionsResolver();
        $resolver->setRequired([
            'url',
        ]);
        $resolver->setDefaults([
            'url_options' => [],
            'url_type' => 'json',
        ]);
        $resolver->setAllowedTypes('url_options', ['array']);
        $resolver->setAllowedTypes('url', ['string']);
        $resolver->setAllowedTypes('url_type', ['string']);
        $resolver->setAllowedValues('url_type', ['redirect', 'json']);
        $url = $resolver->resolve($url);
        return $url;
    }
496668
public function setUrl($url)
    {
        $this->url = $url;

        // Check if the url ends with a slash
        if ($this->url && substr($this->url, -1) !== '/') {
            $this->url .= '/';
        }

        return $this;
    }
513614
public function matchWhen($url = null)
    {
        if (null !== $url) {
            $this->setMatchUrl($url);
        }

        return strpos($this->getRequestedUrl(), $this->getMatchUrl()) === 0;
    }
1355678
protected function checkUrl($url)
    {
        if ($this->fullName) {
            $pos = strpos($this->fullName, '<');

            if (false !== $pos) {
                $str = substr($this->fullName, 0, $pos);
            } else {
                $str = $this->fullName;
            }

            if ($str && 0 !== stripos(str_replace('|', '/', $url), $str)) {
                return false;
            }
        }

        return true;
    }
16907
public function matches($url)
    {
        $infos = parse_url($url);

        if ($this->expired()) {
            return false;
        }

        if (!$this->matchesScheme($infos['scheme'])) {
            return false;
        }

        if (!$this->matchesDomain($infos['host'])) {
            return false;
        }

        return $this->matchesPath($infos['path']);
    }
1088690
public function isWebpage($url) {
		$url = filter_var($url, FILTER_VALIDATE_URL);
		if (!strlen($url)) {
			return false;
		}
		
		$c = curl_init(); 
		curl_setopt($c, CURLOPT_URL, $url); 
		curl_setopt($c, CURLOPT_HEADER, 1); // get the header 
		curl_setopt($c, CURLOPT_NOBODY, 1); // and *only* get the header 
		curl_setopt($c, CURLOPT_RETURNTRANSFER, 1); // get the response as a string from curl_exec(), rather than echoing it 
		curl_setopt($c, CURLOPT_FRESH_CONNECT, 1); // don't use a cached version of the url 
		$result = curl_exec($c);
		
		if (!$result) { 
			return false; 
		} 
		
		if (stripos($result, 'Content-type: text/html')) {
//			$svc = new RestfulService($url);
//			$response = $svc->request('', 'GET');
			return true;
		}
		
		return false;
	}
989552
protected function parseURL($url)
    {
        $parsed = parse_url($url);
        if ($parsed === false) {
            return false;
        } elseif (!isset($parsed['scheme']) || !$this->isValidScheme($parsed['scheme'])) {
            return false;
        } else {
            if (!isset($parsed['host']) || !$this->isValidHostName($parsed['host'])) {
                return false;
            } else {
                if (!isset($parsed['port'])) {
                    $parsed['port'] = getservbyname($parsed['scheme'], 'tcp');
                    if (!is_int($parsed['port'])) {
                        return false;
                    }
                }
            }
        }
        $parsed['custom'] = (isset($parsed['path']) ? $parsed['path'] : '/') . (isset($parsed['query']) ? '?' . $parsed['query'] : '');
        return $parsed;
    }
100303
public function validate($url)
    {
        if (null !== ($headers = $this->getHeader($url))) {
            $statusCode = $this->getStatusCode($headers);
            // see https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
            return ($statusCode >= 200 && $statusCode < 300);
        }
        return false;
    }
18181
public function httpStatusConnection($url)
    {
        if ( ! filter_var($url, FILTER_VALIDATE_URL)) {// check, if a valid url is provided
            return false;
        }

        $handle = curl_init($url);
        curl_setopt($handle,  CURLOPT_RETURNTRANSFER, true);
        curl_setopt($handle, CURLOPT_FOLLOWLOCATION, true);// 301 solved
        $response = curl_exec($handle);
        $httpCode = curl_getinfo($handle, CURLINFO_HTTP_CODE);
        curl_close($handle);

        return $httpCode == 200 ? true : false;
    }
398132
public function resolveUrl($url) {
		// If the URL is seriously malformed it’s probably beyond the scope of this
		// parser to try to do anything with it.
		if (parse_url($url) === false) {
			return $url;
		}

		// per issue #40 valid URLs could have a space on either side
		$url = trim($url);

		$scheme = parse_url($url, PHP_URL_SCHEME);

		if (empty($scheme) and !empty($this->baseurl)) {
			return resolveUrl($this->baseurl, $url);
		} else {
			return $url;
		}
	}