/**
  * Loads all, and redirect the user
  */
 public function start()
 {
     // Starting the session
     session_start();
     // If the user is logged
     if (isset($_SESSION["logged"]) && $_SESSION["logged"] == true) {
         // If the current route is 'Login'
         if (\Paladin\Paladin::getRouteLoader()->getCurrentRoute()['name'] == "Login") {
             // Redirecting him to the index
             header("Location: " . \Paladin\Paladin::getRootFolder());
         } else {
             // Loading the route, normally
             \Paladin\Paladin::getRouteLoader()->loadRoute();
         }
     } else {
         // If the current route isn't in the authorized page list
         if (!$this->isAuthorized(\Paladin\Paladin::getRouteLoader()->getCurrentRoute()['name'])) {
             // Redirecting it
             header("Location: " . \Paladin\Paladin::getRootFolder() . "Login");
         } else {
             // Loading the route, normally
             \Paladin\Paladin::getRouteLoader()->loadRoute();
         }
     }
 }
 public function onCalling($args)
 {
     // Getting the super folder while it ends with ..
     while (isset($args[sizeof($args)]) && $args[sizeof($args)] == "..") {
         unset($args[sizeof($args) - 1]);
         unset($args[sizeof($args) - 1]);
         // Then redirecting
         $redirect = true;
     }
     // Getting the path to explore
     $path = "";
     if (sizeof($args) > 0) {
         foreach ($args as $f) {
             $path .= $f . "/";
         }
     } else {
         $path = "files/";
         $redirect = true;
     }
     // Replacing the //
     $path = str_replace("//", "/", $path);
     // Deleting the last /
     $path = substr($path, 0, strlen($path) - 1);
     // Redirecting if needed
     if (isset($redirect) && $redirect) {
         header("Location: " . \Paladin\Paladin::getRootFolder() . "FileExplorer/" . $path);
         return;
     }
     // If it doesn't exist redirecting the the main explorer
     if (!file_exists($path)) {
         header("Location: " . \Paladin\Paladin::getRootFolder() . "FileExplorer");
         return;
     }
     // If it is not a directory
     if (!is_dir($path)) {
         header("Content-Type: application/force-download; name=\"" . basename($path) . "\"");
         header("Content-Transfer-Encoding: binary");
         header("Content-Length: " . filesize($path));
         header("Content-Disposition: attachment; filename=\"" . basename($path) . "\"");
         header("Expires: 0");
         header("Cache-Control: no-cache, must-revalidate");
         header("Pragma: no-cache");
         readfile($path);
         return;
     }
     // Then displaying the page
     \Paladin\Paladin::getPageLoader()->displayPage("\\SUpdateServer\\Pages", "FileExplorer", array("path" => $path, "files" => self::scan($path), "root" => \Paladin\Paladin::getRootFolder()));
 }
示例#3
0
 private function checkFormResponse()
 {
     // If the password/laguage aren't given
     if (!isset($_POST["password"]) || !isset($_POST["language"])) {
         // Displaying the install page
         \Paladin\Paladin::getPageLoader()->displayPage("\\SUpdateServer\\Pages", "Install", array());
     } else {
         // Seting the user logged
         $_SESSION["logged"] = true;
         // Saving the config
         file_put_contents(\SUpdateServer\SessionManager::getSessionManager()->getPasswordLocation(), sha1($_POST["password"]));
         \SUpdateServer\LangLoader\LangLoader::getLangLoader()->setCurrentLang($_POST["language"]);
         // Redirecting the user
         header("Location: " . \Paladin\Paladin::getRootFolder());
     }
 }
示例#4
0
 private function checkFormResponse()
 {
     // If the password isn't given
     if (!isset($_POST["password"])) {
         // Displaying the login page
         \Paladin\Paladin::getPageLoader()->displayPage("\\SUpdateServer\\Pages", "Login", array("badPassword" => false, "serverActivated" => \SUpdateServer\ServerState::isEnabled()));
     } else {
         if (\SUpdateServer\SessionManager::getSessionManager()->checkPassword($_POST["password"])) {
             // Seting the user logged
             $_SESSION["logged"] = true;
             // Going to the index page
             header("Location: " . \Paladin\Paladin::getRootFolder());
         } else {
             // Displaying the login page, with a bad password message
             \Paladin\Paladin::getPageLoader()->displayPage("\\SUpdateServer\\Pages", "Login", array("badPassword" => true, "serverActivated" => \SUpdateServer\ServerState::isEnabled()));
         }
     }
 }
 /**
  * The icon of the entry
  */
 public function getIcon()
 {
     return \Paladin\Paladin::getRootFolder() . \Paladin\PaladinTwigExtension::getFile("Dashboard", "images/fileexplorer.png", true, "resources");
 }
示例#6
0
 public function beforeDisplayed()
 {
     if (\SUpdateServer\ServerState::isEnabled() == false) {
         header("Location: " . \Paladin\Paladin::getRootFolder());
     }
 }
 /**
  * Display an error page
  *
  * @param errorType
  *            The type of the error
  * @param errorDescription
  *            The description of the error
  * @param errorBacktrace
  *            The backtrace of the error
  */
 public static function displayErrorPage($errorType, $errorDescription, $errorBacktrace)
 {
     // Getting the error page
     $errorPage = file_get_contents(self::$errorPageLocation);
     // Replacing the variables, with the messages, the title, etc...
     $errorPage = str_replace("__ROOT_DIR__", \Paladin\Paladin::getRootFolder(), $errorPage);
     $errorPage = str_replace("__MESSAGE__", $errorDescription, $errorPage);
     $errorPage = str_replace("__TITLE__", $errorType, $errorPage);
     $errorPage = str_replace("__BG_LOCATION__", \Paladin\Paladin::getRootFolder() . \Paladin\PaladinTwigExtension::getFile("shared", "background.png", true, "resources"), $errorPage);
     if (function_exists('debug_backtrace')) {
         $errorPage = str_replace("<!-- __BACKTRACE__ -->", $errorBacktrace, $errorPage);
     }
     // Then diplaying it
     echo $errorPage;
 }