/***************************************************************************
 *                               shop.php
 *                            -------------------
 *   Version              : 1.0.0
 *   began                : Friday, December 6th, 2002
 *   released             : Tuesday, December 10th, 2002
 *   email                : ice_rain_@hotmail.com
 *   aim                  : zarath42
 *   msn messanger        : ice_rain_@hotmail.com
 *
 *   requires             : 2.0.0+ phpbb & points mod
 *   files to edit        : /viewtopic.php
 *                        : /templates/*/viewtopic_body.tpl
 *                        : /includes/page_header.php
 *                        : /templates/*/overall_header.tpl
 *   difficulty           : easy
 *   time                 : 5minutes
 *
 *   special thanks       : thewizard, masterlogan & dave2 who beta tested 
 *                          this mod. Also, eXplosive for the points mod.
 *
 ***************************************************************************/

/***************************************************************************
 *
 *   copyright (C) 2002/2003  IcE-RaiN/Zarath
 *
 *   This program is free software; you can redistribute it and/or
 *   modify it under the terms of the GNU General Public License
 *   as published by the Free Software Foundation; either version 2
 *   of the License, or (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   http://www.gnu.org/copyleft/gpl.html
 *
 ***************************************************************************/

/***************************************************************************
 * Installation
 *
 * 1. Upload files
 *		/admin/admin_shop.php
 *		/templates/*/admin/shop_config_body.tpl
 *		/templates/*/shop_body.tpl
 *		/shop.php
 *		/shop_install.php (Only needed for install)
 *
 * 2. Run shop_install.php then delete it.
 *
 * 3. Execute Steps Below
 *
 ***************************************************************************/


 ------[OPEN]------
 /viewtopic.php

 ------[FIND]------
//
// Go ahead and pull all data for this topic
// 
$sql = "SELECT u.username, u.user_level, u.user_id,

 ------[ADD, AFTER]------
 u.user_items,

 ------[FIND]------
	//
	// Note! The order used for parsing the message _is_ important, moving things around could break any 
	// output
	//


 ------[ADD, BEFORE]------
	//start of display-items
	$gsql = "select * from " . CONFIG_TABLE . " where config_name='viewtopic'";
	if ( !($gresult = $db->sql_query($gsql)) )
	{
		message_die(CRITICAL_ERROR, 'ERROR: Getting Global Variables!');
	}
	$grow = mysql_fetch_array($gresult);
	if ($grow['config_value'] == images)
	{
		$itempurge = str_replace("", "", $postrow[$i]['user_items']);
		$itemarray = explode('',$itempurge);
		$itemcount = count ($itemarray);
		$user_items = "<br>";
     		for ($xe = 0;$xe < $itemcount;$xe++)
		{
			if ($itemarray[$xe] != NULL)
			{
				if (file_exists("shop/images/".$itemarray[$xe].".jpg"))
				{
					$user_items .= " <img src=\"shop/images/$itemarray[$xe].jpg\" title=\"$itemarray[$xe]\" alt=\"$itemaray[$xe]\">";
				}
				elseif (file_exists("shop/images/".$itemarray[$xe].".gif"))
				{
					$user_items .= " <img src=\"shop/images/$itemarray[$xe].gif\" title=\"$itemarray[$xe]\" alt=\"$itemaray[$xe]\">";
				}
			}
		}
	}
	$usernameurl = append_sid("shop.".$phpEx."?action=inventory&searchname=".$postrow[$i]['username']);



 ------[FIND]------
		'DELETE_IMG' => $delpost_img, 
		'DELETE' => $delpost, 

 ------[ADD, AFTER]------
		'ITEMSNAME' => $usernameurl,
		'ITEMS' => $user_items,

 ------[OPEN]------
 /templates/*/viewtopic_body.tpl

 ------[FIND]------
{postrow.POINTS}

 ------[ADD, AFTER]------ 
<a href="{postrow.ITEMSNAME}">Items</a>{postrow.ITEMS}

 ------[OPEN]------
 /includes/page_header.php

 ------[FIND]------
	'PAGE_TITLE' => $page_title,

 ------[ADD, AFTER]------ 
	'SHOP' => '<img src="shop/images/icon_store_rpg.gif">Shop',

 ------[FIND]------
	'U_FAQ' => append_sid('faq.'.$phpEx),

 ------[ADD, AFTER]------ 
	'U_SHOP' => append_sid('shop.'.$phpEx),

 ------[OPEN]------
/template/*/overall_header.tpl

 ------[FIND]------
<a href="{U_LOGIN_LOGOUT}" class="mainmenu">{L_LOGIN_LOGOUT}</a>

 ------[ADD, BEFORE]------
<a href="{U_SHOP}" class="mainmenu">{SHOP}</a>
 ------[SAVE/CLOSE ALL FILES]------