public static function resolve($url) { if (strstr($url, '/admin') !== false) { Router::$module = 'admin'; } else { Router::$module = 'site'; } foreach (self::$routes[self::$module] as $route) { $regex = $route['regex']; if (isset($route['params'])) { foreach ($route['params'] as $k => $v) { $regex = str_replace('{' . $k . '}', "({$v})", $regex); } } $regex = "#^{$regex}\$#"; if (preg_match($regex, $url, $matches)) { $params = array(); array_shift($matches); self::$_controller = Router::$module . '\\' . $route['controller']; self::$_action = $route['action']; if ($matches) { $params = array_combine(array_keys($route['params']), $matches); } $_GET = $_GET + $params; } } if (!self::$_controller || !self::$_action) { throw new Exception('Page not found', 404); } }