Файл: bs.php
Строк: 116
<?
define('PROTECTOR', 1);
include('files/db.php');
include($path.'files/auth.php');
if ($user_id==0){
header('location: index.php');exit;
}
$textl='Башни Силы';
include($path.'files/core.php');
if($udata['clan']==0)
{
header('location: game.php');exit;
}
$gi=mysql_fetch_array(mysql_query("SELECT * FROM `clan` WHERE `id`='".$udata['clan']."'"));
$magaz=mysql_fetch_array(mysql_query("SELECT * FROM `clan_bild` WHERE `clan`='".$gi['id']."' and `img`='7'"));
$bg=mysql_num_rows(mysql_query("SELECT * FROM `clan_battle_b` WHERE `clan`='".$gi['id']."'"));
$bgz=mysql_num_rows(mysql_query("SELECT * FROM `clan_battle_b` WHERE `clan`='".$gi['id']."' and `status`!='0'"));
if($bgz!=0)
{
header('location: bs_b.php');exit;
}
if(isset($_GET['create']))
{
if($gi['lider']==$udata['id'] and $magaz['lvl']>0 and $bg==0)
{
$r=rand(1000,100000);
$r=md5($gi['name'].$r);
mysql_query("INSERT INTO `clan_battle_b` SET
`id`='',
`clan`='".$gi['id']."',
`kod`='".$r."'
");
mysql_query("INSERT INTO `user_log` SET
`id`='',
`usr`='".$udata['id']."',
`text`='Заявку успешно подана.'
");
mysql_query("INSERT INTO `clan_battle_b_bs` SET
`id`='',
`b`='1',
`name`='Башня Силы',
`hp`='30000',
`ef`='sila',
`clan`='0',
`kod`='".$r."'
");
}
header('location: ?');exit;
}
if(isset($_GET['del']))
{
$bgs=mysql_fetch_array(mysql_query("SELECT * FROM `clan_battle_b` WHERE `clan`='".$gi['id']."' and `status`='0'"));
if($gi['lider']==$udata['id'])
{
mysql_query("DELETE FROM `clan_battle_b` WHERE `clan`='".$gi['id']."'");
mysql_query("DELETE FROM `clan_battle_b_bs` WHERE `clan`='".$gi['id']."'");
}
header('location: ?');exit;
}
if(isset($_GET['prn']))
{
$id=mysql_real_escape_string($_GET['prn']);
$bz_sel=mysql_query("SELECT * FROM `clan_battle_b` WHERE `status`='0' and `id`='".$id."'");
$bz_num=mysql_num_rows($bz_sel);
if($bz_num==0)
{
mysql_query("INSERT INTO `user_log` SET
`id`='',
`usr`='".$udata['id']."',
`text`='Заявка не найдена.'
");
}
else
{
$bz=mysql_fetch_array($bz_sel);
if($gi['lider']==$udata['id'] and $magaz['lvl']>0 and $bg==0 and $bz['clan']!=$gi['id'])
{
if($bz['clan']==$gi['b_enemy'])
{
mysql_query("INSERT INTO `user_log` SET
`id`='',
`usr`='".$udata['id']."',
`text`='Запрешено несколько раз подряд сражаться против одной гильдии.'
");
}
else
{
$time=time()+1200;
$close=$time+7200;
mysql_query("INSERT INTO `clan_battle_b` SET
`id`='',
`clan`='".$gi['id']."',
`status`='1',
`enemy_clan`='".$bz['clan']."',
`time`='".$time."',
`kod`='".$bz['kod']."',
`close`='".$close."'
");
mysql_query("UPDATE `clan_battle_b` SET `enemy_clan`='".$gi['id']."', `time`='".$time."', `status`='1', `close`='".$close."' WHERE `id`='".$bz['id']."'");
mysql_query("UPDATE `clan` SET `b_enemy`='".$bz['clan']."' WHERE `id`='".$gi['id']."'");
mysql_query("UPDATE `clan` SET `b_enemy`='".$gi['id']."' WHERE `id`='".$bz['clan']."'");
mysql_query("INSERT INTO `user_log` SET
`id`='',
`usr`='".$udata['id']."',
`text`='Заявка принята.'
");
}
}
}
header('location: ?');exit;
}
include($path.'files/head.php');
include($path.'files/zag.php');
echo '<div class="v3 bts brs bls b p v12">Навигация</div><div class="v4 bts brs bls bbs p">
<img src=img/main/i26.png class="menu"> <a href=game.php>главная</a> / <a href=?>гильдии</a>
</div>';
echo '<div class="v8"><div class="v3 bts brs bls b p v12">Башни Силы</div><div class="v2 bts brs bls bbs p t3">';
if($gi['lider']==$udata['id'] and $magaz['lvl']>0)
{
echo '<table width=100%>
<tr>
<td colspan=1><a href=?create><div style="background: #222266; padding: 2px; margin: 4px; border-radius: 6px" align=center>
<font color=#ffff00><b>Подать Заявку</b></font></div></a></td>
</tr>
</table>';
}
$bz_sel=mysql_query("SELECT * FROM `clan_battle_b` WHERE `status`='0'");
$bz_num=mysql_num_rows($bz_sel);
if($bz_num==0)
{
echo '<div class="v5 v8 p"><font color=#ff0000>Нет доступных заявок.</font></div>';
}
else
{
while($bz=mysql_fetch_array($bz_sel))
{
echo '<div class="v5 v8 p">
<img src=img/main/e28.png> <font color=#ff9900><b>Башни Силы</b></font> <font color=#00ff99><b>#'.$bz['id'].'</b></font><br>
<img src=img/main/e28.png> Гильдия: </td><td colspan=1>';
$users=mysql_query("SELECT * FROM `clan` WHERE `id`='".$bz['clan']."'");
$us=mysql_fetch_array($users);
echo '<a href=clans.php?id='.$us['id'].'>'.$us['name'].'</a> <img src=img/main/p10.png>'.$us['lvl'].'<br>';
if($gi['lider']==$udata['id'] and $gi['id']!=$bz['clan'] and $magaz['lvl']>0)
{
echo '<img src=img/main/e30.png> <a href=?prn='.$bz['id'].'>Принять вызов</a>';
}
if($gi['lider']==$udata['id'] and $gi['id']==$bz['clan'])
{
echo '<img src=img/main/e30.png> <a href=?del>Удалить заявку</a>';
}
echo'</div>';
}
}
echo '</div></div>';
include('files/down.php');
?>