/** * Display the main admin area * * Includes player viewing, account duplicates checking, npc balacing * * @return Response */ public function index() { $request = RequestWrapper::$request; if (!$this->self || !$this->self->isAdmin()) { return new RedirectResponse(WEB_ROOT); } $error = null; $char_infos = null; $char_inventory = null; $first_message = null; $first_char = null; $first_account = null; $first_description = null; $dupes = AdminViews::dupedIps(); $stats = AdminViews::highRollers(); $npcs = NpcFactory::allNonTrivialNpcs(); $trivial_npcs = NpcFactory::allTrivialNpcs(); $char_ids = preg_split("/[,\\s]+/", $request->get('view')); $char_name = trim($request->get('char_name')); if ($char_name) { // View a target non-self character $first_char = Player::findByName($char_name); if (null !== $first_char && null !== $first_char->id()) { $char_ids = [$first_char->id()]; } } if (is_array($char_ids)) { // Get a different first character if an array is specified $first_char = $first_char ? $first_char : Player::find(reset($char_ids)); if ($first_char) { assert($first_char instanceof Player); $first_account = Account::findByChar($first_char); $char_inventory = AdminViews::charInventory($first_char); $first_message = $first_char->messages; $first_description = $first_char->description; } // All the rest multi-character table view try { $char_infos = AdminViews::charInfos($char_ids); } catch (InvalidArgumentException $e) { $error = $e->getMessage(); } } $parts = ['error' => $error, 'stats' => $stats, 'first_char' => $first_char, 'first_description' => $first_description, 'first_message' => $first_message, 'first_account' => $first_account, 'char_infos' => $char_infos, 'dupes' => $dupes, 'char_inventory' => $char_inventory, 'char_name' => $char_name, 'npcs' => $npcs, 'trivial_npcs' => $trivial_npcs]; return new StreamedViewResponse('Admin Actions', 'ninjamaster.tpl', $parts); }
/** * Display the main admin area * * Includes player viewing, account duplicates checking, npc balacing * * @return ViewSpec|RedirectResponse */ public function index() { $result = $this->requireAdmin($this->self); if ($result instanceof RedirectResponse) { return $result; } $viewChar = null; // View a target non-self character $charName = in('char_name'); if (is_string($charName) && trim($charName)) { $viewChar = get_char_id($charName); } // If a request is made to view a character's info, show it. $viewChar = first_value($viewChar, in('view')); $dupes = AdminViews::duped_ips(); $stats = AdminViews::high_rollers(); $npcs = NpcFactory::allNonTrivialNpcs(); $trivialNpcs = NpcFactory::allTrivialNpcs(); $charInfos = null; $charInventory = null; $firstMessage = null; $firstChar = null; $firstAccount = null; $firstDescription = null; if ($viewChar) { $ids = explode(',', $viewChar); $firstChar = new Player(reset($ids)); $firstAccount = AccountFactory::findByChar($firstChar); $charInfos = AdminViews::split_char_infos($viewChar); $charInventory = AdminViews::char_inventory($viewChar); $firstMessage = $firstChar->message(); $firstDescription = $firstChar->description(); } $parts = ['stats' => $stats, 'first_char' => $firstChar, 'first_description' => $firstDescription, 'first_message' => $firstMessage, 'first_account' => $firstAccount, 'char_infos' => $charInfos, 'dupes' => $dupes, 'char_inventory' => $charInventory, 'char_name' => $charName, 'npcs' => $npcs, 'trivial_npcs' => $trivialNpcs]; return ['title' => 'Admin Actions', 'template' => 'ninjamaster.tpl', 'parts' => $parts, 'options' => null]; }