2018-02-27 03:53:10 +00:00
|
|
|
|
<?php
|
2018-01-28 16:40:49 +00:00
|
|
|
|
ob_start("ob_gzhandler");
|
|
|
|
|
session_start();
|
|
|
|
|
if ($_SESSION['uid'] == null) header("Location: index.php");
|
|
|
|
|
include "config.php";
|
|
|
|
|
include "functions.php";
|
2018-02-27 03:53:10 +00:00
|
|
|
|
if ($user['room'] != 29) header("Location: main.php");
|
|
|
|
|
if ($user['battle'] != 0) {
|
|
|
|
|
header('location: fbattle.php');
|
|
|
|
|
die();
|
|
|
|
|
}
|
2018-03-09 18:55:26 +00:00
|
|
|
|
$bank = db::c()->query('SELECT `id`, `cr`, `ekr` FROM `bank` WHERE `id` = ?i', $_SESSION['uid'])->fetch_assoc();
|
2018-01-28 16:40:49 +00:00
|
|
|
|
|
2018-03-09 21:12:03 +00:00
|
|
|
|
/**
|
|
|
|
|
* Если вдруг нет счёта, создаём.
|
|
|
|
|
*/
|
2018-03-09 18:07:04 +00:00
|
|
|
|
if (!$bank['id']) {
|
2018-03-09 18:55:26 +00:00
|
|
|
|
db::c()->query('INSERT INTO `bank` (`id`) VALUES (?i)', $_SESSION['uid']);
|
2018-03-09 18:07:04 +00:00
|
|
|
|
}
|
2018-01-28 16:40:49 +00:00
|
|
|
|
?>
|
|
|
|
|
|
2018-02-27 03:53:10 +00:00
|
|
|
|
<!DOCTYPE html>
|
|
|
|
|
<html>
|
|
|
|
|
<head>
|
|
|
|
|
<meta charset="utf-8">
|
|
|
|
|
<link href="css/main.css" rel="stylesheet"/>
|
|
|
|
|
<title>Банк</title>
|
|
|
|
|
<script>
|
2018-02-27 05:41:56 +00:00
|
|
|
|
function leave() {
|
2018-03-09 18:07:04 +00:00
|
|
|
|
top.frames['main'].location = 'city.php?strah'
|
2018-02-27 03:53:10 +00:00
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
<script src="/js/jquery-1.7.2.min.js"></script>
|
|
|
|
|
<style>
|
|
|
|
|
.appblock {
|
|
|
|
|
background: silver;
|
|
|
|
|
border-radius: 2px;
|
|
|
|
|
float: left;
|
|
|
|
|
height: 200px;
|
|
|
|
|
margin: 10px;
|
2018-03-09 21:12:03 +00:00
|
|
|
|
width: 250px;
|
2018-02-27 03:53:10 +00:00
|
|
|
|
opacity: 0.75;
|
|
|
|
|
padding: 5px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
div.appblock form {
|
2018-03-09 21:12:03 +00:00
|
|
|
|
margin: 5px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
div.appblock span {
|
|
|
|
|
padding: 0.2em 0.5em;
|
|
|
|
|
color: #666;
|
|
|
|
|
font-weight: bold;
|
|
|
|
|
display: block;
|
|
|
|
|
}
|
|
|
|
|
div.appblock br {
|
|
|
|
|
margin:5px;
|
2018-02-27 03:53:10 +00:00
|
|
|
|
}
|
|
|
|
|
</style>
|
2018-01-28 16:40:49 +00:00
|
|
|
|
</head>
|
2018-02-27 03:53:10 +00:00
|
|
|
|
<body>
|
2018-02-27 05:41:56 +00:00
|
|
|
|
<h1>Банк</h1>
|
2018-03-09 22:34:51 +00:00
|
|
|
|
<table class='adm'>
|
|
|
|
|
<tr>
|
|
|
|
|
<th>№</th>
|
|
|
|
|
<th>Кредитов.</th>
|
|
|
|
|
<th>ЕвроКредитов.</th>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr>
|
|
|
|
|
<td><?=$bank['id']?></td>
|
|
|
|
|
<td><?=$bank['cr']?></td>
|
|
|
|
|
<td><?=$bank['ekr']?></td>
|
|
|
|
|
</tr>
|
|
|
|
|
</table><br>
|
2018-02-27 03:53:10 +00:00
|
|
|
|
<?php
|
|
|
|
|
|
2018-02-27 05:41:56 +00:00
|
|
|
|
if ($_GET['exit']) {
|
|
|
|
|
$_SESSION['bankid'] = null;
|
2018-01-28 16:40:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-03-09 22:01:20 +00:00
|
|
|
|
if (isset($_POST['userlogin'])) {
|
|
|
|
|
$_SESSION['bankid'] = $_SESSION['uid'];
|
2018-01-28 16:40:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-02-27 05:41:56 +00:00
|
|
|
|
if (!$_SESSION['bankid']) {
|
2018-02-27 03:53:10 +00:00
|
|
|
|
?>
|
2018-02-27 05:41:56 +00:00
|
|
|
|
<a href=# onclick=leave()> ← выйти из банка</a>
|
2018-03-09 22:34:51 +00:00
|
|
|
|
<form method="post"><input type="submit" name="userlogin" value="Управление счётом"></form>
|
2018-02-27 05:14:11 +00:00
|
|
|
|
<?
|
|
|
|
|
} else {
|
2018-03-09 18:07:04 +00:00
|
|
|
|
|
2018-03-09 22:01:20 +00:00
|
|
|
|
$toid = filter_input(INPUT_POST, 'to-id');
|
2018-03-22 20:46:12 +00:00
|
|
|
|
$summa = (int)filter_input(INPUT_POST, 'summa');
|
2018-03-09 22:16:41 +00:00
|
|
|
|
$submit = filter_input(INPUT_POST, 'action');
|
2018-03-22 20:46:12 +00:00
|
|
|
|
$mywarn = '';
|
2018-03-09 22:01:20 +00:00
|
|
|
|
/**
|
|
|
|
|
* Зачисдение кредитов на счёт.
|
|
|
|
|
*/
|
2018-03-09 22:12:59 +00:00
|
|
|
|
if ($submit == 'money-in' && $summa) {
|
2018-03-09 21:12:03 +00:00
|
|
|
|
if ($summa > 0 && ($summa <= $user['money'])) {
|
|
|
|
|
$user['money'] -= $summa;
|
2018-03-09 23:07:02 +00:00
|
|
|
|
db::c()->query('UPDATE `users` SET `money` = `money` - ?i WHERE `id` = ?i', $summa, $bank['id']);
|
|
|
|
|
db::c()->query('UPDATE `bank` SET `cr` = `cr` + ?i WHERE `id` = ?i', $summa, $bank['id']);
|
2018-03-09 21:12:03 +00:00
|
|
|
|
db::c()->query('INSERT INTO `bank_logs` (`user_id`, `sum`, `type`, `comments`, `source`)
|
2018-03-09 23:07:02 +00:00
|
|
|
|
VALUES (?i, ?i, "?s", "?s", ?i)', $bank['id'], $summa, 'money-in', 'Банк: Зачисление средств на счёт', $bank['id']);
|
2018-02-27 05:14:11 +00:00
|
|
|
|
} else {
|
|
|
|
|
$mywarn = "У вас недостаточно денег для выполнения операции";
|
2018-02-27 03:53:10 +00:00
|
|
|
|
}
|
2018-03-09 22:12:59 +00:00
|
|
|
|
$submit = '';
|
2018-03-09 21:12:03 +00:00
|
|
|
|
$summa = 0;
|
2018-02-27 05:14:11 +00:00
|
|
|
|
}
|
2018-03-09 18:07:04 +00:00
|
|
|
|
|
2018-03-09 22:01:20 +00:00
|
|
|
|
/**
|
|
|
|
|
* Снятие кредитов со счёта.
|
|
|
|
|
*/
|
2018-03-09 22:12:59 +00:00
|
|
|
|
if ($submit == 'money-out' && $summa) {
|
2018-03-09 21:12:03 +00:00
|
|
|
|
if ($summa > 0 && ($summa <= $bank['cr'])) {
|
|
|
|
|
$user['money'] += $summa;
|
2018-03-09 23:07:02 +00:00
|
|
|
|
db::c()->query('UPDATE `bank` SET `cr` = `cr` - ?i WHERE `id` = ?i', $summa, $bank['id']);
|
|
|
|
|
db::c()->query('UPDATE `users` SET `money` = `money` + ?i WHERE `id` = ?i', $summa, $bank['id']);
|
2018-03-09 21:12:03 +00:00
|
|
|
|
db::c()->query('INSERT INTO `bank_logs` (`user_id`, `sum`, `type`, `comments`, `source`)
|
2018-03-09 23:07:02 +00:00
|
|
|
|
VALUES (?i, ?i, "?s", "?s", ?i)', $bank['id'], $summa, 'money-out', 'Банк: Вывод средств на руки', $bank['id']);
|
2018-02-27 05:14:11 +00:00
|
|
|
|
} else {
|
|
|
|
|
$mywarn = "У вас недостаточно денег на счету для выполнения операции";
|
2018-01-28 16:40:49 +00:00
|
|
|
|
}
|
2018-03-09 22:12:59 +00:00
|
|
|
|
$submit = '';
|
2018-03-09 21:12:03 +00:00
|
|
|
|
$summa = 0;
|
2018-02-27 05:14:11 +00:00
|
|
|
|
}
|
2018-01-28 16:40:49 +00:00
|
|
|
|
|
2018-03-09 22:01:20 +00:00
|
|
|
|
/**
|
|
|
|
|
* Перевод кредитов на другой счёт.
|
|
|
|
|
*/
|
2018-03-09 23:28:29 +00:00
|
|
|
|
if ($submit == 'money-send' && $summa && $toid) {
|
2018-03-09 22:01:20 +00:00
|
|
|
|
$receiver = db::c()->query('SELECT `id` FROM `bank` WHERE `id` = ?i', $toid)->fetch_assoc();
|
|
|
|
|
if ($receiver['id']) {
|
|
|
|
|
if ($summa > 0) {
|
|
|
|
|
$nalog = round($summa * 0.05);
|
|
|
|
|
if ($nalog < 1) {
|
|
|
|
|
$nalog = 1;
|
|
|
|
|
}
|
|
|
|
|
$new_summa = $summa + $nalog;
|
|
|
|
|
if ($new_summa <= $bank['cr']) {
|
2018-03-09 23:07:02 +00:00
|
|
|
|
db::c()->query('UPDATE `bank` SET `cr` = `cr` - ?i WHERE `id` = ?i', $new_summa, $bank['id']);
|
2018-03-09 22:01:20 +00:00
|
|
|
|
db::c()->query('UPDATE `bank` SET `cr` = `cr` + ?i WHERE `id` = ?i', $summa, $toid);
|
|
|
|
|
db::c()->query('UPDATE `bank` SET `cr` = `cr` + ?i WHERE `id` = ?i', $nalog, 0);
|
|
|
|
|
db::c()->query('INSERT INTO `bank_logs` (`user_id`, `sum`, `type`, `comments`, `source`)
|
2018-03-09 23:07:02 +00:00
|
|
|
|
VALUES (?i, ?i, "?s", "?s", ?i)', $toid, $summa, 'money-in', 'Получение банковского перевода.', $bank['id']);
|
2018-03-09 22:01:20 +00:00
|
|
|
|
db::c()->query('INSERT INTO `bank_logs` (`user_id`, `sum`, `type`, `comments`, `source`)
|
2018-03-09 23:28:29 +00:00
|
|
|
|
VALUES (?i, ?i, "?s", "?s", ?i)', $bank['id'], $new_summa, 'money-send', 'Банк: Перевод средств на другой счёт. Комиссия: '.$nalog.'.', $toid);
|
2018-03-09 22:01:20 +00:00
|
|
|
|
} else {
|
|
|
|
|
$mywarn = "У вас недостаточно денег на счету для выполнения операции";
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$mywarn = "Укажите сумму!";
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$mywarn = "Счёт не существует.";
|
|
|
|
|
}
|
2018-03-09 22:12:59 +00:00
|
|
|
|
$submit = '';
|
2018-03-09 22:01:20 +00:00
|
|
|
|
$summa = 0;
|
|
|
|
|
$toid = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-27 05:14:11 +00:00
|
|
|
|
/**
|
2018-03-22 20:46:12 +00:00
|
|
|
|
* Обмен еврокредитов на кредиты.
|
2018-02-27 05:14:11 +00:00
|
|
|
|
*/
|
2018-03-22 20:46:12 +00:00
|
|
|
|
if ($_POST['donate-exchange'] && $summa) {
|
|
|
|
|
if ($summa > 0 && $summa <= $bank['ekr']) {
|
|
|
|
|
db::c()->query('UPDATE `bank` SET `cr` = `cr` + ?i WHERE `id` = ?i', ($summa*5), $bank['id']);
|
|
|
|
|
db::c()->query('UPDATE `bank` SET `ekr` = `ekr` - ?i WHERE `id` = ?i', $summa, $bank['id']);
|
|
|
|
|
db::c()->query('INSERT INTO `bank_logs` (`user_id`, `sum`, `type`, `comments`, `source`)
|
|
|
|
|
VALUES (?i, ?i, "?s", "?s", ?i)', $bank['id'], $summa, 'donate-exchange', 'Банк: Обмен валют на сумму '.($summa*5).' кр.', $bank['id']);
|
2018-02-27 05:14:11 +00:00
|
|
|
|
} else {
|
2018-03-22 20:46:12 +00:00
|
|
|
|
$mywarn = "У вас недостаточно денег на валютном счету для выполнения операции";
|
2018-02-27 03:53:10 +00:00
|
|
|
|
}
|
2018-03-22 20:46:12 +00:00
|
|
|
|
$submit = '';
|
|
|
|
|
$summa = 0;
|
2018-02-27 05:14:11 +00:00
|
|
|
|
}
|
2018-01-28 16:40:49 +00:00
|
|
|
|
|
2018-03-22 20:46:12 +00:00
|
|
|
|
//### Чеки
|
|
|
|
|
// /**
|
|
|
|
|
// *
|
|
|
|
|
// */
|
|
|
|
|
// function bank_show()
|
|
|
|
|
// {
|
|
|
|
|
// global $user;
|
|
|
|
|
// $pl = db::c()->query('SELECT `id`,`name`,`bcost` FROM `inventory` WHERE `owner` = ?i AND `bcost` > 0 ORDER BY `bcost` ASC', $user['id']);
|
|
|
|
|
// if ($pl->getNumRows() > 0) {
|
|
|
|
|
// echo '<select name=\'coste\'>';
|
|
|
|
|
// while ($sp = $pl->fetch_assoc()) {
|
|
|
|
|
// echo '<option value=\'' . $sp['id'] . '\'>' . $sp['name'] . '</option>';
|
|
|
|
|
// }
|
|
|
|
|
// echo '</select> <input class="ctContent" type="submit" value="Обменять" name="saled" />';
|
|
|
|
|
// } else {
|
|
|
|
|
// echo '<b>Нет чеков для обмена</b>';
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// if ($_POST['sales'] && $_POST['count_ekr'] && (!empty($user['admin']))) {
|
|
|
|
|
// if (isset($bank['id'])) {
|
|
|
|
|
// $cnt = round($_POST['count_ekr'], 2);
|
|
|
|
|
// if ($cnt < 1) {
|
|
|
|
|
// err('Минимальная сумма: 1 екр');
|
|
|
|
|
// } elseif ($bank['ekr'] < $cnt) {
|
|
|
|
|
// err('Недостаточно средств ...');
|
|
|
|
|
// } else {
|
|
|
|
|
// $name = 'Банковский чек на ' . $cnt . ' еврокредитов';
|
|
|
|
|
// db::c()->query('INSERT INTO `inventory` SET `name` = "?s", `bcost` = ?i, `owner` = ?i, `prototype` = ?i', $name, $cnt, $user['id'], 1123);
|
|
|
|
|
//// $bank['ekr'] -= $cnt;
|
|
|
|
|
//// mysql_query('UPDATE `bank` SET `ekr` = "' . $bank['ekr'] . '" WHERE `id` = "' . $bank['id'] . '" LIMIT 1');
|
|
|
|
|
// db::c()->query('UPDATE `bank` SET `ekr` = `ekr` - ?i WHERE `id` = ?i', $cnt, $bank['id']);
|
|
|
|
|
// err('Чек на сумму : ' . $cnt . ' екр., появится у Вас в инвентаре ...');
|
|
|
|
|
// }
|
|
|
|
|
// } else {
|
|
|
|
|
// err('Банковский счёт, не найден ...');
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// if ($_POST['saled'] && $_POST['coste'] && (!empty($user['admin']))) {
|
|
|
|
|
// $item = mysql_fetch_array(mysql_query('SELECT `id`, `name`, `bcost` FROM `inventory` WHERE `owner` = "' . $user['id'] . '" AND `id` = "' . mysql_real_escape_string($_POST['coste']) . '" LIMIT 1'));
|
|
|
|
|
// if (isset($item['id'])) {
|
|
|
|
|
// if ($item['bcost'] > 0) {
|
|
|
|
|
// mysql_query('DELETE FROM `inventory` WHERE `owner` = "' . $user['id'] . '" AND `id` = "' . $item['id'] . '" LIMIT 1');
|
|
|
|
|
// $bank['ekr'] += $item['bcost'];
|
|
|
|
|
// mysql_query('UPDATE `bank` SET `ekr` = "' . $bank['ekr'] . '" WHERE `id` = "' . $bank['id'] . '" LIMIT 1');
|
|
|
|
|
// err($item['name'] . ', успешно обналичен ...');
|
|
|
|
|
// } else {
|
|
|
|
|
// err('Это не чек ...');
|
|
|
|
|
// }
|
|
|
|
|
// } else {
|
|
|
|
|
// err('Чек, не найден ...');
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//###
|
2018-02-27 03:53:10 +00:00
|
|
|
|
|
2018-02-27 05:14:11 +00:00
|
|
|
|
err($mywarn);
|
|
|
|
|
?>
|
2018-02-27 05:41:56 +00:00
|
|
|
|
<a href="?exit=1"> ← выйти из счёта</a>
|
2018-03-09 23:00:39 +00:00
|
|
|
|
<br><br>Красным <span style="background:#FFAAAA;">помечены</span> нерабочие элементы.<br>
|
2018-02-27 05:14:11 +00:00
|
|
|
|
<div class="appblock">
|
2018-03-09 21:12:03 +00:00
|
|
|
|
<span>Денежные средства</span>
|
|
|
|
|
Кредитов на руках: <b><?=$user['money']?></b> кр.<br>
|
|
|
|
|
<form method="post">
|
|
|
|
|
<input size="10" name="summa" placeholder="Сумма">
|
2018-03-09 22:22:08 +00:00
|
|
|
|
<input type="hidden" name="action" value="money-in">
|
2018-03-09 22:16:41 +00:00
|
|
|
|
<input type="submit" value="Положить на счёт">
|
2018-03-09 21:12:03 +00:00
|
|
|
|
</form>
|
|
|
|
|
<form method="post">
|
|
|
|
|
<input size="10" name="summa" placeholder="Сумма">
|
2018-03-09 22:22:08 +00:00
|
|
|
|
<input type="hidden" name="action" value="money-out">
|
2018-03-09 22:16:41 +00:00
|
|
|
|
<input type="submit" value="Снять со счёта">
|
2018-03-09 21:12:03 +00:00
|
|
|
|
</form>
|
2018-02-27 05:14:11 +00:00
|
|
|
|
</div>
|
2018-03-09 22:01:20 +00:00
|
|
|
|
<div class="appblock">
|
2018-03-09 21:12:03 +00:00
|
|
|
|
<span>Перевод кредитов</span>
|
|
|
|
|
<form method="post">
|
|
|
|
|
<input size="10" name="summa" placeholder="Сумма">
|
2018-03-09 22:12:59 +00:00
|
|
|
|
<input size="10" name="to-id" placeholder="Cчёт"><br>
|
2018-03-09 23:28:29 +00:00
|
|
|
|
<input type="hidden" name="action" value="money-send">
|
2018-03-09 22:16:41 +00:00
|
|
|
|
<input type="submit" value="Перевести кредиты">
|
2018-02-27 05:14:11 +00:00
|
|
|
|
</form>
|
2018-03-09 22:01:20 +00:00
|
|
|
|
<i>Комиссия составит 5% от переводимой суммы, но не менее 1 кр.</i>
|
2018-02-27 05:14:11 +00:00
|
|
|
|
</div>
|
2018-03-22 20:46:12 +00:00
|
|
|
|
<div class="appblock">
|
|
|
|
|
<span>Обменять екр. на кр.</span>
|
|
|
|
|
<form method="post">
|
|
|
|
|
<input size="10" name="summa" placeholder="Сумма">
|
|
|
|
|
<input type="hidden" name="action" value="donate-exchange">
|
|
|
|
|
<input type=submit value="Обменять">
|
|
|
|
|
</form>
|
|
|
|
|
<i>Курс обмена: 1:5.</i>
|
|
|
|
|
</div>
|
2018-02-27 05:14:11 +00:00
|
|
|
|
<? if (!empty($user['admin'])): ?>
|
|
|
|
|
<div class="appblock" style="background:#FFAAAA;">
|
2018-03-22 20:46:12 +00:00
|
|
|
|
<span>Выписать чек</span>
|
2018-02-27 03:53:10 +00:00
|
|
|
|
Услуга "чек на предъявителя". Вы выписываете екровый чек, который затем сможет обналичить любой
|
|
|
|
|
персонаж.<br>
|
|
|
|
|
<form method="POST">
|
|
|
|
|
Сумма (екр): <input type="text" size="4" name="count_ekr"/> <input type="submit" value="Выписать"
|
|
|
|
|
name="sales"/>
|
|
|
|
|
</form>
|
|
|
|
|
</div>
|
2018-03-09 18:07:04 +00:00
|
|
|
|
<div class="appblock" style="background:#FFAAAA;">
|
2018-03-22 20:46:12 +00:00
|
|
|
|
<span>Обналичить чек</span>
|
2018-02-27 03:53:10 +00:00
|
|
|
|
В нашем банке мы принимаем к погашению екровые чеки на предъявителя.
|
|
|
|
|
<form method="POST">
|
2018-03-22 20:46:12 +00:00
|
|
|
|
<?php #bank_show(); ?>
|
2018-02-27 03:53:10 +00:00
|
|
|
|
</form>
|
|
|
|
|
</div>
|
2018-02-27 05:14:11 +00:00
|
|
|
|
<?php endif;
|
|
|
|
|
} # Очень важная и гордая кавычка!
|
2018-01-28 16:40:49 +00:00
|
|
|
|
?>
|
|
|
|
|
|
|
|
|
|
</body>
|
|
|
|
|
</html>
|