From e4db5ce340a9b16ef8abb36f771e52a75e40acf3 Mon Sep 17 00:00:00 2001 From: Jon Atkins Date: Tue, 30 Apr 2013 18:38:50 +0100 Subject: [PATCH] add absoluteurl - http://sourceforge.net/projects/absoluteurl/ --- website/page/code/url/CHANGELOG.txt | 24 ++ website/page/code/url/README.txt | 26 ++ website/page/code/url/url_to_absolute.php | 485 ++++++++++++++++++++++ 3 files changed, 535 insertions(+) create mode 100644 website/page/code/url/CHANGELOG.txt create mode 100644 website/page/code/url/README.txt create mode 100644 website/page/code/url/url_to_absolute.php diff --git a/website/page/code/url/CHANGELOG.txt b/website/page/code/url/CHANGELOG.txt new file mode 100644 index 00000000..cb7d743f --- /dev/null +++ b/website/page/code/url/CHANGELOG.txt @@ -0,0 +1,24 @@ +Changelog +--------- + +absoluteurl v1.6, March 12, 2010 +--------------------------------- +- added encode_url function to convert an absolute url to its percentage + encoded equivalent, according to RFC 3986 + +absoluteurl v1.5, March 11, 2010 +--------------------------------- +- fixed to allow spaces in the path of url + +absoluteurl v1.4, October 2, 2009 +---------------------------------------------- +- Percentage encoding of the absolute url disabled. + +absoluteurl v1.2, 2009-02-27 +----------------------------------------------- +- Minor bug fix + + +absoluteurl v1.0, 2009-08-28 +---------------------------------------- +- Initial release \ No newline at end of file diff --git a/website/page/code/url/README.txt b/website/page/code/url/README.txt new file mode 100644 index 00000000..35f9c8d2 --- /dev/null +++ b/website/page/code/url/README.txt @@ -0,0 +1,26 @@ +absoluteurl +--------------------- + +This script converts the relative url to absolute url, provided a base url. + + +For more, look here: http://publicmind.in/blog/urltoabsolute + +Usage: +---------- + +Extract the script (url_to_absolute.php) into your web directory, include it into your current php file using: + +require(path-to-file); + +then, you can convert the relative url to absolute url by calling: + +url_to_absolute( $baseUrl, $relativeUrl); + +It return false on failure, otherwise returns the absolute url. If the $relativeUrl is a valid absolute url, it is returned without any modification. + +Author/credits +----------- + +1) Original author: David R. Nadeau, NadeauSoftware.com +2) Edited and maintained by: Nitin Kr, Gupta, publicmind.in \ No newline at end of file diff --git a/website/page/code/url/url_to_absolute.php b/website/page/code/url/url_to_absolute.php new file mode 100644 index 00000000..c6df5c24 --- /dev/null +++ b/website/page/code/url/url_to_absolute.php @@ -0,0 +1,485 @@ + '!%3A!ui', + "/" => '!%2F!ui', + "?" => '!%3F!ui', + "#" => '!%23!ui', + "[" => '!%5B!ui', + "]" => '!%5D!ui', + "@" => '!%40!ui', + "!" => '!%21!ui', + "$" => '!%24!ui', + "&" => '!%26!ui', + "'" => '!%27!ui', + "(" => '!%28!ui', + ")" => '!%29!ui', + "*" => '!%2A!ui', + "+" => '!%2B!ui', + "," => '!%2C!ui', + ";" => '!%3B!ui', + "=" => '!%3D!ui', + "%" => '!%25!ui', + ); + + $url = rawurlencode($url); + $url = preg_replace(array_values($reserved), array_keys($reserved), $url); + return $url; +} + +?> \ No newline at end of file