VBulletin Board 3.7.3 Installation
#
#-----[ GOTO ]------------------------------------------
#

VBB Control Panel
	"Style & Templates" in the left side menu
		"Style Manager"

#
#-----[ FOR EACH INSTALLED STYLE ]------------------------------------------
#

In the dropdown menu choose "Edit Templates"
	Double Click the "headinclude" file in the list on the left

#
#-----[ FIND ]------------------------------------------
#

<script type="text/javascript"

#
#-----[ BEFORE, ADD ]------------------------------------------
#

<script src="http://www.wardb.com/js/extooltips.js" type="text/javascript"></script>

#
#-----[ SUBMIT, PROCESS NEXT INSTALLED TEMPLATE ]------------------------------------------
#
#
#-----[ GOTO ]------------------------------------------
#

VBB Control Panel
	"Custom BB Codes" in the left side menu
		"BB Code Manager"

#
#-----[ BBCODE, ADD ]------------------------------------------
#

Title:
WARDB Item

BB Code Tag Name:
item

Replacement:
Warhammer Online Item

Example:
[item]id or name[/item] or [item=full-medium]id or name[/item]. Tip: You can use "text", "full-small", "full-medium" and "full-large"

Description:
Warhammer Online Item

Button Image:
http://www.wardb.com/images/item.gif

#
#-----[ BBCODE, ADD ]------------------------------------------
#

Title:
WARDB Spell

BB Code Tag Name:
spell

Replacement:
Warhammer Online Spell

Example:
[spell]id or name[/spell] or [spell=full-medium]id or name[/spell]. Tip: You can use "text", "full-small", "full-medium" and "full-large"

Description:
Warhammer Online Spell

Button Image:
http://www.wardb.com/images/spell.gif

#
#-----[ BBCODE, ADD ]------------------------------------------
#

Title:
WARDB Quest

BB Code Tag Name:
quest

Replacement:
Warhammer Online Quest

Example:
[quest]id or name[/quest]

Description:
Warhammer Online Quest

Button Image:
http://www.wardb.com/images/quest.gif

#
#-----[ BBCODE, ADD ]------------------------------------------
#

Title:
WARDB NPC

BB Code Tag Name:
npc

Replacement:
Warhammer Online NPC

Example:
[npc]id or name[/npc]

Description:
Warhammer Online NPC

Button Image:
http://www.wardb.com/images/npc.gif

#
#-----[ SQL, REQUEST ]------------------------------------------
#

