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); ?>