Поправил кнопку выхода и, внезапно, полфайла.
This commit is contained in:
parent
f8234dd407
commit
f668e9c122
38
post.php
38
post.php
@ -15,22 +15,18 @@ if ($user->battle) {
|
|||||||
header('location: fbattle.php');
|
header('location: fbattle.php');
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
$changeReceiver = $_GET['change'] ?? 0;
|
if ($_GET['change'] ?? 0) {
|
||||||
if ($changeReceiver) {
|
|
||||||
unset($_SESSION['receiverName']);
|
unset($_SESSION['receiverName']);
|
||||||
}
|
}
|
||||||
$razdelId = $_GET['razdel'] ?? 0;
|
|
||||||
$_SESSION['receiverName'] = $_POST['receiverName'] ?? '';
|
$_SESSION['receiverName'] = $_POST['receiverName'] ?? '';
|
||||||
$receiverId = null;
|
$receiverId = null;
|
||||||
$queryItems = null;
|
$queryItems = null;
|
||||||
|
$statusMessage = null;
|
||||||
|
|
||||||
if ($_SESSION['receiverName']) {
|
if ($_SESSION['receiverName']) {
|
||||||
$receiver = db::c()->query('SELECT `id`, `level`, `login` FROM `users` WHERE `login` = "?s"', $_SESSION['receiverName'])->fetch_assoc();
|
$receiver = db::c()->query('SELECT `id`, `level`, `login` FROM `users` WHERE `login` = "?s"', $_SESSION['receiverName'])->fetch_assoc();
|
||||||
if (!$receiver['id']) {
|
if (!$receiver['id']) {
|
||||||
err('Персонажа не существует!');
|
$statusMessage = 'Персонажа не существует!';
|
||||||
unset($_SESSION['receiverName']);
|
|
||||||
} elseif ($receiver['level'] < 4) {
|
|
||||||
err('Персонажей ниже 4-го уровня не обслуживаем!');
|
|
||||||
unset($_SESSION['receiverName']);
|
unset($_SESSION['receiverName']);
|
||||||
} else {
|
} else {
|
||||||
$receiverId = $receiver['id'];
|
$receiverId = $receiver['id'];
|
||||||
@ -51,27 +47,20 @@ if ($_SESSION['receiverName']) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($submit == 'sendItem' && $sendItemId && $user->money) {
|
if ($submit == 'sendItem' && $sendItemId && $user->money) {
|
||||||
$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();
|
$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['id']) {
|
if (!$res) {
|
||||||
$statusMessage = "Предмет не найден в рюкзаке.";
|
$statusMessage = "Предмет не найден в рюкзаке.";
|
||||||
} else {
|
} else {
|
||||||
$user->money -= 1;
|
$user->money -= 1;
|
||||||
Bank::setWalletMoney($user->money, $user->id);
|
Bank::setWalletMoney($user->money, $user->id);
|
||||||
db::c()->query('UPDATE `inventory` SET `owner` = ?i WHERE `id`= ?i AND `owner`= ?i', $receiverId, $sendItemId, $_SESSION['uid']);
|
db::c()->query('UPDATE `inventory` SET owner_id = ?i WHERE item_id= ?i AND owner_id = ?i', $receiverId, $sendItemId, $_SESSION['uid']);
|
||||||
//TODO: Добавить логи и статистику.
|
//TODO: #9
|
||||||
$statusMessage = 'Предмет "' . $res['name'] . '" передан персонажу ' . $receiverId;
|
$statusMessage = 'Предмет "' . $res['name'] . '" передан персонажу ' . $receiverId;
|
||||||
db::c()->query('INSERT INTO `telegraph` (`receiver`,`text`) VALUES (?i,"?s")', $receiverId, 'Почтовый перевод: ' . $res['name'] . ' от персонажа ' . $user['login'] . '.');
|
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`,
|
$queryItems = db::c()->query('SELECT * FROM inventory WHERE dressed_slot = 0 AND on_sale = 0 AND owner_id = ?i', $user->id);
|
||||||
`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()) {
|
while ($row = $queryItems->fetch_assoc()) {
|
||||||
$iteminfo[] = new InventoryItem($row);
|
$iteminfo[] = new InventoryItem($row);
|
||||||
}
|
}
|
||||||
@ -79,14 +68,13 @@ if ($_SESSION['receiverName']) {
|
|||||||
}
|
}
|
||||||
Template::header('Почта');
|
Template::header('Почта');
|
||||||
?>
|
?>
|
||||||
<script src="js/main.js"></script>
|
|
||||||
<div style="float: right">
|
<div style="float: right">
|
||||||
<button onclick="hrefToFrame('city.php?cp')">Вернуться</button>
|
<button onclick="top.frames['gameframe'].location = 'city.php?cp'">Вернуться</button>
|
||||||
</div>
|
</div>
|
||||||
<h1>Почта</h1>
|
<h1>Почта</h1>
|
||||||
<div style="text-align: center;"><?php if (isset($statusMessage)) err($statusMessage); ?></div>
|
<div style="text-align: center;"><span class="error"><?= $statusMessage ?></span></div>
|
||||||
<legend>Услуги почты платные: 1 кредит.</legend>
|
<legend>Услуги почты платные: 1 кредит.</legend>
|
||||||
<?php if ($_SESSION['receiverName']): ?>
|
<?php if ($_SESSION['receiverName'] ?? ''): ?>
|
||||||
Получатель: <?= Nick::id($receiverId)->full() ?>
|
Получатель: <?= Nick::id($receiverId)->full() ?>
|
||||||
<a href="?change">Сменить</a>
|
<a href="?change">Сменить</a>
|
||||||
<table width=100%>
|
<table width=100%>
|
||||||
@ -136,4 +124,4 @@ Template::header('Почта');
|
|||||||
<form method="post">
|
<form method="post">
|
||||||
<input name='receiverName' placeholder="Логин получателя"> <input type=submit value='Применить'>
|
<input name='receiverName' placeholder="Логин получателя"> <input type=submit value='Применить'>
|
||||||
</form>
|
</form>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
Loading…
Reference in New Issue
Block a user