public function get($stat) { if ($stat != "connections" && $stat != "ips") { return new Response(200, "Bad Arguments"); } return Paladin::config("stats")->get($stat); }
public function postLogin() { if (isset($_POST["password"]) && sha1($_POST["password"]) == Paladin::config("server")->get("password")) { $_SESSION["logged"] = true; return new RedirectResponse("../panel/home"); } else { return Paladin::view("login.twig", array("error" => true, "serverActivated" => Paladin::config("server")->get("enabled"))); } }
public function postPanel($request) { if ($request == "settings") { if (isset($_POST["password"])) { Paladin::config("server")->set("password", sha1($_POST["password"])); return new RedirectResponse("home"); } } return new RedirectResponse("home"); }
public function postInstall() { if (isset($_POST["password"])) { Paladin::config("server")->set("enabled", false); Paladin::config("server")->set("password", sha1($_POST["password"])); Paladin::config("stats")->set("connections", 0); Paladin::config("stats")->set("ips", []); return new RedirectResponse("panel/home"); } return new Response("Argument fail", 500); }
public function postServer($request) { header("Content-Type: application/json"); switch ($request) { case "is-enabled": return new JsonResponse(array("enabled" => (bool) Paladin::config("server")->get("enabled"))); case "size": return $this->size(); case "version": return new JsonResponse(array("version" => SUpdateServer::SERVER_VERSION)); } return new Response("Unknown request"); }
/** * Start the server */ public static function start() { // Initializing session session_start(); // Setting up error handling PaladinErrorHandler::setErrorPageLocation("views/ErrorPage.html"); // Setting up debug if needed if (Paladin::config("app")->get("debug")) { $engine = Paladin::getViewingEngineManager()->getSelectedEngine(); if (get_class($engine) == 'Paladin\\Viewing\\TwigViewingEngine') { $engine->getTwig()->enableAutoReload(); $engine->getTwig()->enableDebug(); } } // Initializing CheckMethodLoader::create(); AppLoader::create(); // Creating files folder if needed if (!file_exists("files/")) { mkdir("files/"); } }
use Paladin\Http\RedirectResponse; use Paladin\Http\Response; use Paladin\Paladin; use SUpdateServer\SUpdateServer; $this->get("/", function () { return new RedirectResponse(Paladin::getRootPath(true) . "panel"); }); $this->get("/panel", function () { return new RedirectResponse(Paladin::getRootPath(true) . "panel/home"); }); $this->get("/panel/:request", ["middleware" => ["install", "auth"], "uses" => "PanelController@getPanel"]); $this->post("/panel/:request", ["middleware" => ["install", "auth"], "uses" => "PanelController@postPanel"]); $this->get("/aubergine", function () { return new RedirectResponse("http://www.google.fr/search?q=aubergine"); }); $this->get("/auth/logout", ["middleware" => ["install", "auth"], "uses" => "AuthController@logout"]); $this->get("/auth/login", ["middleware" => ["install", "auth"], "uses" => "AuthController@getLogin"]); $this->post("/auth/login", ["middleware" => ["install"], "uses" => "AuthController@postLogin"]); // Internal routes $this->get("/set-enabled/:enabled", ["middleware" => ["install", "auth"], "uses" => function ($enabled) { Paladin::config("server")->set("enabled", $enabled == "true"); return new Response(); }]); $this->get("/install", ["middleware" => "install", "uses" => "InstallController@getInstall"]); $this->post("/install", ["middleware" => "install", "uses" => "InstallController@postInstall"]); $this->post("/server/:request", "ServerController@postServer"); $this->post("/server/list/:checkmethod", "ServerController@listFiles"); $this->post("/server/check/:thing/:what", "ServerController@check"); $this->post("/stats/clear/:stat", ["middleware" => "auth", "uses" => "StatsController@clear"]); $this->post("/stats/update", ["middleware" => "auth", "uses" => "StatsController@update"]); $this->post("/stats/get/:stat", "StatsController@get");