2018-12-12 22:43:58 +00:00
|
|
|
|
<?php
|
|
|
|
|
/**
|
|
|
|
|
* Copyright (c) 2018.
|
|
|
|
|
* Author: Igor Barkov <lopar.4ever@gmail.com>
|
|
|
|
|
* Project name: Battles-Game
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
session_start();
|
|
|
|
|
require_once "../functions.php";
|
2021-02-01 19:20:23 +00:00
|
|
|
|
if (!$user->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;
|
2018-12-12 22:43:58 +00:00
|
|
|
|
|
2020-08-29 23:21:22 +00:00
|
|
|
|
if ($player) {
|
|
|
|
|
$row = db::c()->query('SELECT id, login FROM users WHERE id = "?s" OR login = "?s"', $player, $player)->fetch_assoc();
|
|
|
|
|
$_SESSION['player_id'] = $row['id'];
|
|
|
|
|
$_SESSION['player_name'] = $row['login'];
|
|
|
|
|
unset($row);
|
|
|
|
|
}
|
|
|
|
|
if ($undress_char) {
|
2021-03-11 18:58:38 +00:00
|
|
|
|
\Battles\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'])) {
|
|
|
|
|
$inv = db::c()->query('SELECT item_id, name, image FROM inventory WHERE owner = ?i ORDER BY id DESC', $_SESSION['player_id']);
|
|
|
|
|
}
|
|
|
|
|
if ($del) {
|
|
|
|
|
$itemdel = db::c()->query('SELECT item_type, dressed_slot FROM inventory WHERE id=?i', $del)->fetch_assoc();
|
|
|
|
|
if ($itemdel['dressed_slot'] == 1) {
|
2021-03-11 18:42:36 +00:00
|
|
|
|
$item = new \Battles\DressedItems($del);
|
|
|
|
|
$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
|
|
|
|
}
|
|
|
|
|
}
|
2020-08-29 23:21:22 +00:00
|
|
|
|
db::c()->query('DELETE FROM `inventory` WHERE `id` = ?i', $del);
|
2018-12-12 22:43:58 +00:00
|
|
|
|
}
|
2020-10-28 20:21:08 +00:00
|
|
|
|
\Battles\Template::header('ᐰdminка инвентаря');
|
2018-12-12 22:43:58 +00:00
|
|
|
|
?>
|
2018-12-12 22:50:47 +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>
|
|
|
|
|
<th>ID</th>
|
|
|
|
|
<th>Название</th>
|
|
|
|
|
<th>Количество</th>
|
|
|
|
|
<th>Картинка</th>
|
|
|
|
|
<th></th>
|
|
|
|
|
</tr>
|
|
|
|
|
<?php if (empty($_SESSION['player_id'])): ?>
|
|
|
|
|
<tr>
|
|
|
|
|
<th colspan="5">
|
|
|
|
|
<form method="post">
|
|
|
|
|
<input placeholder="Логин или ID" name="player">
|
|
|
|
|
<input type="submit">
|
|
|
|
|
</form>
|
|
|
|
|
</th>
|
|
|
|
|
</tr>
|
|
|
|
|
<?php else: while ($row = $inv->fetch_assoc()): ?>
|
|
|
|
|
<tr>
|
|
|
|
|
<td><?= $row['id'] ?></td>
|
|
|
|
|
<td><?= $row['name'] ?></td>
|
|
|
|
|
<td><?= $row['koll'] ?></td>
|
2018-12-12 22:49:35 +00:00
|
|
|
|
<td><img src='/i/sh/<?= $row['img'] ?>'></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>
|
|
|
|
|
<?php endwhile; ?>
|
|
|
|
|
<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; ?>
|
2020-09-30 22:12:53 +00:00
|
|
|
|
</table>
|