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; if (empty($_POST['text'])) $_POST['text'] = null; $receiver = db::c()->query('SELECT `id` FROM `users` WHERE `login` = ?i', $_POST['receiver'])->fetch_assoc(); if (empty($receiver)) { $status = "Получатель {$receiver} не найден в базе!"; return; } if ($_POST['from'] == 1) $from = null; elseif ($_POST['from'] == 2 && $user['ClanName']) $from = ' клана ' . $user['ClanName']; else $from = $user['login']; db::c()->query('INSERT INTO users_presents (owner, img, text, sender) VALUES (?i,"?s","?s","?s")', $receiver['id'], $_POST['present'], $_POST['text'], $_POST['from']); $deloText = "{$user['login']} купил подарок за %PodarokCost% кр. и подарил его персонажу {$_POST['receiver']}"; addToDelo($deloText); $telegraphText = "Вам пришёл подарок от {$from}!"; db::c()->query('INSERT INTO `telegraph` (receiver, text) VALUES (?i,"?s")', $receiver['id'], $telegraphText)->fetch_assoc(); $status = "Подарок удачно доставлен к {$_POST['receiver']}!"; } else $status = "Не выбран тип подарка!"; ?>