	<?php
		
		$online	=	@mysql_num_rows(@mysql_query(sprintf(
			'SELECT
					*
				FROM
					`users`
				WHERE
					`lastActive`	>	%d',
			time() - (60 * 15)
		)));
		
		if (@$user)
		{
			
	?>
		<div class='line'></div>
		<ul class='list'>
			<li><a href='/user'><img src='/images/icon/user.png' alt='' /> Мой герой</a></li>
	<?php
		$query	=	@mysql_query(sprintf(
			'SELECT
					*
				FROM
					`clan_memb`
				WHERE
					`user_id`	=	%d',
			$user['id']
		));
		
		if (@mysql_num_rows($query) != 0)
		{
			
			$memb	=	@mysql_fetch_assoc($query);
			
			if (@mysql_num_rows(@mysql_query(sprintf(
				'SELECT
						`subforums`.*
					FROM
						`subforums`
					LEFT JOIN
						`topics`
					ON
						`topics`.`subforum_id`	=	`subforums`.`id`
					LEFT JOIN
						`forum_read`
					ON
						`forum_read`.`topic_id`	=	`topics`.`id`
							AND
						`forum_read`.`user_id`	=	%d
					WHERE
						`subforums`.`clan_id`	=	%d 
							AND
						`forum_read`.`id` IS NULL
							AND
						(SELECT
								COUNT(*)
							FROM
								`topics`
							LEFT JOIN
								`subforums`
							ON
								`subforums`.`id`=	`topics`.`subforum_id`
							WHERE
								`subforums`.`clan_id`
												=	%d) != 0',
				$user['id'],
				$memb['clan_id'],
				$memb['clan_id']
			))) != 0)
			{
	?>
		<li><a href='/clan'><img src='/images/icon/clan.png' alt='' /> Мой клан <span class='c_green'>(+)</span></a></li>
	<?php	
			}
			else
			{
			
	?>
		<li><a href='/clan'><img src='/images/icon/clan.png' alt='' /> Мой клан</a></li>
	<?php
			}
		
		}
	
	?>
			<li><a href='/'><img src='/images/icon/arrow.png' alt='' /> Главная</a></li>
		</ul>
		<div class='line'></div>
		<div class='footer'>
			
			<img src='/images/icon/align/<?=$user['align']?>.png' alt=''/> <?=$user['login']?>
			<span class='f_rght'>
			<?php
			if ($user['saved'] == 0)
			{
			?>
			<a href='/save' class='small c_l-green'>Сохранить</a>
			<?php
			}
			else
			{
			?>
			<a href='/settings' class='small'>Настройки</a>
			<?php
			}
			?>
			</span>
			
			<div class='cntr'><img src='/images/icon/level.png' alt='' /> <?=$user['level']?> <img src='/images/icon/gold.png' alt='' /> <?=$user['gold']?> <img src='/images/icon/silver.png' alt='' /> <?=$user['silver']?></div>
			
		</div>
		
		<div class='cntr'>
			
			<div style='padding:	6px 0px;'></div>
			
	<?php
			if (@mysql_num_rows(@mysql_query(sprintf(
				'SELECT
						*
					FROM
						`subforums`
					LEFT JOIN
						`topics`
					ON
						`topics`.`subforum_id`	=	`subforums`.`id`
					LEFT JOIN
						`forum_read`
					ON
						`forum_read`.`topic_id`	=	`topics`.`id` AND `forum_read`.`user_id` = %d
					WHERE
						`subforums`.`id`	=	1
							AND
						`forum_read`.`id` IS NULL
							AND
						(SELECT
								COUNT(*)
							FROM
								`topics`
							LEFT JOIN
								`subforums`
							ON
								`subforums`.`id`=	`topics`.`subforum_id`
							WHERE
								`subforums`.`id`=	1) != 0',
				$user['id']
			))) != 0)
			{
	?>
	<a href='/forum/subforum/1'>Новости</a> <span class='c_green'>(+)</span>
	<?php
			}
			else
			{
	?>
	<a href='/forum/subforum/1/'>Новости</a>
	<?php
			}
	?>
			
			| <a href='/chat/'>Чат</a> | <a href='/forum/'>Форум</a>
			
			<div style='padding:	6px 0px;'></div>
			<a href='/online/' class='small c_grey'>В игре:	<?=$online?></a>
		</div>
		
	<?php
	
		}
		
	?>
	<!--
	<div style='padding:	6px 0px;'></div>
	<div class='cntr'>
		<a href='http://vk.com/cot_reborn' target='_blank' class='small c_white'>Мы в <b><span class='c_blue'>В</span>контакте</b></a>
	</div>
	-->