2018-02-27 03:53:10 +00:00
|
|
|
|
<?php
|
2018-01-28 16:40:49 +00:00
|
|
|
|
ob_start("ob_gzhandler");
|
|
|
|
|
session_start();
|
2019-01-28 15:56:35 +00:00
|
|
|
|
|
2020-09-28 13:27:57 +00:00
|
|
|
|
if (empty($_SESSION['uid'])) {
|
2020-07-03 10:26:38 +00:00
|
|
|
|
header("Location: index.php");
|
2020-09-25 16:27:11 +00:00
|
|
|
|
exit;
|
2020-07-03 10:26:38 +00:00
|
|
|
|
}
|
2018-12-12 11:59:29 +00:00
|
|
|
|
require_once "functions.php";
|
2020-09-25 16:27:11 +00:00
|
|
|
|
$user = $user ?? [];
|
|
|
|
|
if ($user->room != 29) {
|
2018-12-12 19:55:33 +00:00
|
|
|
|
header("Location: main.php");
|
2020-09-25 16:27:11 +00:00
|
|
|
|
exit;
|
2018-12-12 19:55:33 +00:00
|
|
|
|
}
|
2020-09-25 16:27:11 +00:00
|
|
|
|
if ($user->battle != 0) {
|
2018-02-27 03:53:10 +00:00
|
|
|
|
header('location: fbattle.php');
|
2020-09-25 16:27:11 +00:00
|
|
|
|
exit;
|
2018-02-27 03:53:10 +00:00
|
|
|
|
}
|
2020-09-25 16:27:11 +00:00
|
|
|
|
const SUCCESS = "Успешная операция!";
|
2020-10-28 12:31:17 +00:00
|
|
|
|
|
2020-09-25 16:27:11 +00:00
|
|
|
|
$bank = new Bank($user->id);
|
2020-09-30 12:39:42 +00:00
|
|
|
|
$status = '';
|
2018-01-28 16:40:49 +00:00
|
|
|
|
|
2020-10-28 12:31:17 +00:00
|
|
|
|
$toid = (int)$_POST['to_id'] ?? 0;
|
|
|
|
|
$summa = (int)$_POST['summa'] ?? 0;
|
|
|
|
|
$submit = $_POST['action'] ?? '';
|
|
|
|
|
// Зачисление кредитов на счёт.
|
|
|
|
|
if ($submit === 'depositMoney' && $summa) {
|
|
|
|
|
$bank->depositMoney($summa);
|
|
|
|
|
$status = SUCCESS;
|
2020-07-03 10:26:38 +00:00
|
|
|
|
}
|
2020-10-28 12:31:17 +00:00
|
|
|
|
// Снятие кредитов со счёта.
|
|
|
|
|
if ($submit === 'withdrawMoney' && $summa) {
|
|
|
|
|
$bank->withdrawMoney($summa);
|
|
|
|
|
$status = SUCCESS;
|
2020-07-03 10:26:38 +00:00
|
|
|
|
}
|
2020-10-28 12:31:17 +00:00
|
|
|
|
// Перевод кредитов на другой счёт.
|
|
|
|
|
if ($submit === 'sendMoney' && $summa && $toid) {
|
|
|
|
|
$bank->sendMoney($toid, $summa);
|
|
|
|
|
$status = SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
unset($submit, $summa, $toid);
|
|
|
|
|
|
2020-09-30 12:39:42 +00:00
|
|
|
|
Template::header('Банк');
|
2020-07-03 10:26:38 +00:00
|
|
|
|
?>
|
2020-10-28 12:31:17 +00:00
|
|
|
|
<link href="css/secondary.css" rel="stylesheet"/>
|
|
|
|
|
<script src="js/main.js"></script>
|
|
|
|
|
<?php Template::buildingTop(Rooms::$roomNames[29], 'strah') ?>
|
|
|
|
|
<div><?= $status ?></div>
|
|
|
|
|
<div class="appblock appblock-main">
|
|
|
|
|
<span class="wrap">На счету: <span class="num"><?= $bank->getMoney() ?></span></span>
|
|
|
|
|
<hr>
|
|
|
|
|
<span class="wrap">На руках: <span class="num"><?= $user->money ?></span></span>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="appblock">
|
|
|
|
|
<span class="legend">Работа со счётом</span>
|
|
|
|
|
<form method="post">
|
|
|
|
|
<input size="10" name="summa" placeholder="Сумма">
|
|
|
|
|
<input type="hidden" name="action" value="depositMoney">
|
|
|
|
|
<input type="submit" value="Положить деньги">
|
|
|
|
|
</form>
|
|
|
|
|
<form method="post">
|
|
|
|
|
<input size="10" name="summa" placeholder="Сумма">
|
|
|
|
|
<input type="hidden" name="action" value="withdrawMoney">
|
|
|
|
|
<input type="submit" value="Снять деньги">
|
|
|
|
|
</form>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="appblock">
|
|
|
|
|
<span class="legend">Перевод кредитов</span>
|
|
|
|
|
<form method="post">
|
|
|
|
|
<input size="10" name="summa" placeholder="Сумма">
|
|
|
|
|
<input size="10" name="to-id" placeholder="Cчёт"><br>
|
|
|
|
|
<input type="hidden" name="action" value="sendMoney">
|
|
|
|
|
<input type="submit" value="Перевести кредиты">
|
|
|
|
|
</form>
|
|
|
|
|
<span class="wrap">Комиссия: <?= Config::$bank_commission * 100 ?>% от переводимой суммы, но не менее 1 кр.</span>
|
|
|
|
|
</div>
|