<?php
include '../system/bd.php';
include '../system/cook.php';
include ("../system/gzip.php");
if(isset($_SESSION['auth']) && $_SESSION['auth']==1){
include '../system/head.php';
include '../system/head1.php';
$req = mysql_query("SELECT * FROM `user` WHERE `id` = '$user[id]'");
////////////////////////////
$avto=mysql_num_rows($req);
if($avto=="0"){
echo'Ошибка 1';
include 'inc/nogi.php';
exit;
}
$us = mysql_fetch_array($req);
if(empty($us[clan])){

echo' <div class="title">Ошибка</div>
<div class="empty_block item_center"> Вы не состоите в банде! </div>';
echo'<div class="block_link">';
echo"<a href='../index.php'> <img src ='../img/images/arrow.png'> Вернуться</a></div>";
include '../system/foot.php';
exit;}
/////////////

if($us[clan]!="$clans[id]"){

$req = mysql_query("SELECT * FROM `clans` where `id`='$us[clan]' or `leader`='$us[clan]' ");

$req = mysql_query("SELECT * FROM `clans` where `id`='$us[clan]' or `leader`='$us[clan]' ");

$avto=mysql_num_rows($req);
if($avto==1){
$clan1 = mysql_fetch_array($req);
$req = mysql_query("SELECT `id` FROM `user` where `clan`='$clan1[id]'");



////////////////////////////
$kk=mysql_num_rows($req);

echo ' ' ;

} 

switch($_GET[mod]){
default:


echo ' <div class="title">Клан</div>';

echo ' <div class="bor1"><div class="bor2"><div class="bor3"><div class="bor4"><div class="bor_bg item_center"> ';
echo" <b>$clan1[name], $clan1[lvl] ур </b><br>";

echo ' </div> </div> </div> </div></div>';

echo' <div class="empty_block"> ';

if (!empty($clan1[mail])){
$koment = strip_tags($clan1['mail']);
$koment = tags($koment);

echo"О банде: $koment";


}else{
echo"
О банде: Нет информации<a href=\"banda_admin.php?mod=infa\"></a>";
}
echo '<br>';


echo" Основана: ";
$d = time()-$clan1[datareg];
echo ' ('.sec2day($d).' назад)';



  $_exp = round(10/$clan_exp);

  if($_exp > 100) {
       $_exp = 100;
  
  }

echo" </br>
 Опыт: $i[exp]/
$exp_p
<font color='#999'>($_exp%)</font> ";


echo"<br> Опыт банды: 
$cl[exp] / $clan_exp $clans[clan_exp] 
$cl[clan_exp] k ($_exp%)
";




echo"<center>Характеристики:<br>";
echo"<img src='../img/icon/hp.png' alt='*'/> $clan1[hp] 0";
echo"<img src='../img/icon/attack.png' alt='*'/> $clan1[attack] ";
echo"<img src='../img/icon/def.png' alt='*'/> $clan1[def]";
echo"</center>";
echo"";
echo ' </div>';


echo' </div> ';
echo'<div class="line"></div>';
if($user[clan_prava] == 'leader'){
echo'<div class="block_link">';
echo"<a href='?mod=adm'> 
<img src ='../img/images/arrow.png'> Админка</div>";
echo'<div class="line"></div>';
}


echo'<div class="block_link">';
echo"<a href='treasury.php'> 
<img src ='../img/images/arrow.png'> Казна</div>";

echo'<div class="line"></div>';
echo'<div class="block_link">';
echo"<a href='chat.php'>
<img src ='../img/images/arrow.png'> Чат </a></div>";
echo'<div class="line"></div>';


echo'<div class="block_link">';
echo"<a href='journal.php'> <img src ='../img/images/arrow.png'> Журнал </a></div>";


echo'<div class="line"></div>';
echo'<div class="block_link">';
echo"<a href=\"exit.php?usr=$user[id]&ask\">
<img src ='../img/images/del.png'>
 Покинуть банду</a></div>";


echo ' <div class="bor1"><div class="bor2"><div class="bor3"><div class="bor4"><div class="bor_bg item_center"> ';
echo"<center>Состав банды: <img src='/pic/main/banda1.png' alt='*'/> ($kk) из ($clan1[composition])</center>";
echo ' </div> </div> </div> </div></div>';
/////////////////


echo'<center>';
if($user[clan_prava] == 'leader' ){

if(isset($_GET['up'])){
echo ' повышен ';
}}
echo'</center>';





$cop=10;
$ca=mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `clan` ='$clan1[id]' "),0);

$cp=ceil($ca/$cop);
if(isset($_GET['page']) && is_numeric($_GET['page'])){
$page = $_GET['page'];
if($_GET['page']>$cp) $page=$cp;
if($_GET['page']<1)$page=1;
}else{
$page=1;
}
$start=$page*$cop-$cop;
$dlist = 'list1';


$req = mysql_query("SELECT `clan_prava`, 
`clan`,`clan_exp`,`login`,`exp`, `id`, `rasa`,  `sex`, `storona`, `online`, `lvl` FROM `user` WHERE `clan` ='$clan1[id]' ORDER BY clan_prava  LIMIT $start, $cop ");
////////////////////////////




$avto=mysql_num_rows($req);
if($avto>=1){

While($us1 = mysql_fetch_array($req))
{

echo '<div class="empty_block">';

echo"
<a href='../users.php?id=$us1[id]'>";
$d = time()-7000;
if($us1[online] < $d) { 
echo"<img src='../img/user/icons/".$us1[storona]."_".$us1[rasa]."_off.png'>"; 
}else{
echo"<img src='../img/user/icons/".$us1[storona]."_".$us1[rasa].".png'>";
}

echo "$us1[login] </a>";
 
if($us1[clan_prava] == leader){
echo " <font color=#32CD32>Лидер</font>";
}
if($us1[clan_prava] == deputy){
echo " <font color=#32CD32>Заместитель</font>";
}
if($us1[clan_prava] == squaddie){
echo " <font color=#32CD32>Рядовой</font>";
}
if($us1[clan_prava] == rookie){
echo " <font color=#32CD32>Новобранец</font>";
}
echo " $us1[clan_exp] exp
<img src ='../img/icon/exp.png'> ";



if ($us1[clan_prava] == 'leader'){
echo'';
}else{
echo" <a href='prava.php?mod=up&usr=".$us1[id]."'>
<img src ='../img/icon/up.png'> </a>";
echo" <a href='prava.php?mod=down&usr=".$us1[id]."'>
<img src ='../img/icon/down.png'> </a>";
echo" <a href='delpers.php?mod=delpers&usr=".$us1[id]."'> <img src='../img/images/del.png'> </a>";

}
echo ' </div><div class="line"> </div>';
}


echo '
<div class="empty_block top pagi item_center">';

if($page-1>0){

echo '<a href="?&page='.($page-1).'">&lt;</a> ';

}

if($page-1>0){

echo '<a href="?&page='.($page-1).'">'.($page-1).'</a> ';

}

echo '<b>'.$page.'</b>';

if($page+1<=$cp){

echo ' <a href="?&page='.($page+1).'">'.($page+1).'</a>';

}

if($page+1<=$cp){

echo ' <a href="?&page='.($page+1).'">&gt;</a>';

}
echo "</div>";

}else{
echo "<img src='/pic/main/!.png' alt='*'/> Нет игроков.";
}break;

case 'adm':
if($user[clan_prava] == 'leader'){
echo' <div class="title">Админка</div>';

echo'<div class="block_link">';
echo"<a href='invite.php'> 
<img src ='../img/images/arrow.png'>
Заявки</div>";
echo'<div class="line"></div>';
///
echo'<div class="block_link">';
echo"<a href='mail.php'> 
<img src ='../img/images/arrow.png'>
Рассылка</div>";
echo'<div class="line"></div>';
///
echo'<div class="block_link">';
echo"<a href='delete.php'> 
<img src ='../img/images/arrow.png'>
Распустить клан</div>";
echo'<div class="line"></div>';
echo'<div class="block_link">';
echo"<a href='description.php'> 
<img src ='../img/images/arrow.png'>
Изменить описание</div>";
}else{
header ("Location: ../error.php");
}
break;
               ///////
case '1':
mysql_query("UPDATE `user` SET `clan_prava` = 'leader'
 WHERE `id` = '$us1[id]'");
header ("Location: clan.php");exit;
break;
}
}else{
echo"Ошибка 3";
include '../system/foot.php';
exit;}

//////////////////

}else{
header ("Location: index.php"); exit;
}
include '../system/foot.php';
?>
