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'].' and inv.item_id='.$iid) or error('Unable to fetch item list', __FILE__, __LINE__, $db->error()); if ($db->num_rows($result) == 0) message($lang_common['Bad request']); $cur_item = $db->fetch_assoc($result); if (isset($_POST['throw'])) { $db->query('UPDATE '.$db->prefix.'inventory SET quantity=quantity-1 WHERE item_id='.$iid.' and user_id='.$pun_user['id']) 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='.$iid.' 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 item.'); } else if (isset($_POST['throwall'])) { $db->query('DELETE FROM '.$db->prefix.'inventory WHERE item_id='.$iid.' 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 item.'); } else if (isset($_POST['giveto'])) { $result = $db->query('SELECT id, username FROM '.$db->prefix.'users WHERE username=\''.$db->escape($_POST['username']).'\'') or error('Unable to find user.', __FILE__, __LINE__, $db->error()); if ($db->num_rows($result) == 0) message('This user does not exist.'); $user = $db->fetch_assoc($result); $db->query('INSERT INTO '.$db->prefix.'inventory (item_id, user_id, quantity) VALUES ('.$iid.', '.$user['id'].', 1) ON DUPLICATE KEY UPDATE quantity = quantity + VALUES(quantity)') or error('Unable to add items to inventory', __FILE__, __LINE__, $db->error()); $db->query('UPDATE '.$db->prefix.'inventory SET quantity=quantity-1 WHERE item_id='.$iid.' and user_id='.$pun_user['id']) or error('Unable to remove item from user', __FILE__, __LINE__, $db->error()); if ($cur_item['quantity'] == 1) $db->query('DELETE FROM '.$db->prefix.'inventory WHERE item_id='.$iid.' and user_id='.$pun_user['id']) or error('Unable to delete from inventory', __FILE__, __LINE__, $db->error()); $message = 'I have given you a '.$cur_item['item_name'].' because I am so kind and thought you deserve it for all your hard work.'; $db->query('INSERT INTO '.$db->prefix.'messages (owner, subject, message, sender, sender_id, sender_ip, smileys, showed, status, posted) VALUES( \''.$user['id'].'\', \''.$db->escape($cur_item['item_name']).'\', \''.$db->escape($message).'\', \''.$db->escape($pun_user['username']).'\', \''.$pun_user['id'].'\', \''.get_remote_address().'\', \''.$smilies.'\', \'0\', \'0\', \''.time().'\' )') or error('Unable to send message', __FILE__, __LINE__, $db->error()); redirect($_SERVER['REQUEST_URI'], 'You have given your item to '.$user['username']); } } $page_title = pun_htmlspecialchars($pun_config['o_board_title'].' - Inventory'); define('PUN_ALLOW_INDEX', 1); require PUN_ROOT.'header.php'; ?>
| Image | Item Name | Rarity | Quantity Owned | Actions |
|---|---|---|---|---|