cvs: pear /HTTP_Url Url.php
| From: | Richard Heyes | Date: | Sun, 10 Feb 2002 22:22:51 +0000 |
| Subject: | cvs: pear /HTTP_Url Url.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-2372@lists.php.net to get a copy of this message | ||
heyesr Sun Feb 10 17:22:51 2002 EDT
Modified files:
/pear/HTTP_Url Url.php
Log:
* Tabs --> spaces
Index: pear/HTTP_Url/Url.php diff -u pear/HTTP_Url/Url.php:1.1 pear/HTTP_Url/Url.php:1.2 --- pear/HTTP_Url/Url.php:1.1 Sun Feb 10 17:12:29 2002 +++ pear/HTTP_Url/Url.php Sun Feb 10 17:22:51 2002 @@ -15,207 +15,207 @@ // | Author: Richard Heyes <richard@phpguru.org> | // +----------------------------------------------------------------------+ // -// $Id: Url.php,v 1.1 2002/02/10 22:12:29 heyesr Exp $ +// $Id: Url.php,v 1.2 2002/02/10 22:22:51 heyesr Exp $ // // HTTP_Url Class // class HTTP_Url { - /** + /** * Full url - * @var string + * @var string */ - var $url; - - /** + var $url; + + /** * Protocol - * @var string + * @var string */ - var $protocol; + var $protocol; - /** + /** * Username - * @var string + * @var string */ - var $username; + var $username; - /** + /** * Password - * @var string + * @var string */ - var $password; + var $password; - /** + /** * Host - * @var string + * @var string */ - var $host; - - /** + var $host; + + /** * Port - * @var integer + * @var integer */ - var $port; - - /** + var $port; + + /** * Path - * @var string + * @var string */ - var $path; - - /** + var $path; + + /** * Query string - * @var array + * @var array */ - var $querystring; + var $querystring; - /** + /** * Anchor - * @var string + * @var string */ - var $anchor; + var $anchor; - /** + /** * Constructor - * - * Parses the given url and stores the various parts - * Defaults are used in certain cases - * - * @param $url The url - */ - function HTTP_URL($url = null) - { - global $HTTP_SERVER_VARS; - - $this->url = $url; - $this->protocol = 'http' . (@$HTTP_SERVER_VARS['HTTPS'] == 'on' ? 's' : ''); - $this->user = ''; - $this->pass = ''; - $this->host = $HTTP_SERVER_VARS['SERVER_NAME']; - $this->port = $HTTP_SERVER_VARS['SERVER_PORT']; - $this->path = '/'; - $this->querystring = array(); - $this->anchor = ''; - - // Parse the uri and store the various parts - $urlinfo = parse_url($url); - - // Protocol - if (!empty($urlinfo['scheme'])) { - $this->protocol = $urlinfo['scheme']; - } - - // Username - if (!empty($urlinfo['user'])) { - $this->user = $urlinfo['user']; - } - - // Password - if (!empty($urlinfo['pass'])) { - $this->pass = $urlinfo['pass']; - } - - // Host - if (!empty($urlinfo['host'])) { - $this->host = $urlinfo['host']; - } - - // Port - if (!empty($urlinfo['port'])) { - $this->port = $urlinfo['port']; - } - - // Path - if (!empty($urlinfo['path'])) { - $this->path = $urlinfo['path']; - } - - // Querystring - if (!empty($urlinfo['query'])) { - $this->querystring = explode('&', $urlinfo['query']); - for ($i = 0; $i < count($this->querystring); $i++) { - list($name, $value) = explode('=', $this->querystring[$i]); - $querystring[$name] = $value; - } - $this->querystring = $querystring; - } - - // Anchor - if (!empty($urlinfo['fragment'])) { - $this->anchor = $urlinfo['fragment']; - } - } + * + * Parses the given url and stores the various parts + * Defaults are used in certain cases + * + * @param $url The url + */ + function HTTP_URL($url = null) + { + global $HTTP_SERVER_VARS; + + $this->url = $url; + $this->protocol = 'http' . (@$HTTP_SERVER_VARS['HTTPS'] == 'on' ? 's' : ''); + $this->user = ''; + $this->pass = ''; + $this->host = $HTTP_SERVER_VARS['SERVER_NAME']; + $this->port = $HTTP_SERVER_VARS['SERVER_PORT']; + $this->path = '/'; + $this->querystring = array(); + $this->anchor = ''; + + // Parse the uri and store the various parts + $urlinfo = parse_url($url); + + // Protocol + if (!empty($urlinfo['scheme'])) { + $this->protocol = $urlinfo['scheme']; + } + + // Username + if (!empty($urlinfo['user'])) { + $this->user = $urlinfo['user']; + } + + // Password + if (!empty($urlinfo['pass'])) { + $this->pass = $urlinfo['pass']; + } + + // Host + if (!empty($urlinfo['host'])) { + $this->host = $urlinfo['host']; + } + + // Port + if (!empty($urlinfo['port'])) { + $this->port = $urlinfo['port']; + } + + // Path + if (!empty($urlinfo['path'])) { + $this->path = $urlinfo['path']; + } + + // Querystring + if (!empty($urlinfo['query'])) { + $this->querystring = explode('&', $urlinfo['query']); + for ($i = 0; $i < count($this->querystring); $i++) { + list($name, $value) = explode('=', $this->querystring[$i]); + $querystring[$name] = $value; + } + $this->querystring = $querystring; + } + + // Anchor + if (!empty($urlinfo['fragment'])) { + $this->anchor = $urlinfo['fragment']; + } + } - /** + /** * Returns full url - * - * @return string Full url - * @access public - */ - function getURL() - { - $querystring = $this->getQueryString(); - - $this->url = $this->protocol . '://' - . $this->user . (!empty($this->pass) ? ':' : '') - . $this->pass . (!empty($this->user) ? '@' : '') - . $this->host . ($this->port == '80' ? '' : ':' . $this->port) - . $this->path - . (!empty($querystring) ? '?' . $querystring : '') - . (!empty($this->anchor) ? '#' . $this->anchor : ''); + * + * @return string Full url + * @access public + */ + function getURL() + { + $querystring = $this->getQueryString(); + + $this->url = $this->protocol . '://' + . $this->user . (!empty($this->pass) ? ':' : '') + . $this->pass . (!empty($this->user) ? '@' : '') + . $this->host . ($this->port == '80' ? '' : ':' . $this->port) + . $this->path + . (!empty($querystring) ? '?' . $querystring : '') + . (!empty($this->anchor) ? '#' . $this->anchor : ''); - return $this->url; - } + return $this->url; + } - /** + /** * Adds a querystring item - * - * @param $name Name of item - * @param $value Value of item - * @param $preencoded Whether value is urlencoded or not, default = not - * @access public<> - */ - function addQueryString($name, $value, $preencoded = false) - { - $this->querystring[$name] = $preencoded ? $value : urlencode($value); - } - - /** + * + * @param $name Name of item + * @param $value Value of item + * @param $preencoded Whether value is urlencoded or not, default = not + * @access public<> + */ + function addQueryString($name, $value, $preencoded = false) + { + $this->querystring[$name] = $preencoded ? $value : urlencode($value); + } + + /** * Sets the querystring to literally what you supply - * - * @param $querystring The querystring data. Should be of the format foo=bar&x=y etc - * @param $preencoded Whether data is already urlencoded or not, default = already encoded - * @access public - */ - function addRawQueryString($querystring, $preencoded = true) - { - $querystring = explode('&', $querystring); - for ($i = 0; $i < count($querystring); $i++) { - list($name, $value) = explode('=', $querystring[$i]); - $this->querystring[$name] = $preencoded ? $value : urlencode($value); - } - } + * + * @param $querystring The querystring data. Should be of the format foo=bar&x=y etc + * @param $preencoded Whether data is already urlencoded or not, default = already encoded + * @access public + */ + function addRawQueryString($querystring, $preencoded = true) + { + $querystring = explode('&', $querystring); + for ($i = 0; $i < count($querystring); $i++) { + list($name, $value) = explode('=', $querystring[$i]); + $this->querystring[$name] = $preencoded ? $value : urlencode($value); + } + } - /** + /** * Returns flat querystring - * - * @return string Querystring - * @access public - */ - function getQueryString() - { - if (!empty($this->querystring)) { - foreach ($this->querystring as $name => $value) { - $querystring[] = $name . '=' . $value; - } - $querystring = implode('&', $querystring); - } else { - $querystring = ''; - } + * + * @return string Querystring + * @access public + */ + function getQueryString() + { + if (!empty($this->querystring)) { + foreach ($this->querystring as $name => $value) { + $querystring[] = $name . '=' . $value; + } + $querystring = implode('&', $querystring); + } else { + $querystring = ''; + } - return $querystring; - } + return $querystring; + } } ?>
Index: pear/HTTP_Url/Url.php diff -u pear/HTTP_Url/Url.php:1.1 pear/HTTP_Url/Url.php:1.2 --- pear/HTTP_Url/Url.php:1.1 Sun Feb 10 17:12:29 2002 +++ pear/HTTP_Url/Url.php Sun Feb 10 17:22:51 2002 @@ -15,207 +15,207 @@ // | Author: Richard Heyes <richard@phpguru.org> | // +----------------------------------------------------------------------+ // -// $Id: Url.php,v 1.1 2002/02/10 22:12:29 heyesr Exp $ +// $Id: Url.php,v 1.2 2002/02/10 22:22:51 heyesr Exp $ // // HTTP_Url Class // class HTTP_Url { - /** + /** * Full url - * @var string + * @var string */ - var $url; - - /** + var $url; + + /** * Protocol - * @var string + * @var string */ - var $protocol; + var $protocol; - /** + /** * Username - * @var string + * @var string */ - var $username; + var $username; - /** + /** * Password - * @var string + * @var string */ - var $password; + var $password; - /** + /** * Host - * @var string + * @var string */ - var $host; - - /** + var $host; + + /** * Port - * @var integer + * @var integer */ - var $port; - - /** + var $port; + + /** * Path - * @var string + * @var string */ - var $path; - - /** + var $path; + + /** * Query string - * @var array + * @var array */ - var $querystring; + var $querystring; - /** + /** * Anchor - * @var string + * @var string */ - var $anchor; + var $anchor; - /** + /** * Constructor - * - * Parses the given url and stores the various parts - * Defaults are used in certain cases - * - * @param $url The url - */ - function HTTP_URL($url = null) - { - global $HTTP_SERVER_VARS; - - $this->url = $url; - $this->protocol = 'http' . (@$HTTP_SERVER_VARS['HTTPS'] == 'on' ? 's' : ''); - $this->user = ''; - $this->pass = ''; - $this->host = $HTTP_SERVER_VARS['SERVER_NAME']; - $this->port = $HTTP_SERVER_VARS['SERVER_PORT']; - $this->path = '/'; - $this->querystring = array(); - $this->anchor = ''; - - // Parse the uri and store the various parts - $urlinfo = parse_url($url); - - // Protocol - if (!empty($urlinfo['scheme'])) { - $this->protocol = $urlinfo['scheme']; - } - - // Username - if (!empty($urlinfo['user'])) { - $this->user = $urlinfo['user']; - } - - // Password - if (!empty($urlinfo['pass'])) { - $this->pass = $urlinfo['pass']; - } - - // Host - if (!empty($urlinfo['host'])) { - $this->host = $urlinfo['host']; - } - - // Port - if (!empty($urlinfo['port'])) { - $this->port = $urlinfo['port']; - } - - // Path - if (!empty($urlinfo['path'])) { - $this->path = $urlinfo['path']; - } - - // Querystring - if (!empty($urlinfo['query'])) { - $this->querystring = explode('&', $urlinfo['query']); - for ($i = 0; $i < count($this->querystring); $i++) { - list($name, $value) = explode('=', $this->querystring[$i]); - $querystring[$name] = $value; - } - $this->querystring = $querystring; - } - - // Anchor - if (!empty($urlinfo['fragment'])) { - $this->anchor = $urlinfo['fragment']; - } - } + * + * Parses the given url and stores the various parts + * Defaults are used in certain cases + * + * @param $url The url + */ + function HTTP_URL($url = null) + { + global $HTTP_SERVER_VARS; + + $this->url = $url; + $this->protocol = 'http' . (@$HTTP_SERVER_VARS['HTTPS'] == 'on' ? 's' : ''); + $this->user = ''; + $this->pass = ''; + $this->host = $HTTP_SERVER_VARS['SERVER_NAME']; + $this->port = $HTTP_SERVER_VARS['SERVER_PORT']; + $this->path = '/'; + $this->querystring = array(); + $this->anchor = ''; + + // Parse the uri and store the various parts + $urlinfo = parse_url($url); + + // Protocol + if (!empty($urlinfo['scheme'])) { + $this->protocol = $urlinfo['scheme']; + } + + // Username + if (!empty($urlinfo['user'])) { + $this->user = $urlinfo['user']; + } + + // Password + if (!empty($urlinfo['pass'])) { + $this->pass = $urlinfo['pass']; + } + + // Host + if (!empty($urlinfo['host'])) { + $this->host = $urlinfo['host']; + } + + // Port + if (!empty($urlinfo['port'])) { + $this->port = $urlinfo['port']; + } + + // Path + if (!empty($urlinfo['path'])) { + $this->path = $urlinfo['path']; + } + + // Querystring + if (!empty($urlinfo['query'])) { + $this->querystring = explode('&', $urlinfo['query']); + for ($i = 0; $i < count($this->querystring); $i++) { + list($name, $value) = explode('=', $this->querystring[$i]); + $querystring[$name] = $value; + } + $this->querystring = $querystring; + } + + // Anchor + if (!empty($urlinfo['fragment'])) { + $this->anchor = $urlinfo['fragment']; + } + } - /** + /** * Returns full url - * - * @return string Full url - * @access public - */ - function getURL() - { - $querystring = $this->getQueryString(); - - $this->url = $this->protocol . '://' - . $this->user . (!empty($this->pass) ? ':' : '') - . $this->pass . (!empty($this->user) ? '@' : '') - . $this->host . ($this->port == '80' ? '' : ':' . $this->port) - . $this->path - . (!empty($querystring) ? '?' . $querystring : '') - . (!empty($this->anchor) ? '#' . $this->anchor : ''); + * + * @return string Full url + * @access public + */ + function getURL() + { + $querystring = $this->getQueryString(); + + $this->url = $this->protocol . '://' + . $this->user . (!empty($this->pass) ? ':' : '') + . $this->pass . (!empty($this->user) ? '@' : '') + . $this->host . ($this->port == '80' ? '' : ':' . $this->port) + . $this->path + . (!empty($querystring) ? '?' . $querystring : '') + . (!empty($this->anchor) ? '#' . $this->anchor : ''); - return $this->url; - } + return $this->url; + } - /** + /** * Adds a querystring item - * - * @param $name Name of item - * @param $value Value of item - * @param $preencoded Whether value is urlencoded or not, default = not - * @access public<> - */ - function addQueryString($name, $value, $preencoded = false) - { - $this->querystring[$name] = $preencoded ? $value : urlencode($value); - } - - /** + * + * @param $name Name of item + * @param $value Value of item + * @param $preencoded Whether value is urlencoded or not, default = not + * @access public<> + */ + function addQueryString($name, $value, $preencoded = false) + { + $this->querystring[$name] = $preencoded ? $value : urlencode($value); + } + + /** * Sets the querystring to literally what you supply - * - * @param $querystring The querystring data. Should be of the format foo=bar&x=y etc - * @param $preencoded Whether data is already urlencoded or not, default = already encoded - * @access public - */ - function addRawQueryString($querystring, $preencoded = true) - { - $querystring = explode('&', $querystring); - for ($i = 0; $i < count($querystring); $i++) { - list($name, $value) = explode('=', $querystring[$i]); - $this->querystring[$name] = $preencoded ? $value : urlencode($value); - } - } + * + * @param $querystring The querystring data. Should be of the format foo=bar&x=y etc + * @param $preencoded Whether data is already urlencoded or not, default = already encoded + * @access public + */ + function addRawQueryString($querystring, $preencoded = true) + { + $querystring = explode('&', $querystring); + for ($i = 0; $i < count($querystring); $i++) { + list($name, $value) = explode('=', $querystring[$i]); + $this->querystring[$name] = $preencoded ? $value : urlencode($value); + } + } - /** + /** * Returns flat querystring - * - * @return string Querystring - * @access public - */ - function getQueryString() - { - if (!empty($this->querystring)) { - foreach ($this->querystring as $name => $value) { - $querystring[] = $name . '=' . $value; - } - $querystring = implode('&', $querystring); - } else { - $querystring = ''; - } + * + * @return string Querystring + * @access public + */ + function getQueryString() + { + if (!empty($this->querystring)) { + foreach ($this->querystring as $name => $value) { + $querystring[] = $name . '=' . $value; + } + $querystring = implode('&', $querystring); + } else { + $querystring = ''; + } - return $querystring; - } + return $querystring; + } } ?>