Example #1
0
define('QUERY_STRING_HTML', QUERY_STRING_BLANK_HTML . CURRENT_MODULE);
//Строка запроса для текущего модуля в HTML формате.
unset($neededModule, $curModule);
//Загрузка языка модуля.
if (!file_exists('system/lng/' . CURRENT_MODULE . '.lng.' . $userData['language'] . '.php')) {
    $userData['language'] = DEFAULT_LANGUAGE;
}
require_once 'system/lng/' . CURRENT_MODULE . '.lng.' . $userData['language'] . '.php';
//Запуск модуля.
require_once 'system/' . CURRENT_MODULE . '.php';
# Controller?
require_once 'system/lib/MVC.php';
if (class_exists(CURRENT_MODULE . Router::CONTROLLER_SUFFIX)) {
    /* Routing */
    try {
        $router = Router::forClass(CURRENT_MODULE);
        $response = $router->invoke($neededControllerAction, $_REQUEST);
    } catch (NoControllerRouteException $e) {
        return http_error400('Unknown module: ' . $e->getMessage());
    } catch (NoMethodRouteException $e) {
        return http_error400('Unknown action: ' . $e->getMessage());
    } catch (ParamRequiredRouteException $e) {
        return http_error400('Missing param: ' . $e->getMessage());
    } catch (ShouldBeArrayRouteException $e) {
        return http_error400('Param should be an array: ' . $e->getMessage());
    } catch (ActionException $e) {
        return http_error400($e->getMessage());
    } catch (PDOException $e) {
        return http_error400('Database error: ' . $e);
    } catch (Exception $e) {
        return http_error400('Generic error: ' . $e);
Example #2
0
    return http_error(403, 'Unauthorized', 'Invalid security token');
}
/* PHP errors */
if ($components['.'] == 'dump') {
    // Only allowed in .dump
    error_reporting(E_ALL);
    ini_set('display_errors', 1);
} else {
    error_reporting(0);
    ini_set('display_errors', 0);
}
/* Controllers */
require_once "system/api.php";
/* Routing */
try {
    $router = Router::forClass($components['controller']);
    $response = $router->invoke($components['action'], $_REQUEST);
    if (FALSE === $response) {
        return;
    }
} catch (NoControllerRouteException $e) {
    return http_error400('Unknown controller: ' . $e->getMessage());
} catch (NoMethodRouteException $e) {
    return http_error400('Unknown method: ' . $e->getMessage());
} catch (ParamRequiredRouteException $e) {
    return http_error400('Missing param: ' . $e->getMessage());
} catch (ShouldBeArrayRouteException $e) {
    return http_error400('Param should be an array: ' . $e->getMessage());
} catch (ActionException $e) {
    return http_error400($e->getMessage());
}