Exemple #1
0
 static function LoadPage($PageName, $Wrapper = true)
 {
     if (KERNEL::IsValidPage($PageName) == false) {
         KERNEL::OnError("Attempt to load invalid page '" . $PageName . "'");
     }
     if (!is_null(KERNEL::$Pages[$PageName][2])) {
         $Result = call_user_func(KERNEL::$Pages[$PageName][2]);
         if ($Result !== true) {
             KERNEL::OnError("Access Denied - " . $Result);
             die("");
             // Force cancel just incase
         }
     }
     if ($Wrapper) {
         global $GMDConfig;
         $OpenID = new LightOpenID($GMDConfig["Domain"]);
         if ($OpenID->validate()) {
             $ID = $OpenID->identity;
             $URL_Parts = explode("/", $ID);
             // Get their SteamID
             $CommunityID = $URL_Parts[sizeof($URL_Parts) - 1];
             $SteamID = CommunityToSteam($CommunityID);
             // Try and authenticate them
             $User = User::GetByField("User", "SteamID", $SteamID);
             if ($User->IsReal()) {
                 $User->AuthToUser();
             } else {
                 User::RegisterUser($SteamID, $_SERVER['REMOTE_ADDR'])->AuthToUser();
             }
             KERNEL::HardNavigate("home");
         } elseif ($_GET["page"] == "login") {
             if (User::$ActiveUser != false) {
                 if (isset($_GET["logout"])) {
                     User::Logout();
                 }
                 KERNEL::HardNavigate("home");
             } else {
                 $OpenID->identity = 'http://steamcommunity.com/openid';
                 header('Location: ' . $OpenID->authUrl());
             }
         }
         LightOpenID::revalidate();
     }
     global $OutputData;
     $OutputData = "";
     if ($Wrapper) {
         require "includes/util/header.php";
     }
     require "pages/" . $PageName . "/_process.php";
     require "pages/" . $PageName . "/_display.php";
     echo $OutputData;
     if ($Wrapper) {
         require "includes/util/footer.php";
     }
 }