room != 27) {
header("Location: main.php");
exit;
}
if ($user->battle) {
header('location: fbattle.php');
exit;
}
if ($_GET['change'] ?? 0) {
unset($_SESSION['receiverName']);
}
$_SESSION['receiverName'] = $_POST['receiverName'] ?? '';
$receiverId = null;
$queryItems = null;
$statusMessage = null;
if ($_SESSION['receiverName']) {
$receiver = db::c()->query('SELECT `id`, `level`, `login` FROM `users` WHERE `login` = "?s"', $_SESSION['receiverName'])->fetch_assoc();
if (!$receiver['id']) {
$statusMessage = 'Персонажа не существует!';
unset($_SESSION['receiverName']);
} else {
$receiverId = $receiver['id'];
$submit = $_POST['action'] ?? 0;
$sendItemId = $_POST['item_id'] ?? 0;
$telegraphText = $_POST['message'] ?? 0;
if ($submit == 'sendMessage' && $telegraphText && $user->money) {
if ($telegraphText) {
$user->money -= 1;
Bank::setWalletMoney($user->money, $user->id);
db::c()->query('INSERT INTO `telegraph` (`receiver`,`text`) VALUES (?i,"?s")', $receiverId, $telegraphText);
$statusMessage = 'Сообщение отправлено.';
} else {
$statusMessage = 'Сообщение было оставлено пустым!';
}
}
if ($submit == 'sendItem' && $sendItemId && $user->money) {
$res = db::c()->query('SELECT name FROM inventory WHERE owner_id = ?i AND item_id = ?i AND dressed_slot = 0 AND on_sale = 0', $user->id, $sendItemId)->fetch_assoc();
if (!$res) {
$statusMessage = "Предмет не найден в рюкзаке.";
} else {
$user->money -= 1;
Bank::setWalletMoney($user->money, $user->id);
db::c()->query('UPDATE `inventory` SET owner_id = ?i WHERE item_id= ?i AND owner_id = ?i', $receiverId, $sendItemId, $_SESSION['uid']);
//TODO: #9
$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 * FROM inventory WHERE dressed_slot = 0 AND on_sale = 0 AND owner_id = ?i', $user->id);
while ($row = $queryItems->fetch_assoc()) {
$iteminfo[] = new \Battles\InventoryItem($row);
}
}
}
\Battles\Template::header('Почта');
?>
Почта
= $statusMessage ?>
Получатель: = Nick::id($receiverId)->full() ?>
Сменить
|
Передача предметов |
printImage(); ?>
|
printInfo(); ?>
|
getNumRows())): ?>
Нечего передавать... |
|