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 viewrealm($id = 0) { // Get our users selected realm $c = get_realm_cookie(); // Get our realm id if none is provieded if ($c == 0) { output_message('info', 'no_realms_installed'); $this->load->view('blank'); return; } // Absolutly set our cookie realm IF the user selected a different realm if ($id != $c) { load_class('Input')->set_cookie('realm_id', $id); $_COOKIE['realm_id'] = $id; } // Load the view and call it a day! $this->load->view('viewrealm'); }
protected function _build_header() { // Add trace for debugging \Debug::trace('Building template header', __FILE__, __LINE__); // Convert our JS vars into a string :) $string = " var Plexis = {\n url : '" . SITE_URL . "',\n template_url : '{TEMPLATE_URL}',\n debugging : false,\n realm_id : " . get_realm_cookie() . ",\n }\n"; foreach ($this->jsvars as $key => $val) { // Format the var based on type $val = is_numeric($val) ? $val : '"' . $val . '"'; $string .= " var " . $key . " = " . $val . ";\n"; } // Remove last whitespace $string = rtrim($string); // Setup the basic static headings $this->append_metadata("")->append_metadata("<!-- Include jQuery Scripts -->")->append_metadata('<script type="text/javascript" src="' . BASE_URL . '/assets/js/jquery.js"></script>')->append_metadata('<script type="text/javascript" src="' . BASE_URL . '/assets/js/jquery-ui.js"></script>')->append_metadata('<script type="text/javascript" src="' . BASE_URL . '/assets/js/jquery.validate.js"></script>')->append_metadata("")->append_metadata("<!-- Define Global Vars and Include Plexis Static JS Scripts -->")->append_metadata('<script type="text/javascript"> ' . $string . ' </script>')->append_metadata('<script type="text/javascript" src="' . BASE_URL . '/assets/js/plexis.js"></script>'); // Append the template meta data $this->_append_template_metadata(); // Append loaded css files if (!empty($this->cssfiles)) { $this->append_metadata(""); // Add whitespace $this->append_metadata("<!-- Include Controller Defined Css Files -->"); foreach ($this->cssfiles as $f) { // Find the path :O if (preg_match('@^(ftp|http(s)?)://@i', $f)) { // We have a full url $src = $f; } else { // Just a filename $src = $this->template['http_path'] . '/' . trim($this->xml->config->css_folder, '/') . '/' . $f; } // Add the stylesheet to the header $this->set_metadata('stylesheet', $src, 'link'); } } // Append loaded js files if (!empty($this->jsfiles)) { $this->append_metadata(""); // Add whitespace $this->append_metadata("<!-- Include Controller Defined JS Files -->"); foreach ($this->jsfiles as $j) { // Find the path :O if (preg_match('@^(ftp|http(s)?)://@i', $j)) { // We have a full url $src = $j; } else { // Just a filename $path = $this->template['path'] . DS . trim($this->xml->config->js_folder, '/') . DS . $j; if (file_exists(str_replace(array('/', '\\'), DS, $path))) { $src = $this->template['http_path'] . '/' . trim($this->xml->config->js_folder, '/') . '/' . $j; } else { $src = BASE_URL . '/assets/js/' . $j; } } // Add the js path $this->append_metadata('<script type="text/javascript" src="' . $src . '"></script>'); } } // Add the view if we have one $line = $this->view_js_string(); if ($line != false) { $this->append_metadata(''); $this->append_metadata("<!-- Include the page view JS file -->"); $this->append_metadata($line); } // Now, we build the header into a string $head = ""; foreach ($this->_metadata as $data) { $head .= "\t" . trim($data) . "\n"; } return $head; }
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; } } }