You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
vpslist/cphp/components/component.router.php

41 lines
813 B
PHTML

13 years ago
<?php
class CPHPRouter extends CPHPBaseClass
{
public $routes = array();
public $parameters = array();
public function RouteRequest()
{
eval(extract_globals()); // hack hackity hack hack
if(isset($_SERVER['REQUEST_URI']))
{
$requestpath = trim($_SERVER['REQUEST_URI']);
}
else
{
$requestpath = "/";
}
$found = false; // Workaround because a break after an include apparently doesn't work in PHP.
foreach($this->routes as $priority)
{
foreach($priority as $route_regex => $route_destination)
{
if($found === false)
{
$regex = str_replace("/", "\/", $route_regex);
if(preg_match("/{$regex}/i", $requestpath, $matches))
{
$this->uParameters = $matches;
include($route_destination);
$found = true;
}
}
}
}
}
}
?>