<?php
/*================================================================+\
|| # PHPRetro - An extendable virtual hotel site and management
|+==================================================================
|| # Copyright (C) 2009 Yifan Lu. All rights reserved.
|| # http://www.yifanlu.com
|| # Parts Copyright (C) 2009 Meth0d. All rights reserved.
|| # http://www.meth0d.org
|| # All images, scripts, and layouts
|| # Copyright (C) 2009 Sulake Ltd. All rights reserved.
|+==================================================================
|| # PHPRetro is provided "as is" and comes without
|| # warrenty of any kind. PHPRetro is free software!
|| # License: GNU Public License 3.0
|| # http://opensource.org/licenses/gpl-license.php
\+================================================================*/

$page['dir'] = '\housekeeping';
$page['housekeeping'] = true;
$page['rank'] = 5;
require_once('../includes/core.php');

if($user->id > 0){ header('Location: '.PATH.'/housekeeping/dashboard'); exit; }

if(!isset($_SESSION['login'])){
	$_SESSION['login']['enabled'] = true;
	$_SESSION['login']['tries'] = 0;
}

$lang->addLocale("housekeeping.login");

if(!empty($_POST['username'])){
	$username = $input->FilterText($_POST['username']);
	$password = $input->HoloHash($_POST['password'],$username);
	
	$user = new HoloUser($username,$password,true,false);
	
	$lang->addLocale("landing.login");
	
	if($user->error > 0){
		$login_error = $lang->loc['error.'.$user->error];
		if($user->error == 3){
			$login_error = $lang->loc['banned.1'].$user->banned['reason'].$lang->loc['banned.2'].$user->banned['expire'].".";
		}
	}
	if($_SESSION['login']['tries'] > 4 && $settings->find("site_capcha") == "1"){
		if(($_SESSION['register-captcha-bubble'] == strtolower($_POST['bean_captchaResponse']) && !empty($_SESSION['register-captcha-bubble'])) || $settings->find("site_capcha") == "0") {
			unset($_SESSION['register-captcha-bubble']);
		}else{
			$login_error = $lang->loc['error.captcha'];
		}
	}
	if(empty($login_error)){
		unset($_SESSION['login']);
		$_SESSION['hk_user'] = $user;
		header('Location: '.PATH.'/housekeeping/dashboard'); exit;
	}else{
		$_SESSION['login']['tries']++;
	}
}

$page['name'] = $lang->loc['pagename.login'];
$page['category'] = "login";

?> 
<head> 
<title>Housekeeping login</title> 
<style type="text/css"> 
body
{
	font-family: sans-serif;
	font-size: 75%;
	background: #FFFFFF;
	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;
}
 
#loginblock .info
{
	padding-bottom: 2px;
	margin-bottom: 5px;
}
 
input.biginput
{
	width: 100%;
	font-size: 2em;
	text-align: center;
	padding: 3px;
}
</style> 
</head> 
<body> 
 
<div id="text"> 
 
	<img src="./images/lock.png" style="vertical-align: middle;">&nbsp;
	<b>Habbo Housekeeping</b> Login
 
</div> 
 
<div id="loginblock"> 
 
	<div class="info"> 
				<p> 
					This service is intended for staff only and monitored closely, with 24 hour IP Address records being taken. All activity
					is recorded, and abuse or unauthorized access will be dealt with appropriately.
				</p> 
				
				<p> 
					Your username and password to this area are personal. <i>Never</i> give them to anyone under
					<i>any</i> circumstances.
				</p> 
 
				
				<p> 
					Please provide proper authentication in order to access this service.
				</p> 
	</div> 
 
<form id="loginform" action="<?php echo PATH; ?>/housekeeping/" method="post">

<strong><?php echo $lang->loc['username']; ?>:</strong><br />

<input type="text" size="20" class="biginput" name="username" id="namefield" value="<?php echo $input->HoloText($username); ?>" /><br />

<strong><?php echo $lang->loc['password']; ?>:</strong><br />

<input type="password" size="20" class="biginput" name="password" value="" />
<?php if($_SESSION['login']['tries'] > 4 && $settings->find("site_capcha") == "1"){ ?>
<br />
<center><strong>Please enter the Captcha below: </strong></center>
<center><img id="captcha" src="<?php echo PATH; ?>/captcha.jpg?t=<?php echo time(); ?>" alt="" width="200" height="50" /><br /><br /></center>
<input type="text" name="captcha" id="captcha-code" class="biginput" value="" /><br />
<?php } ?><br />
<input type="submit" class="biginput" value="<?php echo $lang->loc['submit']; ?>"></input>
</form>
	
		
					
	
</div> 
 
</body> 
