<?php
if (!defined('MEDIAWIKI')) {
highlight_file(__FILE__);
}
require_once("$IP/extensions/WoWItem/includes/wowiteminfobase.class");
/**
* This class will parse the xml feed from Allakhazam's World of Warcraft website to retrieve item
* information and display it in an popup window.
*
*/
wfWoWItem_RegisterClass('allakhazam', array('alla'));
class allakhazam
{
var $parent;
//*******************************************************************************************************************************
function __construct()
{
$stats = 'http://wow.allakhazam.com/cluster/item-xml.pl?witem=';
$url = 'http://wow.allakhazam.com/db/item.html?witem=';
$search = 'http://wow.allakhazam.com/search.html?q=';
$icons = 'http://wow.allakhazam.com';
$this->parent = new wowiteminfobase(__CLASS__, $url, $search, $stats, $icons);
//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 {
// $xmlfile = simplexml_load_file($this->parent->stats.$itemnumber);
$xml = new XmlHelper();
$xmlfile = itemstats_read_url($this->parent->stats.$itemnumber);
$results['itemnumber'] = $itemnumber;
$results['itemname'] = str_replace("'","",$xml->parse($xmlfile,'name1'));
$results['itemquality'] = $xml->parse($xmlfile,'quality');
$results['itemhtml'] = str_replace("'","\'",$xml->parse($xmlfile,'display_html'));
$results['itemicon'] = $this->parent->icons . $xml->parse($xmlfile,'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);
$itemnumber = $iteminfo['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'] == "")
{
return "<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>";
}
switch ($popquality)
{
case "0":
$style = "greyname";
break;
case "1":
$style = "whitename";
break;
case "2":
$style = "greenname";
break;
case "3":
$style = "bluename";
break;
case "4":
$style = "purplename";
break;
case "5":
$style = "orangename";
break;
case "6":
$style = "redname";
break;
case "7":
$style = "goldname";
break;
default:
$style = "greyname";
break;
}
$mypoptable = sprintf($this->parent->wrapper, $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)
{
$item_found = false;
$name = trim($wowitemname);
if ($this->usedb == 1)
{
global $db;
// $db->show_errors();
if ($myresult = $db->get_row("SELECT * FROM tblwowitems WHERE itemname = '$name'"))
{
$item_id = $myresult->itemnumber;
$item_found = true;
}
else
{
$item = array('name' => $name);
$data = itemstats_read_url($this->parent->search . urlencode($name));
$xml_helper = new XmlHelper();
if (preg_match_all('#images/icons/(.*?)\.png(.*?)witem=(.*?);#s', $data, $matches))
{
foreach ($matches[0] as $key => $match)
{
$item_id = $matches[3][$key];
$xml_data = itemstats_read_url($this->parent->stats . $item_id);
$xml_name = $xml_helper->parse($xml_data, 'name1');
if (strcasecmp($item['name'], $xml_name) == 0)
{
$item_found = true;
break;
}
}
}
}
}
else
{
$item = array('name' => $name);
$data = itemstats_read_url($this->parent->search . urlencode($name));
$xml_helper = new XmlHelper();
if (preg_match_all('#images/icons/(.*?)\.png(.*?)witem=(.*?)">#s', $data, $matches))
{
foreach ($matches[0] as $key => $match)
{
$item_id = preg_replace("(([\d]*).*)", "$1", $matches[3][$key]);
$xml_data = itemstats_read_url($this->parent->stats . $item_id);
$xml_name = $xml_helper->parse($xml_data, 'name1');
if (strcasecmp($item['name'], $xml_name) == 0)
{
$item_found = true;
break;
}
}
}
}
if ($item_found == true)
{
return $item_id;
}
else
{
return "false";
}
}
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/allakhazam.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/allakhazam.php on line 7