Exemplo n.º 1
0
function url_action_subactions($actions)
{
    return function (&$data, $url_now, &$url_next) use($actions) {
        $result = url_process($url_next, $actions, $data);
        if ($result !== NULL) {
            $url_next = $result;
        } else {
            $url_next = array();
        }
    };
}
Exemplo n.º 2
0
function _ratatoeskr()
{
    global $backend_subactions, $ste, $url_handlers, $ratatoeskr_settings, $plugin_objs, $api_compat;
    $ts_start = microtime(True);
    session_start();
    db_connect();
    clean_database();
    if (isset($ratatoeskr_settings["debugmode"]) and $ratatoeskr_settings["debugmode"]) {
        define("__DEBUG__", True);
    }
    if (PLUGINS_ENABLED) {
        $activeplugins = array_filter(Plugin::all(), function ($plugin) {
            return $plugin->active;
        });
        foreach ($activeplugins as $plugin) {
            if (!in_array($plugin->api, $api_compat)) {
                $plugin->active = False;
                $plugin->save();
                continue;
            }
            eval($plugin->code);
            $plugin_obj = new $plugin->classname($plugin->get_id());
            if ($plugin->update) {
                $plugin_obj->update();
                $plugin->update = False;
                $plugin->save();
            }
            $plugin_obj->init();
            $plugin_objs[$plugin->get_id()] = $plugin_obj;
        }
    }
    /* Register URL handlers */
    build_backend_subactions();
    register_url_handler("_default", "frontend_url_handler");
    register_url_handler("_index", "frontend_url_handler");
    register_url_handler("index", "frontend_url_handler");
    register_url_handler("backend", $backend_subactions);
    register_url_handler("_notfound", url_action_simple(function ($data) {
        global $ste;
        header("HTTP/1.1 404 Not Found");
        $ste->vars["title"] = "404 Not Found";
        $ste->vars["details"] = str_replace("[[URL]]", $_SERVER["REQUEST_URI"], isset($translation) ? $translation["e404_details"] : "The page [[URL]] could not be found. Sorry.");
        echo $ste->exectemplate("/systemtemplates/error.html");
    }));
    $urlpath = explode("/", @$_GET["action"]);
    $rel_path_to_root = implode("/", array_merge(array("."), array_repeat("..", count($urlpath) - 1)));
    $GLOBALS["rel_path_to_root"] = $rel_path_to_root;
    $data = array("rel_path_to_root" => $rel_path_to_root);
    $ste->vars["rel_path_to_root"] = $rel_path_to_root;
    url_process($urlpath, $url_handlers, $data);
    if (PLUGINS_ENABLED) {
        foreach ($plugin_objs as $plugin_obj) {
            $plugin_obj->atexit();
        }
    }
    $ratatoeskr_settings->save();
}
Exemplo n.º 3
0
                $settings["repo_baseurl"] = $_POST["repo_baseurl"];
                $settings["repo_mode"] = $_POST["repo_mode"];
                update_repometa();
                $settings["setup_finished"] = True;
                $url_next = array("_prelude", "index");
                return;
            }
        }
    }
    $ste->vars["baseurl_predicted"] = self_url();
    echo $ste->exectemplate("setup.html");
});
/* bootstrapping... */
$urlpath = explode("/", $_GET["action"]);
$rel_path_to_root = implode("/", array_merge(array("."), array_repeat("..", count($urlpath) - 1)));
$GLOBALS["rel_path_to_root"] = $rel_path_to_root;
$data = array("rel_path_to_root" => $rel_path_to_root);
$ste->vars["rel_path_to_root"] = $rel_path_to_root;
/* Enforce setup */
if (!@$settings["setup_finished"]) {
    $urlpath = array("setup");
}
try {
    url_process($urlpath, $url_handlers, $data);
} catch (Exception $e) {
    header("HTTP/1.1 500 Internal Server Error");
    header("Content-Type: text/plain");
    echo "Internal Server Error\nReason: " . get_class($e) . "(" . $e->getMessage() . ") thrown.\n";
}
/* save settings */
$settings->save();