<?php
	
	include_once __DIR__ . '/include/common.php';
	include_once __DIR__ . '/include/general_functions.php';
	include_once __DIR__ . '/include/utils.php';	
	include_once __DIR__ . '/include/user.php';
	
	$dst_image	=	imagecreatetruecolor(50, 50);
	imagesavealpha($dst_image, true);
	imagefill($dst_image, 0, 0, imagecolorallocatealpha($dst_image, 0, 0, 0, 127));
	
	
	$image	=	imagecreatefrompng(__DIR__ . sprintf(
		'/images/items/%d.png',
		@$_GET['index']
	));
	
	imagecopy($dst_image, $image, 0, 0, 0, 0, 50, 50);
	
	$up		=	min(20, max(0, (int) @$_GET['up']));
	if ($up != 0)
	{
		
		switch($up)
		{
			
			case	2:
			case	3:
			
			imagecopy($dst_image, imagecreatefrompng(__DIR__ . '/images/items/borders/1.png'), 0, 0, 0, 0, 50, 50);
			
			break;
			
			case	4:
			case	5:
			imagecopy($dst_image, imagecreatefrompng(__DIR__ . '/images/items/borders/2.png'), 0, 0, 0, 0, 50, 50);
			
			break;
			
			case	6:
			case	7:
			imagecopy($dst_image, imagecreatefrompng(__DIR__ . '/images/items/borders/4.png'), 0, 0, 0, 0, 50, 50);
			
			break;
			
			case	8:
			case	9:
			
			imagecopy($dst_image, imagecreatefrompng(__DIR__ . '/images/items/borders/5.png'), 0, 0, 0, 0, 50, 50);
			
			break;
			
			case	10:
			case	11:
			
			imagecopy($dst_image, imagecreatefrompng(__DIR__ . '/images/items/borders/3.png'), 0, 0, 0, 0, 50, 50);
			
			break;

			
			case	12:
			case	13:
			case	14:
			case	15:
			case	16:
			case	17:
			case	18:
			case	19:
			
			imagecopy($dst_image, imagecreatefrompng(__DIR__ . '/images/items/borders/6.png'), 0, 0, 0, 0, 50, 50);
			
			break;
			
			case	20:
			
			imagecopy($dst_image, imagecreatefrompng(__DIR__ . '/images/items/borders/7.png'), 0, 0, 0, 0, 50, 50);
			
			break;
			
		}
		
	}
	
	setContentType('image/png');
	imagepng($dst_image);