DROP TABLE IF EXISTS `wardb_itemcache`;
CREATE TABLE `wardb_itemcache` (
  `id` int(32) NOT NULL,
  `name_en` varchar(255) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

DROP TABLE IF EXISTS `wardb_npccache`;
CREATE TABLE `wardb_npccache` (
  `id` int(32) NOT NULL,
  `name_en` varchar(255) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

DROP TABLE IF EXISTS `wardb_questcache`;
CREATE TABLE `wardb_questcache` (
  `id` int(32) NOT NULL,
  `name_en` varchar(255) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

DROP TABLE IF EXISTS `wardb_spellcache`;
CREATE TABLE `wardb_spellcache` (
  `id` int(32) NOT NULL,
  `name_en` varchar(255) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
#
#-----[ OPEN ]------------------------------------------
#

vBulletin/includes/class_bbcode.php

#
#-----[ FIND ]------------------------------------------
#

	function parse_bbcode($input_text, $do_smilies, $do_html = false)
	{

#
#-----[ AFTER, ADD ]------------------------------------------
#

		$input_text = wardb_parseTags($input_text);
	
#
#-----[ FIND ]------------------------------------------
#

	else
	{
		return $tag_list;
	}
}

#
#-----[ AFTER, ADD ]------------------------------------------
#

function wardb_parseTags($message) {
	$tags = array(
		array('#\[item=?(.*?)?\](.*?)\[/item\]#ie' => "wardb_item('\$1', '\$2')"),
		array('#\[spell=?(.*?)?\](.*?)\[/spell\]#ie' => "wardb_spell('\$1', '\$2')"),
		array('#\[quest](.*?)\[/quest\]#ie' => "wardb_quest('\$1')"),
		array('#\[npc](.*?)\[/npc\]#ie' => "wardb_npc('\$1')")
	);
	
	foreach ($tags as $key => $val) {
		list($regex, $replace) = each($val);
		if (preg_match($regex, $message)) {
			$message = preg_replace($regex, $replace, $message);
		}
	}
	return $message;
}

function wardb_getNameFromId($database, $type, $id)
{
	global $db;
	$result = $db->query_first("SELECT `name_en` FROM `".$database."` WHERE `id` = '".$id."'");
	if ($result) {
		return $result['name_en'];
	} else {
		$name = file_get_contents("http://www.wardb.com/ajaxIDLookup.aspx?type=".$type."&id=".$id);
		if ($name != "" and $name != "0") {
			$name = str_replace('&#039;', "'", $name);
			$name = str_replace('&#39;', "'", $name);
			$name = str_replace('&#33;', "!", $name);
			$db->query_write("INSERT INTO `".$database."` SET `name_en` = '".str_replace("'", "\'", $name)."', id = ".$id);
			return $name;
		} else
			return '';
	}
}

function wardb_getIdFromName($database, $type, $name)
{
	global $db;
	$name = str_replace('&#039;', "'", $name);
	$name = str_replace('&#39;', "'", $name);
	$name = str_replace('&#33;', "!", $name);
	$result = $db->query_first("SELECT `id` FROM `".$database."` WHERE `name_en` = '".str_replace("'", "\'", $name)."'");
	if ($result) {
		return $result['id'];
	} else {
		$rname = urlencode($name);
		$rname = str_replace('%26quot%3B','%22', $rname);
		$rname = str_replace('+','%20', $rname);
		$id = file_get_contents("http://www.wardb.com/ajaxIDLookup.aspx?type=".$type."&name=".$rname);
		if ($id != "" and $id != "0") {
			$db->query_write("INSERT INTO `".$database."` SET `name_en` = '".str_replace("'", "\'", $name)."', id = '".$id."'");
			return $id;
		} else
			return 0;
	}
}

function wardb_item($modifier, $data)
{
	if ($modifier == NULL || ($modifier != 'text' && $modifier != 'full-small' && $modifier != 'full-medium' && $modifier != 'full-large'))
		$modifier = 'full-medium';
	
	if ($data == '')
		return '';
	
	if (is_numeric($data)) {
		$id = $data;
		$name = wardb_getNameFromId('wardb_itemcache', 1, $id);
	} else {
		$name = $data;
		$id = wardb_getIdFromName('wardb_itemcache', 1, $name);
	}
	
	if ($id != 0 && $name != '')
		return '<a class="wardb-item-'.$modifier.'" href="http://www.wardb.com/item.aspx?id='.$id.'">'.$name.'</a>';
	return $data;
}

function wardb_spell($modifier, $data)
{
	if ($modifier == NULL || ($modifier != 'text' && $modifier != 'full-small' && $modifier != 'full-medium' && $modifier != 'full-large'))
		$modifier = 'full-medium';
	
	if ($data == '')
		return '';
	
	if (is_numeric($data)) {
		$id = $data;
		$name = wardb_getNameFromId('wardb_spellcache', 6, $id);
	} else {
		$name = $data;
		$id = wardb_getIdFromName('wardb_spellcache', 6, $name);
	}
	
	if ($id != 0 && $name != '')
		return '<a class="wardb-spell-'.$modifier.'" href="http://www.wardb.com/spell.aspx?id='.$id.'">'.$name.'</a>';
	return $data;
}

function wardb_quest($data)
{
	if ($data == '')
		return '';
	
	if (is_numeric($data)) {
		$id = $data;
		$name = wardb_getNameFromId('wardb_questcache', 4, $id);
	} else {
		$name = $data;
		$id = wardb_getIdFromName('wardb_questcache', 4, $name);
	}
	
	if ($id != 0 && $name != '')
		return '<a class="wardb-quest" href="http://www.wardb.com/quest.aspx?id='.$id.'">'.$name.'</a>';
	return $data;
}

function wardb_npc($data)
{
	if ($data == '')
		return '';
	
	if (is_numeric($data)) {
		$id = $data;
		$name = wardb_getNameFromId('wardb_npccache', 2, $id);
	} else {
		$name = $data;
		$id = wardb_getIdFromName('wardb_npccache', 2, $name);
	}
	
	if ($id != 0 && $name != '')
		return '<a class="wardb-npc" href="http://www.wardb.com/npc.aspx?id='.$id.'">'.$name.'</a>';
	return $data;
}

#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
#