public function parse($name, $args = array()) { if (trim($name) == '') { return false; } $this->lang = !array_key_exists('lang', $args) ? WHP_LANG : $args['lang']; $this->language->loadLanguage($this->lang); // load the language pack $this->nomats = !array_key_exists('nomats', $args) ? false : $args['nomats']; $cache = new wowhead_cache(); if (!($result = $cache->getCraftable($name, $this->lang))) { $data = $this->_read_url($name, 'craftable'); // accounts for SimpleXML not being able to handle 3 parameters if you're using PHP 5.1 or below. if (!$this->_allowSimpleXMLOptions()) { $data = $this->_removeCData($data); $xml = simplexml_load_string($data, 'SimpleXMLElement'); } else { $xml = simplexml_load_string($data, 'SimpleXMLElement', LIBXML_NOCDATA); } if ($xml->error == '') { // build our craft array $this->craft = array('itemid' => $xml->item['id'], 'name' => $xml->item->name, 'search_name' => $name, 'quality' => $xml->item->quality['id'], 'lang' => $this->lang, 'icon' => 'http://static.wowhead.com/images/icons/small/' . strtolower($xml->item->icon) . '.jpg'); // build spell craft array $this->craft_spell = array('reagentof' => $xml->item['id'], 'spellid' => $xml->item->createdBy->spell['id'], 'name' => $xml->item->createdBy->spell['name']); if ($this->nomats == false) { // build reagent array foreach ($xml->item->createdBy->spell->reagent as $reagent) { array_push($this->craft_reagents, array('itemid' => $reagent['id'], 'reagentof' => $xml->item['id'], 'name' => $reagent['name'], 'quantity' => $reagent['count'], 'quality' => $reagent['quality'], 'icon' => 'http://static.wowhead.com/images/icons/small/' . strtolower($reagent['icon']) . '.jpg')); } } } else { $cache->close(); return $this->_notfound($this->language->words['craft'], $name); } if ($this->nomats == false) { $cache->saveCraftable($this->craft, $this->craft_spell, $this->craft_reagents); } else { $cache->saveCraftable($this->craft, $this->craft_spell); } unset($xml); $cache->close(); return $this->_toHTML(); } else { $this->craft = $result; $this->craft_spell = $cache->getCraftableSpell($this->craft['itemid']); if ($this->nomats == false) { $this->craft_reagents = $cache->getCraftableReagents($this->craft['itemid']); } $cache->close(); return $this->_toHTML(); } }
public function parse($name, $args = array()) { if (trim($name) == '') { return false; } // set up some preliminary stuff $this->lang = array_key_exists('lang', $args) ? $args['lang'] : WHP_LANG; $cache = new wowhead_cache(); $this->language->loadLanguage($this->lang); if (!($result = $cache->getEnchant($name, $this->lang))) { $result = is_numeric($name) ? $this->getEnchantByID($name) : $this->getEnchantByName($name); if (!$result || sizeof($this->reagents) == 0) { $cache->close(); return $this->_notFound($this->language->words['enchant'], $name); } else { $cache->saveEnchant($result, $this->reagents); $cache->close(); return $this->toHTML($result); } } else { $this->reagents = $cache->getEnchantReagents($result['id'], $this->lang); $cache->close(); return $this->toHTML($result); } }
public function parse($name, $args = array()) { if (trim($name) == '') { return false; } $cache = new wowhead_cache(); $this->lang = !array_key_exists('lang', $args) ? WHP_LANG : $args['lang']; $this->language->loadLanguage($this->lang); // if the wowhead arg exists then format it into something the script can read if (array_key_exists('wowhead', $args)) { $args['pins'] = $this->wowhead_map($args['wowhead']); unset($args['wowhead']); } if (!($result = $cache->getZone($name, $this->lang))) { // method depends if the id or name is given $result = is_numeric($name) ? $this->getZoneByID($name) : $this->getZoneByName($name); if (!$result) { // not found $cache->close(); return $this->_notFound($this->language->words['zone'], $name); } else { // transfer the zone map if (WHP_TRANSFER_MAP == true) { $this->transferImage($result['map']); } $cache->saveZone($result); $cache->close(); return $this->toHTML($result, $args); } } else { // found in cache $cache->close(); return $this->toHTML($result, $args); } }
public function parse($name, $args = array()) { if (trim($name) == '') { return false; } $cache = new wowhead_cache(); $this->lang = !array_key_exists('lang', $args) ? WHP_LANG : $args['lang']; $this->language->loadLanguage($this->lang); if (!($result = $cache->getObject($name, 'achievement', $this->lang))) { // not in cache if (is_numeric($name)) { $result = $this->_getAchievementByID($name); } else { $result = $this->_getAchievementByName($name); } if (!$result) { // not found $cache->close(); return $this->_notfound($this->language->words['achievement'], $name); } else { $cache->saveObject($result); $cache->close(); return $this->generateHTML($result, 'achievement'); } } else { $cache->close(); return $this->generateHTML($result, 'achievement'); } }
/** * Parses Items * @access public **/ public function parse($name, $args = array()) { global $item_show_icon; if (trim($name) == '') { return false; } $this->lang = !array_key_exists('lang', $args) ? WHP_LANG : $args['lang']; // load the language pack $this->language->loadLanguage($this->lang); $cache = new wowhead_cache(); if ($item_show_icon == true || array_key_exists('icon', $args)) { $this->show_icon = true; $this->type = 'item_icon'; } // check if its already in the cache if (!($result = $cache->getObject($name, $this->type, $this->lang))) { // not in the cache if (!($result = $this->_getItemInfo($name))) { // item not found $cache->close(); return $this->_notfound($this->language->words['item'], $name); } else { $cache->saveObject($result); // save it to cache $cache->close(); if (array_key_exists('gems', $args) || array_key_exists('enchant', $args)) { $enhance = $this->_buildEnhancement($args); return $this->generateHTML($result, $this->type, '', '', $enhance); } else { return $this->generateHTML($result, $this->type); } } } else { $cache->close(); if (array_key_exists('gems', $args) || array_key_exists('enchant', $args)) { $enhance = $this->_buildEnhancement($args); return $this->generateHTML($result, $this->type, '', '', $enhance); } else { return $this->generateHTML($result, $this->type); } } }
public function parse($name, $args = array()) { if (trim($name) == '') { return false; } $this->lang = array_key_exists('lang', $args) ? $args['lang'] : WHP_LANG; $this->language->loadLanguage($this->lang); $cache = new wowhead_cache(); if (!($result = $cache->getObject($name, 'object', $this->lang))) { $result = is_numeric($name) ? $this->getObjectByID($name) : $this->getObjectByName($name); if (!$result) { $cache->close(); return $this->_notFound($this->language->words['object'], $name); } else { $cache->saveObject($result); $cache->close(); return $this->generateHTML($result, 'object'); } } else { $cache->close(); return $this->generateHTML($result, 'object'); } }
/** * Parse Item Icons * @access public **/ public function parse($name, $args = array()) { if (trim($name) == '') { return false; } $size = !array_key_exists('size', $args) ? 'medium' : $args['size']; $this->lang = !array_key_exists('lang', $args) ? WHP_LANG : $args['lang']; $this->language->loadLanguage($this->lang); $cache = new wowhead_cache(); if (!($result = $cache->getObject($name, 'itemico', $this->lang, '', $size))) { if (!($result = $this->_getItemIcon($name, $size))) { $cache->close(); return $this->_notfound($this->language->words['item'], $name); } else { $cache->saveObject($result); $cache->close(); return $this->generateHTML($result, 'itemico', $size); } } else { $cache->close(); return $this->generateHTML($result, 'itemico', $size); } }
public function parse($name, $args = array()) { if (trim($name) == '') { return false; } // set the language for this parse, and then load the language pack $this->lang = array_key_exists('lang', $args) ? $args['lang'] : WHP_LANG; $this->language->loadLanguage($this->lang); $cache = new wowhead_cache(); if (!($result = $cache->getFaction($name, $this->lang))) { $result = is_numeric($name) ? $this->getFactionByID($name) : $this->getFactionByName($name); if (!$result) { $cache->close(); return $this->_notFound($this->language->words['faction'], $name); } else { $cache->saveFaction($result); $cache->close(); return $this->generateHTML($result, 'faction'); } } else { $cache->close(); return $this->generateHTML($result, 'faction'); } }
/** * Parses information * @access public **/ public function parse($name, $args = array()) { if (trim($name) == '') { return false; } $this->lang = !array_key_exists('lang', $args) ? WHP_LANG : $args['lang']; $this->language->loadLanguage($this->lang); $rank = !array_key_exists('rank', $args) ? '' : $args['rank']; $cache = new wowhead_cache(); if (!($result = $cache->getObject($name, 'spell', $this->lang, $rank))) { $result = is_numeric($name) ? $this->_getSpellByID($name) : $this->_getSpellByName($name, $rank); if (!$result) { $cache->close(); return $this->_notfound($this->language->words['spell'], $name); } else { $cache->saveObject($result); $cache->close(); return $this->generateHTML($result, 'spell', '', $rank); } } else { $cache->close(); return $this->generateHTML($result, 'spell', '', $rank); } }
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. **/ include_once dirname(__FILE__) . '/../config.php'; include_once dirname(__FILE__) . '/../includes/wowhead_cache.php'; $cache = new wowhead_cache(); // get the vars from the get global $get_char = isset($_GET['char']) ? urldecode($_GET['char']) : ''; $get_realm = urldecode(stripslashes($_GET['realm'])); $get_region = array_key_exists('region', $_GET) ? $_GET['region'] : ''; $get_prop = isset($_GET['prop']) ? $_GET['prop'] : 'char'; $get_guild = isset($_GET['guild']) ? urldecode($_GET['guild']) : ''; if ($get_guild != '') { $get_prop = 'guild'; } if (empty($get_guild) && empty($get_char) || empty($get_realm)) { $cache->close(); exit; } if ($get_prop == 'char') { $uniquekey = $cache->generateKey($get_char, $get_realm, $get_region);
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. **/ include_once dirname(__FILE__) . '/../config.php'; include_once dirname(__FILE__) . '/../includes/wowhead_cache.php'; $cache = new wowhead_cache(); $id = isset($_GET['id']) ? (int) $_GET['id'] : null; $lang = isset($_GET['lang']) ? $_GET['lang'] : WHP_LANG; $pins = isset($_GET['pins']) && $_GET['pins'] != '{pins}' ? $_GET['pins'] : null; // images path and urls $wowhead_zone_maps = 'http://static.wowhead.com/images/maps/enus/normal/'; $maps_url = $armory_image_url . 'images/zones/'; $maps_dir = dirname(__FILE__) . '/../images/zones/'; if ($id == null) { echo 'ID not given.'; $cache->close; exit; } if (!($result = $cache->getZone($id, $lang, true))) { echo 'Zone not found in the cache.'; $cache->close();
$found = false; foreach ($items as $standing) { if (sizeof($standing) > 0) { $found = true; } } return $found; } // we'll need this later $standings = array('hated', 'hostile', 'unfriendly', 'neutral', 'friendly', 'honored', 'revered', 'exalted'); // first, we need to get the necessary data from $_GET $id = array_key_exists('id', $_GET) ? (int) $_GET['id'] : null; $lang = array_key_exists('lang', $_GET) ? $_GET['lang'] : WHP_LANG; $mode = array_key_exists('mode', $_GET) ? $_GET['mode'] : 'tooltip'; // connect to sql $cache = new wowhead_cache(); if ($id == null) { echo 'Faction ID not given.'; exit; } if ($mode == 'tooltip') { if (!($result = $cache->getFaction($id, $lang, true))) { $cache->close(); echo 'Faction "' . $id . '" not found in cache.'; exit; } else { echo stripslashes($result['tooltip']); } } elseif ($mode == 'rewards') { if (!($result = $cache->getFactionRewards($id, $lang))) { // gotta build the html
/** * Parse Text * @access public **/ public function parse($name, $args = array()) { if (trim($name) == '') { return false; } $cache = new wowhead_cache(); // they specified a realm/region if (array_key_exists('loc', $args)) { $aLoc = explode(',', $args['loc']); $this->region = $aLoc[0]; $this->realm = $aLoc[1]; } // they specified a language if (array_key_exists('lang', $args)) { $this->lang = $args['lang']; } // see if they want icons if (array_key_exists('noicons', $args)) { $this->icons = false; } if (array_key_exists('noclass', $args)) { $this->class_icon = false; } if (array_key_exists('norace', $args)) { $this->race_icon = false; } if (array_key_exists('gearlist', $args)) { $this->type = 'armory_gearlist'; } if (array_key_exists('recruit', $args)) { $this->type = 'armory_recruit'; } // load the language pack $this->language->loadLanguage($this->lang); $this->char_url = $this->characterURL($name); if (WOWHEAD_DEBUG == true) { print $this->char_url; } $this->now = mktime(); $uniquekey = $cache->generateKey($name, $this->realm, $this->region); $result = $cache->getArmory($uniquekey, $this->char_cache); if (!$result) { $xml_data = $this->getXML($this->characterURL($name)); if (!($xml = @simplexml_load_string($xml_data, 'SimpleXMLElement'))) { // failed to get the xml, most likely blocked by the armory or character not found $cache->close(); return $this->generateError($this->language->words['armory_blocked']); } // make sure the character does exist if (array_key_exists('errcode', $xml->characterInfo)) { $cache->close(); return $this->generateError($this->language->words['char_not_found']); } elseif (!$xml->characterInfo->characterTab) { $cache->close(); return $this->generateError($this->language->words['char_no_data']); } $this->ctab = $xml->characterInfo->characterTab; $this->char = $xml->characterInfo->character; $this->cinfo = $xml->characterInfo; // get character stats $this->stats = $this->generateStats(); // get character talents $this->char_data['talents'] = $this->generateTalents(); // get professions $this->char_data['prof'] = $this->generateProfessions(); // get avatar $this->char_data['avatar'] = $this->generateAvatar(); // generate achievements $this->char_data['achieve'] = $this->generateAchievements(); // generate average item level if ($this->item_level == true) { $this->char_data['itemlevel'] = $this->generateItemLevel(); } // finalize the character and add other randomness $this->finalizeChar(); // save to cache $cache->saveArmory(array('uniquekey' => $uniquekey, 'name' => $this->char_data['name'], 'class' => $this->char_data['class'], 'genderid' => $this->char_data['genderid'], 'raceid' => $this->char_data['raceid'], 'classid' => $this->char_data['classid'], 'realm' => $this->realm, 'region' => $this->region, 'tooltip' => $this->generateTooltip())); unset($xml); $cache->close(); // generate html return $this->generateHTML(array('realm' => $this->realm, 'region' => $this->region, 'name' => $this->char_data['name'], 'icons' => $this->getIcons($this->char_data['raceid'], $this->char_data['genderid'], $this->char_data['classid']), 'link' => $this->characterURL($this->char_data['name']), 'class' => 'armory_tt_class_' . strtolower(str_replace(' ', '', $this->char_data['class'])), 'image' => $this->icon_url . 'images/wait.gif'), $this->type); } else { $cache->close(); return $this->generateHTML(array('realm' => $this->realm, 'region' => $this->region, 'name' => $result['name'], 'icons' => $this->getIcons($result['raceid'], $result['genderid'], $result['classid']), 'link' => $this->characterURL($result['name']), 'class' => 'armory_tt_class_' . strtolower(str_replace(' ', '', $result['class'])), 'image' => $this->icon_url . 'images/wait.gif'), $this->type); } }
/** * Parses itemset bbcode * @access public **/ public function parse($name, $args = array()) { if (trim($name) == '') { return false; } $this->lang = !array_key_exists('lang', $args) ? WHP_LANG : $args['lang']; $this->language->loadLanguage($this->lang); $cache = new wowhead_cache(); if (!($result = $cache->getItemset($name, $this->lang))) { if (!is_numeric($name)) { $data = $this->_read_url($name, 'itemset', false); if (!preg_match('#Location: /\\?itemset=([\\-0-9]{1,10})#s', $data, $match)) { // didn't find the redirect header, so we'll have to look in the search page $summary = $this->summaryLine($data); if (!preg_match('#id:([\\-0-9]{1,10}),name:#s', $summary, $match)) { $cache->close(); return $this->_notFound($this->language->words['itemset'], $name); } } } // we now have the set id, and can query wowhead for the info we need $this->setid = is_numeric($name) ? $name : $match[1]; $data = $this->_read_url($this->setid, 'itemset', false); // if they used ID rather than name, then we must get the name if (is_numeric($name)) { if (!preg_match('#name: \'(.+?)\'};#s', $this->nameLine($data), $match)) { $cache->close(); return $this->_notFound($this->language->words['itemset'], $name); } else { $found_name = stripslashes($match[1]); } } $this->itemset = array('setid' => $this->setid, 'name' => is_numeric($name) ? $found_name : $name, 'search_name' => $name, 'lang' => $this->lang); $summary = $this->summaryLine($data); while (preg_match('#\\[\\[([0-9]{1,10})\\]\\]#s', $summary, $match)) { $data = $this->_read_url($match[1]); if (trim($data) == '' || empty($data)) { return false; } // accounts for SimpleXML not being able to handle 3 parameters if you're using PHP 5.1 or below. if (!$this->_allowSimpleXMLOptions()) { $data = $this->_removeCData($data); $xml = simplexml_load_string($data, 'SimpleXMLElement'); } else { $xml = simplexml_load_string($data, 'SimpleXMLElement', LIBXML_NOCDATA); } if ($xml->error == '') { // add the results to our item array array_push($this->itemset_items, array('setid' => $this->setid, 'itemid' => (int) $xml->item['id'], 'name' => (string) $xml->item->name, 'quality' => (int) $xml->item->quality['id'], 'icon' => 'http://static.wowhead.com/images/icons/small/' . strtolower($xml->item->icon) . '.jpg')); } else { return false; } unset($xml); // strip what it found so we don't get an endless loop $summary = str_replace($match[0], '', $summary); } $cache->saveItemset($this->itemset, $this->itemset_items); $cache->close(); return $this->toHTML(); } else { $this->itemset = $result; $this->itemset_items = $cache->getItemsetReagents($this->itemset['setid']); $cache->close(); return $this->toHTML(); } }
public function parse($name, $args = array()) { if (trim($name) == '') { return false; } $this->lang = !array_key_exists('lang', $args) ? WHP_LANG : $args['lang']; $this->language->loadLanguage($this->lang); $cache = new wowhead_cache(); if (!($result = $cache->getNPC($name, $this->lang))) { // not found in cache $result = $this->getNPCInfo($name); if (!$result) { // not found $cache->close(); return $this->_notFound($this->language->words['npc'], $name); } else { // see if they want to display a map as well if (array_key_exists('map', $args)) { if (!($sql_map = $cache->getZone($args['map']['name'], $this->lang))) { $mapinfo = $this->getZoneMap($args['map']['name']); if (!$mapinfo) { $cache->close(); return $this->_notFound($this->language->words['zone'], $name); } else { if (!file_exists($this->images_path . $mapinfo['map']) && WHP_TRANSFER_MAP == true) { // file doesn't exist, so transfer it locally $this->transferImage($mapinfo['map']); } $cache->saveZone($mapinfo); $mapinfo['x'] = $args['map']['x']; $mapinfo['y'] = $args['map']['y']; $cache->saveNPC($result); $cache->close(); return $this->mapHTML($result, $mapinfo); } } else { if (!file_exists($this->images_path . $sql_map['map']) && WHP_TRANSFER_MAP == true) { // file doesn't exist, so transfer it locally $this->transferImage($sql_map['map']); } $sql_map['x'] = $args['map']['x']; $sql_map['y'] = $args['map']['y']; $cache->saveNPC($result); $cache->close(); return $this->mapHTML($result, $sql_map); } } else { // found, save it and display $cache->saveNPC($result); $cache->close(); return $this->generateHTML($result, 'npc'); } } } else { if (array_key_exists('map', $args)) { $mapinfo = $cache->getZone($args['map']['name'], $this->lang); if (!file_exists($this->images_path . $mapinfo['map']) && WHP_TRANSFER_MAP == true) { // file doesn't exist, so transfer it locally $this->transferImage($mapinfo['map']); } $mapinfo['x'] = $args['map']['x']; $mapinfo['y'] = $args['map']['y']; $cache->close(); return $this->mapHTML($result, $mapinfo); } else { $cache->close(); return $this->generateHTML($result, 'npc'); } } }