Exemplo n.º 1
0
        // 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>
            </html>
        <?php 
        die;
    }
}
$view = $controller->view();
if (No2_HTTP::is_error($view->status()) && !$controller->can_render_errors()) {
    /*
     * The controller declined error handling, so we load the default error
     * controller to generate the response.
     */
    require_once APPDIR . '/controllers/error.class.php';
    $controller = new ErrorController($view->status());
    unset($view);
    goto invoke_it;
}
/* from this point, $controller and $view are set and valid. */
/*
 * Here we know the status code, log the request and render the requested ressource.
 */
No2_Logger::info("{$_SERVER['REMOTE_ADDR']} - {$_SERVER['REQUEST_METHOD']} - {$_SERVER['REQUEST_URI']} - {$view->status()}");
Exemplo n.º 2
0
<?php

ini_set('display_errors', 0);
error_reporting(0);
define('APP_DIR', realpath('.'));
include_once APP_DIR . '/lib/lib.php';
$req = isset($_GET['p']) ? $_GET['p'] : 'home';
$className = ucfirst($req) . "Controller";
try {
    if (!class_exists($className)) {
        throw new Exception("Controller was not found.");
    }
    $controller = new $className($twig);
    switch ($req) {
        case 'home':
            break;
        case 'question':
            break;
        case 'thanks':
            break;
    }
} catch (Exception $e) {
    $controller = new ErrorController($twig);
}
echo $controller->view();