
Untitled
By: a guest on
Aug 23rd, 2012 | syntax:
None | size: 1.08 KB | hits: 7 | expires: Never
public static function uri()
{
/**
* A lot of fuzzing around to get to where we want.
*/
$uri = parse_url($_SERVER['REQUEST_URI']);
$uri = $uri['path'];
$uri = trim(str_replace(basename($_SERVER['SCRIPT_NAME']), '', $uri), '/');
$uri = explode('/', $uri);
/**
* Count how many slashes there are in the base URL.
*/
foreach(count_chars(\Rawr\Rawr::get_config_value('url'), 1) as $i => $val)
{
if(chr($i) === "/")
{
$slashes = $val;
}
}
/*
* Get rid of both index.php if it's in the request and/or subfolders
* I'm dumb and hence I have no idea how to make this shorter and sweeter. Maybe in the future.
*/
if(\Rawr\Rawr::get_config_value('index') === "")
{
if($slashes === 4)
{
unset($uri[0]);
}
if($slashes === 5)
{
unset($uri[1]);
}
if($slashes === 6)
{
unset($uri[2]);
}
}
else
{
if($slashes === 4)
{
unset($uri[0], $uri[1]);
}
if($slashes === 5)
{
unset($uri[0], $uri[1], $uri[2]);
}
if($slashes === 6)
{
unset($uri[0], $uri[1], $uri[2], $uri[3]);
}
}
/**
* Shabam!
*/
return array_values($uri);
}