Зачем-то инкапсуляция...
This commit is contained in:
@@ -13,11 +13,11 @@ require_once 'functions.php';
|
||||
$user = $user ?? new User($_SESSION['uid']);
|
||||
$db = new DBPDO();
|
||||
$clanRow = [];
|
||||
if (!$user->clan) {
|
||||
if (!$user->getClan()) {
|
||||
exit(err('Вы не состоите в клане!'));
|
||||
}
|
||||
try {
|
||||
$clanRow = $db->fetch('SELECT * FROM `clans` WHERE short_name = ?', $user->clan);
|
||||
$clanRow = $db->fetch('SELECT * FROM `clans` WHERE short_name = ?', $user->getClan());
|
||||
} catch (Exception $e) {
|
||||
echo "<div>MYSQL_ERROR: Таблица clans сломана!</div>";
|
||||
}
|
||||
@@ -37,14 +37,14 @@ $tus = $_POST['tus'] ?? null;
|
||||
$lock = true; // блокировка функций
|
||||
|
||||
if ($zamok && !$lock) {
|
||||
$db->execute('UPDATE `clans` SET `zamok` = 1 WHERE `glava` = ?', $user->id);
|
||||
$db->execute('UPDATE `clans` SET `zamok` = 1 WHERE `glava` = ?', $user->getId());
|
||||
$status = "Начат сбор средств на строительство Кланового Замка.";
|
||||
header("Location: clan.php");
|
||||
}
|
||||
if ($kr && $kolv > 0 && !$lock) {
|
||||
if ($user->money >= $kolv) {
|
||||
$db->execute('UPDATE clans SET zbor = zbor + ? WHERE id = ?', [$kolv, $user->clan]);
|
||||
Bank::setWalletMoney($user->money -= $kolv, $user->id);
|
||||
if ($user->getMoney() >= $kolv) {
|
||||
$db->execute('UPDATE clans SET zbor = zbor + ? WHERE id = ?', [$kolv, $user->getClan()]);
|
||||
Bank::setWalletMoney($user->setMoney($user->getMoney() - $kolv), $user->getId());
|
||||
header("Location: clan.php");
|
||||
} else {
|
||||
$status = 'Не хватает денег!';
|
||||
@@ -57,8 +57,8 @@ if ($login && $action == 'add_member') {
|
||||
echo "Нет проверки!";
|
||||
} elseif ($sok['clan']) {
|
||||
echo 'Персонаж уже состоит в клане!';
|
||||
} elseif ($sok['level'] > 0 && $user->money >= COST_ADD_MEMBER) {
|
||||
Bank::setWalletMoney($user->money - COST_ADD_MEMBER, $user->id);
|
||||
} elseif ($sok['level'] > 0 && $user->getMoney() >= COST_ADD_MEMBER) {
|
||||
Bank::setWalletMoney($user->setMoney($user->getMoney() - COST_ADD_MEMBER), $user->getId());
|
||||
$db->execute('UPDATE users SET clan = ?, align = ? WHERE id = ?', [$clanRow['id'], $clanRow['align'], $sok['id']]);
|
||||
$status = "Персонаж «{$login}» успешно принят в клан.";
|
||||
} else {
|
||||
@@ -68,12 +68,12 @@ if ($login && $action == 'add_member') {
|
||||
|
||||
if ($login) {
|
||||
$sok = $db->fetch('SELECT id FROM users WHERE clan = ? AND login = ?', [$clanRow['id'], $login]);
|
||||
if ($action == 'remove_member' && $sok['id'] != $clanRow['owner_id'] && $user->money >= COST_REMOVE_MEMBER) {
|
||||
Bank::setWalletMoney($user->money - COST_REMOVE_MEMBER, $user->id);
|
||||
if ($action == 'remove_member' && $sok['id'] != $clanRow['owner_id'] && $user->getMoney() >= COST_REMOVE_MEMBER) {
|
||||
Bank::setWalletMoney($user->setMoney($user->getMoney() - COST_REMOVE_MEMBER), $user->getId());
|
||||
$db->execute('UPDATE users SET clan = null, align = 0 WHERE id = ?', $sok['id']);
|
||||
$status = "Персонаж «{$login}» покинул клан.";
|
||||
}
|
||||
if ($action == 'change_owner' && $clanRow['owner_id'] == $user->id) {
|
||||
if ($action == 'change_owner' && $clanRow['owner_id'] == $user->getId()) {
|
||||
$db->execute('UPDATE clans SET owner_id = ? WHERE id = ?', [$sok['id'], $clanRow['id']]);
|
||||
$clanRow['owner_id'] = $sok['id'];
|
||||
}
|
||||
@@ -108,7 +108,7 @@ $clanRow['zbor'] = null; // И копилки.
|
||||
<p style="width: 50%; vertical-align: top;" rowspan=2>
|
||||
<h3><img src="./i/clan/<?= $clanRow['short_name'] ?>.png"><?= $clanRow['full_name'] ?></h3>
|
||||
|
||||
<?php if ($clanRow['owner_id'] == $user->id): ?>
|
||||
<?php if ($clanRow['owner_id'] == $user->getId()): ?>
|
||||
<div>
|
||||
<span id="add_member">
|
||||
<input type="submit" onclick="use('add_member')" value="Принять в клан">
|
||||
@@ -123,18 +123,18 @@ $clanRow['zbor'] = null; // И копилки.
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($clanRow['owner_id'] == $user->id): ?>
|
||||
<?php if ($clanRow['owner_id'] == $user->getId()): ?>
|
||||
<?php if ($login && $action == 'edit_status' && $sok['id'] != $clanRow['owner_id']): ?>
|
||||
<form method='post'>
|
||||
<input placeholder='Статус' name='new_status'>
|
||||
<input type="hidden" name="login" value="<?= $login ?>">
|
||||
<?php if ($clanRow['glava'] == $user->id): ?>
|
||||
<?php if ($clanRow['owner_id'] == $user->id): ?>
|
||||
<?php if ($clanRow['glava'] == $user->getId()): ?>
|
||||
<?php if ($clanRow['owner_id'] == $user->getId()): ?>
|
||||
<br><input type=checkbox name=vin checked> Может принимать/выгонять членов клана
|
||||
<?php else: ?>
|
||||
<br><input type=checkbox name=vin> Может принимать/выгонять членов клана
|
||||
<?php endif; ?>
|
||||
<?php if ($clanRow['owner_id'] == $user->id): ?>
|
||||
<?php if ($clanRow['owner_id'] == $user->getId()): ?>
|
||||
<br><input type=checkbox name=tus checked> Может менять статус членов клана
|
||||
<?php else: ?>
|
||||
<br><input type=checkbox name=tus> Может менять статус членов клана
|
||||
@@ -152,7 +152,7 @@ $clanRow['zbor'] = null; // И копилки.
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($clanRow['owner_id'] == $user->id): ?>
|
||||
<?php if ($clanRow['owner_id'] == $user->getId()): ?>
|
||||
<div>
|
||||
<span id="change_owner">
|
||||
<input type="submit" onclick="use('change_owner')" value="Сменить главу клана">
|
||||
|
||||
Reference in New Issue
Block a user