示例#1
0
 public function onCalling($args)
 {
     // Getting the Paladin version
     $paladinVersion = file_get_contents("paladin.version");
     // Getting the Twig version
     $twigVersion = "1.18";
     // Getting the S-Update-Server version
     $serverVersion = file_get_contents("s-update-server.version");
     // Getting the server state
     $serverEnabled = \SUpdateServer\ServerState::isEnabled();
     // Displaying the index page
     \Paladin\Paladin::getPageLoader()->displayPage("\\SUpdateServer\\Pages", "Index", array("paladinVersion" => $paladinVersion, "serverVersion" => $serverVersion, "serverEnabled" => $serverEnabled));
 }
 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()));
         }
     }
 }
示例#5
0
 public function checkFormResponse()
 {
     // If the form variable exist
     if (isset($_POST["form"])) {
         // If the form is the password form
         if ($_POST["form"] == "passwordForm") {
             // If the password variable exist
             if (isset($_POST["password"])) {
                 // Writing it
                 file_put_contents(\SUpdateServer\SessionManager::getSessionManager()->getPasswordLocation(), sha1($_POST["password"]));
                 // Then redirecting the user
                 header("Location: Index");
             } else {
                 // Displaying the settings page
                 \Paladin\Paladin::getPageLoader()->displayPage("\\SUpdateServer\\Pages", "Settings", array());
             }
         } else {
             if ($_POST["form"] == "langForm") {
                 // If the language variable exist
                 if (isset($_POST["language"])) {
                     // Setting it
                     \SUpdateServer\LangLoader\LangLoader::getLangLoader()->setCurrentLang($_POST["language"]);
                     // Then redirecting the user
                     header("Location: Index");
                 } else {
                     // Displaying the settings page
                     \Paladin\Paladin::getPageLoader()->displayPage("\\SUpdateServer\\Pages", "Settings", array());
                 }
             } else {
                 // Displaying the settings page
                 \Paladin\Paladin::getPageLoader()->displayPage("\\SUpdateServer\\Pages", "Settings", array());
             }
         }
     } else {
         // Displaying the settings page
         \Paladin\Paladin::getPageLoader()->displayPage("\\SUpdateServer\\Pages", "Settings", array());
     }
 }
示例#6
0
 public function onCalling($args)
 {
     \Paladin\Paladin::getPageLoader()->displayPage("\\SUpdateServer\\Pages", "Dashboard", array(\SUpdateServer\Dashboard\DashboardManager::getEntries()));
 }
示例#7
0
 /**
  * Loads the applications
  */
 private function loadApps()
 {
     // Getting the files in the applications folder
     $apps = scandir($this->folder);
     // For each file in the folder
     for ($i = 0; $i < count($apps); $i++) {
         // If it is the current/parent folder
         if (trim($apps[$i]) == "." || trim($apps[$i]) == "..") {
             // Continuing the loop
             continue;
         }
         // If it is a directory
         if (is_dir($this->folder . "/" . $apps[$i])) {
             // Getting the application main class path
             $appMainClassPath = $this->folder . "/" . $apps[$i] . "/" . $apps[$i] . ".php";
             // If it doesn't exists
             if (!file_exists($appMainClassPath)) {
                 // Displaying an error page
                 \Paladin\Paladin::getPageLoader()->displayPage("\\Paladin\\Pages", "ErrorPage", array("Application mistake", "Sorry ! We can't find the main class of the application : " . $apps[$i] . " ( file needed : " . $appMainClassPath . ") !"));
                 // Stopping
                 die;
             }
             // Loading it
             require $appMainClassPath;
             // Getting the app php name
             $appPhpName = "\\SUpdateServer\\Applications\\" . $apps[$i];
             // Instancing it
             $app = new $appPhpName();
             // If it is not an Application
             if (!$app instanceof Application) {
                 // Displaying an error page
                 \Paladin\Paladin::getPageLoader()->displayPage("\\Paladin\\Pages", "ErrorPage", array("Application mistake", "Sorry ! The Application " . $apps[$i] . " main class is not extending \\SUpdateServer\\AppLoader\\Application but need to !"));
                 // Stopping
                 die;
             }
             // Executing the preLoad event
             $app->preLoad();
             // Adding its route folder to the Route Loader
             \Paladin\Paladin::getRouteLoader()->addFolder($this->folder . "/" . $apps[$i] . "/Routes/");
             // Creating its Page Loader
             $app->setPageLoader(new \Paladin\PageLoader($this->folder . "/" . $apps[$i] . "/Pages/"));
             // Executing the load event
             $app->load();
             // Adding it to the list
             $this->apps[sizeof($this->apps)] = $app;
         }
     }
 }
示例#8
0
 public function onCalling($args)
 {
     \Paladin\Paladin::getPageLoader()->displayPage("\\SUpdateServer\\Pages", "About", array("serverVersion" => file_get_contents("s-update-server.version")));
 }
 /**
  * Loads the check methods
  */
 private function loadCheckMethods()
 {
     // Getting the files in the check methods folder
     $checkMethods = scandir($this->folder);
     // For each file in the folder
     for ($i = 0; $i < count($checkMethods); $i++) {
         // If it is the current/parent folder, or it is .htaccess
         if (trim($checkMethods[$i]) == "." || trim($checkMethods[$i]) == ".." || trim($checkMethods[$i]) == ".htaccess") {
             // Continuing the loop
             continue;
         }
         // Getting the check method path
         $checkMethodPath = $this->folder . "/" . $checkMethods[$i];
         // If it is a directory
         if (is_dir($checkMethodPath)) {
             // Continuing the loop
             continue;
         }
         // Loading it
         require $checkMethodPath;
         // Getting the class path
         $classPath = '\\SUpdateServer\\Checking\\' . substr($checkMethods[$i], 0, strlen($checkMethods[$i]) - 4);
         // Instancing it
         $checkMethod = new $classPath();
         // If it is not an CheckMethod
         if (!$checkMethod instanceof CheckMethod) {
             // Displaying an error page
             \Paladin\Paladin::getPageLoader()->displayPage("\\Paladin\\Pages", "ErrorPage", array("CheckMethod mistake", "Sorry ! The CheckMethod " . $checkMethods[$i] . " main class is not extending \\SUpdateServer\\AppLoader\\CheckLoader but need to !"));
             // Stopping
             die;
         }
         // Adding it to the list
         $this->checkMethods[sizeof($this->checkMethods)] = $checkMethod;
     }
 }