$itemWeight=db::c()->query('SELECT sum(`massa`) AS `m` FROM `inventory` WHERE `owner` = ?i AND `dressed` = 0 AND `setsale` = 0',$user['id'])->fetch_assoc();
$cur=mysql_fetch_assoc(mysql_query("SELECT `id`,`name`,`nlevel` FROM `inventory` WHERE `owner`='".$user['id']."' AND `id`='".$ids."' AND `artefact`='1'"));
if($cur['id']){
$up_level=$cur['nlevel']+1;
$cur_up=mysql_fetch_assoc(mysql_query("SELECT * FROM `ashop_up` WHERE `name`='".$cur['name']."' AND `level_up`='".$up_level."'"));
if($cur_up['id']){
mysql_query("UPDATE `inventory` SET `upgrade`='".$cur_up['level_up']."',`nlevel`='".$cur_up['level_up']."',`minu`='".$cur_up['minu']."',`maxu`='".$cur_up['maxu']."',`gsila`='".$cur_up['gsila']."',`glovk`='".$cur_up['glovk']."',`ginta`='".$cur_up['ginta']."',`gintel`='".$cur_up['gintel']."',`ghp`='".$cur_up['ghp']."',`mfkrit`='".$cur_up['mfkrit']."',`mfakrit`='".$cur_up['mfakrit']."',`mfuvorot`='".$cur_up['mfuvorot']."',`mfauvorot`='".$cur_up['mfauvorot']."',`gnoj`='".$cur_up['gnoj']."',`gtopor`='".$cur_up['gtopor']."',`gdubina`='".$cur_up['gdubina']."',`gmech`='".$cur_up['gmech']."',`bron1`='".$cur_up['bron1']."',`bron2`='".$cur_up['bron2']."',`bron3`='".$cur_up['bron3']."',`bron4`='".$cur_up['bron4']."' WHERE `owner`='".$user['id']."' AND `id`='".$cur['id']."'");
echo"<font color=green><b>Артефакт успешно улучшен!</b></font>";
$to=mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `login`='".$_POST['to_login']."' LIMIT 1;"));
if($_POST['to_login']==$user['login']){
echo"<b><font color=red>Очень щедро дарить что-то самому себе ;)</font></b>";
}elseif($to['room']>500&&$to['room']<561){
echo"<b><font color=red>Персонаж в данный момент участвует в турнире в Башне Смерти. Попробуйте позже.</font></b>";
}else{
if($_POST['from']==1){
$from='Аноним';
}elseif($_POST['from']==2&&$user['klan']){
$from=' клана '.$user['klan'];
}else{
$from=$user['login'];
}
if($to)if(mysql_query("UPDATE `inventory` SET `owner`='".$to['id']."', `present`='".$from."', `letter`='".$_POST['podarok2']."' WHERE `present`='' AND `id`='".$_POST['flower']."' AND `owner`='".$_SESSION['uid']."' AND `dressed`=0 AND `setsale`=0;")){
$res=mysql_fetch_array(mysql_query("SELECT * FROM `inventory` WHERE `id` = '".$_POST['flower']."' LIMIT 1;"));
$buket_name=$res['name'];
mysql_query("INSERT INTO `delo`(`id`,`author`,`pers`,`text`,`type`,`date`) VALUES ('','0','".$_SESSION['uid']."','Подарен предмет \"".$res['name']."\" id:(cap".$res['id'].") [".$res['duration']."/".$res['maxdur']."] от \"".$from."\" к \"".$to['login']."\"','1','".time()."');");
mysql_query("INSERT INTO `delo`(`id`,`author`,`pers`,`text`,`type`,`date`) VALUES ('','0','{$to['id']}','Подарен предмет \"".$res['name']."\" id:(cap".$res['id'].") [".$res['duration']."/".$res['maxdur']."] от \"".$from."\" к \"".$to['login']."\"','1','".time()."');");
if(($_POST['from']==1)||($_POST['from']==2)){
$action="подарил";
mysql_query("INSERT INTO `delo`(`id`,`author`,`pers`,`text`,`type`,`date`) VALUES ('','0','".$to['id']."','Подарен предмет \"".$res['name']."\" id:(cap".$res['id'].") [".$res['duration']."/".$res['maxdur']."] от \"".$user['login']."\" к \"".$to['login']."\"','5','".time()."');");
}else{
if($user['sex']==0){
$action="подарила";
}else{
$action="подарил";
}
}
$us=mysql_fetch_array(mysql_query("SELECT `id` FROM `online` WHERE `date`>=".(time()-60)." AND `id` = '".$to['id']."' LIMIT 1;"));
$data=mysql_query("SELECT * FROM `inventory` WHERE `owner`='".$_SESSION['uid']."' AND `dressed`=0 AND (`name` LIKE '%Букет%' OR `name` LIKE '%Сувенир%' OR `name` LIKE '%Подарок%' OR `name` LIKE '%Валентинка%' OR `name` LIKE '%Открытка%' OR `name` LIKE 'Ель%' OR `name` LIKE '%Медаль%' OR `name` LIKE '%Статуэтка%') AND `setsale`=0 AND `present` = '' ORDER BY `id` DESC;");