Welcome to the E-Blah Community!
We would like to welcome you to our community and invite you to register an account or login.
Being a registered member is important, as it gives you several advantages over the normal Guest status. After registering you will be able to download files and images, post messages, and access member-only portions of the forum - just to name a few. Registration is quick and simple, and only takes about a minute of your time.

E-Blah Community    Modifications    Mod Requests and Support  ›  WoWhead item Link Moderators: 10 Series Support Team
Users Browsing Forum
No Members and 1 Guests

WoWhead item Link  This thread currently has 975 views. Print
1 Pages 1 Recommend Thread
2pacalypse
June 3, 2009, 5:00am Report to Moderator Report to Moderator
E-Blah Member
Posts: 4
Posts Per Day: 0.00
Time Online: 2 hours 39 minutes
I Found this useful addon for WoW Forums: [LINK REMOVED] unfortunatly its designed for a different forum type is it still possible to use it on Eblah or maybe alter it slightly to adjust to Eblah? (Just nothing too complex please, my knowledge is PHP is extremely basic)

EDIT:

heres the PHP code for it.

Code
<?php
/* wowitem.php -- MyBB plugin for querying World of Warcraft item databases
  version 1.0.0, February 13th, 2009
  http://www.ravenguard.ca/wowitem/

  Copyright (C) 2009 Daniel Major

  This software is provided 'as-is', without any express or implied
  warranty.  In no event will the authors be held liable for any damages
  arising from the use of this software.

  Permission is granted to anyone to use this software for any purpose,
  including commercial applications, and to alter it and redistribute it
  freely, subject to the following restrictions:

  1. The origin of this software must not be misrepresented; you must not
     claim that you wrote the original software. If you use this software
     in a product, an acknowledgment in the product documentation would be
     appreciated but is not required.
  2. Altered source versions must be plainly marked as such, and must not be
     misrepresented as being the original software.
  3. This notice may not be removed or altered from any source distribution.

  Daniel Major dmajor@gmail.com

*/

// Disallow direct access to this file for security reasons
if(!defined("IN_MYBB"))
{
	die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}

// the MyCode tag(s) to parse for, separated by |
define(WOWITEM_MYCODE, 'item|wowitem');

define(WOWITEM_HEADER, '<script type="text/javascript" src="http://www.wowhead.com/widgets/power.js"></script>');

$plugins->add_hook("parse_message", "wowitem_parse");

function wowitem_info()
{
	return array(
		"name"          => "WoW Item Links",
		"description"   => "Queries online databases to display World of Warcraft item data in posts.",
		"website"       => "http://www.ravenguard.ca/wowitem/",
		"author"        => "Bakdu",
		"authorsite"    => "mailto:bakdu@ravenguard.ca",
		"version"       => "1.0.0",
		"guid"          => "15fdaaa7e4e5d0f12defedf033f7c4b7",
		"compatibility" => "14*"
	);
}

function wowitem_install()
{
	global $mybb, $db;

	// create cache table
	$db->write_query("CREATE TABLE ".TABLE_PREFIX."wowitem (
		cache_key varchar(255) NOT NULL,
		fetched int unsigned NOT NULL,
		id int NOT NULL,
		name varchar(255) NOT NULL,
		quality int NOT NULL,
		icon varchar(255) NOT NULL,
		link varchar(255) NOT NULL,
		PRIMARY KEY (cache_key)
	);");

	// delete settings that were not uninstalled cleanly
	$db->delete_query('settings', "name LIKE 'wowitem_%'");
	$db->delete_query('settinggroups', "name = 'wowitem'");

	// add settings group
	$query = $db->simple_select('settinggroups', "MAX(disporder) AS max_disporder");
	$disporder = $db->fetch_field($query, 'max_disporder') + 1;
	$gid = $db->insert_query('settinggroups', array(
		'name' => 'wowitem',
		'title' => 'WoW Item Links',
		'description' => $db->escape_string("Options to configure the WoW Item Links plugin."),
		'disporder' => $disporder,
		'isdefault' => 0
	));

	// add settings
	$db->insert_query('settings', array(
		'name' => 'wowitem_db',
		'title' => 'Item Database',
		'description' => $db->escape_string("Choose the provider to query for item data.<br />\n<br />\nIf set to disabled, no more requests will be sent to external sites but the locally cached items will still show."),
		'optionscode' => "radio\nwowhead=Wowhead\ndisabled=Disabled",
		'value' => 'wowhead',
		'disporder' => 1,
		'gid' => $gid
	));

	$db->insert_query('settings', array(
		'name' => 'wowitem_cached',
		'title' => 'Enable Cache',
		'description' => $db->escape_string("If the cache is enabled, the item data will be stored in the database. This reduces the number of external requests and allows links to work during provider downtime but adds to the database size."),
		'optionscode' => "yesno",
		'value' => '1',
		'disporder' => 2,
		'gid' => $gid
	));

	$db->insert_query('settings', array(
		'name' => 'wowitem_cache_refresh',
		'title' => 'Cache Refresh',
		'description' => $db->escape_string("The number of minutes before the cached data is considered stale and an external request is made to refresh the data. Set to 0 to disable refreshing."),
		'optionscode' => "text",
		'value' => '1440',
		'disporder' => 3,
		'gid' => $gid
	));

	rebuild_settings();
}

