rendered paste body<?php
define('PUN_ROOT', './');
require PUN_ROOT.'include/common.php';
require PUN_ROOT.'lang/'.$pun_user['language'].'/cash.php';
if ($pun_user['is_guest'])
message($lang_common['No view']);
$page_title = pun_htmlspecialchars($pun_config['o_board_title'].' - Inventory');
define('PUN_ALLOW_INDEX', 1);
require PUN_ROOT.'header.php';
$result = $db->query('SELECT inv.item_id, inv.quantity, inv.user_id, it.item_name, it.item_rarity, it.item_image FROM '.$db->prefix.'inventory AS inv INNER JOIN '.$db->prefix.'items AS it ON (it.item_id=inv.item_id) ORDER BY item_name') or error('Unable to fetch item list', __FILE__, __LINE__, $db->error());
while ($cur_item = $db->fetch_assoc($result))
if (isset($_POST['throw']))
{
$db->query('UPDATE '.$db->prefix.'inventory SET quantity=quantity-1 WHERE item_id='.$cur_item['item_id'].' AND user_id='.$pun_user['id'].' LIMIT 1') or error('Unable to throw away', __FILE__, __LINE__, $db->error());
}
if ($cur_item['quantity'] == '1')
$db->query('DELETE FROM '.$db->prefix.'inventory WHERE item_id='.$cur_item['item_id'].' AND user_id='.$pun_user['id']) or error('Unable to throw away item.', __FILE__, __LINE__, $db->error());
redirect($_SERVER['REQUEST_URI'], 'You have thrown away your '.$cur_item['item_name']);
}
?>
<div class="blocktable">
<h2><span>Your inventory</span></h2>
<div class="box">
<div class="inbox">
<table cellspacing="0">
<thead>
<tr>
<th class="tc3" scope="col">Image</th>
<th class="tcl" scope="col">Item Name</th>
<th class="tc2" scope="col">Rarity</th>
<th class="tc3" scope="col">Quantity Owned</th>
<th class="tcr" scope="col">Actions</th>
</tr>
</thead>
<tbody>
<?php
// Display all the categories and forums
$result = $db->query('SELECT inv.item_id, inv.quantity, it.item_name, it.item_rarity, it.item_image FROM '.$db->prefix.'inventory AS inv INNER JOIN '.$db->prefix.'items AS it ON (it.item_id=inv.item_id) WHERE user_id='.$pun_user['id'].' ORDER BY item_name') or error('Unable to fetch item list', __FILE__, __LINE__, $db->error());
while ($cur_item = $db->fetch_assoc($result))
{
?>
<tr>
<td class="tc3"><img src="img/items/<?php echo pun_htmlspecialchars($cur_item['item_image']) ?>" alt="<?php echo pun_htmlspecialchars($cur_item['item_name']) ?>" width="70px" height="70px" /></td>
<td class="tcl" style="text-align:center"><?php echo pun_htmlspecialchars($cur_item['item_name']) ?></td>
<td class="tc2"><?php echo $cur_item['item_rarity'] ?></td>
<td class="tc3"><?php echo $cur_item['quantity'] ?></td>
<td class="tcr"><form name="action" action="<?php echo $_SERVER['REQUEST_URI'] ?>" method="post">
<input type="submit" name="throw" value="Throw away" /><br />
<input type="submit" name="give" value="Give to" /> <input type="text" name="username" value="<?php echo $user['username']; ?>" />
</form></td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
</div>
</div>
<?php
require PUN_ROOT.'footer.php';