<?
include('cfg.php');
echo '<link rel="stylesheet" type="text/css" href="style.css"/>
<body>
<div class="head">'.$date.'-['.$user['country'].'] </div><div class="money">';

echo $style;
echo '['.$user[login].']<br />';

switch($_GET[a])
	{
    default:
    $isset_wars = mysql_result(mysql_query("SELECT count(*) FROM `fight_log` WHERE `attacker`='$id' OR `protector`='$id'"),0);
	if ($isset_wars != '0')
		{
		echo '</div>';
		$query = mysql_query("SELECT DISTINCT `war` FROM `fight_log` WHERE `attacker`='$id' OR `protector`='$id' order by `id` DESC");
		while($w = mysql_fetch_assoc($query))
			{
			$war = mysql_fetch_array(mysql_query("SELECT * FROM `fight_log` WHERE `war`=$w[war]"));
			if ($war[attacker]==$id) $login_war_p = mysql_fetch_array(mysql_query("SELECT `country` FROM `users` WHERE `id`='$war[protector]'"));
			if ($war[protector]==$id) $login_war_p = mysql_fetch_array(mysql_query("SELECT `country` FROM `users` WHERE `id`='$war[attacker]'"));
			if (empty($login_war_p)) echo '<a class="razd" href="?a=view&amp;id='.$w[war].'">(Страна противника удалена)';
			else echo '<a class="razd" href="?a=view&amp;id='.$w[war].'">Война с '.$login_war_p[country].'';
			if ($war[attacker]==$id) echo ' (нападение)</a>';
			if ($war[protector]==$id) echo ' (вторжение)</a>';
			}
		} else echo 'У вас еще не было войн</div>';

    break;

    case 'view':
	echo '</div><div class="money">';
	$id_war = intval(abs($_GET[id]));
    $isset_wars = mysql_result(mysql_query("SELECT count(*) FROM `fight_log` WHERE `war`=$id_war"),0);
	if ($isset_wars != '0')
		{
		$query = mysql_query("SELECT * FROM `fight_log` WHERE `war`='$id_war' ORDER by id DESC");
		while($r = mysql_fetch_assoc($query))
			{
			echo $r[text].'</div><div class="money">';
			}
		} else echo 'Такой войны не существовало';
		echo '</div><a class="razd" href="./log_war.php">Вернуться</a>';
    break;
	}

echo '<div class="money">Меню</div>
<a class="razd" href="game.php">'.$iback.' Назад</a>
<a class="razd" href="exit.php">'.$iexit.' Выход</a>
';


?>