Class

Url

Package: Util Copyright: © 2005-2019 PHPBoost License: GNU/GPL-3.0 Author: Loic ROUCHON horn@phpboost.com Version: PHPBoost 5.2 - last update: 2019 01 22 Since: PHPBoost 2.0 - 2009 01 14 Contributor: Julien BRISWALTER j1.seth@phpboost.com Contributor: Arnaud GENET elenwii@phpboost.com Contributor: mipel mipel@phpboost.com Contributor: janus57 janus57@janus57.fr Located at: util/Url.class.php
Methods summary
public
# __construct( string $url = '.', string $path_to_root = null, $server_url = null )

Build a Url object. By default, builds an Url object representing the current path. If the url is empty, no computation is done and an empty string will be returned when asking for both relative and absolute form of the url.

public boolean
# is_relative( )
public string
# relative( )

Returns the root relative url if defined, else the absolute one

public string
# rel( )

Returns the relative url if defined, else the absolute one

public string
# absolute( )

Returns the absolute url

public string
# root_to_local( )

Returns the relative path from the website root to the current path if working on a relative url

public static string
# encode_rewrite( string $url )

Prepares a string for it to be used in an URL (with only a-z, 0-9 and - characters).

public static integer
# check_url_validity( string $url )

Checks the status of an url.

public static integer
# get_url_file_size( string $url )

Retrieves the size of a file in url.

public static string
# compress( string $url )

Compress a url by removing all "folder/.." occurrences

public static string
# get_absolute_root( )

Returns the absolute website root Url

public static string
# html_convert_root_relative2absolute( string $html_text, string $path_to_root = PATH_TO_ROOT, string $server_url = SERVER_URL )

Returns the HTML text with only absolutes urls

public static string
# html_convert_absolute2root_relative( string $html_text, string $path_to_root = PATH_TO_ROOT, string $server_url = SERVER_URL )

Returns the HTML text with only relatives urls

public static string
# html_convert_root_relative2relative( string $html_text, string $path_to_root = PATH_TO_ROOT, string $server_url = SERVER_URL )

Transforms the relative URL whose base is the site root (for instance /images/mypic.png) to the real relative path fited to the current page.

public static string
# get_relative( string $url, string $path_to_root = null, string $server_url = null )
public static the
# get_wellformness_regex( integer $protocol = RegexHelper::REGEX_MULTIPLICITY_OPTIONNAL, integer $user = RegexHelper::REGEX_MULTIPLICITY_OPTIONNAL, integer $domain = RegexHelper::REGEX_MULTIPLICITY_OPTIONNAL, integer $folders = RegexHelper::REGEX_MULTIPLICITY_OPTIONNAL, integer $file = RegexHelper::REGEX_MULTIPLICITY_OPTIONNAL, integer $args = RegexHelper::REGEX_MULTIPLICITY_OPTIONNAL, integer $forbid_js = true, boolean $forbid_js,… )

Returns the regex matching the requested url form

public static true
# check_wellformness( integer $url, integer $protocol = RegexHelper::REGEX_MULTIPLICITY_OPTIONNAL, integer $user = RegexHelper::REGEX_MULTIPLICITY_OPTIONNAL, integer $domain = RegexHelper::REGEX_MULTIPLICITY_OPTIONNAL, integer $folders = RegexHelper::REGEX_MULTIPLICITY_OPTIONNAL, integer $file = RegexHelper::REGEX_MULTIPLICITY_OPTIONNAL, integer $args = RegexHelper::REGEX_MULTIPLICITY_OPTIONNAL, boolean $anchor = RegexHelper::REGEX_MULTIPLICITY_OPTIONNAL, $forbid_js = true )

Returns true if the url match the requested url form

public static string
# to_rel( mixed $url )

Returns an url relative from the server root

public static string
# to_relative( mixed $url )

Returns an url relative from PHPBoost root

public static string
# to_absolute( mixed $url )

Returns an absolute url

public static
# is_current_url( string $check_url, boolean $real_url = false )

Returns true if $check_url is current url

Constants summary
string FORBID_JS_REGEX
# '(?!javascript:)'
string PROTOCOL_REGEX
# '[a-z0-9-_]+(?::[a-z0-9-_]+)*://'
string USER_REGEX
# '[a-z0-9-_]+(?::[a-z0-9-_]+)?@'
string DOMAIN_REGEX
# '(?:[a-z0-9-_~]+\.)*[a-z0-9-_~]+(?::[0-9]{1,5})?/'
string FOLDERS_REGEX
# '/*(?:[A-Za-z0-9~_\.+@,-]+/+)*'
string FILE_REGEX
# '[A-Za-z0-9-+_,~:/\.\%!=]+'
string ARGS_REGEX
# '(/([\w/_\.#-]*(\?)?(\S+)?[^\.\s])?)?'
integer STATUS_OK
# 200
integer STATUS_FOUND
# 302