<?php

if (!defined('IN_HK') || !IN_HK)
{
	exit;
}

if (HK_LOGGED_IN)
{
	exit;
}

if (isset($_POST['usr']) && isset($_POST['pwd']))
{
	$username = filter($_POST['usr']);
	$password = $core->uberHash($_POST['pwd']);

	if ($users->validateUser($username, $password))
	{		
		$hkId = $users->name2id($username);
		
		if ($users->GetUserVar($hkId, 'rank') > 4)
		{	
			session_destroy();
			session_start();
		
			$_SESSION['UBER_USER_N'] = $users->getUserVar($hkId, 'username');
			$_SESSION['UBER_USER_H'] = $password;
			$_SESSION['UBER_HK_USER_N'] = $_SESSION['UBER_USER_N'];
			$_SESSION['UBER_HK_USER_H'] = $_SESSION['UBER_USER_H'];
			
			header("Location: " . HK_WWW . "/index.php?_cmd=main");
			
			exit;
		}
		else
		{
			$_SESSION['HK_LOGIN_ERROR'] = "<center><br>You do not have access to the Housekeeping</center>";
		}
	}		
	else
	{
		$_SESSION['HK_LOGIN_ERROR'] = '<center><br>Invalid Details</center>';
	}
}

?>
<html>
<head>
<title>iHabbo: Housekeeping-login</title>
<style type="text/css">

body
{
	font-family: sans-serif;
	font-size: 75%;
	background: #FFFFFF;
	color: #000;
	background-color: black;
	background-image: url(../../images/grass.gif);
}

#text
{
	display: block;
	padding-top: 100px;
	padding-bottom: 10px;
	margin: 0 auto;
	text-align: right;
	width: 420px;
 text-decoration: blink; color:#FFFFFF;

}

#loginblock
{
	display: block;
	margin: 10px auto;
	border: 1px solid #000;
	width: 400px;
	padding: 5px 15px 10px 15px;
	background: #FFFFFF;
}

#loginblock .info
{
	padding-bottom: 2px;
	margin-bottom: 5px;
}

input.biginput
{
	width: 100%;
	font-size: 2em;
	text-align: center;
	padding: 3px;
}
</style>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head>
<body>

<div id="text">
	<center><b>Welcome, to iHabbo Hotel Housekeeping!</b></center>

</div>

<div id="loginblock">

	<div class="info">
				<p>
     This service, and only for team members administrativa.Toda activity is logged, and unauthorized access or abuse will be dealt with appropriately.
				</p>
				
				<p>
    Your user name and password for this area are personal. <i> Never </i> of them to any person <i>any</i> circumstances.
				</p>

				
				<p>
     Please provide proper authentication for access to the service.
				</p>
	</div>

	<form method="post">
         <h3>Username
		<input type="text" name="usr" class="biginput" value="<?php if (LOGGED_IN) { echo USER_NAME; } ?>"><br />
		<br />
		Password
		<br />
		<input type="password" name="pwd" class="biginput" value=""><br />
		<br />
		<input type="submit" class="biginput" value="Login">
		<input type="button" onClick="document.location = '/';" class="biginput" value="Back to site"><br>

	</form>
	
	<?php
	
	if (isset($_SESSION['HK_LOGIN_ERROR']))
	{
		echo '<b style="color: darkred;">' . $_SESSION['HK_LOGIN_ERROR'] . '</b>';
		unset($_SESSION['HK_LOGIN_ERROR']);
	}
	
	?>
	
				<?php if (LOGGED_IN) { ?>
				<p>
					<center>You are Logged in the site as <b><?php echo USER_NAME; ?></center></b>
				</p>
				<?php } ?>	
	
</div>

</body>
</html>