<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="keywords" content="Драконоборцы , онлайн игра, пвп, сражения, pvp, приключения, прокачка героя, арена, битва, турнир, подземелья, бесплатная, mmorpg, драконы" />
    <meta name="viewport" content="width=device-width; minimum-scale=1; maximum-scale=1" />
    <link type="text/css" rel="stylesheet" href="http://mdrag.ru/style/css/reset.css" />
    <link type="text/css" rel="stylesheet" href="http://mdrag.ru/style/css/style.css?v=1.4.3" />
    <link rel="icon" type="image/x-icon" href="http://mdrag.ru/favicon.png" />
    <title>Драконоборцы  </title>
    <script type="text/javascript">
        if (/Opera Mini/.test(navigator.userAgent)) document.getElementsByTagName('html')[0].className += ' operamini';
    </script>
    <script src="/js/timer.js?v=1.4" type="text/javascript"></script>
</head>
<body>
<div class="container">

<?php
if (isset($clan))
{
	$expProgress = round(100/($expClan[$clan['level']]/($clan['exp']+1)))+1;
	if ($expProgress>100)
	{
		$expProgress = 100;
	}
}

if (isset($user))
{
	$expProgress = round(100/($expLevel[$user['level']]/($user['exp']+1)))+1;
	if ($expProgress>100)
	{
		$expProgress = 100;
	}






	?>

<div class="header">
            <div class="header-bar">
                <img src="http://mdrag.ru/style/images/icons/icon_str.png"> <?=$user['str'];?>                <img src="http://mdrag.ru/style/images/icons/icon_hp.png"> <?=$user['hp'];?>                  <img src="http://mdrag.ru/style/images/icons/icon_def.png"> <?=$user['def'];?>                  
                
                            </div>

		
		<br/>
		<?php
		$buffs = $db->rows("SELECT `user` FROM `buffs` WHERE `user`=?",
												array($user['id']));

		if ($buffs > 0)
		{
			$buffi =$db->fetch("SELECT * FROM `buffs` WHERE `user`=?",
														array($user['id']));

			if ( $buffi['gladiator_time'] > time())
			{
				?>
				<img src ='/imgData/buff/gladiator.png' width='16' height='16'/>
				<?
			}

			if ( $buffi['know_time'] > time())
			{
				?>
				<img src ='/imgData/buff/know.png' width='16' height='16'/>
				<?
			}

			if ($buffi['gladiator'] ==  1 && $buffi['gladiator_time'] < time()) 
			{
				$upd = $db->query("UPDATE `buffs` SET `gladiator`='0',`gladiator_time`='0' WHERE `user`=?",
																			array($user['id']));

				?>
									<div class="bntf">
		<div class="nl">
			<div class="nr cntr lyell lh1 p5 sh">
				<span class="win">
					Действие заклятия гладиатора истекло!
				</span>
			</div>
		</div>
	</div>
	<?
			}

			if ($buffi['know'] ==  1 && $buffi['know'] < time()) 
			{
				$upd = $db->query("UPDATE `buffs` SET `know`='0',`know`='0' WHERE `user`=?",
																			array($user['id']));

				?>
					<div class="bntf">
		<div class="nl">
			<div class="nr cntr lyell lh1 p5 sh">
				<span class="win">
					Действие заклятия знаний истекло!
				</span>
			</div>
		</div>
	</div>
				<?
			}
		}

		?>		
	</div>
<div class="t h-bar">
                    <tbody>
                        <div class="row">
                            <div class="cell _var">
                                <?=$user['level'];?> ур
                            </div>
                            <div class="cell">
                                <div class="progress-bar exp">
                                    <div style="width: <?=$expProgress;?>%;" class="progress _green"></div>
                                </div>
                            </div>
                            <div class="cell _var">
                                <?=$expProgress;?>%
                            </div>
                        </div>
                    </tbody>
                </div>
                    </div>



	<?

	$rowsDuelInvite = $db->rows("SELECT `usto`,`status` FROM `duel` WHERE `usto`=? and `status`='invite'",
																						array($user['id']));


	if ($rowsDuelInvite > 0)
	{
		if (isset($_GET['accept']) && !empty($_GET['accept']))
		{
			$idA =  (int) abs($_GET['accept']);


		}

		if (isset($_GET['cancel']) && !empty($_GET['cancel']))
		{
			$idC = (int) abs($_GET['cancel']);

			$cancel = $db->query("DELETE FROM `duel` WHERE `id`=?",
													array($idC));

			$_SESSION['error'] = 'Вы отказались от боя!';
			header("Location:".$_SERVER['PHP_SELF']);
			exit;
		}

		$dataInviteDuel =  $db->fetch("SELECT * FROM `duel` WHERE `usto`=? and `status`='invite'",
																			array($user['id']));

		$oppDuel = $db->fetch("SELECT `id`,`login` FROM `users` WHERE `id`=?",
														array($dataInviteDuel['user']));
		?>

		<div class ='content'/>
			<center>
				Игрок <a href ='/user?id=<?=$oppDuel['id'];?>'/> <?=$oppDuel['login'];?></a>
				вызывает вас на дуэль
			</center>
		</div>
		<a class ='mbtn mb2' href ='?accept=<?=$dataInviteDuel['id'];?>'/>
			<img class="icon" src="/imgData/static/str.png">Принять вызов
		</a>
		<a class ='mbtn mb2' href ='?cancel=<?=$dataInviteDuel['id'];?>'/>
			<img class="icon" src="/imgData/static/logout.png">Отклонить вызов
		</a>		
		<?
	}
} else { }

if ($_SERVER['PHP_SELF'] != '/index.php')
{
	?>
		<div class="title">	
 			<?=$title;?>
		</div>
	<?	
}

if (isset($_SESSION['info']))
{
	?>
		<div class='message'>
			<?=$_SESSION['info'];?>
		</div>
	<?
	$_SESSION['info'] =  null;
}

if (isset($_SESSION['error']))
{
	?>
		<div class="error">
			<?=$_SESSION['error'];?>
		</div>
	<?
	$_SESSION['error'] =  null;
}

if($user['read_id'] != '' and $user['read_id'] != '0'){ ?>
	<div class="list">
		<a class="menu" href='/mail/index.php'>Новое сообщение</a></li>
	</div>
<? } 

$clans_invite = $db->fetchAll("SELECT clan_id FROM clans_invite WHERE user_id = ?", array($user['id']));
?>


<?php if($clans_invite): ?>

	<?php foreach($clans_invite as $clan_invite): ?>
		<?php $clan = $db->fetch("SELECT id, name FROM clans WHERE id = ?", array($clan_invite['clan_id'])); ?>
		<div class="menu">
			Вас пригласили в клан <a href="/clans/clan?id=<?= $clan['id'] ?>"><?= $clan['name'] ?></a><br>
			<a href="/clans/user?confirm=<?= $clan['id'] ?>">Принять</a> | <a href="/clans/user?decline=<?= $clan['id'] ?>">Отклонить</a>
		</div>
	<?php endforeach; ?>
<?php endif; ?>

