Файл: public_html/modules/alliance/my.php
Строк: 226
<?php
$root = $_SERVER['DOCUMENT_ROOT'];
include_once ($root.'/core/base.php');
falseauth();
allianceStatus(1);
$header = "Альянс";
include_once ($root.'/core/head.php');
$allianceRanks = [null, 'Унтер-офицер', 'Мл. офицер', 'Ст. офицер', 'Генерал', 'Глава'];
$count = $db -> query("SELECT * FROM `alliance_members` WHERE `alliance` = '".$u['alliance_id']."'") -> num_rows;
if(isset($_GET['invite']))
{
$invite_id = fl($_GET['id']);
if($u['alliance_id'] == 0) redirect('/alliance', 'Вы не состоите в альянсе!');
if($u['alliance_rank'] < 4) redirect('/alliance', 'Доступ закрыт!');
$issetInvites = $db->query("SELECT * FROM `alliance_invites` WHERE `user` = '".$invite_id."' AND `alliance` = '".$u['alliance_id']."'");
if($issetInvites->num_rows > 0) redirect('/alliance', 'Вы уже отправили приглашение!');
$usInfo = $db->query("SELECT * FROM `users` WHERE `id` = '".$invite_id."'");
if($usInfo->num_rows == 0) redirect('/alliance', 'Игрок не найден!');
if($usInfo->fetch_object()->alliance_id != 0) redirect('/alliance', 'Игрок уже в альянсе!');
if($count >= $allianceMembersLimit) redirect('/alliance', 'Мест в альянсе нет!');
$db->query("INSERT INTO `alliance_invites` (`user`,`inviter`,`alliance`,`time`) VALUES ('".$invite_id."', '".$u['id']."', '".$u['alliance_id']."', '".time()."')");
loggingAllianceAction(who($u['id']).' отправил приглашение игроку '.who($invite_id).'.');
redirect('/alliance', 'Приглашение отправлено!');
}
if(isset($_GET['dissolve']))
{
if($u['alliance_rank'] != 5) redirect('/alliance/my');
if(isset($_GET['yes']))
{
$members = $db->query("SELECT * FROM `alliance_members` WHERE `alliance` = '".$u['alliance_id']."'");
$db->query("DELETE FROM `alliances` WHERE `id` = '".$u['alliance_id']."'");
while($m = $members->fetch_object())
{
$db->query("UPDATE `users` SET `alliance_id` = '0', `alliance_rank` = '0' WHERE `id` = '".$m->user."'");
$db->query("DELETE FROM `alliance_members` WHERE `id` = '".$m->id."'");
}
redirect('/alliance');
}
echo '<div class="b"><center><big>Вы действительно хотите распустить альянс?</big><br>
<a class = "btn _orange" href="/alliance/dissolve/yes">Да</a> <a class = "btn _blue" href="/alliance/my">Нет</a>
</center></div>';
}
if(isset($_GET['exit']))
{
if($u['alliance_rank'] == 5) redirect('/alliance/my', 'Вы не можете покинуть альянс, т.к. вы - глава!');
if(isset($_GET['yes']))
{
loggingAllianceAction(who($u['id']).' покинул альянс.');
$db->query("DELETE FROM `alliance_members` WHERE `alliance` = '".$u['alliance_id']."' AND `user` = '".$u['id']."'");
$db->query("UPDATE `users` SET `alliance_id` = '0', `alliance_rank` = '0' WHERE `id` = '".$u['id']."'");
redirect('/alliance');
}
echo '<div class="b"><center>Вы действительно хотите покинуть альянс?<br>
<a href="/alliance/exit/yes">Да</a> | <a href="/alliance/my">Нет</a>
</center></div>';
}
echo'
<div class="index-alliance">
<div class="clan-info">
<table>
<tr>
<td class="clan-infor">
<h4 class="info-clan-stat">Уровень<br>
<small><strong><big>'.$alliance->level.'</big></strong><small>
</h4>
</td>
<td class="clan-infor">
<img src="/images/aliance.png" width="125px" alt="">
</td>
<td class="clan-infor">
<h4 class="info-clan-stat">Опыт<br>
<small><strong><big>'.$allianceLevelProgress.'%</big></strong><small>
</h4>
</td>
<tr>
<td class="clan-infor">
<img src="/images/silver.png" width="30px" alt="гемы"><br>
<strong>'.$alliance->silver.'</strong>
</td>
<td class="clan-infor">
</td>
<td class="clan-infor">
<img src="/images/ic-gem.png" width="30px" alt="гемы"><br>
<strong>'.$alliance->gems.'</strong>
</td>
</tr>
</table><big>
<center>
'.$alliance->name.'<br>
<small>'.$alliance->description.'</small><br>
</center></big></br>
</div>
</div>
<div class = "line"></div>
';
$k_page = k_page($count,10);
$page = page($k_page);
$start = 10*$page-10;
$sql = $db -> query("SELECT * FROM `alliance_members` WHERE `alliance` = '".$u['alliance_id']."' ORDER BY `rank` DESC LIMIT $start, 10");
echo '<div class="b"><center>Участники альянса ['.$count.'/'.$allianceMembersLimit.']</center></div><div class = "line"></div>';
while($q = $sql->fetch_object())
{
echo"<div class = 'ram-two'><div class = 'rang-".$q->rank."'>";
$us_info = $db->query("SELECT * FROM `users` WHERE `id` = '".$q->user."'")->fetch_object();
echo' <a href = "/alliance/manage/'.$us_info->id.'"><img src="/images/users.png" width="35px"> '.($us_info->login).', '.$us_info->level.' ур. </a>';
echo"</div></div>";
}
echo '</div>';
$chestStatus = $db->query("SELECT * FROM `events_config` WHERE `event_name` = 'alliance_chest'")->fetch_object();
echo'<center><div class="menu"><div class="menu-link"><table>';
echo'<td class="menu-link">';
echo'<a href="/alliance/coffers"><img src="/images/all-k-min.jpg" width="35" height="35" alt=""><br> Казна</a>';
echo'</td><center><td class="menu-link">';
echo'<a href="/alliance/chest"><img src="/images/all-s-min.jpg" width="35" height="35" alt=""><br> Сундук '.(($chestStatus->status == 0) ? '<b><font color = "red">-</font></b>' : '<b><font color = "lime">['.$alliance->chest_level.'/15]</font></b>').'</a></center>';
echo'</td>';
echo'<td class="menu-link">';
echo'<a href="/alliance/chat"><img src="/images/all-c-min.jpg" width="35" height="35" alt=""><br> Чат </a>';
echo'</td></tr></table></div></div></center>';
echo'<center><div class="menu"><div class="menu-link"><table>';
echo'<td class="menu-link">';
echo'<a href="/alliance/altar"><img src="/images/altar.png" width="35" height="35" alt=""><br> Алтарь</a>';
echo'</td><td class="menu-link">';
echo'<a href="/alliance/forum/'.$alliance->id.'"><img src="/images/all-f-min.jpg" width="35" height="35" alt=""><br> Форум</a>';
echo'</td><center><td class="menu-link">';
echo'<a href="/alliance/journal"><img src="/images/all-j-min.jpg" width="35" height="35" alt=""><br> Журнал </a></center>';
echo'</td>';
echo'</tr></table></div></div></center>';
if($u['alliance_rank'] == 5){
echo'<center><div class="menu"><div class="menu-link"><table>';
echo'<td class="menu-link">';
echo'<a href="/alliance/dissolve"><img src="/images/all-o-min.jpg" width="35" height="35" alt=""><br> Распустить альянс</a>';
echo'</td></tr></table></div></div></center>';
}else{
echo'<center><div class="menu"><div class="menu-link"><table>';
echo'<td class="menu-link">';
echo'<a href="/alliance/exit"><img src="/images/all-o-min.jpg" width="35" height="35" alt=""><br> Покинуть </a>';
echo'</td></tr></table></div></div></center>';
}
if($count >= 10) echo str('/alliance/my/?', $k_page, $page);
include_once ($root.'/core/foot.php');