function wowitem_is_installed()
{
	global $mybb, $db;

	return $db->table_exists('wowitem');
}

function wowitem_uninstall()
{
	global $mybb, $db;

	// remove settings
	$db->delete_query('settings', "name LIKE 'wowitem_%'");
	$db->delete_query('settinggroups', "name = 'wowitem'");

	rebuild_settings();

	// drop cache
	$db->drop_table('wowitem');
}

function wowitem_activate()
{
	require_once MYBB_ROOT.'/inc/adminfunctions_templates.php';
	find_replace_templatesets('headerinclude', '#{\$newpmmsg}#', WOWITEM_HEADER . "\n{\$newpmmsg}");
}

function wowitem_deactivate()
{
	require_once MYBB_ROOT.'/inc/adminfunctions_templates.php';
	find_replace_templatesets('headerinclude', '#' . preg_quote(WOWITEM_HEADER) . '\n#', '', 0);
}

function wowitem_parse($message)
{
	$mycodes = explode('|', WOWITEM_MYCODE);
	foreach ($mycodes as $mycode)
	{
		$message = preg_replace('#\['.$mycode.'\](.*?)\[/'.$mycode.'\]#ie', "wowitem_item('\$1')", $message);
	}
}

function wowitem_item($data)
{
	global $mybb, $db;

	// fetch from cache or provider
	$stale = 0;
	$cache = wowitem_cache_query('item', $data);
	if ($cache)
	{
		$cache_refresh = intval($mybb->settings['wowitem_cache_refresh']) * 60;
		$stale = ($cache_refresh > 0) && ($cache['fetched'] < TIME_NOW - $cache_refresh);
	}
	if (!$cache || $stale)
	{
		eval("\$item = wowitem_" . $mybb->settings['wowitem_db'] . "_query('item', \$data);");
		if ($item && $mybb->settings['wowitem_cached'] == 1)
		{
			if ($stale)
			{
				$db->update_query('wowitem', array(
					'fetched' => $item['fetched'],
					'id' => $item['id'],
					'name' => $db->escape_string($item['name']),
					'quality' => $item['quality'],
					'icon' => $db->escape_string($item['icon']),
					'link' => $db->escape_string($item['link']),
				), "cache_key = '" . $db->escape_string($data) . "'");
			}
			else
			{
				$db->insert_query('wowitem', array(
					'cache_key' => $db->escape_string($data),
					'fetched' => $item['fetched'],
					'id' => $item['id'],
					'name' => $db->escape_string($item['name']),
					'quality' => $item['quality'],
					'icon' => $db->escape_string($item['icon']),
					'link' => $db->escape_string($item['link']),
				));
			}
		}
	}
	if (!$item)
	{
		$item = $cache;
	}

	// no cached data and error with provider, make up a null item
	if (!$item)
	{
		$item = array(
			'id'      => 0,
			'name'    => $data,
			'quality' => 0,
			'icon'    => '',
			'link'    => 'javascript:void(0);',
			'fetched' => TIME_NOW
		);
	}

	// HTML is generated, customize here if desired
	return '<a class="q' . $item['quality'] . '" href="' . $item['link'] . '"><b>[' . $item['name'] . ']</b></a>';
}

