Файл: public_html/modules/capture/index.php
Строк: 41
<?php
$root = $_SERVER['DOCUMENT_ROOT'];
include_once ($root.'/core/base.php');
falseauth();
$header = "Захват";
include_once ($root.'/core/head.php');
$btl = $db->query("SELECT * FROM `capture_battles` WHERE `status` = 'prepare' LIMIT 1");
if($u['capture_result'] != '')
{
echo '<div class="b">'.$u['capture_result'].'</div>';
$db->query("UPDATE `users` SET `capture_result` = '' WHERE `id` = '".$u['id']."'");
}
if($btl->num_rows == 0)
{
$btl_battle = $db->query("SELECT * FROM `capture_battles` WHERE `status` = 'battle'");
if($btl_battle->num_rows > 0)
{
$btl_battle = $btl_battle->fetch_object();
$myPlayer = $db->query("SELECT * FROM `capture_players` WHERE `user` = '".$u['id']."' AND `battle` = '".$btl_battle->id."'")->num_rows;
if($btl_battle->status == 'battle' && $myPlayer > 0) redirect('/capture/battle');
echo '<div class="index-towers"><div class = "notice_container"><div class = "gborder notice_alert alert-success">
<center>
Захват уже идёт!<br>
До окончания захвата: '.tl($btl_battle->endtime-time()).'
</center>
</div></div></div>';
}
else
{
echo '<div class="index-towers"><div class = "notice_container"><div class = "gborder notice_alert alert-success">
<center>
Запись на захват закрыта!<br>
Регистрация на событие состоится в каждые 2 часа!
</center>
</div></div></div>';
}
}
else
{
$btl = $btl->fetch_object();
$myPlayer = $db->query("SELECT * FROM `capture_players` WHERE `user` = '".$u['id']."' AND `battle` = '".$btl->id."'")->num_rows;
$side1Players = $db->query("SELECT * FROM `capture_players` WHERE `side` = '1' AND `battle` = '".$btl->id."'")->num_rows;
$side2Players = $db->query("SELECT * FROM `capture_players` WHERE `side` = '2' AND `battle` = '".$btl->id."'")->num_rows;
if(isset($_GET['enter']))
{
if($myPlayer > 0) redirect('/capture', 'Вы уже записаны на захват!');
if($btl->status == 'battle') redirect('/capture', 'Захват уже начался!');
$parameters = get_max_health($u['id'])+get_power($u['id'])+get_block($u['id']);
$side = $u['side'] == 'light' ? 1 : 2;
$db->query("INSERT INTO `capture_players` (battle, user, side) VALUES ('".$btl->id."', '".$u['id']."', '".$side."')");
$db->query("UPDATE `capture_battles` SET `parameters` = `parameters` + '".$parameters."' WHERE `id` = '".$btl->id."'");
redirect('/capture', 'Заявка подана!');
}
if(isset($_GET['leave']))
{
if($myPlayer == 0) redirect('/capture', 'Вы не подали заявку на захват!');
$parameters = get_max_health($u['id'])+get_power($u['id'])+get_block($u['id']);
$db->query("DELETE FROM `capture_players` WHERE `user` = '".$u['id']."' AND `battle` = '".$btl->id."'");
$db->query("UPDATE `capture_battles` SET `parameters` = `parameters` - '".$parameters."'");
redirect('/capture', 'Заявка отозвана!');
}
echo '<div class="index-towers"><div class = "notice_container"><div class = "gborder notice_alert alert-success">
<center>
Регистрация на событие открыта!<br>
До начала захвата: '.tl($btl->starttime-time()).'<br><br>
'.($myPlayer == 0 ? '<a href="/capture/enter"><input type="submit" value="Подать заявку"></a>' : '<a href="?" class = "btn _green">Обновить</a><br><a href="/capture/leave"><input type="submit" value="Отозвать заявку"></a>').'<br>
</center>
</div></div></div>';
}
include_once ($root.'/core/foot.php');