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"; } }
<?php if (Servers::GetCacheCount("Servers") == 0) { KERNEL::OnError("You must first add a server before adding an item.", false); } else { if (isset($_FILES["itemImage"])) { $ImageURLName = "item_default.png"; // TODO -- Make this utilize the built in functionality of the Item class if (isset($_FILES["itemImage"])) { $File = $_FILES["itemImage"]; $FileExtension = end(explode(".", $File["name"])); $FileType = $File["type"]; $FileSize = $File["size"]; if (75000 < $FileSize) { // Too Big } elseif ($FileType != "image/png" && $FileType != "image/jpg" && $FileType != "image/jpeg") { // Bad Type } elseif ($FileExtension != "png" && $FileExtension != "jpg" && $FileExtension != "jpeg") { // Bad Extension } else { $ImageURLName = md5(rand()); move_uploaded_file($File["tmp_name"], "includes/images/uploaded/" . $ImageURLName . "." . $FileExtension); } } Database::Insert("gmd_items", array("Category" => intval($_POST["catID"]), "Name" => $_POST["itemName"], "Description" => $_POST["itemDesc"], "Cost" => floatval($_POST["itemCost"]), "Image" => $ImageURLName, "ShowImage" => !empty($_POST["showImage"]) ? 1 : 0, "Status" => ItemStatus::ACTIVE)); echo "<h4>You are being redirected..</h4>"; KERNEL::HardNavigate("admin", "&area=items"); } else { $CatObj = ItemCategory::GetByField("ItemCategory", "ID", $_GET["catid"]); ?>
<?php $ItemCategories = ItemCategory::GetCachedResults("ItemCategory"); if (count($ItemCategories) == 0) { KERNEL::OnError("You must add an item category before accessing this page.", false); } else { foreach ($ItemCategories as $ItemCat) { echo ' <div class="panel panel-default"> <div class="panel-heading"> <a href="?page=admin&area=items&newitem=1&catid=' . $ItemCat->GetValue("ID") . '" style="float: right;"><span class="btn btn-xs btn-success">Add Item</span></a> <b>' . $ItemCat->GetValue("Name") . ' Items</b> </div> <table class="table"> <thead style="font-size: 12px;"> <th style="width: 50%;">Name</th> <th style="width: 25%;">Cost</th> <th style="width: 25%;text-align: right;">Actions</th> </thead> <tbody> '; $Items = Item::SearchCachedResults("Item", "Category", $ItemCat->GetValue("ID")); if (count($Items) == 0) { echo '<tr><td colspan=3 style="text-align: center;padding: 16px;font-size: 12px;"><i>No items to display!</i></td></tr>'; } else { foreach ($Items as $ItemObj) { echo ' <tr style="font-size: 12px;"> <td>' . $ItemObj->GetValue("Name") . '