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` = '".mysql_real_escape_string($_POST['podarok2'])."' WHERE `present` = '' AND `id` = '".mysql_real_escape_string($_POST['flower'])."' AND `owner` = '".mysql_real_escape_string($_SESSION['uid'])."' AND `dressed` = 0 AND `setsale`=0")) {
$res = mysql_fetch_array(mysql_query("SELECT * FROM `inventory` WHERE `id` = '".mysql_real_escape_string($_POST['flower'])."' LIMIT 1; "));
$buket_name=$res['name'];
mysql_query("INSERT INTO `delo`(`id` , `author` ,`pers`, `text`, `type`, `date`) VALUES ('','0','".mysql_real_escape_string($_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','".mysql_real_escape_string($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','".mysql_real_escape_string($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;"));
if($us[0]){
addchp ('<font color=red>Внимание!</font> '.$from.' '.$action.' вам [b]'.$buket_name.'[/b]. ','{[]}'.$_POST['to_login'].'{[]}');
} else {
// если в офе
mysql_query("INSERT INTO `telegraph` (`owner`,`date`,`text`) values ('".mysql_real_escape_string($to['id'])."','','".'<font color=red>Внимание!</font> '.$from.' '.$action.' вам [b]'.$buket_name.'[/b]. '."');");
}
echo "[b]<font color=red>Подарок удачно доставлен к \"",$_POST['to_login'],"\"</font>[/b]";
}
echo mysql_error();
}