public function onlinelist($realm = 0) { // check if the realm is installed if ($realm != 0 && realm_installed($realm) == FALSE) { $realm = get_realm_cookie(); } // Load the WoWLib $this->load->wowlib($realm, 'wowlib'); $output = $this->wowlib->characters->listCharactersDatatables(0, true); // Loop, and add options foreach ($output['aaData'] as $key => $value) { $g = $value[5]; $r = $value[3]; $race = $this->wowlib->characters->raceToText($r); $class = $this->wowlib->characters->classToText($value[4]); $zone = $this->wowlib->zone->name($value[6]); $output['aaData'][$key][3] = '<img src="' . BASE_URL . '/assets/images/icons/race/' . $r . '-' . $g . '.gif" title="' . $race . '" alt="' . $race . '">'; $output['aaData'][$key][4] = '<img src="' . BASE_URL . '/assets/images/icons/class/' . $value[4] . '.gif" title="' . $class . '" alt="' . $class . '">'; $output['aaData'][$key][5] = $zone; unset($output['aaData'][$key][6], $output['aaData'][$key][7], $output['aaData'][$key][8]); } // Push the output in json format echo json_encode($output); }
public function characters($realmid = 0, $character = 0) { // Make sure the user can view this page if (!$this->check_permission('manage_characters')) { return; } // Set new realm if ($realmid != 0 && realm_installed($realmid)) { $current = $realmid; } else { $current = get_realm_cookie(); } // Get our installed realms $realms = get_installed_realms(); // If no realms installed, display a message instead if (empty($realms)) { // Build our page title / desc, then load the view $data = array('page_title' => "Character Editor", 'page_desc' => "This page allows you to edit character information. NOTE: You cannot edit a character while they are playing!"); $this->load->view('no_realms', $data); return; } // Editing a character? if ($character != 0) { // Load the wowlib for this realm $Lib = $this->load->wowlib($realmid, false); if ($Lib == false) { // Give the admin an error output_message('warning', 'Unable to load wowlib for this realm. Please make sure the character and world databases are online'); // Build our page title / desc, then load the view $data = array('page_title' => "Character Editor", 'page_desc' => "This page allows you to edit character information. NOTE: You cannot edit a character while they are playing!"); $this->load->view('blank', $data); return; } // Fetch character $char = $Lib->characters->fetch((int) $character); if ($char == false) { // Give the admin an error output_message('error', 'Character Doesnt Exist!'); // Build our page title / desc, then load the view $data = array('page_title' => "Character Editor", 'page_desc' => "This page allows you to edit character information. NOTE: You cannot edit a character while they are playing!"); $this->load->view('blank', $data); return; } // Get alist of login flags $flags = array(); $aflags = $Lib->characters->loginFlags(); $has_flag = $char->getLoginFlags(); // Loop through each flag so we can set the proper enabled : disabled at login select options foreach ($aflags as $key => $flag) { // Dont show flags that arent enabled by this realm if ($flag == false) { continue; } // Create a name, and add to the flags array $name = str_replace('_', ' ', ucfirst($key)); $flags[] = array('label' => $key, 'name' => $name, 'enabled' => $has_flag[$key]); } // Fetch account and character postion $Account = $this->realm->fetchAccount($char->getAccountId()); $pos = $char->getPosition(); // Build our page title / desc, then load the view $data = array('page_title' => "Character Editor", 'page_desc' => "This page allows you to edit character information.", 'flags' => $flags, 'character' => array('id' => $character, 'name' => $char->getName(), 'level' => $char->getLevel(), 'money' => $char->getMoney(), 'xp' => $char->getXp()), 'account' => $Account->getUsername(), 'race' => $char->getRace(true), 'class' => $char->getClass(true), 'zone' => $Lib->zone->name($pos['zone']), 'realm' => $realmid); $this->load->view('edit_character', $data); return; } // Otherwise, list $array = array(); $set = false; foreach ($realms as $realm) { $selected = ''; if ($realm['id'] == $current) { $selected = 'selected="selected" '; } // Add the language folder to the array $array[] = '<option value="' . $realm['id'] . '" ' . $selected . '>' . $realm['name'] . '</option>'; } // Build our page title / desc, then load the view $data = array('page_title' => "Character Editor", 'page_desc' => "This page allows you to edit character information. NOTE: You cannot edit a character while they are playing!", 'realms' => $array); $this->load->view('characters', $data); }
public function characters($realm = 0) { // If not post action, we are loading the list if (!isset($_POST['action'])) { // check if the realm is installed if ($realm != 0 && !realm_installed($realm)) { $realm = get_realm_cookie(); } // Load the WoWLib $this->load->wowlib($realm, 'wowlib'); if (is_object($this->wowlib) && is_object($this->wowlib->characters)) { $output = $this->wowlib->characters->listCharactersDatatables(); // Loop, each character, and format the rows accordingly foreach ($output['aaData'] as $key => $value) { $Account = $this->realm->fetchAccount((int) $value[7]); $g = $value[5]; // Gender $r = $value[3]; // Race $race = $this->wowlib->characters->raceToText($r); $class = $this->wowlib->characters->classToText($value[4]); $zone = $this->wowlib->zone->name($value[6]); $output['aaData'][$key][3] = '<center><img src="' . BASE_URL . '/assets/images/icons/race/' . $r . '-' . $g . '.gif" title="' . $race . '" alt="' . $race . '"></center>'; $output['aaData'][$key][4] = '<center><img src="' . BASE_URL . '/assets/images/icons/class/' . $value[4] . '.gif" title="' . $class . '" alt="' . $class . '"></center>'; $output['aaData'][$key][5] = $zone; $output['aaData'][$key][6] = '<a href="' . SITE_URL . '/admin/users/' . $Account->getUsername() . '">' . $Account->getUsername() . '</a>'; $output['aaData'][$key][7] = '<a href="' . SITE_URL . '/admin/characters/' . $realm . '/' . $value[0] . '">Edit Character</a>'; unset($output['aaData'][$key][8]); } // Push the output in json format echo json_encode($output); return; } else { // Unable to load Wowlib $this->output(false, 'Failed to load Wowlib. Please make sure the character / world Databases are online'); } } else { // Mandaroty checks $id = $this->Input->post('id', true); $realm = $this->Input->post('realm', true); // Make sure the realm is installed if (!realm_installed($realm)) { $this->output(false, "Realm ID: {$realm} not installed!"); die; } // Load the wowlib for this realm $Lib = $this->load->wowlib($realm, false); if (!is_object($Lib)) { $this->output(false, "Unable to connect to character and/or world databases"); die; } // Fetch character $Char = $Lib->characters->fetch((int) $id); if (!is_object($Char)) { $this->output(false, "Character ID: Does not exist!"); die; } // Make sure the character isnt online if ($Char->isOnline()) { $this->output(false, "Character is online. You cannot edit characters while they are in game.", 'warning'); die; } // Process specific actions switch ($_POST['action']) { case "update": // Make sure this person has permission to do this! $this->check_permission('manage_characters'); // Get our realm name $r = get_realm($realm); // Log action $this->log('Edited character ' . $Char->getName() . ' from realm ' . $r['name']); // Update the character data $Char->setName($this->Input->post('name', true)); $Char->setLevel($this->Input->post('level', true)); //$Char->setGender( $this->Input->post('gender', true) ); $Char->setMoney($this->Input->post('money', true)); $Char->setXp($this->Input->post('xp', true)); // Get the characters flags $flags = $Char->getLoginFlags(); foreach ($flags as $key => $val) { // Updates? $bool = (bool) $_POST[$key]; if (isset($_POST[$key]) && $bool != $val) { $Char->setLoginFlag($key, $bool); } } // Any successfull changes? if ($Char->save() !== false) { $this->output(true, "Character updated successfully!"); } else { $this->output(false, "There was an error updating the character information. Please check your error logs"); } break; case "delete": // Make sure this person has permission to do this! $this->check_permission('delete_characters'); // Get our realm name $r = get_realm($realm); // Log action $this->log('Deleted character ' . $Char->getName() . ' from realm ' . $r['name']); $result = $Lib->characters->delete($this->Input->post('id', true)); $result == true ? $this->output(true, "Character deleted successfully!") : $this->output(false, "There was an error deleting the character!"); break; case "unstuck": // Make sure this person has permission to do this! $this->check_permission('manage_characters'); // Get our realm name $r = get_realm($realm); // Log action $this->log('Reset character position of "' . $Char->getName() . '" from realm ' . $r['name']); $Char->resetPosition(); $Char->save() !== false ? $this->output(true, "Character position reset successfully") : $this->output(false, "Failed to reset Characters position", 'error'); break; } } }