<?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');
/*
if($udata['prava']<1){
echo'Доступ закрыт!';
include($path.'files/down.php');exit;
}
*/

$req = mysql_query("SELECT * FROM `clan` WHERE `lider` = '$log'");
$inv = mysql_query("SELECT * FROM `invite` WHERE `usr` = '$log'");
$inv=mysql_num_rows($inv);
$lider=mysql_num_rows($req);
$liders=mysql_fetch_array($req);
switch($_GET['mod']){

default:
echo'<div class="main"><div class="block_zero center"><span style="color: #9bc;"></span>';
if(empty($udata['clan'])){
echo'</div><div class="mini-line"></div><div class="block_zero center">Для того, что-бы вступить в уже существующую банду, напишите главарю банды, в которую хотите вступить<br><a href="home.php?mod=list"><span class="btn"><span class="end"><input class="label" type="submit" value="Список банд"></a></span></span></div><div class="mini-line"></div><div class="block_zero center">Хочешь быть лидером? Создай свой Банду!<br><a href="home.php?mod=new"><span class="btn"><span class="end"><input class="label" type="submit" value="Создать банду"></a></span></span></div><div class="mini-line"></div><div class="block_zero"><img src="image/icon/ok.png" alt="*"/><a href="home.php?mod=inv"> Приглашения в банду</a> ('.$inv.')';
}else{
echo'</div><div class="mini-line"></div><div class="block_zero center">Ты уже состоишь в банде!</div><div class="dot-line"></div><div class="block_zero center"><a href="home.php?mod=list"><span class="btn"><span class="end"><input class="label" type="submit" value="Рейтинг банд"></a></span></span></div><div class="mini-line"></div><div class="block_zero center">Хочешь быть лидером? Создай свою банду!';
}
echo'</div></div>';
break;

case 'list':
if ($_GET['page'] == "" || $_GET['page'] < 0 || $_GET['page'] == "0") {
$_GET['page'] = 0;
}
$next = $_GET['page'] + 1;
$back = $_GET['page'] - 1;
$num = $_GET['page'] * 10;
if($_GET['page'] == "0"){
$i = 1;
}else{
$i = ($_GET['page']*10)+1;
}
$req = mysql_query("SELECT * FROM `clan` ORDER by `exp` DESC LIMIT $num,10");
$avto=mysql_num_rows($req);
if($avto>=1){
$puslap = floor($avto/10);
While($clan = mysql_fetch_array($req))
{
if($udata['storona']==$clan['emblema']){
echo'<div class="main">';
echo'<div class="block_zero">';
//Модификация опыта на следующий уровень
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'];}
if(empty($clan['logo'])){
echo'<img class="float-left" src="image/clan/gerb/0.png" width="50" height="50" style="margin-left:1px; margin-right:10px;" alt="*">';
}else{
echo'<img class="float-left" src="image/clan/gerb/'.$clan['logo'].'" width="50" height="50" style="margin-left:1px; margin-right:10px;" alt="*">';
}
echo"<img src=\"image/clan/$clan[emblema].png\" alt=\"\"/> <a href=\"clan.php?id=$clan[id]\">$clan[name]</a>";
if($clan['set_d']==0){
echo" <img src=\"image/icon/error.png\" alt=\"\"/>";
}else{
echo" <img src=\"image/icon/ok.png\" alt=\"\"/>";
}
echo"</br><img src=\"image/icon/level.png\" alt=\"\"/> Уровень: $clan[level]</br>
<img src=\"image/icon/exp.png\" alt=\"\"/> Авторитет: $clan[exp]/$o</div><div class='dot-line'></div>";
}
}
}else{
echo'<div class="main"><div class="block_zero center">Нет банд</div><div class="dot-line"></div></div></div>';
}
echo'<div class="main"><div class="block_zero center">';
//-----НАВИГАЦИЯ-----//
if ($_GET['page'] > 0){
echo'<a href="home.php?mod=list&amp;page='.$back.'"><< Назад - |</a>';
}
if(isSet($puslap) AND $_GET['page'] < $puslap || $_GET['page'] == "" || $_GET['page'] == 0)
{
echo'<a href="home.php?mod=list&amp;page='.$next.'">| - Далее >></a>';
}
//-----КОНЕЦ НАВИГАЦИИ-----//
echo'</div><div class="dot-line"></div><div class="block_zero">';
echo"<img src=\"image/icon/error.png\" alt=\"\"/> - приватные банды<br>";
echo"<img src=\"image/icon/ok.png\" alt=\"\"/> - открытые банды";
echo'</div></div></div></div>';
break;

case 'new':
if($lider==1 OR !empty($udata['clan'])){
echo'<div class="main"><div class="block_zero center">';
echo'Вы уже находитесь в банде!</div></div>';
include($path.'files/down.php');exit;
}
if(empty($_POST['name'])){
echo'<div class="main"><div class="block_zero center">';
echo "<form action=\"home.php?mod=new\" method=\"post\">";
echo"Название банды:<br/>";
echo"<input class='text' type=\"text\" size=\"16\" name=\"name\" maxlength=\"15\"/><br/>";
echo"Описание банды:<br/>";
echo'<textarea class="text large" name="desk" rows="5"></textarea>';
echo '<span class="btn"><span class="end"><input class="label" type="submit" value="Создать"></span></span></form><span style="color: #999;">Цена: <img src="image/icon/almaz.png" alt="*"/>8000 рублей</span></div></div>';
break;
}else{
$_POST['name'] = htmlspecialchars($_POST['name']);
$_POST['desk'] = htmlspecialchars($_POST['desk']);

$req = mysql_query("SELECT `name` FROM `clan` WHERE `name` = '$_POST[name]' LIMIT 1");
$avto=mysql_num_rows($req);
if($avto==1){
echo'<div class="main"><div class="block_zero center">Данное назване банды занято!</div></div>';
include($path.'files/down.php');exit;
}
$avto=mysql_num_rows($req);
if($udata['almaz']<8000){
echo'<div class="main"><div class="block_zero center">Не хватает <img src="image/icon/almaz.png" alt="*"/> рублей!</div></div>';
include($path.'files/down.php');exit;
}
mysql_query("UPDATE `set` SET `dclan` = 'lider' WHERE `usr` = '$log'");
mysql_query("INSERT INTO `clan` SET `lider` = '$log',`name` = '$_POST[name]', `emblema`='$udata[storona]', `level`='1', `desk` = '$_POST[desk]', `money` = '0', `max` = '1000'");
mysql_query("UPDATE `users` SET `almaz` = `almaz`-'8000', `clan`='$log', `dolz`='lider' WHERE `usr` = '$log'");
echo'<div class="main"><div class="block_zero center">Банда <b>'.$_POST['name'].'</b> успешно создан!</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'logotip':
if($lider==0){
echo'<div class="main"><div class="block_zero center">Вы не лидер банды!</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>';
include($path.'files/down.php');exit;
}

if(empty($_GET['name'])){
echo'<div class="main"><div class="block_zero center">Сменить герб банды стоит 2000 <img src="image/icon/almaz.png" alt="*"/> рублей</div><div class="dot-line"></div>';
$dira = opendir ("image/clan/gerb");
while ($filea = readdir ($dira))
{
if (( $filea != ".") && ($filea != ".."))
{
$aa[]=$filea;
}
}
closedir ($dira);
$totala = count($aa);
for ($ia = 0; $ia < $totala; $ia++){
$data_namea[]=$aa[$ia];
}
foreach($data_namea as $ka=>$va){
$dat_screena[]="<img src=\"image/clan/gerb/$data_namea[$ka]\" alt=\"Лого\"/> - <a href=\"home.php?name=$data_namea[$ka]&amp;mod=logotip\">выбрать</a>";
}
$totala = count($dat_screena);
if (empty($_GET['logs'])){
$logs = 0;
}else{
$logs = $_GET['logs'];
}
if ($totala < $logs + 10){
$end = $totala;
}else{
$end = $logs + 10;
}
for ($ia = $logs; $ia < $end; $ia++){
echo"<div class='block_zero'>$dat_screena[$ia]";
echo"</div><div class='dot-line'></div>";
}
echo"<div class='block_zero center'>";
//-----НАВИГАЦИЯ-----//
if ($logs != 0){
echo'<a href="home.php?logs='.($logs - 10).'&amp;mod=logotip"><< Назад - |</a>';
}
if ($totala > $logs + 10) {
echo'<a href="home.php?logs='.($logs + 10).'&amp;mod=logotip">| - Далее >></a>';
}
//-----КОНЕЦ НАВИГАЦИИ-----//
}else{
$name = $_GET['name'];
if($udata['almaz']<2000){
echo'<div class="main"><div class="block_zero center">Не хватает рублей!</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>';
include('files/down.php');exit;
}
if(!file("image/clan/gerb/$name")){
echo'<div class="main"><div class="block_zero center">Такой эмблемы не существует!</div></div>';
include('files/down.php');exit;
}
mysql_query("UPDATE `clan` SET `logo` = '$name' WHERE `lider` = '$log'");
mysql_query("UPDATE `users` SET `almaz` = '$udata[almaz]'-'2000' WHERE `usr` = '$log'");
echo'<div class="main"><div class="block_zero center">Эмблема выбрана!</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 'toclan':
echo'<div class="main"><div class="block_zero center">';
if($udata['dolz'] == 'general' OR $udata['dolz'] == 'lider'){
$lider=1;
}
if($lider==0){
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>';
include($path.'files/down.php');exit();
}
if(empty($_POST['name']) OR empty($_POST['text'])){
echo "<form action=\"home.php?mod=toclan\" method=\"POST\">";
echo"Заключенный:<br/>";
echo"<input class='text' type=\"text\" size=\"10\" name=\"name\" maxlength=\"10\"/><br/>";
echo"Текст приглашения:<br/>";
echo'<textarea class="text large" name="text" value="Привет! Приглашаю тебя в банду!"></textarea><br><span class="btn"><span class="end"><input class="label" type="submit" value="Отправить"></span></span></form>';
}else{
$name=htmlspecialchars($_POST['name']);
$text=htmlspecialchars($_POST['text']);
$req = mysql_query("SELECT * FROM `users` WHERE `usr` = '$name'");
$avto=mysql_num_rows($req);
$inv = mysql_fetch_array($req);
if($avto=="0"){
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>';
include($path.'files/down.php');exit();
}
if($name==$log){
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>';
include($path.'files/down.php');exit();
}
if($inv['clan']==$udata['clan']){
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>';
include($path.'files/down.php');exit();
}
if($inv['storona']!==$udata['storona']){
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>';
include($path.'files/down.php');exit();
}
if(!empty($inv['clan'])){
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>';
include($path.'files/down.php');exit();
}
$time = date("H:i d.m.y");
$textt = "Пользователь $udata[usr] приглашает вас в банду, зайдите в раздел Банды->приглашения!";
mysql_query("INSERT INTO `msg_r` SET `user_from` = 'Журнал', `user_to` = '$name', `time` = '$time', `read` = 1, `mail_msg` = '$textt'");
mysql_query("INSERT INTO `invite` SET `clan` = '$udata[clan]',`usr` = '$name',`text` = '$text'");
echo"Приглашение для игрока $name отослано!<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;

case 'clanlist':
echo'<div class="main"><div class="block_zero center">';
if($lider==0){
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>';
include($path.'files/down.php');exit;
}
$req = mysql_query("SELECT * FROM `clan` WHERE `lider` = '$udata[clan]'");
$cl = mysql_fetch_array($req);
echo"<b>$cl[name]</b>:<br/>";
echo "<b>1. <a href=\"search.php?nick=$cl[lider]&amp;go=go\">$cl[lider]</a> [Лидер]</b><br/>";
$req = mysql_query("SELECT clan,usr FROM `users` where `clan`='$udata[clan]' and `usr`!='$udata[clan]' ORDER BY lvl DESC");
$avto=mysql_num_rows($req);
$i=2;
if($avto>=1){
While($clan = mysql_fetch_array($req)){
echo"$i. <a href=\"search.php?nick=$clan[usr]&amp;go=go\">$clan[usr]</a> [<a href=\"home.php?mod=outclan&amp;usr=$clan[usr]\">искл.</a>]<br/>";
$i++;
}
echo"<br/><b>Всего в банде: $avto</b><br/>";}else{
echo"<b>Пусто!</b><br/>";}
echo"<a href=\"home.php?\">Назад</a>";break;

case 'outclan':
if(empty($_GET['usr'])){
echo'Не выбран игрок!<br/>';
include('files/down.php');exit;}
$_GET['usr']=htmlspecialchars(stripslashes($_GET['usr']));
$req = mysql_query("SELECT * FROM `users` WHERE `usr` = '$_GET[usr]' LIMIT 1");
$avto = mysql_num_rows($req);
if ($avto == 1) {
$claner = mysql_fetch_array($req);
$user_clan = mysql_fetch_array(mysql_query("SELECT * FROM `clan` WHERE `lider` = '".$udata['usr']."' "));
$usdata = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `usr` = '".$_GET['usr']."' "));
$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`='".$_GET['usr']."' AND `tip`='hpall' "));
$my_bon_mpall = mysql_fetch_array(mysql_query("SELECT * FROM `clan_user_time` WHERE `user`='".$_GET['usr']."' AND `tip`='mpall' "));
$my_bon_sila = mysql_fetch_array(mysql_query("SELECT * FROM `clan_user_time` WHERE `user`='".$_GET['usr']."' AND `tip`='sila' "));
$my_bon_prot = mysql_fetch_array(mysql_query("SELECT * FROM `clan_user_time` WHERE `user`='".$_GET['usr']."' AND `tip`='prot' "));




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


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


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


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


mysql_query("UPDATE `users` SET `clan` = '',`dolz` = '',`clanexp` = '0' WHERE `usr` = '$_GET[usr]'");
$time = date("H:i d.m.y");
$text = "$log исключил вас из банды!";
mysql_query("INSERT INTO `msg_r` SET `user_from` = 'Журнал', `user_to` = '$_GET[usr]', `time` = '$time', `read` = 1, `mail_msg` = '$text'");
echo"$_GET[usr] исключён из клана!<br/>";
}else{
echo'Нет такого игрока в вашей банде!';
include($path.'files/down.php');exit;}
echo'<a href="javascript:history.go(-1)">Назад</a>';
break;


case 'vxod':
if(empty($_GET['lider'])){
echo"Не выбрана банда</a>";
}else{
$lider=htmlspecialchars(stripslashes($_GET['lider']));
$req = mysql_query("SELECT * FROM `clan` WHERE lider='$lider'");
$vxod = mysql_fetch_array($req);
echo"Вы вступили в банду $vxod[name]</a>";
mysql_query("UPDATE `users` SET `clan`='$lider' WHERE `usr` = '$log'");
$dolz='user';
mysql_query("UPDATE `users` SET `dolz`='".mysql_real_escape_string($dolz)."' WHERE `usr` = '$log'");
}
break;

case 'inv':
$req = mysql_query("SELECT * FROM `invite` WHERE `usr` = '$log'");
$avto=mysql_num_rows($req);
echo'<div class="main"><div class="block_zero center">Всего приглашений: '.$avto.'</div><div class="mini-line"></div>';
echo'<div class="menuList">';
if(empty($_GET['id'])){
if($avto>=1){
While($inv = mysql_fetch_array($req)){
$req = mysql_query("SELECT * FROM `clan` WHERE `lider` = '$inv[clan]'");
$clan = mysql_fetch_array($req);
echo'<li><a href="home.php?mod=inv&amp;id='.$inv['id'].'"><img src="image/icon/inv.png" alt="*"/>Приглашение от банды - <span style="color: #9c9;">'.$clan['name'].'</span></a></li>';
}
echo'</div></div>';
}else{
echo'<div class="main"><div class="block_zero center">Нет приглашений!</div></div>';
}
}else{
$req = mysql_query("SELECT * FROM `invite` WHERE `usr` = '$log' and `id`='$_GET[id]'");
$avto=mysql_num_rows($req);
if($avto=="0"){
echo'<div class="main"><div class="block_zero center">Нет приглашений!</div></div>';
include($path.'files/down.php');exit;
}
$inv = mysql_fetch_array($req);
$req = mysql_query("SELECT * FROM `clan` WHERE `lider` = '$inv[clan]'");
$clan = mysql_fetch_array($req);
if(empty($_GET['go'])){
echo"Отправитель: <b>$clan[name]</b><br/>";
echo"Текст: $inv[text]<br/>";
echo"<a href=\"home.php?mod=inv&amp;id=$_GET[id]&amp;go=ok\">Принять</a><br/>";
echo"<a href=\"home.php?mod=inv&amp;id=$_GET[id]&amp;go=no\">Отказаться</a><br/>";
echo"<a href=\"home.php?mod=inv\">Назад</a>";}else{
if($_GET['go']=='ok'){
if(!empty($udata['clan'])){
echo'Вы уже находитесь в банде!';
include($path.'files/down.php');exit;
}
mysql_query("DELETE FROM `invite` WHERE usr='$log' and `id`='$_GET[id]'");
mysql_query("UPDATE `users` SET `clan`='$inv[clan]' WHERE `usr` = '$log'");
$time = date("H:i d.m.y");
$text = "Заключенный $udata[usr] вступил в вашу банду!";
mysql_query("INSERT INTO `msg_r` SET `user_from` = 'Журнал', `user_to` = '$clan[lider]', `time` = '$time', `read` = 1, `mail_msg` = '$text'");
echo"Вы вступили в банду $clan[name]!<br/>";
}
elseif($_GET['go']=='no'){
mysql_query("DELETE FROM `invite` WHERE usr='$log' and `id`='$_GET[id]'");
echo"Приглашение отклонено.<br/>";
}else{
echo"Ошибка!<br/>";
}
echo"<a href=\"home.php?mod=inv\">Назад</a>";
}
}
echo'</div></div>';
break;

case 'delet':
$req = mysql_query("SELECT * FROM `clan` WHERE `lider` = '$log'");
$clan = mysql_fetch_array($req);
$clans = mysql_num_rows($req);
if($clans!==1){
echo'<div class="main"><div class="block_zero center"><img src="image/icon/error.png" alt=""/> Вы не являетесь лидером банды!</div></div>';
break;
}
if($clans==1){
echo'<div class="main"><div class="block_zero center">';
echo"Вы действительно хотите удалить банду  $clan[name] ?<br>";
echo'<a href="home.php?mod=delok"><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;
}
break;
case 'delok':
$req = mysql_query("SELECT * FROM `users` WHERE `clan` = '$log'");
$clans = mysql_num_rows($req);
if($clans!==1){
echo'<div class="main"><div class="block_zero center"><img src="image/icon/error.png" alt=""/> Исключите всех участников банды!</div></div>';
break;
}else{
$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("DELETE FROM `clan_buildings` WHERE `clan` = '".$user_clan['name']."' ");

mysql_query("DELETE FROM `clan` WHERE `lider`='$log'");
mysql_query("UPDATE `users` SET `clan` = '',`dolz` = '',`clanexp` = '0' WHERE `usr` = '$log'");
echo'<div class="main"><div class="block_zero center"><img src="image/icon/ok.png" alt=""/> Банда успешно удалена!</div></div>';
}
break;
break;
}
include($path.'files/down.php');
?>