<?
$owner = $homez;
$owner = strtolower($owner);
$user = $_SESSION[habboname];
if($_POST['submit']){
$post = mysql_query("SELECT * FROM users WHERE name = '$user'");
$my = mysql_fetch_array($post);
$user = $my['name'];
$comment = $_POST['comment'];
$time = date("d-M-Y H:i:s");
mysql_query("INSERT INTO guestbook VALUES ('','$user','$homez','$comment','$time')");
}
?>
<link rel="stylesheet" type="text/css" href="<?php echo ("$imgpath") ?>css/homes.css" />
<link rel="stylesheet" type="text/css" href="<?php echo ("$imgpath") ?>css/kh.css" />
</head>

<body bgcolor="47839D">
<?php $uexist = mysql_query("SELECT * FROM users WHERE name = '" . $homez . "'");
$uexist2 = mysql_fetch_array($uexist);
if(mysql_num_rows($uexist)=="0"){ ?>
<div id="myspan"></div>
<center>
<div class="v3box orange" style="width: 50%">
	<div class="v3box-top"><h3><?php echo("$name"); ?> Homes</h3></div>
	<div class="v3box-content">
		<div class="v3box-body">
	Oh no! Looks like <b><?php echo $homez; ?></b> hasn't got a <?php echo("$name"); ?> home yet! Are you <?php echo $homez; ?>? If you are, <a href="../index.php">get a Habbos home today</a>!
	</div>
	</div>
<div class="v3box-bottom"><div></div></div>
</div>
</center>
<?php }
elseif($uexist2['ban']=="1"){ ?>
<center>
<div class="v3box orange" style="width: 50%">
	<div class="v3box-top"><h3>Sorry!</h3></div>
	<div class="v3box-content">
		<div class="v3box-body">
	This page is not available any more, <b><?php echo $propowner['name']; ?></b> was banned.
	</div>
	</div>
<div class="v3box-bottom"><div></div></div>
</div>
</center>

<?php }
else{
$user = strtolower($user);
$home = mysql_fetch_array(mysql_query("SELECT * FROM homes WHERE owner = '$owner'"));
$usr = mysql_fetch_array(mysql_query("SELECT * FROM users WHERE name = '$owner'"));
?>
<div align="left" style="margin: 0px 0px 0px 4px;height: 800px; width: 920px; position: relative;" class="<?php echo $home['bg']; ?>">
<?php $notecheck = mysql_query("SELECT * FROM stickers WHERE home = '$owner' AND type = 'note'");
if(!mysql_num_rows($notecheck)=="0"){
while($row = mysql_fetch_array($notecheck)){
?>
<div class="movable stickie" style=" left: <?php echo $row['x']; ?>px; top: <?php echo $row['y']; ?>px; z-index: 3;" id="S_<?php echo $row['id']; ?>">
	<div class="n_skin_<?php echo $row['skin']; ?>skin" >

		<div class="stickie-header">
			<h3>			</h3>
			<div class="clear"></div>
		</div>
		<div class="stickie-body">
			<div class="stickie-content">
				<p><?php echo $row['content']; ?></p>
				<div class="stickie-footer">

				</div>
			</div>
		</div>
	</div>
</div>
<?php } } ?>
<?php $profilecheck = mysql_query("SELECT * FROM stickers WHERE home = '$owner' AND type = 'profile'");
if(!mysql_num_rows($profilecheck)=="0"){ 
$profile = mysql_fetch_array(mysql_query("SELECT * FROM stickers WHERE home = '$owner' AND type = 'profile'"));
?>
<div class="movable widget ProfileWidget" id="S_<?php echo $profile['id']; ?>" style=" left: <?php echo $profile['x']; ?>px; top: <?php echo $profile['y']; ?>px; z-index: <?php echo $profile['z']; ?>; position: absolute;">
<div class="w_skin_<?php echo $profile['skin']; ?>skin">
	<div class="widget-corner" id="widget-<?php echo $profile['id']; ?>-handle">
		<div class="widget-headline"><h3>
		<span class="header-left">&nbsp;</span><span class="header-middle">MY PROFILE</span><span class="header-right">&nbsp;</span></h3>
		</div>	
	</div>
	<div class="widget-body">
		<div class="widget-content">
	<div class="profile-info">
		<div class="name" style="float: left">
		<span class="name-text"><?php echo $home['owner']; ?></span>
		</div>

		<br class="clear" />
		<br class="clear" />
		<div class="birthday text">
		<?php echo("$name"); ?> Name:
		</div>
		<div class="birthday date">
		<?php echo $usr['name']; ?>
		</div>
		<?php if($home['badge']){
		$chk = mysql_query("SELECT * FROM badges WHERE code = '" . $home['badge'] . "'");
		if(mysql_num_rows($chk)=="0"){
		?>
		<div>
		<img src="http://images.habbohotel.co.uk/c_images/album1584/<?php echo $home['badge']; ?>.gif">
		</div>
		<?php } else { 
		$chkrow = mysql_fetch_array($chk);
		?>
		<div>
		<img src="<?php echo $chkrow['url']; ?>">
		</div>
		<?php } } ?>
	</div>
	<div class="profile-figure">
			<img src="http://www.habbo.co.uk/habbo-imaging/avatarimage?user=<?php echo $home['habboname']; ?>&action=std&frame=3&direction=4&head_direction=4&gesture=sml&img_format=gif" />
	</div>
	<div class="profile-motto">
		<?php echo $usr['mission']; ?>
		<div class="clear"></div>
	</div>
		<div class="clear"></div>
		</div>
	</div>
</div>
</div>
<?php } ?>
<?php $guestcheck = mysql_query("SELECT * FROM stickers WHERE home = '$owner' AND type = 'guestbook'");
if(!mysql_num_rows($guestcheck)=="0"){ 
$guest = mysql_fetch_array(mysql_query("SELECT * FROM stickers WHERE home = '$owner' AND type = 'guestbook'"));
$gbpostd = mysql_query("SELECT * FROM guestbook WHERE home = '$owner'");
?>
<div class="movable widget GuestbookWidget" id="S_<?php echo $guest['id']; ?>" style=" left: <?php echo $guest['x']; ?>px; top: <?php echo $guest['y']; ?>px; z-index: <?php echo $guest['z']; ?>;">
<div class="w_skin_<?php echo $guest['skin']; ?>skin">
	<div class="widget-corner" id="widget-<?php echo $guest['id']; ?>-handle">
		<div class="widget-headline"><h3><span class="header-left">&nbsp;</span><span class="header-middle">My Guestbook(<?php echo mysql_num_rows($gbpostd); ?>) <span id="guestbook-type" class="public"><img src="/images/groups/status_exclusive.gif" title="Friends only" alt="Friends only"/></span></span><span class="header-right">&nbsp;</span></h3>
		</div>	
	</div>
	<div class="widget-body">
		<div class="widget-content">
<div id="guestbook-wrapper" class="gb-public">
<ul class="guestbook-entries" id="guestbook-entry-container">
<?	
while($row = mysql_fetch_array($gbpostd)){ 
?>
	<li id="guestbook-entry-<?php echo $row['id']; ?>" class="guestbook-entry">
		<div class="guestbook-author">
		</div>
			<div class="guestbook-actions">
			</div>
		<div class="guestbook-message">
				<a href="home/<?php echo $row['poster']; ?>" target="_parent"><?php echo $row['poster']; ?></a>
			<p><?php echo $row['content']; ?></p>
		</div>
		<div class="guestbook-cleaner">&nbsp;</div>
		<div class="guestbook-entry-footer metadata"><?php echo $row['time']; ?></div>
	</li>
<?php } ?>
	<?php if(mysql_num_rows($gbpostd)=="0"){ ?>
	This user has no guestbook comments :(
	<?php } ?>
</div>
</ul>
	<?php if($_SESSION[login] == 'true'){ ?>
	<a href="edit/gbpost/<?php echo("$homez") ?>" class="lbOn colorlink orange">
	<span><img src="http://images.habbohotel.com/habboweb/16/11/web-gallery/images/myhabbo/buttons/icon_envelope.gif" />Post new message</span>
	</a>
	<?php } ?>
		<div class="clear"></div>
		</div>
	</div>
</div>
</div>
<?php }
$pillows = mysql_query("SELECT * FROM stickers WHERE home = '$owner'");
while($row = mysql_fetch_array($pillows)){
if($row['type']==""){
$row['z'] = str_replace("Â","",$row['z']);
?>
<div class="<?php echo $row['class']; ?>" style="left: <?php echo $row['x']; ?>px; top: <?php echo $row['y']; ?>px; z-index: <?php echo $row['z']; ?>; position: absolute;" id="S_<?php echo $row['id']; ?>">
</div>
<?php } } } ?>
</div>