<?php
define('PROTECTOR', 1);
include('files/path.php');
include($path.'files/db.php');
include($path.'files/auth.php');
include($path.'files/func.php');
$textl='Банда';
include($path.'files/core.php');
include($path.'files/head.php');
include($path.'files/zag.php');
include($path.'files/clanlvl.php');

if(empty($udata['clan'])){
echo'<div class="main"><div class="block_zero center">Вы не состоите в банде!</div></div>';
include($path.'files/down.php');exit;
}

$req = mysql_query("SELECT usr FROM `users` WHERE `clan`='$udata[clan]'");
$kk=mysql_num_rows($req);
$req = mysql_query("SELECT * FROM `clan` WHERE `lider`='$udata[clan]'");
$avto=mysql_num_rows($req);
if($avto==1){
$clan = mysql_fetch_array($req);
}else{
echo'<div class="main"><div class="block_zero center">Отсутствует такая банда! Обратитесь к администрации игры за помощью!</div></div>';
include($path.'files/down.php');exit;
}

switch($_GET['go']) {

default:
//Модификация опыта на следующий уровень
if($clan['level'] == 0){$o = 750000;$nlvl = $o-$clan['exp'];}
if($clan['level'] == 1){$o = 2500000;$nlvl = $o-$clan['exp'];}
if($clan['level'] == 2){$o = 4000000;$nlvl = $o-$clan['exp'];}
if($clan['level'] == 3){$o = 6000000;$nlvl = $o-$clan['exp'];}
if($clan['level'] == 4){$o = 10000000;$nlvl = $o-$clan['exp'];}
if($clan['level'] == 5){$o = 15000000;$nlvl = $o-$clan['exp'];}
if($clan['level'] == 6){$o = 21000000;$nlvl = $o-$clan['exp'];}
if($clan['level'] == 7){$o = 28000000;$nlvl = $o-$clan['exp'];}
if($clan['level'] == 8){$o = 36000000;$nlvl = $o-$clan['exp'];}
if($clan['level'] == 9){$o = 45000000;$nlvl = $o-$clan['exp'];}
if($clan['level'] == 10){$o = 100000000;$nlvl = $o-$clan['exp'];}

$reit=($clan['exp']/50000)+($kk/10)+$clan['money']/2000;
$reiting = round($reit);
$ref=rand(1000,9999);
$procent=round(($clan['exp']/$o)*100,2);
mysql_query("UPDATE `clan` SET `reiting` = '$reiting' WHERE `lider` = '$udata[clan]'");
echo'<div class="main"><div class="block_zero">';
if(empty($clan['logo'])){
echo"<a href=\"home.php?mod=logotip\">";
echo'<img class="float-left" src="image/clan/gerb/0.png" width="50" height="50" style="margin-left:1px; margin-right:10px;" alt="*">';
echo"</a>";
}else{
echo"<a href=\"home.php?mod=logotip\">";
echo'<img class="float-left" src="image/clan/gerb/'.$clan['logo'].'" width="50" height="50" style="margin-left:1px; margin-right:10px;" alt="*">';
echo"</a>";
}
echo"<img src=\"image/clan/$clan[emblema].png\" alt=\"\"/> <b>$clan[name]</b></br>
<img src=\"image/icon/level.png\" alt=\"\"/> Уровень: $clan[level]</br>
<img src=\"image/icon/exp.png\" alt=\"\"/> Авторитет: $clan[exp]/$o<font color='grey'> ($procent%)</font>";
$exp=$clan['exp']/$o*100;
echo'<div class="stat_bar"><div class="progress" style="width:'.$exp.'%"></div></div>';

echo'</div><div class="mini-line"></div><div class="block_zero">';

echo"Рейтинг: $reiting<br/>";
echo"Описание: $clan[desk]";

echo'</div><div class="mini-line"></div><div class="menuList">';

echo"<li><a href=\"clanroom.php?go=bankadd\">";
echo'<img class="float-left" src="image/clan/kazna.png" style="margin-left:1px; margin-right:10px;" alt="*">';
echo"Общак банды (<img src=\"image/icon/money.png\" alt=\"*\"/> $clan[money] <img src=\"image/icon/almaz.png\" alt=\"*\"/> $clan[almaz])</li></a>";
echo'<div class="dot-line"></div><div class="block_zero">';

echo"<li><a href='clan-buildings.php?'>";
echo'<img class="float-left" src="image/clan/building.png" style="margin-left:1px; margin-right:10px;" alt="*">';
echo"Постройки</li></a><br/>";
echo"</div>";
/*
$tip = mysql_num_rows(mysql_query("SELECT `tip` FROM `clan_buildings` WHERE `clan` = '".$clan['name']."'"));
if($t==0){
echo'<br/>';
}else{

if($t['hpall']==1){
echo'<img src="image/clan/hpall.png" width="15" height="15" alt="*">';
}
if($t==1){
echo'<img src="image/clan/mpall.png" width="15" height="15" alt="*">';
}
if($t==1){
echo'<img src="image/clan/sila.png" width="15" height="15" alt="*">';
}
if($t==1){
echo'<img src="image/clan/prot.png" width="15" height="15" alt="*">';
}
}
*/
echo'</div><div class="mini-line"></div>';

echo'<div class="menuList">';
if($clan['lider']==$log){
echo"<li><a href=\"clanroom.php?go=adm\"><img src=\"image/icon/arrow.png\" alt=\"*\"/>Управление бандой</a></li>";
echo"<li><a href=\"clanroom.php?go=rass\"><img src=\"image/icon/arrow.png\" alt=\"*\"/>Дать объяву</a></li>";
}

if($set['dclan']=='general' OR $clan['lider']==$log){
echo"<li><a href=\"home.php?mod=toclan\"><img src=\"image/icon/arrow.png\" alt=\"*\"/>Пригласить заключенного</a></li>";
}

if(!empty($clan['site'])){
echo"<li><a href=\"$clan[site]\"><img src=\"image/icon/arrow.png\" alt=\"*\"/>Сайт банды</a></li>";
}
/*
if($clan['set_m']==0){
echo"<li><a href=\"clanroom.php?go=my\">Взять денег</a></li>";
}
*/
echo"<li><a href=\"clanroom.php?go=who\"><img src=\"image/icon/arrow.png\" alt=\"*\"/>Состав банды ($kk)</a></li>";

echo"<li><a href=\"clanroom.php?go=chat\"><img src=\"image/icon/arrow.png\" alt=\"*\"/>Чат банды </a></li>";

if($udata['clan']!==$udata['usr']){
echo"<li><a href=\"clanroom.php?go=ask\"><img src=\"image/icon/arrow.png\" alt=\"*\"/>Покинуть банду</a></li>";
}
echo'</div></div>';
break;

case 'chat':
if (empty($_GET['start'])){
$start = 0;
}else{
$start = $_GET['start'];
}
$req = mysql_query("SELECT * FROM `clanchat` where `clan`='$udata[clan]' ORDER BY id DESC LIMIT $start,10");
$avto=mysql_num_rows($req);
echo"<div class='main'><div class='block_zero'>";
if($avto==0){
echo"Чат пуст";
}else{
while($chat = mysql_fetch_array($req)){
echo"<a href=\"search.php?go=go&amp;nick=$chat[usr]\">$chat[usr]</a> - $chat[msg]<br/>";
}
}
echo'</div><div class="mini-line"></div><div class="block_zero">';
echo'<form action="clanroom.php?go=add" method="POST">';
echo'<input class="text large" type="text" size="100%" name="msg" maxlength="250"><span class="btn"><span class="end"><input class="label" type="submit" value="Отправить"></span></span>';
echo'<a href="clanroom.php?go=chat"><span style="color: #999;"> Обновить</span></a>';
echo'</div><div class="mini-line"></div><div class="block_zero center">';
if ($start != 0) {
echo '<a href="clanroom.php?go=chat&amp;start='.($start - 10).'&amp;log='.$log.'&amp;pas='. htmlspecialchars($pas).'"><< Назад - |</a> ';
}
if ($avto > $start+5) {
echo ' <a href="clanroom.php?go=chat&amp;start='.($start + 10).'&amp;log='.$log.'&amp;pas='. htmlspecialchars($pas).'">| - Далее >></a>';
}
echo'</div></div>';
break;

case 'adm':
echo"<div class='main'><div class='menuList'>";
if($udata['clan'] = "$udata[usr]"){
echo"<li><a href=\"clanroom.php?go=logs\"><img src=\"image/icon/arrow.png\" alt=\"*\"/>Логи операций с общаком</a></li>
";
/*
echo"<li><a href=\"clanroom.php?go=desk\"><img src=\"image/icon/arrow.png\" alt=\"*\"/>Вывесить объявление</a></li>";
*/
//echo"<li><a href=\"clanroom.php?go=site\"><img src=\"image/icon/arrow.png\" alt=\"*\"/>Вывесить сайт клана</a></li>";
/*
if($clan['set_m']==0){
echo"<li><a href=\"clanroom.php?go=set_m\"><img src=\"image/icon/arrow.png\" alt=\"*\"/>Выкл: Взять монет </a></li>";
}else{
echo"<li><a href=\"clanroom.php?go=set_m\"><img src=\"image/icon/arrow.png\" alt=\"*\"/>Вкл: Взять монет</a></li>";
echo"<li><a href=\"clanroom.php?go=max\"><img src=\"image/icon/arrow.png\" alt=\"*\"/>Ограничение снятия серебра</a></li>";
}
*/
if($clan['set_d']==0){
echo"<li><a href=\"clanroom.php?go=set_d\"><img src=\"image/icon/arrow.png\" alt=\"*\"/>Открыть банду</a></li>";
}else{
echo"<li><a href=\"clanroom.php?go=set_d\"><img src=\"image/icon/arrow.png\" alt=\"*\"/>Закрыть банду</a></li>";
}

echo"
<li><a href=\"clanroom.php?go=dolz\"><img src=\"image/icon/arrow.png\" alt=\"*\"/>Назначить помошника</a></li>

<li><a href=\"clanroom.php?go=admin\"><img src=\"image/icon/arrow.png\" alt=\"*\"/>Список помошников</a></li>";

echo"<li><a href=\"home.php?mod=delet\"><img src=\"image/icon/arrow.png\" alt=\"*\"/>Удалить банду</a></li>";

echo"</div></div>";
}
echo '</div><div class="dot-line"></div><div class="main"><div class="block_zero"><a href="javascript:history.go(-1)"><span style="color: #999;"><< Назад</span></a></div></div></div>';
break;

case 'del':
echo'<div class="main"><div class="block_zero center">';
if($udata['clan'] == $udata['usr']){
echo"Лидер не может покинуть банду!";
echo '</div><div class="dot-line"></div><div class="main"><div class="block_zero"><a href="javascript:history.go(-1)"><span style="color: #999;"><< Назад</span></a></div></div></div>';
}else{
echo"Вы покинули банду!";

$user_clan = mysql_fetch_array(mysql_query("SELECT * FROM `clan` WHERE `lider` = '".$udata['clan']."' "));
$bhpall = mysql_fetch_array(mysql_query("SELECT * FROM `clan_buildings` WHERE `clan` = '".$user_clan['name']."' AND `tip`='hpall' "));
$bmpall = mysql_fetch_array(mysql_query("SELECT * FROM `clan_buildings` WHERE `clan` = '".$user_clan['name']."' AND `tip`='mpall' "));
$bsila = mysql_fetch_array(mysql_query("SELECT * FROM `clan_buildings` WHERE `clan` = '".$user_clan['name']."' AND `tip`='sila' "));
$bprot = mysql_fetch_array(mysql_query("SELECT * FROM `clan_buildings` WHERE `clan` = '".$user_clan['name']."' AND `tip`='prot' "));
$my_bon_hpall = mysql_fetch_array(mysql_query("SELECT * FROM `clan_user_time` WHERE `user`='".$udata['usr']."' AND `tip`='hpall' "));
$my_bon_mpall = mysql_fetch_array(mysql_query("SELECT * FROM `clan_user_time` WHERE `user`='".$udata['usr']."' AND `tip`='mpall' "));
$my_bon_sila = mysql_fetch_array(mysql_query("SELECT * FROM `clan_user_time` WHERE `user`='".$udata['usr']."' AND `tip`='sila' "));
$my_bon_prot = mysql_fetch_array(mysql_query("SELECT * FROM `clan_user_time` WHERE `user`='".$udata['usr']."' AND `tip`='prot' "));

mysql_query("UPDATE `users` SET `hpall`='".($udata['hpall']-$my_bon_hpall['bonus'])."' WHERE `usr` ='".$udata['usr']."'   ");
mysql_query("DELETE FROM `clan_user_time` WHERE `tip`='hpall' AND `user`='".$udata['usr']."' ")or die(mysql_error());

mysql_query("UPDATE `users` SET `mpall`='".($udata['mpall']-$my_bon_mpall['bonus'])."' WHERE `usr` ='".$udata['usr']."'   ");
mysql_query("DELETE FROM `clan_user_time` WHERE `tip`='mpall' AND `user`='".$udata['usr']."' ")or die(mysql_error());

mysql_query("UPDATE `users` SET `sila`='".($udata['sila']-$my_bon_sila['bonus'])."' WHERE `usr` ='".$udata['usr']."'   ");
mysql_query("DELETE FROM `clan_user_time` WHERE `tip`='sila' AND `user`='".$udata['usr']."' ")or die(mysql_error());

mysql_query("UPDATE `users` SET `prot`='".($udata['prot']-$my_bon_prot['bonus'])."' WHERE `usr` ='".$udata['usr']."'   ");
mysql_query("DELETE FROM `clan_user_time` WHERE `tip`='prot' AND `user`='".$udata['usr']."' ")or die(mysql_error());

mysql_query("UPDATE `users` SET `clan` = '',`dolz` = '',`clanexp` = '0' WHERE `usr` = '$log'");
mysql_query("UPDATE `set` SET `dclan` = '', `cid`='' WHERE `usr` = '$log'");

echo'</div></div>';
}
break;
case 'ask':
echo'<div class="main"><div class="block_zero center">';
echo"Вы действительно хотите покинуть банду  $clan[name] ?<br>";
echo'<a href="clanroom.php?go=del"><span class="btn"><span class="end"><input class="label" type="submit" value="Да"></span></span></a> <a href="clanroom.php?"><span class="btn"><span class="end"><input class="label" type="submit" value="Нет"></span></span></a>';
echo'</div></div>';
break;
/*
case 'site':
echo'<div class="main"><div class="block_zero center">';
if($udata['clan']!==$log){}
if(empty($_POST['site'])){
echo "<form action=\"clanroom.php?log=".$log."&amp;pas=".$pas."&amp;go=site\" method=\"post\">Адрес:<br/>";
echo "<input name=\"site\" maxlength=\"100\" value=\"http://\" title=\"name\"/><br/>";
echo '<input type="submit" value="Ok" /></form>';
}else{
$_POST['site']=htmlspecialchars(stripslashes($_POST['site']));
mysql_query("UPDATE `clan` SET `site` = '$_POST[site]' WHERE `lider` = '$udata[clan]'");

echo"сайт установлен!";
echo"<br/><a href=\"clanroom.php?\">Продолжить</a>";
}
break;

*/
/*
case 'desk':
echo'<div class="main"><div class="block_zero center">';

if($udata['clan']!==$log){}

if(empty($_POST['text'])){
echo "<form action=\"clanroom.php?log=".$log."&amp;pas=".$pas."&amp;go=desk\" method=\"POST\">Текст обьявления:<br/>";
echo'<textarea class="text large" name="text" rows="5"></textarea><br><span class="btn"><span class="end"><input class="label" type="submit" value="Отправить"></span></span></form>';
}else{
mysql_query("UPDATE `clan` SET `desk` = '$_POST[text]' WHERE `lider` = '$udata[clan]'");
header('Location: clanroom.php?');exit();
}
echo'</div></div>';
break;

*/
case 'rass':
echo'<div class="main"><div class="block_zero center">';
if($udata['clan']!==$log){
echo"У вас нет прав доступа!</br><a href=\"clanroom.php?\">Назад</a>";
include($path.'files/down.php');exit();
}
if(empty($_POST['txt'])){
echo "<form action='clanroom.php?go=rass' method='POST'>";
echo "Текст объявления:<br/>";
echo'<textarea class="text large" name="txt" rows="5" wrap="off"></textarea><br><span class="btn"><span class="end"><input class="label" type="submit" value="Отправить"></span></span></form>';
}else{
$time = date("H:i d.m.y");
$text = htmlspecialchars($_POST['txt']);
$req = mysql_query("SELECT * FROM `users` where `clan`='$udata[clan]' and `usr`!='$udata[clan]'");
$avto=mysql_num_rows($req);
if($avto>=1){
While($clan = mysql_fetch_array($req)){
mysql_query("INSERT INTO `msg_r` SET `user_from` = 'Объява банды', `user_to` = '$clan[usr]', `time` = '$time', `read` = 1, `mail_msg` = '$text'");
}
echo"$avto писем отправлено!";
}
}
echo'</div></div>';
break;

case 'add':
$msg=$_POST['msg'];
$msg=eregi_replace("((https?|ftp|http)://[[:alnum:]_=/-]+(\\.[[:alnum:]_=/-]+)*(/[[:alnum:]+&._=/%]*(\\?[[:alnum:]?+&_=/%]*)?)?).(ru|org|net|info|com)", "Реклама запрещена", $msg);
$msg=eregi_replace("([[:alnum:]_=/-]+(\\.[[:alnum:]_=/-]+)*(/[[:alnum:]+&._=/%]*(\\?[[:alnum:]?+&_=/%]*)?)?).(ru|su|org|net|info|com)", "Реклама запрещена", $msg);
$msg=stripslashes($msg);
$msg=htmlspecialchars($msg);
$msg=str_replace("\\","",$msg);
$msg=str_replace("/","",$msg);
$msg=str_replace("|","",$msg);
$msg=str_replace("$","",$msg);
$msg=str_replace("&","",$msg);
$msg=str_replace("<","",$msg);
$msg=str_replace(">","",$msg);
$msg=str_replace("#","",$msg);
$log=str_replace("#","",$log);
mysql_query("INSERT INTO clanchat SET usr='$log',clan='$udata[clan]',msg='$msg'");
header('Location: clanroom.php?go=chat');exit();
break;


case 'bankadd':
echo'<div class="main"><div class="block_zero center">';
if(empty($_POST['kol']) AND empty($_POST['koll'])){
echo "<form action=\"clanroom.php?log=".$log."&amp;pas=".$pas."&amp;go=bankadd\" method=\"post\">Сигареты:<br/>";
echo "<input class=\"text\" name=\"kol\" maxlength=\"20\" title=\"name\"/><br/>Рубли:<br/>";
echo "<input class=\"text\" name=\"koll\" maxlength=\"20\" title=\"name\"/><br/>";
echo '<span class="btn"><span class="end"><input class="label" type="submit" value="Пополнить"></span></span></form>';
}else{
if($_POST['kol']<=0 AND $_POST['koll']<=0){
echo'Введена слишком маленькая сумма!';
echo'</div></div>';
include($path.'files/down.php');exit();
}
if(eregi("[^0-9]",$_POST['kol'])){
echo"Вводите число, а не буквы!";
echo'</div></div>';
include($path.'files/down.php');exit();
}
if(eregi("[^0-9]",$_POST['koll'])){
echo"Вводите число, а не буквы!";
echo'</div></div>';
include($path.'files/down.php');exit();
}
if($_POST['kol']>$udata['money'] OR $_POST['koll']>$udata['almaz']){
echo"У вас нет такой суммы!";
echo'</div></div>';
include($path.'files/down.php');exit();
}
if($_POST['kol']>0){
mysql_query("INSERT INTO clanlog SET clan='$udata[clan]',msg='$log положил $_POST[kol] сигарет.', `log` = 'down', `user` = '$log',  time= '$time'");
}
if($_POST['koll']>0){
mysql_query("INSERT INTO clanlog SET clan='$udata[clan]',msg='$log положил $_POST[koll] рублей.', `log` = 'down', `user` = '$log',  time= '$time'");
}
$clan['money']=$clan['money']+$_POST['kol'];
$udata['money']=$udata['money']-$_POST['kol'];

$clan['almaz']=$clan['almaz']+$_POST['koll'];
$udata['almaz']=$udata['almaz']-$_POST['koll'];

mysql_query("UPDATE `clan` SET `money` = '$clan[money]', `almaz` = '$clan[almaz]' WHERE `lider` = '$udata[clan]'");

mysql_query("UPDATE `users` SET `money` = '$udata[money]', `almaz` = '$udata[almaz]' WHERE `usr` = '$log'");

header('Location: clanroom.php?');exit();
}
break;

/*
case 'max':
$req = mysql_query("SELECT * FROM `clan` where `lider`='$udata[clan]'");
$avto=mysql_num_rows($req);
if($udata[clan]!=$udata[usr]){echo"Доступ закрыт!";}else{
if(empty($_POST[max])){
echo "<form action=\"clanroom.php?log=".$log."&amp;pas=".$pas."&amp;go=max\" method=\"post\">Сумма:<br/>";
echo "<input name=\"max\" maxlength=\"20\" title=\"name\"/><br/>";
echo '<input type="submit" value="Ok" /></form>';
}else{
$_POST[max] = htmlspecialchars(stripslashes(addslashes($_POST['max'])));
if($_POST[max]>$clan[money]){echo'Введена слишком большая сумма .$clan[money].!';include('files/down.php'); exit;}
if(eregi("[^0-9]",$_POST[kol])){echo"Вводите число, а не буквы!"; include('files/down.php'); exit;}
mysql_query("UPDATE `clan` SET `max` = '$_POST[max]' WHERE `lider` = '$udata[clan]'");
echo"Вы ввели ограничение на $_POST[max] монет!";}}
echo"<a href=\"clanroom.php?\">Назад</a>";
break;
*/
/*
case 'my':
$dol = mysql_query("SELECT * FROM `set` where `usr`='$log'");
$dl = mysql_fetch_array($dol);
$rel = mysql_query("SELECT * FROM `limit` where `usr`='$log'");
$avol=mysql_num_rows($rel);
$rev = mysql_query("SELECT * FROM `clan` where `lider`='$udata[clan]'");
$avo=mysql_fetch_array($rel);
$req = mysql_query("SELECT * FROM `clanlog` where `user`='$log' and `log`='down'");
$avto=mysql_num_rows($req);
$my = mysql_fetch_array($req);
$time = time();
if($clan[set_m]==1 and $udata[clan]!=$log){echo"Доступ закрыт!";}else{
if(empty($_POST[kol])){
echo "<form action=\"clanroom.php?log=".$log."&amp;pas=".$pas."&amp;go=my\" method=\"post\">Сумма:<br/>";
echo "<input name=\"kol\" maxlength=\"20\" title=\"name\"/><br/>";
echo '<input type="submit" value="Ok" /></form>';
}else{
$ost = round(24-($time-$avo[clan])/3600, 2);
if($time<($avo[clan]+86500) and $dl[dclan] != 'lider'){echo"Деньги можно брать раз в сутки!Осталось $ost часов ";include('files/down.php'); exit;}
if($_POST[kol]>$clan[max]){echo"Вы привысили ограничение $clan[max] монет!";include('files/down.php'); exit;}
if(eregi("[^0-9]",$_POST[kol])){echo"Вводите число, а не буквы!"; include('files/down.php'); exit;}
if($_POST[kol]>$clan[money]){echo"У клана нет такой суммы!$clan[money]"; include('files/down.php'); exit;}
if($clan[set_m]==1){echo"Нельзя брать"; include('files/down.php'); exit;}
mysql_query("INSERT INTO clanlog SET clan='$udata[clan]',msg='$log забрал $_POST[kol] монет.', `log` = 'down', `user` = '$log',  time= '$time'");
if($avol==0){mysql_query("INSERT INTO `limit` SET `usr`='$log'");}
$clan[money]=$clan[money]-$_POST[kol];
$udata[money]=$udata[money]+$_POST[kol];

mysql_query("UPDATE `clan` SET `money` = '$clan[money]'  WHERE `lider` = '$udata[clan]' ");
mysql_query("UPDATE `users` SET `money` = '$udata[money]' WHERE `usr` = '$log'");
mysql_query("UPDATE `limit` SET `clan` = '$time' WHERE `usr` = '$log'");
echo"Вы забрали $_POST[kol] монет!";
}}
echo"<br/><a href=\"clanroom.php?\">Продолжить</a>";
break;
*/
case 'logs':
echo'<div class="main"><div class="block_zero">';
if (empty($_GET['start'])){
$start = 0;
}else{
$start = $_GET['start'];
}
$req = mysql_query("SELECT * FROM `clanlog` WHERE `clan`='$udata[clan]' ORDER BY id DESC LIMIT $start,15");
$avto=mysql_num_rows($req);
if($avto==0){
echo"Лог пуст";
}else{
while($chat = mysql_fetch_array($req))
{
echo"$chat[msg]<br/>";
}
}
echo'</div><div class="mini-line"></div>';
echo'<div class="block_zero center">';
if ($start != 0) {
echo '<a href="clanroom.php?go=logs&amp;start='.($start - 15).'&amp;log='.$log.'&amp;pas='. htmlspecialchars($pas).'&amp;go=logs"><<Назад-|</a> ';
}
if ($avto > $start+15) {
echo ' <a href="clanroom.php?go=logs&amp;start='.($start + 15).'&amp;log='.$log.'&amp;pas='. htmlspecialchars($pas).'&amp;go=logs">|-Далее>></a>';
}
echo'</div></div>';
break;

case 'who':
echo'<div class="main"><div class="block_zero">';
echo"Состав банды $clan[name]<br/>
Заключенные: $kk<br/>";

$cla = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `usr`='$clan[lider]' LIMIT 1"));

echo'</div><div class="mini-line"></div><div class="block_zero">';

if($cla['storona']=='white'){
$p=1;
}else{
$p=0;
}
$laikas = 300;
$dabar = time();
$timeout = $dabar - $laikas;
$asd = mysql_num_rows(mysql_query("SELECT `laikas`, `usr` FROM `online` WHERE `laikas` > '$timeout' AND `usr` = '$cla[usr]'"));
if($asd==0){
$gde='off';
}else{
$gde='';
}

echo"1. <img src=\"image/icon/$p$gde.png\" alt=\"*\"/><a href=\"search.php?nick=$clan[lider]&amp;go=go\"> $clan[lider]</a> <img src=\"image/icon/level.png\" alt=\"*\"/>$cla[lvl] ур, Лидер";

$w = round($cla['clanexp']/1000,1);
if($cla['clanexp'] > 1000) {
echo' - '.$w.'Авт.';
}else{
echo" - $cla[clanexp] Авт.";
}

echo'</div><div class="dot-line"></div>';

$req = mysql_query("SELECT * FROM `users` where `clan`='$clan[lider]' and `usr`!='$clan[lider]' ORDER BY dolz DESC,clanexp DESC");

//$req = mysql_query("SELECT clan,usr,lvl FROM `users` where `clan`='$clan[lider]' AND `usr`!='$clan[lider]' ORDER BY lvl DESC");
$avto=mysql_num_rows($req);
$i=2;
if($avto>=1){
While($cl = mysql_fetch_array($req))
{

if($cl['storona']=='white'){
$p=1;
}else{
$p=0;
}
$laikas = 300;
$dabar = time();
$timeout = $dabar - $laikas;
$asd = mysql_num_rows(mysql_query("SELECT `laikas`, `usr` FROM `online` WHERE `laikas` > '$timeout' AND `usr` = '$cla[usr]'"));
if($asd==0){
$gde='off';
}else{
$gde='';
}

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

echo"$i. <img src=\"image/icon/$p$gde.png\" alt=\"*\"/><a href=\"search.php?nick=$cl[usr]&amp;go=go\"> $cl[usr]</a> <img src=\"image/icon/level.png\" alt=\"*\"/>$cl[lvl] ур,";

if($cl['dolz']=='general'){
echo' пом. лидера';
}else{
echo' участник';
}

$w = round($cl['clanexp']/1000,1);
if($cl['clanexp'] > 1000) {
echo' - '.$w.'Авт.';
}else{
echo" - $cl[clanexp] Авт.";
}

if($clan['lider'] == $udata['usr'])
{
echo"<span style=\"float: right;\"><a href=\"home.php?mod=outclan&amp;usr=$cl[usr]\">искл.</a>";
}

echo'</div><div class="dot-line"></div>';
$i++;
}
}else{
echo'<div class="block_zero">';
echo"";
}

/*
$re = mysql_query("SELECT * FROM `clan` WHERE `lider` = '$udata[clan]'");
$cl = mysql_fetch_array($re);
echo "<b>1. <a href=\"search.php?nick=$cl[lider]&amp;go=go\">$cl[lider]</a> [Лидер]</b>";
$req = mysql_query("SELECT * FROM `users` where `clan`='$clan[lider]' and `usr`!='$clan[lider]' ORDER BY dolz DESC,clanexp DESC");
$avto=mysql_num_rows($req);
$clan = mysql_fetch_array($req);
$avto=$avto+1;
$i=2;
if($avto>0){
While($clan = mysql_fetch_array($req)){
echo"</br>$i. <a href=\"search.php?nick=$clan[usr]&amp;go=go\">$clan[usr]</a><small> [$clan[lvl] ур. ";
$w = round($clan['clanexp']/1000,1);
if($clan['clanexp'] > 1000) {
echo' '.$w.'K оп.]</small>';
}else{
echo"$clan[clanexp] оп.]</small>";
}
if($clan['dolz'] == 'general'){
echo" зам. главы";
}
if($cl['lider'] == $udata['usr'])
{
echo" [<a href=\"home.php?mod=outclan&amp;usr=$clan[usr]\">искл.</a>]";
}
$i++;
}
echo"<br/><b>Всего в банде: $avto</b><br/>";}else{
echo"<b>В банде нет членов</b><br/>";
}
*/
break;

/*
case 'set_m':
if($udata[clan]!==$log){}
if($clan[set_m]==0){$on=1;}else{$on=0;}
mysql_query("UPDATE `clan` SET `set_m` = '$on' WHERE `lider` = '$udata[clan]'");
echo"Изменения сохранены!<br/>";
echo"<a href=\"clanroom.php?go=adm\">Продолжить</a>";
break;

*/
case 'set_d':
if($udata['clan']!==$log){}
if($clan['set_d']==0){
$on=1;
$otv='включен';
}else{
$on=0;
$otv='отключен';
}
mysql_query("UPDATE `clan` SET `set_d` = '$on' WHERE `lider` = '$udata[clan]'");
header('Location: clanroom.php?go=adm');exit();
break;

case 'admin':
echo'<div class="main"><div class="block_zero">';
$req = mysql_query("SELECT * FROM `clan` WHERE `lider` = '$udata[clan]'");
if (mysql_num_rows($req)) {
echo 'Лидер:';
$i=1;
While($res = mysql_fetch_array($req)){
echo"$i. <b><a href=\"search.php?nick=$res[lider]&amp;go=go\"><font color='#ff5445'>$res[lider]</a></b></font><br/>";
$i++;
}
}
$req = mysql_query("SELECT * FROM `users` WHERE `dolz` = 'general' and `clan`='$udata[clan]'");
if (mysql_num_rows($req)) {
echo'Помошники:';
$i=1;
While($res = mysql_fetch_array($req)){
echo"$i. <b><a href=\"search.php?nick=$res[usr]&amp;go=go\">$res[usr]</a></b> [<a href=\"clanroom.php?go=down&nick=$res[usr]\">снять</a>]<br/>";
$i++;
}
}
echo '</div><div class="dot-line"></div><div class="main"><div class="block_zero"><a href="javascript:history.go(-1)"><span style="color: #999;"><< Назад</span></a></div></div></div>';
break;

case 'down':
echo'<div class="main"><div class="block_zero center">';
if(empty($_GET['nick'])){
echo "Игрок не выбран!";
}else{
$req = mysql_query("SELECT * FROM `users` WHERE `usr` = '$_GET[nick]' and `clan` = '$udata[clan]'");
$ite = mysql_num_rows($req);
if($ite > 0 ){
echo "Игрок $_GET[nick] снят с должности заместителя!";
mysql_query("UPDATE `users` SET `dolz` = 'user' WHERE `usr` = '$_GET[nick]'");
}else{
echo"Ошибка";
}
}
break;

case 'dolz':
echo'<div class="main"><div class="block_zero center">';
if(empty($_POST['us'])){
echo "<form action='clanroom.php?go=dolz' method='POST'>";
echo"Введите ник:<br/>
<input class='text' type=\"text\" value=\"\" size=\"20\" name=\"us\"/><br/>";
echo'<span class="btn"><span class="end"><input class="label" type="submit" value="Отправить"></span></span></form>';
}else{
$_POST['us']=htmlspecialchars(stripslashes($_POST['us']));
$req = mysql_query("SELECT * FROM `users` WHERE `usr` = '$_POST[us]' and `clan` = '$udata[clan]'");
$ite = mysql_num_rows($req);
$item = mysql_fetch_array($req);
if($ite == 0 ){
echo'Должность не назначена, игрок пока не может быть помошником! <br/>';
}else{
if($item['clan'] = $udata['clan']){
mysql_query("UPDATE `users` SET `dolz` = 'general' WHERE usr='$_POST[us]' LIMIT 1");
echo'Должность назначена! <br/>';
}else{
echo'Должность не назначена, игрок находится не в вашем клане!<br/>';
}
}
}
echo '</div><div class="dot-line"></div><div class="main"><div class="block_zero"><a href="javascript:history.go(-1)"><span style="color: #999;"><< Назад</span></a></div></div></div>';
break;
}

echo'</div></div>';
include($path.'files/down.php');
?>