<?php
if (!defined('MEDIAWIKI')) {
highlight_file(__FILE__);
}
require_once("$IP/extensions/WoWItem/includes/wowiteminfobase.class");
/**
* This class will parse the xml feed from Curse's World of Warcraft website to retrieve item
* information and display it in an popup window.
*
*/
wfWoWItem_RegisterClass('curse');
class curse
{
//*******************************************************************************************************************************
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 $style = array(
"0" => "greyname",
"1" => "whitename",
"2" => "greenname",
"3" => "bluename",
"4" => "purplename",
"5" => "orangename",
"6" => "redname",
"7" => "goldname",
);
var $parent;
function __construct()
{
$url = 'http://www.wowdb.com/';
$search = $url . 'search.aspx?search_text=%s';
$stats = $url . 'item.aspx?id=%s';
$icons = $url;
$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);
}
$itemhtml = array(
'top' => '<div class="wowitem"><span class="iname"><span class="%s">%s</span></span><br />' . "\n",
);
/*
<div class="tooltip" id="detailsTooltip">
<table>
<tbody><tr>
<td><b class="r1">Hearthstone</b><br>Binds when picked up<br>Unique<br><span class="r2">Use: <a href="spell.aspx?id=8690" class="r2">Returns you to <home>. Speak to an Innkeeper in a different place to change your home location.</home></a></span><br></td>
<th style="background-position: right top;"></th>
</tr>
<tr>
<th style="background-position: left bottom;"></th>
<th style="background-position: right bottom;"></th>
</tr>
</tbody></table>
</div>
*/
if ($this->items[$itemnumber]) {
// echo 'Found<br />';
$results = $this->items[$itemnumber];
} else {
$output = array();
$itemid = $itemnumber;
$page = itemstats_read_url(sprintf($this->parent->stats, $itemid));
$begin = false;
// $rawData = str_replace("\n", "", $page);
foreach(explode("\n", $page) AS $rawData) {
$rawData = trim($rawData);
if ('<div class="tooltip" id="detailsTooltip">' == $rawData) {
$begin = true;
continue;
}
if ($begin && $rawData == '</div>') {
break;
}
if ($begin) {
preg_match('(<b class=r(.*?)>(.*?)</b>)', $rawData, $nameMatches);
// print_r($nameMatches);
if ($nameMatches) {
preg_match('(<td>(.*?)</td>)', $rawData, $matches);
$popquality = $nameMatches[1];
$output['item_name'] = $nameMatches[2];
$stats = preg_replace('(<b.*?>.*?</b>)', '', $matches[1]);
$itemhtml['stats'] = str_replace('spell.aspx?id=', $this->parent->url .'spell.aspx?id=', $stats) . '<br />Item display is courtesy <a href="'. $this->parent->url .'">'. substr(str_replace('http://', '', $this->parent->url), 0, -1) .'</a>';
// $itemhtml['stats'] = $matches[1];
}
}
if (preg_match('(<div class="iconlarge" style="background-image: url\((.*?)\);">)', $rawData, $matches)) {
$output['icon'] = $this->parent->icons . $matches[1];
}
}
$itemhtml['top'] = sprintf($itemhtml['top'], $this->style[$popquality], $output['item_name']);
$i = 1;
$stats = array();
// unset($itemhtml['stats'], $itemhtml['otherstats']);
$itemhtml['bottom'] = '</div>' . "\n";
$results['itemnumber'] = $itemnumber;
$results['itemname'] = $output['item_name'];
$results['itemquality'] = $this->style[$popquality];
$results['itemhtml'] = implode("\n", $itemhtml);
$temp = array();
foreach (explode("\n", $results['itemhtml']) AS $i => $line) {
$temp[$i] = trim($line);
}
$results['itemhtml'] = implode($temp);
$results['itemhtml'] = str_replace("<br /><br /><br /><br />", "", $results['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) //[{id:6948,name:'Hearthstone',rarity:1,level:1,source:[1],type:'15.0'}]
{
$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('(\[\{id:(.*?),name:\''. $wowitemname .'\',rarity:.*?,level:.*?,source:.*?,type:.*?\}\])', $line, $matches)) {
return $matches[1];
}
}
}
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/curse.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/curse.php on line 7