78 if ($this->uri_protocol ==
'AUTO') {
80 if (php_sapi_name() ==
'cli' || defined(
'STDIN')) {
93 $path=(isset($_SERVER[
'PATH_INFO'])) ? $_SERVER[
'PATH_INFO'] : @getenv(
'PATH_INFO');
94 if (trim($path,
'/') !=
'' && $path !=
"/" . SELF) {
100 $path=(isset($_SERVER[
'QUERY_STRING'])) ? $_SERVER[
'QUERY_STRING'] : @getenv(
'QUERY_STRING');
101 if (trim($path,
'/') !=
'') {
107 if (\is_array($_GET) && count($_GET) == 1 && trim(key($_GET),
'/') !=
'') {
117 if ($uri ==
'REQUEST_URI') {
122 $path=(isset($_SERVER[$uri])) ? $_SERVER[$uri] : @getenv($uri);
157 if (!isset($_SERVER[
'REQUEST_URI']) || !isset($_SERVER[
'SCRIPT_NAME'])) {
161 $uri=$_SERVER[
'REQUEST_URI'];
162 if (strpos($uri, $_SERVER[
'SCRIPT_NAME']) === 0) {
163 $uri=substr($uri, strlen($_SERVER[
'SCRIPT_NAME']));
164 } elseif (strpos($uri, dirname($_SERVER[
'SCRIPT_NAME'])) === 0) {
165 $uri=substr($uri, strlen(dirname($_SERVER[
'SCRIPT_NAME'])));
170 if (strncmp($uri,
'?/', 2) === 0) {
171 $uri=substr($uri, 2);
173 $parts=preg_split(
'#\?#i', $uri, 2);
175 if (isset($parts[1])) {
176 $_SERVER[
'QUERY_STRING']=$parts[1];
177 parse_str($_SERVER[
'QUERY_STRING'], $_GET);
179 $_SERVER[
'QUERY_STRING']=
'';
183 if ($uri ==
'/' || empty($uri)) {
187 $uri=parse_url($uri, PHP_URL_PATH);
190 return str_replace(array (
'//',
'../' ),
'/', trim($uri,
'/'));
205 $args=array_slice($_SERVER[
'argv'], 1);
207 return $args ?
'/' . implode(
'/', $args) :
'';
221 if ($str !=
'' && $this->permitted_uri_chars !=
'' && $this->enable_query_strings == FALSE) {
224 if (!preg_match(
"|^[" . str_replace(array (
'\\-',
'\-' ),
'-', preg_quote($this->permitted_uri_chars,
'-')) .
"]+$|i", $str)) {
225 show_error(
'The URI you submitted has disallowed characters.', 400);
230 $bad=array (
'$',
'(',
')',
'%28',
'%29' );
231 $good=array (
'$',
'(',
')',
'(',
')' );
233 return str_replace($bad, $good, $str);
246 foreach ( explode(
"/", preg_replace(
"|/*(.+?)/*$|",
"\\1", $this->
uri_string)) as $val ) {
251 $this->segments[]=$val;
270 array_unshift($this->segments, NULL);
271 array_unshift($this->rsegments, NULL);
272 unset($this->segments[0]);
273 unset($this->rsegments[0]);
290 return (!isset($this->segments[$n])) ? $no_result : $this->segments[$n];
309 return (!isset($this->rsegments[$n])) ? $no_result : $this->rsegments[$n];
367 if ($which ==
'segment') {
368 $total_segments=
'total_segments';
369 $segment_array=
'segment_array';
371 $total_segments=
'total_rsegments';
372 $segment_array=
'rsegment_array';
375 if (!is_numeric($n)) {
379 if (isset($this->keyval[$n])) {
380 return $this->keyval[$n];
383 if ($this->$total_segments() < $n) {
384 if (count($default) == 0) {
389 foreach ( $default as $val ) {
395 $segments=array_slice($this->$segment_array(), ($n - 1));
402 $retval[$lastval]=$seg;
411 if (count($default) > 0) {
412 foreach ( $default as $val ) {
413 if (!array_key_exists($val, $retval)) {
420 $this->keyval[$n]=$retval;
437 foreach ( ( array ) $array as $key => $val ) {
442 return implode(
'/', $temp);
491 if ($where ==
'trailing') {
493 } elseif ($where ==
'leading') {
497 return $leading . $this->$which($n) . $trailing;
536 return count($this->segments);
549 return count($this->rsegments);
__construct()
Constructor.
_reindex_segments()
Re-index Segments.
_explode_segments()
Explode the URI Segments.
_detect_uri()
Detects the URI.
_parse_cli_args()
Parse cli arguments.
ruri_to_assoc($n=3, $default=array())
Identical to above only it uses the re-routed segment array.
ruri_string()
Fetch the entire Re-routed URI string.
total_segments()
Total number of segments.
assoc_to_uri($array)
Generate a URI string from an associative array.
uri_to_assoc($n=3, $default=array())
Generate a key value pair from the URI string.
segment($n, $no_result=FALSE)
Fetch a URI Segment.
_set_uri_string($str)
Set the URI String.
_uri_to_assoc($n=3, $default=array(), $which='segment')
Generate a key value pair from the URI string or Re-routed URI string.
_slash_segment($n, $where='trailing', $which='segment')
Fetch a URI Segment and add a trailing slash - helper function.
rsegment_array()
Routed Segment Array.
slash_rsegment($n, $where='trailing')
Fetch a URI Segment and add a trailing slash.
slash_segment($n, $where='trailing')
Fetch a URI Segment and add a trailing slash.
segment_array()
Segment Array.
_filter_uri($str)
Filter segments for malicious characters.
uri_string()
Fetch the entire URI string.
_fetch_uri_string()
Get the URI String.
$uri_protocol
| 'AUTO' Default - auto detects | 'PATH_INFO' Uses the PATH_INFO | 'QUERY_STRING' Uses the QUERY_STRI...
total_rsegments()
Total number of routed segments.
rsegment($n, $no_result=FALSE)
Fetch a URI "routed" Segment.