<?php
	
	function put_item($user_id, $shop_id, $place = 0, $quality = 0, $bonus = 0, $up = 0, $rune = 0)
	{
		
		$place	=	max(0, min(1, $place));
		$quality	=	max(0, min(6, $quality));
		
		switch	($quality)
		{
			
			default:	case	0:	$bonus	=	min(0, $bonus);	break;
			case	1:	$bonus	=	min(5, $bonus);	break;
			case	2:	$bonus	=	min(10, $bonus);	break;
			case	3:	$bonus	=	min(15, $bonus);	break;
			case	4:	$bonus	=	min(20, $bonus);	break;
			case	5:	$bonus	=	min(50, $bonus);	break;
			case	6:	$bonus	=	min(65, $bonus);	break;

		}
		
		$up	=	max(0, min(20, $up));
		$rune	=	max(0, min(5, $rune));
		
		@mysql_query(sprintf(
			'INSERT INTO
					`inv`
					(
						`user_id`,
						`place`,
						`shop_id`,
						`quality`,
						`bonus`,
						`up`,
						`rune`
					)
					VALUES
					(
						%d,
						%d,
						%d,
						%d,
						%d,
						%d,
						%d
					)',
			$user_id,
			$place,
			$shop_id,
			$quality,
			$bonus,
			$up,
			$rune
		));
		
	}
	
?>