/**
  * 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();
         }
     }
 }
示例#2
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;
         }
     }
 }