<?php
define('NTLCMS', 1);
include ('../system/start.php');
include ('../system/function.php');
include ('../system/antidos.php');
$page_title = 'Страница ваших ставок - клик клуба ' . strtoupper($_SERVER['HTTP_HOST']);
include ('../system/head.php');
if (!$active){
header('Location: '.URL);
$_SESSION['fail'] = 'Вы не авторизированы!';
exit;
}
echo '<div class="title"><b>'.razd.' Мои ставки</b></div>';
$sql = DB :: run() -> query("select * from `exchange` where `login` = '".$ulogin."'");
$userbet = DB :: run() -> querySingle("select count(`id`) from `exchange` where `login` = '".$ulogin."'");
if ($userbet == 0){
echo '<div class="post"><center><i class="fa fa-close fa-fw"></i> Ваших ставок на бирже нет!</center></div>';
} else {
if (isset($_GET['do'])){
$k_post = DB :: run() -> querySingle("select count(`id`) from `exchange` where `id` = '".ints($_GET['do'])."' and `login` = '".$ulogin."'");
$k_page = k_page($k_post, $onpage);
$page = page($k_page);
$start = $onpage * $page - $onpage;
$sql = DB :: run() -> query("select * from `exchange` where `id` = '".ints($_GET['do'])."' and `login` = '".$ulogin."' limit ".$start.", ".$onpage);
if ($k_post){
if (isset($_POST['yes'])){
$row = $sql -> fetch(PDO::FETCH_OBJ);
if (DB :: run() -> query("update `users` set `bank` = `bank` + '".ints($row -> credit)."' where `login` = '".$ilogin."' limit 1")){
DB :: run() -> query("delete from `exchange` where `id` = '".ints($_GET['do'])."' and `login` = '".$ilogin."' limit 1");
header('Location: '.URL.'/myrates');
} else {
echo '<div class="post"><center><i class="fa fa-check-circle fa-fw"></i> Ставка отменена!</center></div>';
}
} elseif ($_POST['no']){
header('Location: '.URL.'/myrates');
}
echo '<div class="menu"><center><form name="del_ref" action="'.URL.'/myrates/'.ints($_GET['do']).'" method="post">
Вы действительно хотите отменить ставку?<br/>
<input type="submit" name="yes" value="Да"/> <input type="submit" name="no" value="Нет"/>
</form></center></div>';
} else {
header('Location: '.URL.'/myrates');
}
}
while ($row = $sql -> fetch(PDO::FETCH_OBJ)){
echo '<div class="menu">
<i class="fa fa-dot-circle-o fa-fw"></i> Кол-во: '.coins(ints($row -> credit)).' <br/>
<i class="fa fa-dot-circle-o fa-fw"></i> Цена за 1000 кр:   '.money(ints($row -> sum)).'<br/>
<i class="fa fa-dot-circle-o fa-fw"></i> На сумму: '.money(((int) $row -> credit * $row -> sum / 1000)).' <br/>
<i class="fa fa-remove fa-fw"></i> <a href="'.URL.'/myrates/'.ints($row -> id).'">Отменить ставку</a></div>';
}
if ($k_page > 1) navigation(URL.'/myrates&', $k_page, $page);
}
echo '<div class="block"><i class="fa fa-home fa-fw"></i> <a href="'.URL.'/cabinet">В кабинет</a> | <a href="'.URL.'/exchanges">Биржа кредитов</a></div>';
include ('../system/foot.php');
?>