Example #1
0
    }
}
// 4) Language
if (!isset($session['lang'])) {
    $session['lang'] = '';
}
set_emoncms_lang($session['lang']);
// 5) Get route and load controller
$route = new Route(get('q'), server('DOCUMENT_ROOT'), server('REQUEST_METHOD'));
if (get('embed') == 1) {
    $embed = 1;
} else {
    $embed = 0;
}
// If no route specified use defaults
if ($route->isRouteNotDefined()) {
    if (!isset($session['read']) || isset($session['read']) && !$session['read']) {
        // Non authenticated defaults
        $route->controller = $default_controller;
        $route->action = $default_action;
        $route->subaction = "";
    } else {
        // Authenticated defaults
        $route->controller = $default_controller_auth;
        $route->action = $default_action_auth;
        $route->subaction = "";
    }
}
if ($devicekey && !($route->controller == 'input' && ($route->action == 'bulk' || $route->action == 'post'))) {
    header($_SERVER["SERVER_PROTOCOL"] . " 401 Unauthorized");
    print "Unauthorized. Device key autentication only permits input post or bulk actions";