escape(trim($_POST['item_name'])); $item_price = intval($_POST['item_price']); $item_quantity = intval($_POST['item_quantity']); $item_rarity = intval($_POST['item_rarity']); $item_image = $db->escape(trim($_POST['item_image'])); $item_cat = intval($_POST['item_cat']); if (strlen($item_name) == 0) message('Items need names, you know.'); if ($item_price < 0) message('You can\'t sell an item for less than 0 '.$pun_config['cm_cur_name'].'.'); if ($item_quantity < 0) message('You can\'t have a negative number of an item in the shop.'); if ($item_rarity < 0) message('An item may not have a negative rarity.'); if (strlen($item_image) == 0) message('An image might be handy.'); if ($item_cat < 0) message('An item must have a category.'); $db->query('INSERT INTO '.$db->prefix.'items (item_name, item_cost, item_quantity, item_rarity, item_image, item_cat) VALUES ("'.$item_name.'", '.$item_price.', '.$item_quantity.', '.$item_rarity.', "'.$item_image.'", '.$item_cat.')') or error('Unable to add new item', __FILE__, __LINE__, $db->error()); redirect($_SERVER['REQUEST_URI'], 'Item added. Redirecting …'); } else if (isset($_POST['update_items'])) { while (list($item_id, $item_info) = @each($_POST['item'])) { $item_price = intval($item_info['item_price']); $item_quantity = intval($item_info['item_quantity']); $item_rarity = intval($item_info['item_rarity']); $item_cat = intval($item_info['item_cat']); if ($item_price < 0) message('You can\'t sell an item for less than 0 '.$pun_config['cm_cur_name'].'.'); if ($item_quantity < 0) message('You can\'t have a negative number of an item in the shop.'); if ($item_rarity < 0) message('An item may not have a negative rarity.'); if ($item_cat < 0) message('An item must have a category.'); $db->query('UPDATE '.$db->prefix.'items SET item_cost='.$item_price.', item_quantity='.$item_quantity.', item_rarity='.$item_rarity.', item_cat='.$item_cat.' WHERE item_id='.intval($item_id)) or error('Unable to update item', __FILE__, __LINE__, $db->error()); } redirect($_SERVER['REQUEST_URI'], 'Items updated. Redirecting …'); } else { // Display the admin navigation menu generate_admin_menu($plugin); ?>

Add item

Create a new item
Item Image The image for this item.
Item Name The name for the new item you are creating.
Item Price The price for the new item you are creating.
Item Quantity The quantity of the new item you are creating.
Item Rarity The rarity of new item you are creating.
Item Category The item category. 1 = Food, 2 = Drink, 3 = Misc

query('SELECT '.$db->prefix.'items.* FROM '.$db->prefix.'items ORDER BY item_name') or error('Unable to fetch item list', __FILE__, __LINE__, $db->error()); if ($db->num_rows($result) > 0) { ?>

Edit items

Item List:
fetch_assoc($result)) { ?>
Price     Quantity     Rarity     Category     Image  

Upload Image

$file_array) { if (is_uploaded_file($file_array['tmp_name'])) { move_uploaded_file($file_array['tmp_name'], $file_dir.'/'.$file_array['name']) or die("Couldn't copy."); } } ?>
Image Upload

File to upload: