PHPBB3 Installation
#
#-----[ GOTO ]------------------------------------------
#

PHPBB3 Admin Panel
 Style (Tabulation)
  Templates (Under the Style Component part of the left side menu)

#
#-----[ FOR EACH INSTALLED TEMPLATE ]------------------------------------------
#

Click the Edit link

#
#-----[ OPEN ]------------------------------------------
#

overall_header.html

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

<script type="text/javascript" src="{T_TEMPLATE_PATH}

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

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

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

PHPBB3 Admin Panel
 Posting (Tabulation)

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

Usage:
[Item]{NUMBER}[/Item]

HTML Replacement:
Nothing

Help Line:
Warhammer Item: [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"

Display on posting page:
YES

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

Usage:
[Spell]{NUMBER}[/Spell]

HTML Replacement:
Nothing

Help Line:
Warhammer Spell: [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"

Display on posting page:
YES

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

Usage:
[Quest]{NUMBER}[/Quest]

HTML Replacement:
Nothing

Help Line:
Warhammer Quest: [quest]id or name[/quest]

Display on posting page:
YES

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

Usage:
[Npc]{NUMBER}[/Npc]

HTML Replacement:
Nothing

Help Line:
Warhammer NPC: [Npc]id or name[/Npc]

Display on posting page:
YES

#
#-----[ 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 ]------------------------------------------
#

phpBB3/includes/message_parser.php

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

			'flash'			=> array('bbcode_id' => 11,	'regexp' => array('#\[flash=([0-9]+),([0-9]+)\](.*?)\[/flash\]#ie' => "\$this->bbcode_flash('\$1', '\$2', '\$3')"))

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

			,'item'			=> array('bbcode_id' => 13,	'regexp' => array('#\[item=?(.*?)?\](.*?)\[/item\]#ie' => "\$this->bbcode_item('\$1', '\$2')")),
			'spell'			=> array('bbcode_id' => 14,	'regexp' => array('#\[spell=?(.*?)?\](.*?)\[/spell\]#ie' => "\$this->bbcode_spell('\$1', '\$2')")),
			'quest'			=> array('bbcode_id' => 15,	'regexp' => array('#\[quest](.*?)\[/quest\]#ie' => "\$this->bbcode_quest('\$1')")),
			'npc'			=> array('bbcode_id' => 16,	'regexp' => array('#\[npc](.*?)\[/npc\]#ie' => "\$this->bbcode_npc('\$1')")),

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

		return '[i:' . $this->bbcode_uid . ']' . $in . '[/i:' . $this->bbcode_uid . ']';
	}

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

	/**
	* Parse wardb tags
	*/
	function bbcode_item($modifier, $in)
	{
		if (!$this->check_bbcode('item', $in))
			return $in;
		
		if ($modifier)
			return '[item=' . $modifier . ':' . $this->bbcode_uid . ']' . $in . '[/item:' . $this->bbcode_uid . ']';
		else
			return '[item:' . $this->bbcode_uid . ']' . $in . '[/item:' . $this->bbcode_uid . ']';
	}

	function bbcode_spell($modifier, $in)
	{
		if (!$this->check_bbcode('spell', $in))
			return $in;
		
		if ($modifier)
			return '[spell=' . $modifier . ':' . $this->bbcode_uid . ']' . $in . '[/spell:' . $this->bbcode_uid . ']';
		else
			return '[spell:' . $this->bbcode_uid . ']' . $in . '[/spell:' . $this->bbcode_uid . ']';
	}

	function bbcode_quest($in)
	{
		if (!$this->check_bbcode('spell', $in))
			return $in;
		
		return '[quest:' . $this->bbcode_uid . ']' . $in . '[/quest:' . $this->bbcode_uid . ']';
	}

	function bbcode_npc($in)
	{
		if (!$this->check_bbcode('npc', $in))
			return $in;
		
		return '[npc:' . $this->bbcode_uid . ']' . $in . '[/npc:' . $this->bbcode_uid . ']';
	}
#
#-----[ OPEN ]------------------------------------------
#

phpBB3/includes/bbcode.php

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

				case 12:
					$this->bbcode_cache[$bbcode_id] = array(
						'str'	=> array(
							'[/attachment:$uid]'	=> $this->bbcode_tpl('inline_attachment_close', $bbcode_id)
						),
						'preg'	=> array(
							'#\[attachment=([0-9]+):$uid\]#'	=> $this->bbcode_tpl('inline_attachment_open', $bbcode_id)
						)
					);
				break;

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

				case 13:
					$this->bbcode_cache[$bbcode_id] = array(
						'preg' => array(
							'#\[item:$uid\]((.*?))\[/item:$uid\]#ise'				=> "wardb_item(NULL, '\$1');",
							'#\[item=([^\[]+):$uid\](.*?)\[/item:$uid\]#ise'		=> "wardb_item('\$1', '\$2');"
						)
					);
				break;

				case 14:
					$this->bbcode_cache[$bbcode_id] = array(
						'preg' => array(
							'#\[spell:$uid\]((.*?))\[/spell:$uid\]#ise'				=> "wardb_spell(NULL, '\$1');",
							'#\[spell=([^\[]+):$uid\](.*?)\[/spell:$uid\]#ise'		=> "wardb_spell('\$1', '\$2');"
						)
					);
				break;

				case 15:
					$this->bbcode_cache[$bbcode_id] = array(
						'preg' => array(
							'#\[quest:$uid\]((.*?))\[/quest:$uid\]#ise'				=> "wardb_quest('\$1');",
						)
					);
				break;

				case 16:
					$this->bbcode_cache[$bbcode_id] = array(
						'preg' => array(
							'#\[npc:$uid\]((.*?))\[/npc:$uid\]#ise'				=> "wardb_npc('\$1');",
						)
					);
				break;

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

		$code = $this->bbcode_tpl('code_open') . $code . $this->bbcode_tpl('code_close');

		return $code;
	}
}

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

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

function wardb_getIdFromName($database, $type, $name)
{
	global $db;
	$result = $db->sql_query("SELECT `id` FROM `".$database."` WHERE `name_en` = '".str_replace("'", "\'", $name)."'");
	if ($row = $db->sql_fetchrow($result)) {
		return $row['id'];
	} else {
		$rname = urlencode($name);
		$rname = str_replace('%26quot%3B','%22', $rname);
		$rname = str_replace('%26%23039%3B', '%27', $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->sql_query("INSERT INTO `".$database."` SET `name_en` = '".str_replace("'", "\'", $name)."', id = ".$id);
			return $id;
		} else
			return 0;
	}
	$db->sql_freeresult($result);
}

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 ]------------------------------------------
#