query('SELECT `login`, `name` AS `ClanName`, u.`money` FROM `users` u LEFT JOIN `clans` c ON c.`id` = `klan` WHERE u.`id` = ?i', $_SESSION['uid'])->fetch_assoc(); $dirname = "i/presents/"; $images = glob($dirname . "*.png"); if (!empty($_POST['present'])) { if (empty($_POST['receiver'])) { $status = 'Получатель не указан!'; return; } if (empty($_POST['days']) OR $_POST['days'] < 1 OR !is_numeric($_POST['days'])) $_POST['days'] = 1; $to = db::c()->query('SELECT `id` FROM `users` WHERE `login` = ?i', $_POST['receiver'])->fetch_assoc(); if ($_POST['from'] == 1) $from = 'Аноним'; elseif ($_POST['from'] == 2 && $user['ClanName']) $from = ' клана ' . $user['ClanName']; else $from = $user['login']; db::c()->query('UPDATE `inventory` SET `owner` = ?i, `present` = "?s", `letter` = "?s" WHERE `present` = "?s" AND `id` = "?s" AND `owner` = ?i AND `dressed` = 0 AND `setsale` = 0', $to['id'], $from, $_POST['text'], null, $_POST['flower'], $_SESSION['uid']); $res = db::c()->query('SELECT `id`,`name`,`duration`,`maxdur` FROM `inventory` WHERE `id` = ?i', $_POST['flower'])->fetch_assoc(); $deloText = "{$user['login']} купил подарок «%PodarokName%» за %PodarokCost% кр. и подарил его персонажу {$_POST['receiver']}"; addToDelo($deloText); $telegraphText = "Вам пришёл подарок \"" . $res['name'] . "\" от " . $from . "!"; db::c()->query('INSERT INTO `telegraph` (receiver, text) VALUES (?i,"?s")', $to['id'], $telegraphText)->fetch_assoc(); err('Подарок удачно доставлен к ' . $_POST['receiver']); } else $status = 'Не выбран тип подарка!'; ?>