<?php
require_once '../core/system.php';
require_once 'sys.php';
echo only_reg();
if (isset($_GET['id']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `id` = '$get_id'"),0) == true) {
$player = mysql_fetch_assoc(mysql_query("SELECT * FROM `user` WHERE `id` = '$get_id'"));
}else{
echo playerNotFound();
}
if ($user['clan_prava'] < 3 || $user['clan_prava'] < $player['clan_prava']) {
header('Location: /');
exit();
}
if ($user['clan_id'] != $player['clan_id'] || $user['id'] == $player['id']) {
header('Location: /user/'.$player['id'].'/');
exit();
}
if (isset($_GET['rank'])) {
$rank = (num($_GET['rank'])-1);
$available_ranks = array('0','1','2','3','4');
/*
// Создаем массив существующих званий и 
// проверяем есть ли в нем указанный в GET-запросе 
// ранг функцией in_array(). Если есть то 
// изменяем ранг игрока на указанный.
*/
if ($rank > $player['clan_prava']) {
$action = 'повысил';
}
if ($rank < $player['clan_prava']) {
$action = 'понизил';
}
if (in_array($rank, $available_ranks)) {
if ($player['clan_prava'] != $rank) {
mysql_query("UPDATE `user` SET `clan_prava` = '$rank' WHERE `id` = '$get_id' LIMIT 1");
$text = '<img src="/images/icon/'.$user['storona'].'.png" /> <a href="/user/'.$user['id'].'/">'.$user['nick'].'</a> '.$action.' игрока <img src="/images/icon/'.$player['storona'].'.png" /> <a href="/user/'.$player['id'].'/">'.$player['nick'].'</a> до '.clan_prava($rank);
mysql_query("update `user` set `clan_jornal` =`clan_jornal` +1  where `id`<> '$user[id]' and `clan_id`= '".$user['clan_id']."'");
mysql_query("INSERT INTO `jr_rekrut` SET `clan_id` = '".$player['clan_id']."', `text` = '$text'");
}
header('Location: /user/'.$player['id'].'/');
exit();
}
}
$header = 'Изменить ранг';
include_once '../core/head.php';
echo '<div>
<center>
<b>Сменить звание <a href="/user/'.$player['id'].'/">'.$player['nick'].'</a></b>
<br />';
if ($user['clan_prava'] >= '4') {
echo '<a href="change_rank?id='.$player['id'].'&amp;rank=5">';
if ($player['clan_prava'] == '4'){
echo '<span class="dflt_button">';
}else{
echo '<span class="button">';
}
echo 'Лидер клана</span>
</a>
<br />
<a href="change_rank?id='.$player['id'].'&amp;rank=4">';
if ($player['clan_prava'] == '3'){
echo '<span class="dflt_button">';
}else{
echo '<span class="button">';
}
echo 'Генерал</span>
</a>
<br />';
}
echo '<a href="change_rank?id='.$player['id'].'&amp;rank=3">';
if ($player['clan_prava'] == '2'){
echo '<span class="dflt_button">';
}else{
echo '<span class="button">';
}
echo 'Офицер</span>
</a>
<br />
<a href="change_rank?id='.$player['id'].'&amp;rank=2">';
if ($player['clan_prava'] == '1'){
echo '<span class="dflt_button">';
}else{
echo '<span class="button">';
}
echo 'Боец</span>
<br />
<a href="change_rank?id='.$player['id'].'&amp;rank=1">';
if ($player['clan_prava'] == '0'){
echo '<span class="dflt_button">';
}else{
echo '<span class="button" style="font-size:9px;">';
}
echo 'Новобранец</span>
</a>
<br />
<a href="kick?id='.$player['id'].'">
<span class="button">Выгнать из клана</span>
</a>
<br />
</center>
</div>';
include_once '../core/foot.php';
?>