/***************************************************************************
 *                               upgrade1.txt
 *                            -------------------
 *   Version              : 1.1.0
 *   began                : Wednesday, December 11th, 2002
 *   released             : Sunday, December 15th, 2002
 *   forums               : http://www.auzdev.com/chaos/forums
 *   email                : ice_rain_@hotmail.com
 *
 *   requires             : 2.0.0+ phpbb
 *                          points mod
 *                          first version of the shop mod
 *   files to edit        : /viewtopic.php
 *                        : /templates/*/viewtopic_body.tpl
 *                        : /includes/usercp_viewprofile.php
 *                        : /templates/*/profile_view_body.tpl
 *   difficulty           : medium
 *   time                 : 5-10minutes
 *
 ***************************************************************************/

/***************************************************************************
 *
 *   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. Reupload files
 *		/admin/admin_shop.php
 *		/templates/*/admin/shop_config_body.tpl
 *		/templates/*/shop_body.tpl
 *		/shop.php
 *		/shop_install.php
 *
 * 2. Run shop_install.php then delete it.
 *
 * 3. Make sure folder /shop/images/ exists, upload all shop images to there.
 *
 * 3. Execute Steps Below
 *
 ***************************************************************************/


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

(depending on your downloaded version, this could already be done.)

 ------[FIND]------
append_sid("shop.".$phpEx."?action=inventory&searchname=".$poster);

 ------[REPLACE WITH]------
append_sid("shop.".$phpEx."?action=inventory&searchname=".$postrow[$i]['username']);

(end possibly already done)

 ------[FIND]------
u.user_items,

 ------[ADD, After]------
 u.user_privs, u.user_effects,

 ------[FIND]------
	//start of display-items

 ------[REPLACE ALL BETWEEN]------
	//start of display-items
 ------[AND]------
	//
	// Note! The order used for parsing the message _is_ important, moving things around could break any 
	// output
	//

 ------[WITH]------
	$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]\">";
				}
			}
		}
	}
	$ususername = $postrow[$i]['username'];
	$usernameurl = append_sid("shop.".$phpEx."?action=inventory&searchname=".$ususername);

	$usql = "select user_privs, user_effects from " . USERS_TABLE . " where username='$ususername'";
	if ( !($uresult = $db->sql_query($usql)) ) { message_die(GENERAL_MESSAGE, 'Fatal Error Getting User Info!'); }
	$urow = mysql_fetch_array($uresult);
	$usereffects = explode("", $urow['user_effects']);
	$userprivs = explode("", $urow['user_privs']);
	$userbs = array();
	$usercount = count($userprivs);
	for ($x = 0; $x < $usercount; $x++) { $temppriv = explode("", $userprivs[$x]); $userbs[] = $temppriv[0]; $userbs[] = $temppriv[1]; }
	$usercount = count($usereffects);
	for ($x = 0; $x < $usercount; $x++) { $temppriv = explode("", $usereffects[$x]); $userbs[] = $temppriv[0]; $userbs[] = $temppriv[1]; }
	$sql = "select config_value from " . CONFIG_TABLE . " where config_name='specialshop'";
	if ( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_MESSAGE, 'Fatal Error Getting Item Info!'); }
	$row = mysql_fetch_array($result);
	$shoparray = explode("", $row['config_value']);
	$shoparraycount = count ($shoparray);
	$shopstatarray = array();
	for ($x = 0; $x < $shoparraycount; $x++)
	{
		$temparray = explode("", $shoparray[$x]);
		$shopstatarray[] = $temparray[0];
		$shopstatarray[] = $temparray[1];
	}
	if (($userbs[10] == on) && ($shopstatarray[12] == on)) { $poster = "<font color=\"".$userbs[11]."\">".$poster."</font>"; }
	if ((($userbs[12] == on) && ($shopstatarray[14] == on)) || (($userbs[14] == on) && ($shopstataray[16] = on))) {
		$nameeffects = "<span style=\"width:100";
		if (($userbs[12] == on) && ($shopstatarray[14] == on)) { $nameeffects .= "; filter:shadow(color=#".$userbs[13].", strength=5)"; }
		if (($userbs[14] == on) && ($shopstatarray[16] == on)) { $nameeffects .= "; filter:glow(color=#".$userbs[15].", strength=5)"; }
		$nameeffects .= "\">".$poster."</span>";
		$poster = $nameeffects;
	}
	if (($shopstatarray[6] == on) && ($userbs[2] != on) && ($poster_rank != "Site Admin")) { $poster_avatar = ""; }
	if (($shopstatarray[8] == on) && ($userbs[4] != on) && ($poster_rank != "Site Admin")) { $user_sig = ""; }
	if (($shopstatarray[10] == on) && ($userbs[6] != on) && ($poster_rank != "Site Admin")) { $poster_rank = "None"; $rank_image = ""; }

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

 ------[FIND]------
          <a href="{postrow.ITEMSNAME}" >Items</a>

 ------[REPLACE WITH]------
          <a href="{postrow.ITEMSNAME}" class=\"nav\">Items</a>

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

 ------[FIND]------
//
// Generate page
//

 ------[ADD, BEFORE]------
//start of profile-items
$gsql = "select * from " . CONFIG_TABLE . " where config_name='viewprofile'";
if ( !($gresult = $db->sql_query($gsql)) )
{
	message_die(CRITICAL_ERROR, 'ERROR: Getting Global Variables!');
}
$grow = mysql_fetch_array($gresult);
if ($grow['config_value'] == images)
{
	$usql = "select * from " . USERS_TABLE . " where username='$profiledata[username]'";
	if ( !($uresult = $db->sql_query($usql)) )
	{
		message_die(CRITICAL_ERROR, 'ERROR: Getting Global Variables!');
	}
	$urow = mysql_fetch_array($uresult);
	$itempurge = str_replace("", "", $urow['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 = "<a href=\"".append_sid("shop.".$phpEx."?action=inventory&searchname=".$profiledata['username'])."\" class=\"nav\">Items</a>: ";
}
if ($grow['config_value'] == link)
{
	$usernameurl = "<a href=\"".append_sid("shop.".$phpEx."?action=inventory&searchname=".$profiledata['username'])."\" class=\"nav\">Items</a>";
}


 ------[FIND]------
	'POSTER_RANK' => $poster_rank,
	'RANK_IMAGE' => $rank_image,

 ------[ADD, AFTER]------
	'INVENTORYLINK' => $usernameurl,
	'INVENTORYPICS' => $user_items,


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

 ------[FIND]------
		<tr>
		  <td valign="top" align="right" nowrap="nowrap"><span class="gen">{L_POINTS}:</span></td>
		  <td><b><span class="gen">{POINTS}</span></b><span class="genmed">{DONATE_POINTS}</span></td>
		</tr>
 ------[OR WITHOUT POINTS MOD]------
		<tr> 
		  <td valign="top" align="right" nowrap="nowrap"><span class="gen">{L_INTERESTS}:</span></td>
		  <td> <b><span class="gen">{INTERESTS}</span></b></td>
		</tr>

 ------[ADD, AFTER]------
		<tr> 
		  <td valign="top" align="right" nowrap="nowrap"><span class="gen">{INVENTORYLINK}</span></td>
		  <td> <span class="gen">{INVENTORYPICS}</span></td>
		</tr>

 ------[SAVE, CLOSE, UPLOAD]------


