2018-12-12 22:43:58 +00:00
|
|
|
|
<?php
|
|
|
|
|
/**
|
|
|
|
|
* Copyright (c) 2018.
|
|
|
|
|
* Author: Igor Barkov <lopar.4ever@gmail.com>
|
|
|
|
|
* Project name: Battles-Game
|
|
|
|
|
*/
|
|
|
|
|
|
2022-01-26 23:15:33 +00:00
|
|
|
|
use Battles\Database\Db;
|
2021-08-25 15:24:12 +00:00
|
|
|
|
use Battles\DressedItems;
|
|
|
|
|
use Battles\Template;
|
2022-01-26 23:15:33 +00:00
|
|
|
|
use Battles\User;
|
2021-08-25 15:24:12 +00:00
|
|
|
|
|
2018-12-12 22:43:58 +00:00
|
|
|
|
require_once "../functions.php";
|
2022-01-26 23:15:33 +00:00
|
|
|
|
if (!User::getInstance()->getAdmin()) {
|
2020-08-29 23:21:22 +00:00
|
|
|
|
header("HTTP/1.0 404 Not Found");
|
2018-12-12 22:43:58 +00:00
|
|
|
|
exit;
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-29 23:21:22 +00:00
|
|
|
|
$player = $_POST['player'] ?? null;
|
|
|
|
|
$undress_char = $_POST['undress_char'] ?? null;
|
|
|
|
|
$end = $_POST['end'] ?? null;
|
|
|
|
|
$del = $_POST['del'] ?? null;
|
2022-12-16 23:20:43 +00:00
|
|
|
|
$inv = [];
|
2018-12-12 22:43:58 +00:00
|
|
|
|
|
2020-08-29 23:21:22 +00:00
|
|
|
|
if ($player) {
|
2022-01-26 23:15:33 +00:00
|
|
|
|
$row = Db::getInstance()->ofetch('select id, login from users where id = ? or login = ?', [$player, $player]);
|
2021-08-25 15:24:12 +00:00
|
|
|
|
$_SESSION['player_id'] = $row->id;
|
|
|
|
|
$_SESSION['player_name'] = $row->login;
|
2020-08-29 23:21:22 +00:00
|
|
|
|
unset($row);
|
|
|
|
|
}
|
|
|
|
|
if ($undress_char) {
|
2021-08-25 15:24:12 +00:00
|
|
|
|
DressedItems::undressAllItems($_SESSION['player_id']);
|
2020-08-29 23:21:22 +00:00
|
|
|
|
}
|
|
|
|
|
if ($end) {
|
2018-12-12 22:43:58 +00:00
|
|
|
|
unset($_SESSION['player_id']);
|
|
|
|
|
unset($_SESSION['player_name']);
|
|
|
|
|
}
|
2020-08-29 23:21:22 +00:00
|
|
|
|
if (isset($_SESSION['player_id'])) {
|
2022-12-16 23:20:43 +00:00
|
|
|
|
$inv = Db::getInstance()->fetchAll('SELECT item_id, name, image FROM inventory WHERE owner_id = ? ORDER BY item_id DESC', $_SESSION['player_id']);
|
2020-08-29 23:21:22 +00:00
|
|
|
|
}
|
|
|
|
|
if ($del) {
|
2022-12-16 23:20:43 +00:00
|
|
|
|
$itemdel = Db::getInstance()->fetch('SELECT item_type, dressed_slot FROM inventory WHERE item_id = ?', $del);
|
2020-08-29 23:21:22 +00:00
|
|
|
|
if ($itemdel['dressed_slot'] == 1) {
|
2021-08-25 15:24:12 +00:00
|
|
|
|
$item = new DressedItems($del);
|
2021-03-11 18:42:36 +00:00
|
|
|
|
$item->undressItem($itemdel['item_type']);
|
2020-08-29 23:21:22 +00:00
|
|
|
|
if ($itemdel['item_type'] == 5) {
|
2021-03-11 18:42:36 +00:00
|
|
|
|
$item->undressItem(6);
|
|
|
|
|
$item->undressItem(7);
|
2018-12-12 22:43:58 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2022-12-16 23:20:43 +00:00
|
|
|
|
Db::getInstance()->execute('delete from inventory where item_id = ?', $del);
|
2018-12-12 22:43:58 +00:00
|
|
|
|
}
|
2021-08-25 15:24:12 +00:00
|
|
|
|
Template::header('ᐰdminка инвентаря');
|
2018-12-12 22:43:58 +00:00
|
|
|
|
?>
|
2022-12-16 23:20:43 +00:00
|
|
|
|
<h1>Администрирование инвентаря <?php if (isset($_SESSION['player_name'])) { echo $_SESSION['player_name']; } ?></h1>
|
2018-12-12 22:43:58 +00:00
|
|
|
|
<table class='adm'>
|
|
|
|
|
<tr>
|
2022-12-16 23:20:43 +00:00
|
|
|
|
<th scope="col">ID</th>
|
|
|
|
|
<th scope="col">Название</th>
|
|
|
|
|
<th scope="col">Количество</th>
|
|
|
|
|
<th scope="col">Картинка</th>
|
|
|
|
|
<th scope="col"></th>
|
2018-12-12 22:43:58 +00:00
|
|
|
|
</tr>
|
|
|
|
|
<?php if (empty($_SESSION['player_id'])): ?>
|
|
|
|
|
<tr>
|
2022-12-16 23:20:43 +00:00
|
|
|
|
<th scope="col" colspan="5">
|
2018-12-12 22:43:58 +00:00
|
|
|
|
<form method="post">
|
2022-12-16 23:20:43 +00:00
|
|
|
|
<label>
|
|
|
|
|
<input placeholder="Логин или ID" name="player">
|
|
|
|
|
</label>
|
2018-12-12 22:43:58 +00:00
|
|
|
|
<input type="submit">
|
|
|
|
|
</form>
|
|
|
|
|
</th>
|
|
|
|
|
</tr>
|
2022-12-16 23:20:43 +00:00
|
|
|
|
<?php else: foreach ($inv as $row): ?>
|
2018-12-12 22:43:58 +00:00
|
|
|
|
<tr>
|
|
|
|
|
<td><?= $row['id'] ?></td>
|
|
|
|
|
<td><?= $row['name'] ?></td>
|
|
|
|
|
<td><?= $row['koll'] ?></td>
|
2022-12-16 23:20:43 +00:00
|
|
|
|
<td><img src='/i/sh/<?= $row['img'] ?>' alt=""></td>
|
2018-12-12 22:43:58 +00:00
|
|
|
|
<td>
|
|
|
|
|
<form method='post'>
|
|
|
|
|
<input name='del' type='hidden' value='<?= $row['id'] ?>'>
|
|
|
|
|
<input name='ok' type='submit' value='Удалить'>
|
|
|
|
|
</form>
|
|
|
|
|
</td>
|
|
|
|
|
</tr>
|
2022-12-16 23:20:43 +00:00
|
|
|
|
<?php endforeach; ?>
|
2018-12-12 22:43:58 +00:00
|
|
|
|
<th colspan='6'>
|
|
|
|
|
<form method='post'>
|
|
|
|
|
<input name='undress_char' type='submit' value='Стриптиз'>
|
|
|
|
|
</form>
|
|
|
|
|
<form method="post">
|
|
|
|
|
<input name='end' type='submit' value='Выйти'>
|
|
|
|
|
</form>
|
|
|
|
|
</th>
|
|
|
|
|
<?php endif; ?>
|
2022-12-16 23:20:43 +00:00
|
|
|
|
</table>
|