<?php
	
	require_once '../includes/start.php';
	require_once '../includes/function.php';
	require_once '../includes/header1.php';
		 if($game==0 OR $level==0 OR $ban!=0){
   		echo "<title>Доступ закрыт!!!</title>";
	 	echo "<script type=\"text/javascript\">createPopup().show( 0, 0, 0, 0, 0 );</script>";
	 	echo "<body oncontextmenu=\"return false;\"><body onselectstart='return false' oncopy='return false'><body onselectstart=\"return false\" oncopy=\"return false\"><body onload=\"digitalWatch()\">";
		echo '<div class="blok3"><img src="/images/errors.png" width="200px"/></div><div class="blok3"><b>Вы не авторизованный или заблокированный пользователь или вы не достигли условий для доступа на страницу!!!</b><br/><a href="/?sign_in=1"><font color="#4EEE94"><b>Авторизуйтесь</font></a></b> или <a href="/reg.php"><font color="#4EEE94"><b>Зарегистрируйтесь</b></font></a></div>';
   }else{
	switch ($act) {
	default:
	echo "<title>Сражения</title>"; 
	echo "<script type=\"text/javascript\">createPopup().show( 0, 0, 0, 0, 0 );</script>";
	echo "<body oncontextmenu=\"return false;\"><body onselectstart='return false' oncopy='return false'><body onselectstart=\"return false\" oncopy=\"return false\"><body onload=\"digitalWatch()\">";
	echo '<div class="razd"></div>';
	echo '<div class="top-nav1"><font color="#4EEE94"><b>Сражения</b></font> | <b><a href="?act=lost">Общие потери</b></a></div>';
	echo '<div class="razd"></div>';
			$count = mysql_result(mysql_query("SELECT COUNT(*) FROM `log_battle` WHERE `uid`='".$use_id."';"), 0);
			$PAGINGS = new PAGINGS(1, "SELECT * FROM `log_battle` WHERE `uid`='".$use_id."' ORDER BY `id` DESC");
			if($PAGINGS->count_get > 0)
			{
				while($row = mysql_fetch_array($PAGINGS->get))
				{
				echo '<div class="cont">';
				if($row['result']==1)echo '<span class="green">Ваш отряд '.rasa($row['rasa1']).' <span class="'.crasa($row['rasa1']).'">'.$row['name1'].'</span> нанес поражение отряду  '.rasa($row['rasa2']).' <span class="'.crasa($row['rasa2']).'">'.$row['name2'].'</span></span>';
				if($row['result']==2)echo '<span class="red">Отряд '.rasa($row['rasa2']).' <span class="'.crasa($row['rasa2']).'">'.$row['name2'].'</span> нанес поражение вашему отряду '.rasa($row['rasa1']).' <span class="'.crasa($row['rasa1']).'">'.$row['name1'].'</span></span>';

		echo '</div>';
		echo '<div class="ch">Ваши потери:</div><div class="blok">';
		
		if($row['u1']!=0)echo ''.rasa($row['rasa1']).' '.units(1, $row['rasa1']).': '.$row['u1'].' [<span class="green">-'.$row['d1'].'</span>]<br/>';
		if($row['u2']!=0)echo ''.rasa($row['rasa1']).' '.units(2, $row['rasa1']).': '.$row['u2'].' [<span class="green">-'.$row['d2'].'</span>]<br/>';
		if($row['u3']!=0)echo ''.rasa($row['rasa1']).' '.units(3, $row['rasa1']).': '.$row['u3'].' [<span class="green">-'.$row['d3'].'</span>]<br/>';
		if($row['u4']!=0)echo ''.rasa($row['rasa1']).' '.units(4, $row['rasa1']).': '.$row['u4'].' [<span class="green">-'.$row['d4'].'</span>]<br/>';
		if($row['u5']!=0)echo ''.rasa($row['rasa1']).' '.units(5, $row['rasa1']).': '.$row['u5'].' [<span class="green">-'.$row['d5'].'</span>]<br/>';
		if($row['u6']!=0)echo ''.rasa($row['rasa1']).' '.units(6, $row['rasa1']).': '.$row['u6'].' [<span class="green">-'.$row['d6'].'</span>]<br/>';
		if($row['u7']!=0)echo ''.rasa($row['rasa1']).' '.units(7, $row['rasa1']).': '.$row['u7'].' [<span class="green">-'.$row['d7'].'</span>]<br/>';
		if($row['u8']!=0)echo ''.rasa($row['rasa1']).' '.units(8, $row['rasa1']).': '.$row['u8'].' [<span class="green">-'.$row['d8'].'</span>]<br/>';
		if($row['u9']!=0)echo ''.rasa($row['rasa1']).' '.units(9, $row['rasa1']).': '.$row['u9'].' [<span class="green">-'.$row['d9'].'</span>]<br/>';
		if($row['u10']!=0)echo ''.rasa($row['rasa1']).' '.units(10, $row['rasa1']).': '.$row['u10'].' [<span class="green">-'.$row['d10'].'</span>]<br/>';
		if($row['u11']!=0)echo ''.rasa($row['rasa1']).' '.units(11, $row['rasa1']).': '.$row['u11'].' [<span class="green">-'.$row['d11'].'</span>]<br/>';
		if($row['u12']!=0)echo ''.rasa($row['rasa1']).' '.units(12, $row['rasa1']).': '.$row['u12'].' [<span class="green">-'.$row['d12'].'</span>]<br/>';
		echo '</div>';
		$q = mysql_query("SELECT * FROM `log_battle` WHERE `aid2`='".$row['aid1']."' AND `aid1`='".$row['aid2']."' AND `time`='".$row['time']."'");
		$f = mysql_fetch_array($q);
		echo '<div class="top">Потери противника:</div><div class="conts">';
		
		if($f['u1']!=0)echo ''.rasa($f['rasa1']).' '.units(1, $f['rasa1']).': '.$f['u1'].' [<span class="green">-'.$f['d1'].'</span>]<br/>';
		if($f['u2']!=0)echo ''.rasa($f['rasa1']).' '.units(2, $f['rasa1']).': '.$f['u2'].' [<span class="green">-'.$f['d2'].'</span>]<br/>';
		if($f['u3']!=0)echo ''.rasa($f['rasa1']).' '.units(3, $f['rasa1']).': '.$f['u3'].' [<span class="green">-'.$f['d3'].'</span>]<br/>';
		if($f['u4']!=0)echo ''.rasa($f['rasa1']).' '.units(4, $f['rasa1']).': '.$f['u4'].' [<span class="green">-'.$f['d4'].'</span>]<br/>';
		if($f['u5']!=0)echo ''.rasa($f['rasa1']).' '.units(5, $f['rasa1']).': '.$f['u5'].' [<span class="green">-'.$f['d5'].'</span>]<br/>';
		if($f['u6']!=0)echo ''.rasa($f['rasa1']).' '.units(6, $f['rasa1']).': '.$f['u6'].' [<span class="green">-'.$f['d6'].'</span>]<br/>';
		if($f['u7']!=0)echo ''.rasa($f['rasa1']).' '.units(7, $f['rasa1']).': '.$f['u7'].' [<span class="green">-'.$f['d7'].'</span>]<br/>';
		if($f['u8']!=0)echo ''.rasa($f['rasa1']).' '.units(8, $f['rasa1']).': '.$f['u8'].' [<span class="green">-'.$f['d8'].'</span>]<br/>';
		if($f['u9']!=0)echo ''.rasa($f['rasa1']).' '.units(9, $f['rasa1']).': '.$f['u9'].' [<span class="green">-'.$f['d9'].'</span>]<br/>';
		if($f['u10']!=0)echo ''.rasa($f['rasa1']).' '.units(10, $f['rasa1']).': '.$f['u10'].' [<span class="green">-'.$f['d10'].'</span>]<br/>';
		if($f['u11']!=0)echo ''.rasa($f['rasa1']).' '.units(11, $f['rasa1']).': '.$f['u11'].' [<span class="green">-'.$f['d11'].'</span>]<br/>';
		if($f['u12']!=0)echo ''.rasa($f['rasa1']).' '.units(12, $f['rasa1']).': '.$f['u12'].' [<span class="green">-'.$f['d12'].'</span>]<br/>';
		echo '</div>';
		
					if($row['proch']==0)mysql_query("UPDATE `log_battle` SET `proch`='1' WHERE `id`='".$row['id']."'");
					++$i;
				}
				if($count>1)echo $PAGINGS->Links('?'); // вывод меню навигации в аргументе указывать адрес страницы 
			}
			else
			{
				echo '<center><div class="window"><b>Сражений небыло!</b></div></center>';
			}
	break;
	case 'lost':
	echo "<title>Общие потери</title>"; 
	echo "<script type=\"text/javascript\">createPopup().show( 0, 0, 0, 0, 0 );</script>";
	echo "<body oncontextmenu=\"return false;\"><body onselectstart='return false' oncopy='return false'><body onselectstart=\"return false\" oncopy=\"return false\"><body onload=\"digitalWatch()\">";
	echo '<div class="razd"></div>';
	echo '<div class="top-nav1"><a href="log_battle.php"><b>Сражения</b></a> | <font color="#4EEE94"><b>Общие потери</b></font></div>';
	echo '<div class="razd"></div>';
	echo '<center><div class="window">';
$count1 = mysql_result(mysql_query("SELECT SUM(d1) FROM `log_battle` WHERE `uid`='".$use_id."';"), 0);
$count2 = mysql_result(mysql_query("SELECT SUM(d2) FROM `log_battle` WHERE `uid`='".$use_id."';"), 0);
$count3 = mysql_result(mysql_query("SELECT SUM(d3) FROM `log_battle` WHERE `uid`='".$use_id."';"), 0);
$count4 = mysql_result(mysql_query("SELECT SUM(d4) FROM `log_battle` WHERE `uid`='".$use_id."';"), 0);
$count5 = mysql_result(mysql_query("SELECT SUM(d5) FROM `log_battle` WHERE `uid`='".$use_id."';"), 0);
$count6 = mysql_result(mysql_query("SELECT SUM(d6) FROM `log_battle` WHERE `uid`='".$use_id."';"), 0);
$count7 = mysql_result(mysql_query("SELECT SUM(d7) FROM `log_battle` WHERE `uid`='".$use_id."';"), 0);
$count8 = mysql_result(mysql_query("SELECT SUM(d8) FROM `log_battle` WHERE `uid`='".$use_id."';"), 0);
$count9 = mysql_result(mysql_query("SELECT SUM(d9) FROM `log_battle` WHERE `uid`='".$use_id."';"), 0);
$count10 = mysql_result(mysql_query("SELECT SUM(d10) FROM `log_battle` WHERE `uid`='".$use_id."';"), 0);
$count11 = mysql_result(mysql_query("SELECT SUM(d11) FROM `log_battle` WHERE `uid`='".$use_id."';"), 0);
$count12 = mysql_result(mysql_query("SELECT SUM(d12) FROM `log_battle` WHERE `uid`='".$use_id."';"), 0);
$count=$count1+$count2+$count3+$count4+$count5+$count6+$count7+$count8+$count9+$count10+$count11+$count12;
		if($count1!=0)echo ''.rasa($rasa).' '.units(1, $rasa).': '.$count1.'<br/>';
		if($count2!=0)echo ''.rasa($rasa).' '.units(2, $rasa).': '.$count2.'<br/>';
		if($count3!=0)echo ''.rasa($rasa).' '.units(3, $rasa).': '.$count3.'<br/>';
		if($count4!=0)echo ''.rasa($rasa).' '.units(4, $rasa).': '.$count4.'<br/>';
		if($count5!=0)echo ''.rasa($rasa).' '.units(5, $rasa).': '.$count5.'<br/>';
		if($count6!=0)echo ''.rasa($rasa).' '.units(6, $rasa).': '.$count6.'<br/>';
		if($count7!=0)echo ''.rasa($rasa).' '.units(7, $rasa).': '.$count7.'<br/>';
		if($count8!=0)echo ''.rasa($rasa).' '.units(8, $rasa).': '.$count8.'<br/>';
		if($count9!=0)echo ''.rasa($rasa).' '.units(9, $rasa).': '.$count9.'<br/>';
		if($count10!=0)echo ''.rasa($rasa).' '.units(10, $rasa).': '.$count10.'<br/>';
		if($count11!=0)echo ''.rasa($rasa).' '.units(11, $rasa).': '.$count11.'<br/>';
		if($count12!=0)echo ''.rasa($rasa).' '.units(12, $rasa).': '.$count12.'<br/>';
		if($count==0)echo '<b>Нет потерь...</b>';
		echo '</div></center>';
	}
}
	echo '<div class="razd"></div>';
	echo '<center><div class="blok2"><a href="../"><b>На Главную</b></a></div></center>';
	echo '<div class="razd"></div>';
	require_once '../includes/footer1.php';
?>