<?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->hasFuse($hkId, 'fuse_housekeeping_login'))
		{	
			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'] = "You do not have permission to access this service";
		}
	}		
	else
	{
		$_SESSION['HK_LOGIN_ERROR'] = 'Invalid details';
	}
}

?>
<html>
<head>
<title>Epic Hotel -> Hotel Staff Housekeeping</title>
<style type="text/css">
body
{
	font-family: tahoma;
	font-size: 75%;
	color: #000;

}

#text
{
	display: block;
	padding-top: 100px;
	padding-bottom: 10px;
	margin: 0 auto;
	text-align: right;
	width: 420px;
}

#loginblock
{
	display: block;
	margin: 10px auto;
	border: 1px solid #000;
	width: 400px;
	padding: 5px 15px 10px 15px;
	-moz-border-radius: 4px;
	-webkit-border-radius: 4px;
	background: #FFFFFF;

}

#loginblock .info
{
	padding-bottom: 2px;
	margin-bottom: 5px;
}

input.biginput
{
	width: 60%;
	text-align: center;
	padding: 3px;
}
</style>
</head>
<body background="%www%/images/bg.png">

	<center><img src="http://zaphotel.net/images/hk.png"></center>



<div id="loginblock">

	<div class="info">
				<p> <?php $ipaddy = $_SERVER['REMOTE_ADDR']; ?>
					<center><font color="darkred"><b>You must have the correct access level to enter this area.</b></font color></p>
					<p>Your IP address (<?php echo $ipaddy; ?>) has been logged and entered into our system.</p>
					<p>If you have the correct access level - log in below.</p>
	</div>
</div>
<div id="loginblock">
<center>
	<form method="post">

		<input type="text" name="usr" class="biginput" value="<?php if (LOGGED_IN) { echo USER_NAME; } ?>"><br />
		<br />
		<input type="password" name="pwd" class="biginput" value=""><br />
		<br />
		<input type="submit" class="biginput" value="Log in">

	</form>
	
				<?php /* if (LOGGED_IN) { ?>
				<p>
					You are currently logged in to the main site as <b><?php echo USER_NAME; ?></b>.
				</p>
				<?php } */ ?>	
	</center>
</div>
<div id="loginblock">
<center></center>
</div>
</body>
</html>