Пример #1
0
/*
 * Find the controller that registered for the requested URI. Note that here
 * $_REQUEST['controller'] stand for an alias and not a controller class, hence
 * the need of the router's logic.
 */
$controller = $router->find_route(isset($_REQUEST['controller']) ? $_REQUEST['controller'] : NULL, isset($_REQUEST['action']) ? $_REQUEST['action'] : NULL, $_SERVER['REQUEST_METHOD']);
if (is_null($controller)) {
    require_once APPDIR . '/controllers/error.class.php';
    $controller = new ErrorController(No2_HTTP::NOT_FOUND);
}
/*
 * Execute the requested action in order to be able to render the ressource.
 */
invoke_it:
if (No2_Logger::$level >= No2_Logger::DEBUG) {
    $controller->invoke();
} else {
    try {
        $controller->invoke();
    } catch (Exception $_) {
        // Something Bad™ happened. This exception wasn't expected, so we
        // go to a failsafe codepath.
        No2_Logger::err(__FILE__ . ': ' . $_->getMessage());
        header('HTTP/1.1 500 Internal Server Error');
        ?>
            <html>
                <head><title>500 Internal Server Error</title></head>
                <body>
                    <h1>500 Internal Server Error</h1>
                    <p>Please contact the site administrator</p>
                </body>