query('SELECT `id`, `level`, `login` FROM `users` WHERE `login` = "?s"', $_SESSION['receiverName'])->fetch_assoc();
if (!$receiver['id']) {
err('Персонажа не существует!');
unset($_SESSION['receiverName']);
} elseif ($receiver['level'] < 4) {
err('Персонажей ниже 4-го уровня не обслуживаем!');
unset($_SESSION['receiverName']);
} else {
$receiverId = $receiver['id'];
$submit = filter_input(INPUT_POST, 'action');
$sendItemId = filter_input(INPUT_POST, 'item_id');
$telegraphText = filter_input(INPUT_POST, 'message');
if ($submit == 'sendMessage' && $telegraphText && $user['money'] >= 1) {
if ($telegraphText) {
db::c()->query('UPDATE `users` SET `money` = `money` - 1 WHERE id=?i', $user['id']);
db::c()->query('INSERT INTO `telegraph` (`receiver`,`text`) VALUES (?i,"?s")', $receiverId, $telegraphText);
$statusMessage = 'Сообщение отправлено.';
} else $statusMessage = 'Сообщение было оставлено пустым!';
}
if ($submit == 'sendItem' && $sendItemId && $user['money'] >= 1) {
$res = db::c()->query('SELECT `id`,`name` FROM `inventory` WHERE `owner` = ?i AND `id` = ?i AND `dressed` = 0 AND `setsale` = 0 AND `present` = "?s" AND `artefact` = 0', $_SESSION['uid'], $sendItemId, null)->fetch_assoc();
if (!$res['id']) {
$statusMessage = "Предмет не найден в рюкзаке.";
} else {
db::c()->query('UPDATE `users` SET `money` = `money` - 1 WHERE id=?i', $user['id']);
db::c()->query('UPDATE `inventory` SET `owner` = ?i WHERE `id`= ?i AND `owner`= ?i', $receiverId, $sendItemId, $_SESSION['uid']);
//TODO: Добавить логи и статистику.
$statusMessage = 'Предмет "' . $res['name'] . '" передан персонажу ' . $receiverId;
db::c()->query('INSERT INTO `telegraph` (`receiver`,`text`) VALUES (?i,"?s")', $receiverId, 'Почтовый перевод: ' . $res['name'] . ' от персонажа ' . $user['login'] . '.');
}
}
$queryItems = db::c()->query('SELECT `inventory`.*,
`magic`.`name` AS `magic_name`,
`magic`.`chanse` AS `magic_chanse`,
`magic`.`time` AS `magic_time`,
`magic`.`file` AS `magic_file`,
`magic`.`targeted` AS `magic_targeted`,
`magic`.`needcharge` AS `magic_needcharge`,
`magic`.`img` AS `magic_img` FROM `inventory` LEFT JOIN `magic` ON `magic` = `magic`.`id` WHERE `owner` = ?i AND `dressed` = 0 AND `setsale` = 0 AND `present` = "?s" AND `artefact` = 0 ORDER BY `update` DESC', $_SESSION['uid'], null);
$iteminfo = [];
while ($row = $queryItems->fetch_assoc()) {
$iteminfo[] = new InventoryItem($row);
}
}
}
?>
Почта
Получатель: = Nick::id($receiverId)->full() ?>
Сменить
|
Передача предметов |
printImage(); ?>
|
printInfo(); ?>
|
getNumRows())): ?>
Нечего передавать... |
|