Файл: public_html/modules/capture/battle.php
Строк: 29
<?php
$root = $_SERVER['DOCUMENT_ROOT'];
include_once ($root.'/core/base.php');
falseauth();
$header = "Захват";
include_once ($root.'/core/head.php');
$btl = $db->query("SELECT * FROM `capture_battles` WHERE `status` = 'battle' LIMIT 1");
if($btl->num_rows == 0) redirect('/capture');
$btl = $btl->fetch_object();
$myPlayer = $db->query("SELECT * FROM `capture_players` WHERE `user` = '".$u['id']."' AND `battle` = '".$btl_battle->id."'")->fetch_object();
captureResult($btl->id);
if(isset($_GET['attack']))
{
if($btl->tower_health > 0)
{
$damage = getDamage(get_power($u['id']),0);
$logMsg = who($u['id']).' нанёс башне '.$damage.' урона.';
if($u['side'] == 'light') $side = 'side1_damage';
else $side = 'side2_damage';
$db->query("UPDATE `capture_battles` SET `$side` = `$side` + '".$damage."', `tower_health` = `tower_health` - '".$damage."' WHERE `id` = '".$btl->id."'");
$db->query("UPDATE `capture_players` SET `damage` = `damage` + '".$damage."' WHERE `user` = '".$u['id']."' AND `battle` = '".$btl->id."'");
$db->query("INSERT INTO `battle_logs` (type, battle, msg, time) VALUES ('capture', '".$btl->id."', '".$logMsg."', '".time()."')");
}
redirect('/capture/battle');
}
$progressHealth = round(($btl->tower_health*100)/($btl->parameters*100));
echo '
<div class="b">
<table width="100%">
<tr>
<td width="55px" valign="top">
<img width="50px" src="/images/towers.png"/>
</td>
<td valign="top">
<big> <font color = "white">Атакующая башня</font></big>
<div class="txt">
<img src="/images/health.png" width="30px"> '.$btl->tower_health.'
</div> ';
echo" <div style='height: 4px; border: 1px solid #000; background: #171410; position:relative; border-radius: 10px'>
<div style='height: 4px;background: #CD5C35; width:".$progressHealth."%; max-width:100%; position: absolute; left: 0px; top: 0px; border-radius: 10px; border-bottom-right-radius: 10px;border-top-right-radius: 10px;'>
</td>
</tr>
</table> </br>
";
echo '
<center>
<a href="?attack"><input type="submit" value="Атаковать башню"></a>
</center>
</div>';
$log = $db->query("SELECT * FROM `battle_logs` WHERE `battle` = '".$btl->id."' AND `type` = 'capture' ORDER BY `time` DESC LIMIT 10");
echo'<div class = "b"><center>До окончания: '.tl($btl->endtime-time()).'</center></div>';
echo '<div class="notice_container"><div class = "gborder notice_alert alert-success">';
while($l = $log->fetch_object())
{
echo $l->msg.'<br>';
}
echo '</div></div>';
include_once ($root.'/core/foot.php');