Файл: public_html/modules/alliance/invites.php
Строк: 130
<?php
$root = $_SERVER['DOCUMENT_ROOT'];
include_once ($root.'/core/base.php');
falseauth();
allianceStatus(0);
$header = "Приглашения в альянсы";
include_once ($root.'/core/head.php');
if(isset($_GET['accept']))
{
$invite_id = fl($_GET['invite_id']);
$inviteInfo = $db->query("SELECT * FROM `alliance_invites` WHERE `id` = '".$invite_id."'");
if($inviteInfo->num_rows == 0) redirect('/alliance/invites');
$inviteInfo = $inviteInfo->fetch_object();
if($inviteInfo->user != $u['id']) redirect('/alliance/invites');
if($u['alliance_id'] != 0) redirect('/alliance/my');
if(allianceInfo($inviteInfo->alliance, 'id') == 'error') redirect('/alliance/invites');
$db->query("UPDATE `users` SET `alliance_id` = '".$inviteInfo->alliance."', `alliance_rank` = '1' WHERE `id` = '".$u['id']."'");
$db->query("INSERT INTO `alliance_members` (alliance, user, rank, exp, gems, silver, addtime) VALUES ('".$inviteInfo->alliance."', '".$u['id']."', '1', '0', '0', '0', '".time()."')");
$db->query("DELETE FROM `alliance_invites` WHERE `user` = '".$u['id']."'");
loggingAllianceAction(who($u['id']).' вступил в альянс.');
redirect('/alliance/my');
}
if(isset($_GET['decline']))
{
$invite_id = fl($_GET['invite_id']);
$inviteInfo = $db->query("SELECT * FROM `alliance_invites` WHERE `id` = '".$invite_id."'");
if($inviteInfo->num_rows == 0) redirect('/alliance/invites');
$inviteInfo = $inviteInfo->fetch_object();
if($inviteInfo->user != $u['id']) redirect('/alliance/invites');
if(allianceInfo($inviteInfo->alliance, 'id') == 'error') redirect('/alliance/invites');
$db->query("DELETE FROM `alliance_invites` WHERE `id` = '".$invite_id."'");
redirect('/alliance/invites');
}
$count = $db -> query("SELECT * FROM `alliance_invites` WHERE `user` = '".$u['id']."'") -> num_rows;
$k_page = k_page($count,10);
$page = page($k_page);
$start = 10*$page-10;
$sql = $db -> query("SELECT * FROM `alliance_invites` WHERE `user` = '".$u['id']."' ORDER BY `time` LIMIT $start, 10");
while($q = $sql->fetch_object())
{
$count = $db -> query("SELECT * FROM `alliance_members` WHERE `alliance` = '".$q->alliance."'") -> num_rows;
$limit = 8+allianceInfo($q->alliance, 'level')*2+allianceInfo($q->alliance, 'altar_level');
if($count >= $limit)
{
$db->query("DELETE FROM `alliance_invites` WHERE `alliance` = '".$q->alliance."' AND `user` = '".$u['id']."'");
redirect('/alliance/invites');
}
echo '<div class="b">
'.who($q->inviter).' приглашает вас в альянс <a href="/alliance/info/'.$q->alliance.'">"'.allianceInfo($q->alliance, "name").'"</a>!<br>
<a href="/alliance/invites/'.$q->id.'/accept">Принять</a> | <a href="/alliance/invites/'.$q->id.'/decline">Отказаться</a>
</div>';
}
if($count == 0) echo '<div class="b">Нет приглашений!</div>';
if($count >= 10) echo str('/alliance/invites/?', $k_page, $page);
include_once ($root.'/core/foot.php');