public function __construct($id, $row = null) { if ($id != -1 && GameserverManager::ExistsById($id)) { // Check if (null != $row) { $this->Data = $row; } else { $con = Database::getCon(); $res = $con->query("SELECT * FROM gameserver WHERE id = {$id}") or die(mysqli_error($con)); $this->Data = $res->fetch_array(); $this->Data["settings"] = json_decode($this->Data["settings"], true); unset($this->Data["settings"][0]); $this->initDataObject("gameserver", "id", $id); } } else { die("tried to create gameserver with no valid id"); } }
public function setSelectedGameserver($gameserver) { if ($gameserver != null) { if (GameserverManager::ExistsById($gameserver->getData("id"))) { if ($gameserver->getOwnerId() == $this->getData("id")) { $_SESSION["gameserver"] = $gameserver->getData("id"); } else { $_SESSION["gameserver"] = INVALID_ID; } } else { $_SESSION["gameserver"] = INVALID_ID; } } else { $_SESSION["gameserver"] = INVALID_ID; } }