Файл: bank/index.php
Строк: 79
<?php
require_once '../core/system.php';
function _num($i) {
$i = (int) abs($i);
return $i;
}
function _time($i) {
$h = floor(($i / 3600) - $d * 24);
$m = floor(($i - $h * 3600 - $d * 86400) / 60);
$s = $i - ($m * 60 + $h * 3600 + $d * 86400);
return ($h > 0 ? ($h < 10 ? '0':'').$h.':':'').($m > 0 ? ($m < 10 ? '0':'').$m.':':'00:').($s > 0 ? ($s < 10 ? '0':'').$s:'00');
}
$req = mysql_query("SELECT ban from `ban` where `id_us` = '".$user['id']."' and `time` > '".$_SERVER['REQUEST_TIME']."'");
$ban = mysql_fetch_array($req);
if($ban['ban'] == 3){
header('Location: /moduls/ban');
}
if(!isset($user['id'])) header('Location: /');
$header = 'Банк';
require_once '../core/head.php';
if($user['mesto'] != 'Банк')
mysql_query("UPDATE `user` set `mesto` = 'Банк' where `id` = '".$user['id']."'");
if($user['save'] < 1){
header('Location: /');
}
if($borrowing && $borrowing['cost'] <= 0) {
mysql_query('DELETE FROM `borrowing` WHERE `user` = '.$user['id'].'');
header('location: /bank/');
exit;
}
?>
<div class='title'><?=$title;?></div>
<div class='content' align='center'>
<div class="head">
<img src='https://news.ereality.ru/uploads/posts/2015-12/1451573116_coupon2014.png' alt='*'>
</div><div class="head">
<div class='content' align='center'>
<?=$borrowing ? 'Необходимо вернуть: '.$borrowing['cost'].' серебра! <br />
Осталость времени до погашения кредита '._time($borrowing['times'] - time()).'' : '
- В банке вы можете взять определенное количество золота на 7 д, под 25%. <br />
- Максимальная сумма кредита 500 золота.<br />
- 50000 серебра = 500 золота.
';?>
</div></div><div class='line'></div>
<div class='content' align='center'>
<?
if(isset($_GET['wheitGo'])) {
if(isset($_POST['send'])){
$cost = _num($_POST['cost']);
if($borrowing) {
if($cost <= 0 OR $cost > $borrowing['cost']) {
header('location: /bank/');
exit;
}
if($user['gold'] < $cost) {
header('location: /bank/');
exit;
}
mysql_query("UPDATE `user` SET `gold` = `gold` - '".$cost."' WHERE `id` = '".$user['id']."'");
mysql_query('UPDATE `borrowing` SET `cost` = '.($borrowing['cost'] - $cost).' WHERE `user` = '.$user['id'].'');
header('location: /bank/');
exit;
}else{
if($cost <= 0 OR $cost > 50000) {
header('location: /bank/');
exit;
}
if($user['gold'] < 0) {
header('location: /bank/');
exit;
}
mysql_query("UPDATE `user` SET `gold` = `gold` + '".$cost."' WHERE `id` = '".$user['id']."'");
$cost += round($cost/100) * 25;
mysql_query('INSERT INTO `borrowing` SET `user` = '.$user['id'].', `cost` = '.$cost.', `times` = '.(time() + 604800).'');
header('location: /bank/');
exit;
}}
?>
<div class="head">
<form action="" method="post">
<input name="cost" value="50000">
<center><input type="submit" name="send" value="<?=$borrowing ? 'Вернуть' : 'Взять';?>"></center>
</form></center>
<?
}else{
?><div class="head">
<a href='?wheitGo' class = "button"> <?=$borrowing ? 'Вернуть' : 'Взять';?> займ</a></div>
<?
}
?>
</div></div></div>
<?php
include_once '../core/foot.php';
?>