escape(trim($_POST['item_name'])); $item_description = $db->escape(trim($_POST['item_description'])); $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'])); if (strlen($item_name) == 0) message('Items need names, you know.'); if (strlen($item_description) == 0) message('Items need some info or you don\'t know what it is.'); 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.'); $db->query('INSERT INTO '.$db->prefix.'items (item_name, description, item_cost, item_quantity, item_rarity, item_image) VALUES ("'.$item_name.'", "'.$item_description.'", '.$item_price.', '.$item_quantity.', '.$item_rarity.', "'.$item_image.'")') 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_description = intval($item_info['item_description']); $item_quantity = intval($item_info['item_quantity']); $item_rarity = intval($item_info['item_rarity']); $item_image = trim($item_info['item_image']); if ($item_description < 0) message('You should add info so everyone knows what it is.'); 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.'); $db->query('UPDATE '.$db->prefix.'items SET item_description="'.$item_description.'", item_cost='.$item_price.', item_quantity='.$item_quantity.', item_rarity='.$item_rarity.' 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); ?>