42 var
$options = array(
'encode_query_keys' =>
false);
134 $HTTP_SERVER_VARS = !empty($_SERVER) ? $_SERVER :
$GLOBALS[
'HTTP_SERVER_VARS'];
141 $this->querystring = array();
145 if (!preg_match(
'/^[a-z0-9]+:\/\//i', $this->url)) {
146 $this->protocol = (!empty($_SERVER[
'HTTPS']) && $_SERVER[
'HTTPS'] ==
'on' ?
'https' :
'http');
151 if (!empty($HTTP_SERVER_VARS[
'HTTP_HOST']) &&
152 preg_match(
'/^(.*)(:([0-9]+))?$/U', $HTTP_SERVER_VARS[
'HTTP_HOST'], $matches))
155 if (!empty($matches[3])) {
164 $this->host = !empty(
$host) ?
$host : (isset($HTTP_SERVER_VARS[
'SERVER_NAME']) ? $HTTP_SERVER_VARS[
'SERVER_NAME'] :
'localhost');
165 $this->port = !empty(
$port) ?
$port : (isset($HTTP_SERVER_VARS[
'SERVER_PORT']) ? $HTTP_SERVER_VARS[
'SERVER_PORT'] : $this->
getStandardPort($this->protocol));
166 $this->path = !empty($HTTP_SERVER_VARS[
'PHP_SELF']) ? $HTTP_SERVER_VARS[
'PHP_SELF'] :
'/';
167 $this->querystring = isset($HTTP_SERVER_VARS[
'QUERY_STRING']) ? $this->
_parseRawQuerystring($HTTP_SERVER_VARS[
'QUERY_STRING']) : null;
172 if (!empty($this->url)) {
173 $urlinfo = parse_url($this->url);
176 $this->querystring = array();
178 foreach ($urlinfo as
$key => $value) {
181 $this->protocol = $value;
189 $this->
$key = $value;
193 if ($value{0} ==
'/') {
194 $this->path = $value;
196 $path = dirname($this->path) == DIRECTORY_SEPARATOR ?
'' : dirname($this->path);
197 $this->path = sprintf(
'%s/%s',
$path, $value);
202 $this->querystring = $this->_parseRawQueryString($value);
206 $this->anchor = $value;
222 $this->url = $this->protocol .
'://'
223 . $this->user . (!empty($this->pass) ?
':' :
'')
224 . $this->pass . (!empty($this->user) ?
'@' :
'')
228 . (!empty($this->anchor) ?
'#' . $this->anchor :
'');
247 if ($this->
getOption(
'encode_query_keys')) {
252 $this->querystring[
$name] = $value;
254 $this->querystring[
$name] = is_array($value) ? array_map(
'rawurlencode', $value): rawurlencode($value);
266 if ($this->
getOption(
'encode_query_keys')) {
270 if (isset($this->querystring[
$name])) {
271 unset($this->querystring[$name]);
283 $this->querystring = $this->_parseRawQueryString(
$querystring);
294 if (!empty($this->querystring)) {
295 foreach ($this->querystring as
$name => $value) {
299 if (is_array($value)) {
300 foreach ($value as $k => $v) {
303 }
elseif (!is_null($value)) {
326 $parts = preg_split(
'/[' . preg_quote(ini_get(
'arg_separator.input'),
'/') .
']/',
$querystring, -1, PREG_SPLIT_NO_EMPTY);
329 foreach ($parts as $part) {
330 if (strpos($part,
'=') !==
false) {
331 $value = substr($part, strpos($part,
'=') + 1);
332 $key = substr($part, 0, strpos($part,
'='));
338 if (!$this->
getOption(
'encode_query_keys')) {
342 if (preg_match(
'#^(.*)\[([0-9a-z_-]*)\]#i',
$key, $matches)) {
347 if (empty($return[
$key]) || !is_array($return[$key])) {
348 $return[
$key] = array();
353 $return[
$key][] = $value;
355 $return[
$key][$idx] = $value;
357 }
elseif (!$this->useBrackets AND !empty($return[
$key])) {
358 $return[
$key] = (array)$return[$key];
359 $return[
$key][] = $value;
361 $return[
$key] = $value;
383 $path = explode(
'/', str_replace(
'//',
'/',
$path));
385 for ($i=0; $i<count(
$path); $i++) {
386 if (
$path[$i] ==
'.') {
391 }
elseif (
$path[$i] ==
'..' AND ($i > 1 OR ($i == 1 AND
$path[0] !=
'') ) ) {
407 return implode(
'/',
$path);
420 switch (strtolower($scheme)) {
421 case 'http':
return 80;
422 case 'https':
return 443;
423 case 'ftp':
return 21;
424 case 'imap':
return 143;
425 case 'imaps':
return 993;
426 case 'pop3':
return 110;
427 case 'pop3s':
return 995;
428 default:
return null;
456 if (!array_key_exists($optionName, $this->options)) {
460 $this->options[$optionName] = $value;
477 if (!isset($this->options[$optionName])) {
481 return $this->options[$optionName];