Файл: public_html/modules/panel/alliances.php
Строк: 127
<?php
include_once ('../../core/base.php');
$header = 'Редактирование альянса';
include_once ('../../core/head.php');
falseauth();
adm();
switch($_GET['case'])
{
case 'edit':
$id = fl($_GET['id']);
$alliance = $db->query("SELECT * FROM `alliances` WHERE `id` = '".$id."'")->fetch_object();
$levels = $db->query("SELECT * FROM `alliance_levels`");
if(isset($_GET['edit']))
{
$name = fl($_POST['name']);
$desc = fl($_POST['desc']);
$level = fl($_POST['level']);
$gems = fl($_POST['gems']);
$silver = fl($_POST['silver']);
if($u['admin'] < 3) redirect('/');
$db->query("UPDATE `alliances` SET `name` = '".$name."', `description` = '".$desc."', `level` = '".$level
."', `gems` = '".$gems."', `silver` = '".$silver."' WHERE `id` = '".$id."'");
redirect('/access/alliances', 'Альянс изменён!');
}
if(isset($_GET['delete']))
{
if(isset($_GET['yes']))
{
$players = $db->query("SELECT * FROM `alliance_members` WHERE `alliance` = '".$id."'");
while($pl = $players->fetch_object())
{
$db->query("UPDATE `users` SET `alliance_id` = '0', `alliance_rank` = '0' WHERE `id` = '".$pl->user."'");
}
$db->query("DELETE FROM `alliance_members` WHERE `alliance` = '".$id."'");
$db->query("DELETE FROM `alliance_journal` WHERE `alliance` = '".$id."'");
$db->query("DELETE FROM `alliance_forum_sections` WHERE `alliance` = '".$id."'");
$db->query("DELETE FROM `alliance_invites` WHERE `alliance` = '".$id."'");
$db->query("DELETE FROM `alliances` WHERE `id` = '".$id."'");
redirect('/access/alliances', 'Альянс удалён!');
}
echo '<div class = "ram-t">
<div class = "b">
<font color="white">
<center>
Вы действительно хотите удалить альянс "'.$alliance->name.'"?<br><br>
<a href="/access/alliances/'.$id.'/edit/delete/yes" class = "btn _green">Да</a>
<a href="/access/alliances/'.$id.'/edit" class = "btn _orange">Нет</a>
</center>
</font>
</div>
</div>';
}
echo '<div class="b">
<form action="/access/alliances/'.$id.'/edit/yes" method="post">
Название:<br>
<input type="text" name="name" value="'.$alliance->name.'" required><br>
Описание:<br>
<input type="text" name="desc" value="'.$alliance->description.'" required><br>
Уровень:<br>
<select name="level">';
while($l = $levels->fetch_object())
{
if($l->level == $alliance->level) echo '<option value="'.$l->level.'" selected>'.$l->level.' ур.</option>';
else echo '<option value="'.$l->level.'">'.$l->level.' ур.</option>';
}
echo '</select><br>
Гемы:<br>
<input type="text" name="gems" value="'.$alliance->gems.'" required><br>
Серебро:<br>
<input type="text" name="silver" value="'.$alliance->silver.'" required><br>
<input type="submit" name="yes" value="Редактировать">
</form>
</div>';
echo '<a class="link" href="/access/alliances/'.$id.'/edit/leader">Сменить лидера</a>';
echo '<a class="link" href="/access/alliances/'.$id.'/edit/delete">Удалить альянс</a>';
break;
case 'leader':
$id = fl($_GET['id']);
$alliance = $db->query("SELECT * FROM `alliances` WHERE `id` = '".$id."'")->fetch_object();
if(isset($_GET['change']))
{
$login = fl($_POST['login']);
$usInfo = $db->query("SELECT * FROM `users` WHERE `login` = '".$login."'");
if($usInfo->num_rows == 0) redirect('/access/alliances/'.$id.'/edit');
$usInfo = $usInfo->fetch_object();
if($usInfo->alliance_id != $id) redirect('/access/alliances/'.$id.'/edit', 'Игрок не состоит в этом альянсе!');
$db->query("UPDATE `users` SET `alliance_rank` = '5' WHERE `id` = '".$usInfo->id."'");
$db->query("UPDATE `alliance_members` SET `rank` = '5' WHERE `user` = '".$usInfo->id."' AND `alliance` = '".$id."'");
$db->query("UPDATE `alliance_members` SET `rank` = '4' WHERE `user` = '".$alliance->leader."' AND `alliance` = '".$id."'");
$db->query("UPDATE `users` SET `alliance_rank` = '4' WHERE `id` = '".$alliance->leader."'");
$db->query("UPDATE `alliances` SET `leader` = '".$usInfo->id."' WHERE `id` = '".$id."'");
redirect('/access/alliances/'.$id.'/edit');
}
echo '<div class="b">
<form action="/access/alliances/'.$id.'/edit/leader/yes" method="post">
Текущий лидер: '.who($alliance->leader).'<br>
Ник нового лидера:<br>
<input type="text" name="login" required><br>
<input type="submit" name="yes" value="Сменить лидера">
</form>
</div>';
break;
default:
$alliances = $db->query("SELECT * FROM `alliances`");
if($alliances->num_rows > 0)
{
while($all = $alliances->fetch_object())
{
echo '<a href="/access/alliances/'.$all->id.'/edit" class="link">'.$all->name.'</a>
<div class="line"></div>';
}
}
break;
}
include_once ('../../core/foot.php');
?>