<?php
if (!defined('MEDIAWIKI')) {
highlight_file(__FILE__);
}
require_once("$IP/extensions/WoWItem/includes/wowiteminfobase.class");
/**
* This class will parse the xml feed from Wowarmory's World of Warcraft website to retrieve item
* information and display it in an popup window.
*
*/
wfWoWItem_RegisterClass('wowarmory');
class wowarmory
{
//*******************************************************************************************************************************
var $usedb = 0; // 0 will not use a db, 1 will use a db for faster page loading.
var $showpuicon = 1; // display icon in popup?
var $init = true;
var $itemInfo;
var $parent;
function __construct()
{
$url = 'http://www.wowarmory.com/';
$search = $url . 'search.xml?searchQuery=%s&searchType=items';
$stats = $url . 'item-info.xml?i=%s';
$this->parent = new wowiteminfobase(__CLASS__, $url, $search, $stats, '');
//echo 'Initialized';
}
function getiteminfo($itemnumber, $img = false)
{
if (!is_numeric($itemnumber))
{
$itemnumber = $this->getitemid($itemnumber);
if (!$itemnumber && preg_match('((.*) of (.*))', $itemnumber, $matches)) {
$itemnumber = $this->getitemid(trim($matches[1]));
}
}
$tmpitem = $this->parent->getCachedItemInfo($itemnumber);
if ($tmpitem) {
$this->parent->saveItemInfo($this, $tmpitem, $itemnumber);
}
if ($this->items[$itemnumber]) {
// echo 'Found<br />';
$results = $this->items[$itemnumber];
} else {
$itemhtml = array(
'top' => '<div class="wowitem"><span class="iname"><span class="%s">%s</span></span><br />' . "\n",
'slot' => '%s' . "\n",
'stats' => '%s' . "\n",
'otherstats' => '<span class="itemeffectlink">%s</span><br />' . "\n",
);
$output = array();
$itemid = $itemnumber;
$page = itemstats_read_url(sprintf($this->parent->stats, $itemid));
$begin = false;
foreach (explode("\n", $page) AS $line) {
$line = trim($line);
if ($line == '<div class="myTable">') $begin = true;
if ($begin && trim(strip_tags($line)) !== '') {
if (strpos($line, 'myItemName') !== false) {
$output['item_name'] = strip_tags($line);
if (preg_match('(class="(.*?) myBold myItemName")', $line, $matches)) {
$output['rarity'] = str_replace('my', '', strtolower($matches[1])) . 'name';
}
} else {
if (strpos($line, '<br>', 1) > 0) {
$output[] = strip_tags_r(preg_split('(<br>|<span.*?>)', $line));
} else {
$output[] = strip_tags(str_replace('<br>', '', $line));
}
}
$original[] = $line;
}
if (preg_match('(<img class="p" src="(.*?)">)', $line, $matches)) {
$output['icon'] = $this->parent->url . $matches[1];
}
if ($begin && $line == '</div>') break;
}
$itemhtml['top'] = sprintf($itemhtml['top'], $output['rarity'], $output['item_name']);
if ($output[0]) {
$itemhtml['slot'] = sprintf($itemhtml['slot'], @implode('<br />' . "\n", $output[0])) . '<br />' . "\n";
} else {
unset($itemhtml['slot']);
}
$i = 1;
$stats = array();
while (isset($output[$i])) {
if (!is_array($output[$i])) {
$stats[] = $output[$i];
} else {
$stats[] = implode('<br />' . "\n", $output[$i]);
}
$i++;
}
$i = 0;
if ($stats) {
foreach ($stats AS $v) {
if (strpos($v, ':')) {
$itemhtml['otherstats'.$i] = sprintf($itemhtml['otherstats'], $v . "\n");
} else {
$itemhtml['stats'.$i] = sprintf($itemhtml['stats'], $v . '<br />' . "\n");
}
$i++;
}
}
$itemhtml['stats'.$i] = 'Item display is courtesy <a href="'. $this->parent->url .'">'. substr(str_replace('http://', '', $this->parent->url), 0, -1) .'</a>';
unset($itemhtml['stats'], $itemhtml['otherstats']);
$itemhtml['bottom'] = '</div>' . "\n";
$results['itemnumber'] = $itemnumber;
$results['itemname'] = $output['item_name'];
$results['itemquality'] = $output['rarity'];
$results['itemhtml'] = implode($itemhtml);
$results['itemicon'] = $output['icon'];
$results['itemicon'] = $this->addIconLocal($results['itemicon']);
}
if ($img == '__IMG__') {
$results['displayitemhtml'] = str_replace('<span class="iname">', '<img style="float: left" src="'.$results['itemicon'].'">' . '<span class="iname">', $results['itemhtml']);
} else if (is_string($img)) {
$results['displayitemhtml'] = str_replace('<span class="iname">', '<img style="float: left" src="'.$img.'">' . '<span class="iname">', $results['itemhtml']);
} else {
$results['displayitemhtml'] = $results['itemhtml'];
}
$this->parent->saveItemInfo($this, $results, $itemnumber);
return $results['itemname'] == "" ? false : $results;
}
function showpopup($itemnumber, $img="", $received="")
{
$iteminfo = $this->getiteminfo($itemnumber);
$popname = $iteminfo['itemname'];
$popquality = $iteminfo['itemquality'];
if ($img)
{
if ($img == "__IMG__") {
$icon = $iteminfo['itemicon'];
} else {
$icon = $img;
}
$pophtml = "<img src='" . $icon . "' border=0 width='50' height='50'>" . $iteminfo['displayitemhtml'];
}
else
{
$pophtml = $iteminfo['displayitemhtml'];
}
if ($iteminfo['itemname'] == "")
{
$error = "<span
onmouseover='return overlib(\"". rawurlencode('<span class="iname">Item not found!</span>') ."\", CAPTION, \"ERROR\", FGCOLOR, \"#FFFFFF\", CGCOLOR, \"#FF0000\", AUTOSTATUS);'
onmouseout='nd();'>Item Not Found</a>";
return false;
break;
}
if ($received != "")
{
$pophtml .= "<div class='wowitem'><span class='sm'><br> Looted by: " . $received . "</span></div>";
}
$mypoptable = sprintf($this->parent->wrapper, sprintf($this->parent->stats, $iteminfo['itemnumber']), rawurlencode($pophtml), $style);
if ($img == "")
{
$mypoptable .= '[' . $popname . ']';
}
else
{
if ($img == "__IMG__")
{
$mypoptable .= "<img src='" . $iteminfo['itemicon'] . "' border=0>";
}
else
{
$mypoptable .= "<img src='" . $img . "' border=0>";
}
}
$mypoptable .= '</a>';
return $mypoptable;
}
function getitemid($wowitemname)
{
$search = urlencode(trim($wowitemname));
$page = itemstats_read_url(sprintf($this->parent->search, $search));
foreach(explode("\n", $page) AS $line) {
$line = trim($line);
if (preg_match('(theArray\[.*?\] = \[\[".*?", .*?, "i=(.*?)", ".*?"],)', $line, $matches)) {
$itemid = $matches[1];
}
if ($line == '["'. urldecode($search) .'"],') break;
}
return $itemid;
}
function addIconLocal($icon) {
return $this->parent->addIconLocal($icon);
}
}
?>
Warning: require_once(/extensions/WoWItem/includes/wowiteminfobase.class) [function.require-once]: failed to open stream: No such file or directory in /home/.aardvarkkiln/theraven/sites/wowkoe.com/test/wiki/extensions/WoWItem/includes/sites/wowarmory.php on line 7
Fatal error: require_once() [function.require]: Failed opening required '/extensions/WoWItem/includes/wowiteminfobase.class' (include_path='.:/usr/local/php5/lib/php:/usr/local/lib/php') in /home/.aardvarkkiln/theraven/sites/wowkoe.com/test/wiki/extensions/WoWItem/includes/sites/wowarmory.php on line 7