OK well I've finished off the code. If any needs RIFT support here are the new getItem and getItemId functions in your new includes\rift_SITENAME.php file
Code:
// Attempts to retrieve data for the specified item from Allakhazam. -- http://rift.zam.com/en/item.html?riftitem=C9DFDFA30201010101
function getItem($name)
{
// Ignore blank names.
$name = trim($name);
if (empty($name))
{
return null;
}
$item = array('name' => $name);
for ($ct = 0; isset($GLOBALS["allakhazam_lang"][$ct]); $ct++)
{
$current_lang = $GLOBALS["allakhazam_lang"][$ct];
// Perform the search.
//$data = itemstats_read_url('http://rift.zam.com/en/search.html?q=' . urlencode($name)); //urlencode(utf8_encode($name)));
$data = itemstats_read_url('http://rift.yg.com/search?s=' . urlencode($name)); //urlencode(utf8_encode($name)));
$item_found = false;
// Look for a name match in the search result.
//regex fixed by hoofy
//if (preg_match_all('#item\/(\w+)\/#', $data, $matches))
if (preg_match_all('#item\/(\S+)\?id=(\w+)#', $data, $matches))
{
//header( 'Location: http://www.yahoo.com' ) ;
foreach ($matches[0] as $key => $match)
{
// Extract the item's ID from the match.
//$item_id = $matches[1][$key];
$item_id = $matches[2][$key];
// Retrieve the XML for this item from Allakhazam.
//$xml_data = itemstats_read_url('http://rift.zam.com/en/item-xml.pl?riftitem=' . $item_id);
//$xml_data = itemstats_read_url('http://rift.yg.com/api/lookup?i=' . $item_id . ' &t=xml');
$request_url = 'http://rift.yg.com/api/lookup?i=' . $item_id . ' &t=xml';
$xml_data = simplexml_load_file($request_url) or die("Feed could not load");
foreach ($xml_data as $object)
{
$xml_name = $object->name;
$xml_url = $object->url;
foreach ($object as $icon)
{
$xml_icon = $icon->medium;
}
if ($xml_icon == "")
{
$xml_icon = "quest_1.jpg";
}
if (strcasecmp($item['name'], $xml_name) == 0)
{
// If we have a match, grab additional information about this item and break out of this loop.
$item['name'] = $xml_name;
$item['id'] = $item_id;
$item['lang'] = "en";
$item['icon'] = $xml_icon;
$item['link'] = $xml_url;
$item_found = true;
break;
}
}
}
}
// If a match was found, retrieve additional info about it.
if ($item_found)
{
$html_data = utf8_decode(itemstats_read_url('http://rift.yg.com/search?s=' . urlencode($name)));
$intPositionBody = strpos($html_data, '<div class="yg_itemdetailscontent">', 0);
$intPositionEndHTML = strpos($html_data, '<tr><td colspan="4" class="currency_container">', 0);
if ($intPositionEndHTML === false)
{
$intPositionEndHTML = strpos($html_data, '</html>', 0);
}
$item['html'] = substr($html_data, $intPositionBody, $intPositionEndHTML - $intPositionBody);
//echo $item['html'];
//die;
// Parse out the display html of this item from the XML
$item['html'] = str_replace("</div>", "{ITEMSTATS_LINK}</div>", $item['html']);
// Append Image
$item['html'] .= "</tbody></table></div>";
// Fix up the html a bit.
//$item['html'] = str_replace("</span></span><br /><span class='wowrttxt'>", "</span></span>\n<br /><span class='wowrttxt'>", $item['html']);
$item['html'] = str_replace('"', '\'', $item['html']);
$item['html'] = preg_replace('#(<[ /]*br[ /]*>)<[ /]*br[ /]*>#', '$1', $item['html']);
//$item['html'] = str_replace("<a href='http://rift.zam.com/en/item/", "<br><a class='set' href='http://rift.zam.com/en/item/", $item['html']);
$item['html'] = str_replace("<a", "<a target='_new'", $item['html']);
$item['html'] = preg_replace("#<a ([^>]*) class='itemcreatelink'>#", "<br><span class='itemeffectlink'>Creates: </span>\\0", $item['html']);
$item['html'] = str_replace('(', "", $item['html']);
$item['html'] = str_replace(')', "", $item['html']);
$item['html'] = str_replace("yg_itemdetailscontent", "wowitemt", $item['html']);
$item['html'] = str_replace("rift_item5", "purplename", $item['html']);
$item['html'] = str_replace("rift_item4", "bluename", $item['html']);
$item['html'] = str_replace("rift_item8", "itemGold", $item['html']);
$item['html'] = str_replace("rift_item3", "greenname", $item['html']);
$item['html'] = str_replace("rift_item1", "greyname", $item['html']);
$item['html'] = str_replace("rift_item6", "orangename", $item['html']);
$item['html'] = str_replace(""", "", $item['html']);
// Extract the item color from the HTML.
preg_match_all("#<strong class='(.*?)'>#s", $item['html'], $matches);
foreach ($matches[1] as $match)
{
if ($match == "purplename") // Purple
{
$item['color'] = "purplename";
break;
}
if ($match == "bluename") // Blue
{
$item['color'] = "bluename";
break;
}
if ($match == "itemGold") // Yellow
{
$item['color'] = "itemGold";
break;
}
if ($match == "greenname") // Green
{
$item['color'] = "greenname";
break;
}
if ($match == "greyname") // Gray
{
$item['color'] = "greyname";
break;
}
if ($match == "orangename") // Orange
{
$item['color'] = "orangename";
break;
}
}
// If this is a set, grab the set bonuses and add it to the html.
//$item_set_id = $this->xml_helper->parse($xml_data, 'setid');
//if (!empty($item_set_id) && ($item_set_id != '0'))
//{
// Read the item set page.
//$data = utf8_decode(itemstats_read_url('http://lotro.allakhazam.com/db/itemset.html?lotritemset=' . $item_set_id));
// Extract the set bonus html from this page.
//preg_match('#Set Bonuses:</div>(.*?)<br/><div class#s', $data, $match);
//$item_set_bonuses = $match[1];
// Fix up the html a bit /* COMMENT - MAY NEED TO CHANGE spell.html to skill.html ~Sokol */
//$item_set_bonuses = str_replace('/db/skill.html', 'http://lotro.allakhazam.com/db/skill.html', $item_set_bonuses);
//$item_set_bonuses = str_replace("<a", "<a class='setbonus' target='_new'", $item_set_bonuses);
//$item_set_bonuses = str_replace('"', '\'', $item_set_bonuses);
//$item_set_bonuses = preg_replace('#<[ /]*br[ /]*>$#','',$item_set_bonuses);
//$item_set_bonuses = "<span class='setbonus'>" . $item_set_bonuses . "</span>";
// Insert the set bonus text into the display html;
//$item['html'] = preg_replace('#setid=(.*?)</span></a>#s', '\\0' . $item_set_bonuses, $item['html']);
//}
/*
$temp_size_object_data = strlen($object_data);
if (substr($item['html'], $temp_size_object_data - 5, 5) == '<br/>')
$item['html'] = substr($item['html'], 0, $temp_size_object_data - 5);
*/
// Build the final HTML by merging the template and the data we just prepared.
$template_html = trim(file_get_contents(dirname(__FILE__) . '/../templates/popup.tpl'));
$item['html'] = str_replace('{ITEM_HTML}', $item['html'], $template_html);
return $item;
}
}
unset($item['link']);
//echo "Aucun objet trouvé !<br/>";
return ($item);
}
// Attempts to retrieve data for the specified item with ID from Allakhazam.
function getItemId($item_id, $locale_lang)
{
$request_url = 'http://rift.yg.com/api/lookup?i=' . $item_id . ' &t=xml';
$xml_data = simplexml_load_file($request_url) or die("Feed could not load");
foreach ($xml_data as $object)
{
$xml_name = $object->name;
$xml_url = $object->url;
foreach ($object as $icon)
{
$xml_icon = $icon->medium;
}
if ($xml_icon == "")
{
$xml_icon = "quest_1.jpg";
}
if (strcasecmp($item['name'], $xml_name) == 0)
{
// If we have a match, grab additional information about this item and break out of this loop.
$item['name'] = $xml_name;
$item['id'] = $item_id;
$item['lang'] = "en";
$item['icon'] = $xml_icon;
$item['link'] = $xml_url;
$item_found = true;
break;
}
}
if ($item_found)
{
$html_data = utf8_decode(itemstats_read_url('http://rift.yg.com/search?s=' . urlencode($name)));
$intPositionBody = strpos($html_data, '<div class="yg_itemdetailscontent">', 0);
$intPositionEndHTML = strpos($html_data, '<tr><td colspan="4" class="currency_container">', 0);
if ($intPositionEndHTML === false)
{
$intPositionEndHTML = strpos($html_data, '</html>', 0);
}
$item['html'] = substr($html_data, $intPositionBody, $intPositionEndHTML - $intPositionBody);
//echo $item['html'];
//die;
// Parse out the display html of this item from the XML
$item['html'] = str_replace("</div>", "{ITEMSTATS_LINK}</div>", $item['html']);
// Append Image
$item['html'] .= "</tbody></table></div>";
// Fix up the html a bit.
//$item['html'] = str_replace("</span></span><br /><span class='wowrttxt'>", "</span></span>\n<br /><span class='wowrttxt'>", $item['html']);
$item['html'] = str_replace('"', '\'', $item['html']);
$item['html'] = preg_replace('#(<[ /]*br[ /]*>)<[ /]*br[ /]*>#', '$1', $item['html']);
//$item['html'] = str_replace("<a href='http://rift.zam.com/en/item/", "<br><a class='set' href='http://rift.zam.com/en/item/", $item['html']);
$item['html'] = str_replace("<a", "<a target='_new'", $item['html']);
$item['html'] = preg_replace("#<a ([^>]*) class='itemcreatelink'>#", "<br><span class='itemeffectlink'>Creates: </span>\\0", $item['html']);
$item['html'] = str_replace('(', "", $item['html']);
$item['html'] = str_replace(')', "", $item['html']);
$item['html'] = str_replace("yg_itemdetailscontent", "wowitemt", $item['html']);
$item['html'] = str_replace("rift_item5", "purplename", $item['html']);
$item['html'] = str_replace("rift_item4", "bluename", $item['html']);
$item['html'] = str_replace("rift_item8", "itemGold", $item['html']);
$item['html'] = str_replace("rift_item3", "greenname", $item['html']);
$item['html'] = str_replace("rift_item1", "greyname", $item['html']);
$item['html'] = str_replace("rift_item6", "orangename", $item['html']);
$item['html'] = str_replace(""", "", $item['html']);
// Extract the item color from the HTML.
preg_match_all("#<strong class='(.*?)'>#s", $item['html'], $matches);
foreach ($matches[1] as $match)
{
if ($match == "purplename") // Purple
{
$item['color'] = "purplename";
break;
}
if ($match == "bluename") // Blue
{
$item['color'] = "bluename";
break;
}
if ($match == "itemGold") // Yellow
{
$item['color'] = "itemGold";
break;
}
if ($match == "greenname") // Green
{
$item['color'] = "greenname";
break;
}
if ($match == "greyname") // Gray
{
$item['color'] = "greyname";
break;
}
if ($match == "orangename") // Orange
{
$item['color'] = "orangename";
break;
}
}
// If this is a set, grab the set bonuses and add it to the html.
//$item_set_id = $this->xml_helper->parse($xml_data, 'setid');
//if (!empty($item_set_id) && ($item_set_id != '0'))
//{
// Read the item set page.
//$data = utf8_decode(itemstats_read_url('http://lotro.allakhazam.com/db/itemset.html?lotritemset=' . $item_set_id));
// Extract the set bonus html from this page.
//preg_match('#Set Bonuses:</div>(.*?)<br/><div class#s', $data, $match);
//$item_set_bonuses = $match[1];
// Fix up the html a bit
//$item_set_bonuses = str_replace('/db/spell.html', 'http://lotro.allakhazam.com/db/skill.html', $item_set_bonuses);
//$item_set_bonuses = str_replace("<a", "<a class='setbonus' target='_new'", $item_set_bonuses);
//$item_set_bonuses = str_replace('"', '\'', $item_set_bonuses);
//$item_set_bonuses = preg_replace('#<[ /]*br[ /]*>$#','',$item_set_bonuses);
//$item_set_bonuses = "<span class='setbonus'>" . $item_set_bonuses . "</span>";
// Insert the set bonus text into the display html;
//$item['html'] = preg_replace('#setid=(.*?)</span></a>#s', '\\0' . $item_set_bonuses, $item['html']);
//}
// Build the final HTML by merging the template and the data we just prepared.
$template_html = trim(file_get_contents(dirname(__FILE__) . '/../templates/popup.tpl'));
$item['html'] = str_replace('{ITEM_HTML}', $item['html'], $template_html);
return $item;
}
}