Файл: public_html/modules/dungeon/list.php
Строк: 87
<?php
$root = $_SERVER['DOCUMENT_ROOT'];
include_once ($root.'/core/base.php');
falseauth();
$header = "Подземелья";
include_once ($root.'/core/head.php');
isDungeon();
$id = fl($_GET['id']);
$dungeons = $db->query("SELECT * FROM `dungeon_battles` WHERE `leader` != '".$u['id']."' AND `dungeon` = '".$id."' AND `status` = 'prepare'");
if(isset($_GET['enter']))
{
$btlId = fl($_GET['btl']);
$btlInfo = $db->query("SELECT * FROM `dungeon_battles` WHERE `id` = '".$btlId."'");
if($btlInfo->num_rows == 0) redirect('/dungeon');
$myPlayer = $db->query("SELECT * FROM `dungeon_players` WHERE `battle` = '".$btlId."' AND `user` = '".$u['id']."'");
if($myPlayer->num_rows > 0) redirect('/dungeon');
$dungeon = $db->query("SELECT * FROM `dungeons` WHERE `id` = '".$btlInfo->fetch_object()->dungeon."'")->fetch_object();
$isLeader = $db->query("SELECT * FROM `dungeon_battles` WHERE `leader` = '".$u['id']."'")->num_rows;
$isBtl = $db->query("SELECT * FROM `dungeon_players` WHERE `user` = '".$u['id']."'")->num_rows;
$playersCount = $db->query("SELECT * FROM `dungeon_players` WHERE `battle` = '".$btlId."'")->num_rows;
if($playersCount >= 4) redirect('/dungeon', 'Лобби заполнено!');
if($isLeader > 0) redirect('/dungeon', 'Вы уже в подземелье!');
if($isBtl > 0) redirect('/dungeon', 'Вы уже в подземелье!');
if($u['dungeon_count'] <= 0) redirect('/dungeon', 'Исчерпан лимит походов в подземелье!');
if($u['level'] < $dungeon->level) redirect('/dungeon');
$db->query("INSERT INTO `dungeon_players` (`battle`,`user`,`health`) VALUES ('".$btlId."', '".$u['id']."', '"
.get_health($u['id'])."')");
redirect('/dungeon/battle/'.$btlId);
}
if($dungeons->num_rows > 0)
{
while($dung = $dungeons->fetch_object())
{
$playersCount = $db->query("SELECT * FROM `dungeon_players` WHERE `battle` = '".$dung->id."'")->num_rows;
if($playersCount < 4)
{
echo '<a class="link" href="/dungeon/info/'.$id.'/list/'.$dung->id.'/enter">
Игроков: '.$playersCount.'/4<br>
Лидер: '.name($dung->leader).'<br>
</a>
<div class="line"></div>';
}
}
}
else
{
echo '<div class="b">Нет лобби!</div>';
}
include_once ($root.'/core/foot.php');