function wowitem_cache_query($type, $data)
{
	global $mybb, $db;

	if ($mybb->settings['wowitem_cached'] == 1)
	{
		$query = $db->simple_select('wowitem', 'id, name, quality, icon, link, fetched', "cache_key = '" . $db->escape_string($data) . "'");
		$item = $db->fetch_array($query);
		if (isset($item['id']))
		{
			return $item;
		}
	}

	return false;
}

function wowitem_disabled_query($type, $data)
{
	return false;
}

function wowitem_wowhead_query($type, $data)
{
	$url = 'http://www.wowhead.com/?' . $type . '=' . urlencode($data) . '&xml';
	$ch = curl_init();
	curl_setopt($ch, CURLOPT_URL, $url);
	curl_setopt($ch, CURLOPT_TIMEOUT, 5);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
	$response = curl_exec($ch);
	curl_close($ch);
	if ($response)
	{
		$xml = simplexml_load_string($response);
		if (!$xml->error) {
			return array(
				'id'      => intval($xml->item['id']),
				'name'    => $xml->item->name,
				'quality' => $xml->item->quality['id'],
				'icon'    => $xml->item->icon,
				'link'    => $xml->item->link,
				'fetched' => TIME_NOW
			);
		}
	}
	return false;
}

?>

Revision History (2 edits)
iCONICA  -  June 3, 2009, 10:34am
iCONICA  -  June 3, 2009, 10:34am
Logged Offline
Private Message Private message
iCONICA
June 3, 2009, 10:36am Report to Moderator Report to Moderator

Forum Moderation
Posts: 1,431
Gender: Male
Posts Per Day: 0.96
Reputation: 98.25%
Reputation Score: +56 / -1
Time Online: 16 days 2 hours 20 minutes
Location: Manchester UK
E-Blah is perl and there isn't a way to parse both perl and php to my knowledge. I can't think of a way to integrate this unless it was written in perl...

You didn't explain what exactly it does... Maybe there's something similar already created for E-Blah if you explain it's purpose...


Logged Offline
Site Site Private Message Private message Windows Live Messenger WLM Reply: 1 - 4
2pacalypse
June 3, 2009, 11:12am Report to Moderator Report to Moderator
E-Blah Member
Posts: 4
Posts Per Day: 0.00
Time Online: 2 hours 39 minutes
It allows for a new BBS code ( [wowitem] ) which if supplied with a URL or Item ID shows you the information about that item (World of Warcraft items). for example lets say you write

[wowitem]21460[/wowitem] or [wowitem]http://www.wowhead.com/?item=21460[/wowitem] it "formats" the item to its appropriate color (aswell as placing it within [ ]  - just like in the game) and shows a tooltip with details about that item taken from WoWhead(click on the link and mouseover an item to see the tooltip)

Heres an example image
Logged Offline
Private Message Private message Reply: 2 - 4
evixion
June 4, 2009, 12:29pm Report to Moderator Report to Moderator

Web Developer for Hire
Forum Moderation
Posts: 226
Gender: Male
Posts Per Day: 0.19
Reputation: 100.00%
Reputation Score: +6 / -0
Time Online: 7 days 1 hours 34 minutes
Location: Elizabethton, Tennessee
Age: 26
I may try and make that my project because I know PHP and not very good at Perl and learning to port it would be an interesting task. Doubt I'll succeed so don't depend on this anytime soon.


Logged Offline
Site Site Private Message Private message Windows Live Messenger WLM Reply: 3 - 4
2pacalypse
June 5, 2009, 12:15pm Report to Moderator Report to Moderator
E-Blah Member
Posts: 4
Posts Per Day: 0.00
Time Online: 2 hours 39 minutes
Thanks Evixion I'm sure the entire Eblah-WoW community will appriciate your attempt and if you will fail please post what you made -perhaps you will have a successor
Logged Offline
Private Message Private message Reply: 4 - 4
1 Pages 1 Recommend Thread
Print

E-Blah Community    Modifications    Mod Requests and Support  ›  WoWhead item Link