<?php
include_once ('./core/base.php');
falseauth();

$id=fl($_GET['id']);

$item = $base -> query('SELECT * FROM `users_items` WHERE `id` = "'.$id.'" AND `user` = "'.$u['id'].'" LIMIT 1') -> fetch_assoc();

$header = ''.$item['name'].'';

include_once ('./core/head.php');

if($item != 0) {

	$base -> query('INSERT INTO `locations_items` SET
	`world` = "'.$u['world'].'",
	`x` = "'.$u['x'].'",
	`y` = "'.$u['y'].'",
	`name` = "'.$item['name'].'",
	`description` = "'.$item['description'].'",
	`image` = "'.$item['image'].'",
	`level` = "'.$item['level'].'",
	`what` = "'.$item['what'].'",
	`potion` = "'.$item['potion'].'",
	`hp_regen` = "'.$item['hp_regen'].'",
	`mp_regen` = "'.$item['mp_regen'].'",
	`type` = "'.$item['type'].'",
	`attack_type` = "'.$item['attack_type'].'",
	`p_att` = "'.$item['p_att'].'",
	`m_att` = "'.$item['m_att'].'",
	`p_def` = "'.$item['p_def'].'",
	`m_def` = "'.$item['m_def'].'",
	`endurance` = "'.$item['endurance'].'",
	`intellect` = "'.$item['intellect'].'",
	`agility` = "'.$item['agility'].'",
	`skill` = "'.$item['skill'].'",
	`quality` = "'.$item['quality'].'",
	`max_quality` = "'.$item['max_quality'].'",
	`set` = "'.$item['set'].'",
	`mark` = "'.$item['mark'].'",
	`smith` = "'.$item['smith'].'",
	`rune_type` = "'.$item['rune_type'].'",
	`rune` = "'.$item['rune'].'",
	`amount` = "'.$item['amount'].'",
	`cost` = "'.$item['cost'].'",
	`ident_id` = "'.$item['ident_id'].'"');
	if($item['potion']){
		if($item['id'] == $u['belt_slot_1']) $slot = 1;
		if($item['id'] == $u['belt_slot_2']) $slot = 2;
		if($item['id'] == $u['belt_slot_3']) $slot = 3;
		$base -> query('UPDATE `users` SET `belt_slot_'.$slot.'` = "0" WHERE `id` = "'.$u['id'].'" LIMIT 1');
	}
	$base -> query('DELETE FROM `users_items` WHERE `id` = "'.$item['id'].'" LIMIT 1');
	$_SESSION['message'] = 'Предмет '.$item['name'].' выброшен на локацию.';
	if($item['what'] == 'clothing') header('Location: /inventory/'.$item['type'].'/');
	else header('Location: /inventory/res/'.$item['what'].'/');
	exit;

}else{
	header('Location: /inventory/');
}


include_once ('./core/foot.php');
?>