<?php
define('USERNAME_REQUIRED', TRUE);
define('ACCOUNT_REQUIRED', TRUE);
include('global.php');
define("THIS_SCRIPT", 'home');
if(isset($_GET['u']))
{
$username = $core->EscapeString($_GET['u']);
}
else
{
$username = $core->EscapeString($_SESSION['username']);
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo $sitename." - ".$username; ?></title>
    <script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
    <script type="text/javascript" src="Public/JS/jquery.history.js"></script>
    <link type="text/css" rel="stylesheet" href="Public/Styles/<?php echo $currentstyle ?>/CSS/main.css" />
</head> 

<body id="mainbox"> 
 
<div class="mainBox"> 
	<?php include("header.php"); ?>
	<?php
    if(strtolower(@$_GET['u']) == strtolower($_SESSION['username']) || !isset($_GET['u']))
	include("system/homenav.php");
	else
	include("system/communitynav.php");
	?>

	<div class="mid" id="midcontent"> 

<?php
if($users->NameTaken($username))
{
?>

<div class="column" id="column1">

	<div class="contentBox">
		<div class="boxHeader"><?php echo $users->UserInfo($username, 'username'); ?></div>
		<div class="boxContent">
        	<div class="HomeBox" style="height:170px;">
            <img src="http://www.habbo.com/habbo-imaging/avatarimage?figure=<?php echo $users->UserInfo($username, 'look'); ?>" alt="<?php echo $users->UserInfo($username, 'username'); ?>" style="float:left" />
					<div class="OnlineStatus">
						<?php
						if($users->UserInfo($username, 'online') == 1)
						{
						?>
							<div class="Online"><?php echo $lang['online']; ?></div>
						<?php
						}
						else
						{
						?>
							<div class="Offline"><?php echo $lang['offline']; ?></div>
						<?php
						}
						?>
					</div>
					<div class="UsersName"><?php echo $users->UserInfo($username, 'username'); ?></div>
					<div class="UsersMotto"><strong><?php echo $lang['user_motto']; ?>:</strong> <?php echo $users->UserInfo($username, 'motto'); ?></div>
                    <div class="UsersLastLogin"><strong><?php echo $lang['last_login']; ?>:</strong> <?php echo @date("d-m-Y",$users->UserInfo($username, 'last_online')); ?></div>
                    <div class="UsersCreated"><strong><?php echo $lang['user_created_on']; ?>:</strong> <?php echo @date("d-m-Y",$users->UserInfo($username, 'account_created')); ?></div>
                    <div class="UsersCreated"><strong><?php echo $lang['rank']; ?>:</strong> <?php echo $users->RankName($users->UserInfo($username, 'rank')); ?></div>
                    <div class="UsersCreated"><strong><?php echo $lang['tags']; ?>:</strong>
					<?php
					$tags = mysql_query("SELECT * FROM user_tags WHERE user_id = '".$users->UserID($username)."'");
					while($tag= mysql_fetch_array($tags))
					echo $tag['tag'].'<a href="functions/removetag.php?id='.$tag['id'].'">(x)</a>,';
					?></div>
                    <?php
					if(strtolower($username) == strtolower($_SESSION['username']))
					{
						?>
                    <form name="Tag" action="functions/addtag.php" method="post">
                    <label for="tag"><?php echo $lang['add_tag']; ?></label>
					<input type="text" name="tag" id="tag"  />
					<div class="Submitbtn right">
						<button type="submit" class="positive" name="submitcomment"><?php echo $lang['submit']; ?></button>
		   			</div>
	   				</form>
                    <?php
					}
					?>
            </div>
		</div>
	</div>
    <div class="contentBox">
        <div class="boxHeader"><?php echo $lang['my_badges']; ?></div>
		<div class="boxContent">
        <div class="BadgeBox">
        <?php
		$userbadges = mysql_query("SELECT * FROM user_badges WHERE user_id = '".$users->UserInfo($username, 'id')."'");
		if(mysql_num_rows($userbadges) == 0)
		{
			echo '<strong><center>'.$lang['no_badges'].'</center></strong>';
		}
		while($userbadge = mysql_fetch_array($userbadges))
		{
		?>
            <img src="Public/Images/badges/<?php echo $userbadge['badge_id']; ?>.gif" />
        <?php
		}
		?>
        </div>
        </div>
    </div>
</div>

<div class="column" id="column2">
	<div class="contentBox">
		<div class="boxHeader"><?php echo $lang['my_rooms']; ?></div>
        <?php
		$userrooms = mysql_query("SELECT * FROM rooms WHERE owner = '".$username."'");
		$color = 'odd';
		if(mysql_num_rows($userrooms) == 0)
		{
			echo '<div class="RoomBox" id="even"><strong>'.$lang['no_rooms'].'</strong></div>';
		}
		while($userroom = mysql_fetch_array($userrooms))
		{
			?>
			<div class="RoomBox" id="<?php echo $color; ?>">
            <strong><?php echo $userroom['caption']; ?></strong><br /><br />
            <?php echo $lang['room_visitors']; ?>: <?php echo $userroom['users_now']; ?> ~ <?php echo $lang['room_rating']; ?>: <?php echo $userroom['score']; ?>
            </div>
            <?php
			if($color == 'odd')
			$color='even';
			else
			$color='odd';
		}
		?>
	</div>
</div>
<?php
}
else
{
?>
<div class="column" id="column1">
	<div class="contentBox">
		<div class="boxHeader"><?php echo $lang['page_not_found']; ?></div>
		<div class="boxContent">
			<?php echo $lang['page_not_found_text']; ?>
		</div>
	</div>
</div>
<div class="column" id="column2">
	<?php
	$query = mysql_query("SELECT * FROM cms_news ORDER BY published DESC LIMIT 1");
	$num = mysql_num_rows($query);
	if($num > 0)
	{
		$news = mysql_fetch_array($query);
		echo'<div class="newsHeader">
				<div class="HeadlineStory" id="'.$news["id"].'" style="background: url('.$news["image"].') no-repeat; display:block;">
					<p class="Mainheadline"><a href="articles.php?story='.$news["id"].'">'.stripslashes($news["title"]).'</a></p>
					<p class="Mainstory">'.strip_tags($news["shortstory"], '<br><br/><br />').'</p>
				</div>
		</div>';
		$color = 'odd';
		$query = mysql_query("SELECT * FROM cms_news ORDER BY published DESC LIMIT 5");
		while($news = mysql_fetch_array($query))
		{
			echo'<div class="storybox" id="'.$color.'" ref="'.$news["id"].'">
				<p class="headline"><a href="articles.php?story='.$news["id"].'">'.$news["title"].'</a></p>
				<p class="date">'.@date("d-m-Y", $news['published']).'</p>
			</div>';
			if($color == 'odd')
			$color='even';
			else
			$color='odd';
		}
	}
	?>
		<div class="storyboxEnd">
			<div class="readmore"><a href="articles.php"><?php echo $lang['read_more']; ?></a></div>
		</div>
</div>
<?php
}
?>
		
<?php include("system/sideads.php"); ?>

	</div> 

	<?php include("system/footer.php"); ?>
</div> 

</body> 
</html>