Файл: bs_b.php
Строк: 202
<?
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'"));
$bgz=mysql_num_rows(mysql_query("SELECT * FROM `clan_battle_b` WHERE `clan`='".$gi['id']."' and `status`!='0'"));
if($bgz==0)
{
header('location: bs.php');exit;
}
$bz=mysql_fetch_array(mysql_query("SELECT * FROM `clan_battle_b` WHERE `clan`='".$gi['id']."' and `status`!='0'"));
$enemy=mysql_fetch_array(mysql_query("SELECT * FROM `clan` WHERE `id`='".$bz['enemy_clan']."'"));
if($bz['time']<time())
{
$us1=mysql_num_rows(mysql_query("SELECT * FROM `clan_battle_b_usr` WHERE `kom`='".$bz['clan']."'"));
$us2=mysql_num_rows(mysql_query("SELECT * FROM `clan_battle_b_usr` WHERE `kom`='".$enemy['id']."'"));
if($us1==0 and $us2==0)
{
$rows21=mysql_num_rows(mysql_query("SELECT * FROM `msg_kont` WHERE `usr1`='2' and `usr2`='0'"));
if($rows21==0)
{
mysql_query("INSERT INTO `msg_kont` SET
`id`='',
`usr1`='2',
`usr2`='0',
`read`='1',
`time`='".time()."'
");
}else
{
$rows2=mysql_fetch_array(mysql_query("SELECT * FROM `msg_kont`
WHERE `usr2`='0' and `usr1`='2'"));
mysql_query("UPDATE `msg_kont` SET `read`='1', `time`='".time()."' WHERE `usr2`='0' and `usr1`='2'");
}
$rows2=mysql_fetch_array(mysql_query("SELECT * FROM `msg_kont`
WHERE `usr2`='0' and `usr1`='2'"));
$text='<font color=#ff2222>Бой БС: <a href=clans.php?id='.$gi['id'].'><font color=#ffff00>'.$gi['name'].'</font></a> VS
<a href=clans.php?id='.$enemy['id'].'><font color=#ffff00>'.$enemy['name'].'</font></a>.(Распущено.)</font>';
mysql_query("INSERT INTO `msg_dialog` SET
`id`='',
`dialog`='".$rows2['id']."',
`vhod`='1',
`time`='".time()."',
`text`='".$text."',
`usr`='2'
");
mysql_query("DELETE FROM `clan_battle_b_bs` WHERE `clan`='".$bz['clan']."'");
mysql_query("DELETE FROM `clan_battle_b_bs` WHERE `clan`='".$enemy['id']."'");
mysql_query("DELETE FROM `clan_battle_b` WHERE `id`='".$bz['id']."'");
mysql_query("DELETE FROM `clan_battle_b` WHERE `clan`='".$enemy['id']."'");
header('location: ?');exit;
}
elseif($us1!=0 and $us2==0)
{
$usst=mysql_query("SELECT * FROM `clan_battle_b_usr` WHERE `kom`='".$bz['clan']."'");
while($u1=mysql_fetch_array($usst))
{
mysql_query("INSERT INTO `user_log` SET
`id`='',
`usr`='".$u1['usr']."',
`text`='Битва распущена. Противник не явился на бой.'
");
}
$rows21=mysql_num_rows(mysql_query("SELECT * FROM `msg_kont` WHERE `usr1`='2' and `usr2`='0'"));
if($rows21==0)
{
mysql_query("INSERT INTO `msg_kont` SET
`id`='',
`usr1`='2',
`usr2`='0',
`read`='1',
`time`='".time()."'
");
}else
{
$rows2=mysql_fetch_array(mysql_query("SELECT * FROM `msg_kont`
WHERE `usr2`='0' and `usr1`='2'"));
mysql_query("UPDATE `msg_kont` SET `read`='1', `time`='".time()."' WHERE `usr2`='0' and `usr1`='2'");
}
$rows2=mysql_fetch_array(mysql_query("SELECT * FROM `msg_kont`
WHERE `usr2`='0' and `usr1`='2'"));
$text='<font color=#ff2222>Бой БС: <a href=clans.php?id='.$gi['id'].'><font color=#ffff00>'.$gi['name'].'</font></a> VS
<a href=clans.php?id='.$enemy['id'].'><font color=#ffff00>'.$enemy['name'].'</font></a>.(Распущено.)</font>';
mysql_query("INSERT INTO `msg_dialog` SET
`id`='',
`dialog`='".$rows2['id']."',
`vhod`='1',
`time`='".time()."',
`text`='".$text."',
`usr`='2'
");
mysql_query("DELETE FROM `clan_battle_b_bs` WHERE `clan`='".$bz['clan']."'");
mysql_query("DELETE FROM `clan_battle_b_usr` WHERE `kom`='".$bz['clan']."'");
mysql_query("DELETE FROM `clan_battle_b_bs` WHERE `clan`='".$enemy['id']."'");
mysql_query("DELETE FROM `clan_battle_b` WHERE `id`='".$bz['id']."'");
mysql_query("DELETE FROM `clan_battle_b` WHERE `clan`='".$enemy['id']."'");
header('location: ?');exit;
}
elseif($us1==0 and $us2!=0)
{
$usst=mysql_query("SELECT * FROM `clan_battle_b_usr` WHERE `kom`='".$enemy['id']."'");
while($u2=mysql_fetch_array($usst))
{
mysql_query("INSERT INTO `user_log` SET
`id`='',
`usr`='".$u2['usr']."',
`text`='Битва распущена. Противник не явился на бой.'
");
}
$rows21=mysql_num_rows(mysql_query("SELECT * FROM `msg_kont` WHERE `usr1`='2' and `usr2`='0'"));
if($rows21==0)
{
mysql_query("INSERT INTO `msg_kont` SET
`id`='',
`usr1`='2',
`usr2`='0',
`read`='1',
`time`='".time()."'
");
}else
{
$rows2=mysql_fetch_array(mysql_query("SELECT * FROM `msg_kont`
WHERE `usr2`='0' and `usr1`='2'"));
mysql_query("UPDATE `msg_kont` SET `read`='1', `time`='".time()."' WHERE `usr2`='0' and `usr1`='2'");
}
$rows2=mysql_fetch_array(mysql_query("SELECT * FROM `msg_kont`
WHERE `usr2`='0' and `usr1`='2'"));
$text='<font color=#ff2222>Бой БС: <a href=clans.php?id='.$gi['id'].'><font color=#ffff00>'.$gi['name'].'</font></a> VS
<a href=clans.php?id='.$enemy['id'].'><font color=#ffff00>'.$enemy['name'].'</font></a>.(Распущено.)</font>';
mysql_query("INSERT INTO `msg_dialog` SET
`id`='',
`dialog`='".$rows2['id']."',
`vhod`='1',
`time`='".time()."',
`text`='".$text."',
`usr`='2'
");
mysql_query("DELETE FROM `clan_battle_b_bs` WHERE `clan`='".$bz['clan']."'");
mysql_query("DELETE FROM `clan_battle_b_bs` WHERE `clan`='".$enemy['id']."'");
mysql_query("DELETE FROM `clan_battle_b_usr` WHERE `kom`='".$enemy['id']."'");
mysql_query("DELETE FROM `clan_battle_b` WHERE `id`='".$bz['id']."'");
mysql_query("DELETE FROM `clan_battle_b` WHERE `clan`='".$enemy['id']."'");
header('location: ?');exit;
}
}
if(isset($_GET['vst']))
{
$bu=mysql_num_rows(mysql_query("SELECT * FROM `clan_battle_b_usr` WHERE `kom`='".$gi['id']."' and `usr`='".$udata['id']."'"));
if($bu==0 and $bz['time']>time())
{
mysql_query("INSERT INTO `clan_battle_b_usr` SET
`id`='',
`usr`='".$udata['id']."',
`tip`='usr',
`kom`='".$bz['clan']."',
`hp`='".$udata['hp']."',
`sila`='".$udata['sila']."',
`arm`='".$udata['arm']."',
`kod`='".$bz['kod']."'
");
mysql_query("INSERT INTO `user_log` SET
`usr`='".$udata['id']."',
`text`='Вы успешно записались на бой.'
");
}
header('location: ?');exit;
}
if(isset($_GET['ssb']))
{
mysql_query("DELETE FROM `clan_battle_b_usr` WHERE `usr`='".$udata['id']."'");
header('location: ?');exit;
}
$bu=mysql_num_rows(mysql_query("SELECT * FROM `clan_battle_b_usr` WHERE `kom`='".$gi['id']."' and `usr`='".$udata['id']."'"));
if($bu!=0)
{
if($bz['time']<time())
{
header('location: bs_battle.php');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">';
echo '<center><font color=#ffff00>'.$gi['name'].'</font> <b>VS</b> <font color=#ff0000>'.$enemy['name'].'</font></center>';
echo '<img src=img/main/e28.png> <small><i><font color=#ff9900>Ваша задача разрушить башни противника или набрать 500 очков.</font></i></small><br>';
echo '<img src=img/main/e28.png> До боя: ';
$time=$bz['time']-time();
$h=floor($time/3600);
$m=floor(($time-($h*3600))/60);
$s=$time-($h*3600)-($m*60);
$tim=$h.':'.$m.':'.$s;
if($time>0)
{
echo '<font color=#0099ff><i>'.$tim.'</i></font><br>';
}
else
{
echo '<font color=#ff0000>В бою.</font><br>';
}
$bu=mysql_num_rows(mysql_query("SELECT * FROM `clan_battle_b_usr` WHERE `kom`='".$gi['id']."' and `usr`='".$udata['id']."'"));
if($bu==0 and $bz['time']>time())
{
echo '<img src=img/main/e30.png> <a href=?vst>Участвовать</a>';
}
else
{
$bu=mysql_num_rows(mysql_query("SELECT * FROM `clan_battle_b_usr` WHERE `kom`='".$gi['id']."' and `usr`='".$udata['id']."'"));
if($bu!=0)
{
echo '<img src=img/main/e30.png> <a href=?ssb>Сбежать</a>';
}
}
echo '</div></div>';
echo '<div class="v8"><div class="v3 bts brs bls b p v12">Участники</div><div class="v2 bts brs bls bbs p t3">';
$bz_user=mysql_query("SELECT * FROM `clan_battle_b_usr` WHERE `kom`='".$bz['clan']."' and `tip`='usr'");
while($b_usz=mysql_fetch_array($bz_user))
{
$b_users=mysql_query("SELECT * FROM `users` WHERE `id`='".$b_usz['usr']."'");
$b_us=mysql_fetch_array($b_users);
echo '<img src=img/main/c'.$b_us['klass'].'.png> <img src=img/main/r'.$b_us['rasa'].'.png>
<a href=info.php?id='.$b_us['id'].'>'.$b_us['usr'].'</a> <img src=img/main/p10.png> '.$b_us['lvl'].'<br>';
}
echo '</div></div>';
include('files/down.php');
?>