Чистка оптимизация и унификация кода.
This commit is contained in:
+25
-20
@@ -8,37 +8,42 @@
|
||||
session_start();
|
||||
require_once "../functions.php";
|
||||
|
||||
if (empty($user['admin'])) {
|
||||
echo "<!DOCTYPE HTML><html><head><title>404 Not Found</title></head><body><h1>Not Found</h1><p>The requested URL {$_SERVER['SCRIPT_NAME']} was not found on this server.</p><hr><address>Apache/2.2.22 (@RELEASE@) Server at Hetzner Datacenter 426</address></body></html>";
|
||||
if (!$user->admin) {
|
||||
header("HTTP/1.0 404 Not Found");
|
||||
exit;
|
||||
}
|
||||
|
||||
if (isset($_POST['player'])) {
|
||||
$p = db::c()->query('SELECT `id`, `login` FROM `users` WHERE `id` = "?s" OR `login` = "?s"', $_POST['player'], $_POST['player'])->fetch_assoc();
|
||||
$_SESSION['player_id'] = $p['id'];
|
||||
$_SESSION['player_name'] = $p['login'];
|
||||
$player = $_POST['player'] ?? null;
|
||||
$undress_char = $_POST['undress_char'] ?? null;
|
||||
$end = $_POST['end'] ?? null;
|
||||
$del = $_POST['del'] ?? null;
|
||||
|
||||
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 (isset($_POST['undress_char'])) undressall($_SESSION['player_id']);
|
||||
|
||||
if (isset($_POST['end'])) {
|
||||
if ($undress_char) {
|
||||
undressall($_SESSION['player_id']);
|
||||
}
|
||||
if ($end) {
|
||||
unset($_SESSION['player_id']);
|
||||
unset($_SESSION['player_name']);
|
||||
}
|
||||
|
||||
if (isset($_SESSION['player_id']))
|
||||
$inv = db::c()->query('SELECT `id`,`name`,`koll`,`img` FROM `inventory` WHERE `owner` = ?i ORDER BY `id` DESC', $_SESSION['player_id']);
|
||||
|
||||
if (input::post('del')) {
|
||||
$itemdel = db::c()->query('SELECT `type`,`dressed` FROM `inventory` WHERE `id`=?i', input::post('del'))->fetch_assoc();
|
||||
if ($itemdel['dressed'] == 1) {
|
||||
dropitem($itemdel['type']);
|
||||
if ($itemdel['type'] == 5) {
|
||||
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) {
|
||||
dropitem($itemdel['item_type']);
|
||||
if ($itemdel['item_type'] == 5) {
|
||||
dropitem(6);
|
||||
dropitem(7);
|
||||
}
|
||||
}
|
||||
db::c()->query('DELETE FROM `inventory` WHERE `id` = ?i', input::post('del'));
|
||||
db::c()->query('DELETE FROM `inventory` WHERE `id` = ?i', $del);
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
|
||||
Reference in New Issue
Block a user