Accept url

@param string $until
@return string
2148
protected function acceptUrl( $until = ';' )
    {
        if ( 'url' == strtolower( substr( $this->buffer, 0, 3 ) ) )
        {
            $this->buffer = substr( $this->buffer, 3 );
            $this->acceptWhiteSpace();

            if ( '(' == $this->buffer[0] )
            {
                $this->buffer = substr( $this->buffer, 1 );
                $this->acceptWhiteSpace();
                $result = $this->acceptString( ')' );

                if ( ')' == $this->buffer[0] )
                {
                    $this->buffer = substr( $this->buffer, 1 );
                    $this->acceptWhiteSpace();
                }

                return $result;
            }
        }

        return $this->acceptString( $until );
    }
1337197
protected function url(&$out)
    {
        if ($this->match('(url\(\s*(["\']?)([^)]+)\2\s*\))', $m)) {
            $out = [Type::T_STRING, '', ['url(' . $m[2] . $m[3] . $m[2] . ')']];

            return true;
        }

        return false;
    }
1062904
public function url($url, $params = [])
    {
        if (filter_var($url, FILTER_VALIDATE_URL)) {
            return $url;
        }
        $url = '/' . ltrim($url, '/');
        $baseUrl = "";
        if ($this->cacheBaseurl === null) {
            $vitex = Vitex::getInstance();
            $baseUrl = $vitex->getConfig('baseurl');
        }
        $qs = http_build_query($params);
        return rtrim($baseUrl, '/') . $url . ($params ? '?' . $qs : '');
    }
1353756
static function _fetchURL($url)
    {
        if (self::$disable_url_fetch) {
            return false;
        }

        $parts = parse_url($url);
        $data = '';
        switch ($parts['scheme']) {
            case 'http':
                $fsock = @fsockopen($parts['host'], isset($parts['port']) ? $parts['port'] : 80);
                if (!$fsock) {
                    return false;
                }
                fputs($fsock, "GET $parts[path] HTTP/1.0\r\n");
                fputs($fsock, "Host: $parts[host]\r\n\r\n");
                $line = fgets($fsock, 1024);
                if (strlen($line) < 3) {
                    return false;
                }
                preg_match('#HTTP/1.\d (\d{3})#', $line, $temp);
                if ($temp[1] != '200') {
                    return false;
                }

                // skip the rest of the headers in the http response
                while (!feof($fsock) && fgets($fsock, 1024) != "\r\n") {
                }

                while (!feof($fsock)) {
                    $data.= fread($fsock, 1024);
                }

                break;
            //case 'ftp':
            //case 'ldap':
            //default:
        }

        return $data;
    }
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;
    }
643132
public static function prepare_url ($url, $absolute = false) {
		if ($url === false) {
			return false;
		}
		if ($url[0] == '#') {
			$url = static::url_with_hash($url);
		} elseif (
			substr($url, 0, 2) != '$i' &&
			substr($url, 0, 5) != 'data:' &&
			$url[0] != '/' &&
			substr($url, 0, 7) != 'http://' &&
			substr($url, 0, 8) != 'https://'
		) {
			if ($absolute) {
				return static::absolute_url($url);
			}
			return "/$url";
		}
		return $url;
	}
957387
private function upgradeUrl(&$value)
    {
        if (!empty($value)
            && false === strpos($value, 'http://')
            && false === strpos($value, 'https://')
            && false === strpos($value, 'ftp://')
            && false === strpos($value, 'ftps://')
            && false === strpos($value, 'mailto:')
            && false === strpos($value, '//')
        ) {
            $value = 'http://' . $value;
        }

        return $value;
    }
400478
protected function getAbsoluteUrl($href)
    {
        if (preg_match('#^(https?|ftps?)://#', $href)) {
            return $href;
        } elseif (substr($href, 0, 2) == '//') {
            return parse_url($this->baseUrl, PHP_URL_SCHEME).':'.$href;
        } elseif ($href[0] == '/') {
            return $this->baseUrl.$href;
        } else {
            return $this->localUrl.'/'.$href;
        }
    }
116482
function canFetchURL($url)
    {
        if ($this->isHTTPS($url) && !$this->supportsSSL()) {
            Auth_OpenID::log("HTTPS URL unsupported fetching %s",
                             $url);
            return false;
        }

        if (!$this->allowedURL($url)) {
            Auth_OpenID::log("URL fetching not allowed for '%s'",
                             $url);
            return false;
        }

        return true;
    }
424204
public function endpointUrl($prefix = null, $includeId = true)
    {
        $url = self::API_URL;

        // push company id
        if ($includeId) {
            $url = $url .'/'. $this->getCompanyId();
        }

        // push prefix
        if ($prefix = trim($prefix, '/')) {
            $url = $url .'/'. $prefix;
        }

        return $url;
    }
256400
public function buildUrl(string $url): string
    {
        if (filter_var($url, FILTER_VALIDATE_URL)) {
            return $url;
        }
        return $this->endPoint . static::ENDPOINT_SUFFIX . $url;
    }
96716
public function scopeUntil($query, $until = null)
    {
        if (!$until) {
            return $query;
        }

        return $query->where('date', '<', $until->toDateTimeString());
    }
1157509
public function initFromUrl($url)
    {
        
        $options = [
            'http' => [
                'method'=>"GET",
                'header'=>"Accept-language: en\r\n".
                "User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.2 (KHTML, like Gecko) Chrome/22.0.1216.0 Safari/537.2\r\n"
          ]
        ];
        
        $context  = stream_context_create($options);
        

        if ($data = @file_get_contents($url, false, $context)) {
            return $this->initFromBinary($data);
        }

        throw new \Intervention\Image\Exception\NotReadableException(
            "Unable to init from given url (".$url.")."
        );
    }
663400
public static function prefaceURLwithHTTP($url) {
        $url = trim($url);

        if (substr($url, 0, 7 ) == "http://") {
            return $url;
        }

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

        return "http://".$url;
    }
485308
public static function OpenRemoteDocument($url)
	{
		// Expression Regular:
		// [1]: http or ftp
		// [2]: Server name
		// [4]: Full Path
		$pat = '/(http|ftp|https):\\/\\/((\\w|\\.)+)/i';
		$urlParts = preg_split($pat, $url, -1,PREG_SPLIT_DELIM_CAPTURE);

		$handle = fsockopen($urlParts[2], 80, $errno, $errstr, 30);
		if (!$handle)
		{
			throw new FileUtilException("Socket error: $errstr ($errno)");
		}
		else
		{
			$out = "GET " . $urlParts[4] . " HTTP/1.1\r\n";
			$out .= "Host: " . $urlParts[2] . "\r\n";
			$out .= "Connection: Close\r\n\r\n";

			fwrite($handle, $out);

			return $handle;
		}
	}
470035
public function gitUrl($url)
    {
        // Source/credit: https://github.com/jonschlinkert/is-git-url/blob/master/index.js
        $options = ['options' => ['regexp' => '/(?:git|ssh|https?|git@[\w\.]+):(?:\/\/)?[\w\.@:\/~_-]+\.git(?:\/?|\#[\d\w\.\-_]+?)$/']];
        if (filter_var($url, FILTER_VALIDATE_REGEXP, $options) === false) {
            throw new \InvalidArgumentException(sprintf('Invalid URL: %s', $url));
        }

        return $url;
    }
639656
public static function url(string $value):bool
    {
        $value = (string)$value;
        $valid = filter_var($value, FILTER_VALIDATE_URL);
        return $valid !== false;
    }