<?PHP
$f = 'app/php/pdo.php';

if (!file_exists($f)) {
header('Location: /install/index.php');
exit();
}
$erreur = false;
require_once('core.php');
if(isset($_SESSION['id']))
{
header("Location: home.php");
exit();
}
if (isset($_POST['pseudo'])) {
    $pseudo = htmlspecialchars(htmlentities(trim($_POST['pseudo'])));
    $mdp = htmlspecialchars(htmlentities(trim($_POST['mdp'])));
    $VUtilisateur = $bdd->prepare("SELECT * FROM users WHERE username = ? AND password = ? LIMIT 1");
    $VUtilisateur->execute(array($pseudo,sha1($mdp)));
    $Utilisateur = $VUtilisateur->fetch();

if ($VUtilisateur->rowCount() == 0) {
    $erreur = true;
} else {
    $UpLine = $bdd->prepare('UPDATE users SET last_online = ? WHERE id = ?');
    $UpLine->execute(array(time(),$Utilisateur['id']));
    $_SESSION['id'] = $Utilisateur['id'];
    header ("Location: home.php");
   }
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
    <title><?PHP echo htmlentities(trim($cms['nom_hotel'])); ?> - Un monde étrange !</title>
    <link rel="stylesheet" type="text/css" href="web/css/index.css">
    <script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>
</head>
<body>
    <?PHP if($erreur == true) { ?> <script>sweetAlert("Oops !", "Impossible de t\'identifier..", "error");</script> <?PHP } ?>
 <header>
     <img src="http://hsource.fr/font/habbo_new/Habbo.gif" class="logo"></img>
     <form method="post" style="display: initial;">
     <input class="<?PHP echo htmlentities(trim($cms['themes'])); ?>Border <?PHP echo htmlentities(trim($cms['themes'])); ?>Color" type="text" name="pseudo" placeholder="Pseudonyme">
     <input class="<?PHP echo htmlentities(trim($cms['themes'])); ?>Border <?PHP echo htmlentities(trim($cms['themes'])); ?>Color" type="password" name="mdp" placeholder="Mot de passe">
     <button type="submit" name="submit" class="connexion <?PHP echo htmlentities(trim($cms['themes'])); ?>">Connexion</button>
     </form>
     <a style="margin-left: 10px;" href="inscription.php"><button class="connexion <?PHP echo htmlentities(trim($cms['themes'])); ?>">Inscription</button></a>
 </header>
 <div class="context <?PHP echo htmlentities(trim($cms['themes'])); ?>" style="background-image: url(web/img/<?PHP echo htmlentities(trim($cms['themes'])); ?>.png);">
    <div class="text">
        <p style="font-size: 25px;">Bienvenue sur <?PHP echo htmlentities(trim($cms['nom_hotel'])); ?> Hôtel !</p>
        <i>Ici des personnes étrange y résident, seras-tu devenir membre de cette grande famille ? Mais attention tu risque de t'attacher très vite à cette aventure !</i>
    </div>
 </div>
 <div class="news" style="text-align: center;">
     <h2 class="<?PHP echo htmlentities(trim($cms['themes'])); ?>Color" style="text-transform: uppercase;">Rejoins les <?PHP echo $JoueurEnLigne; ?> connectés maintenant !</h2>
     <img src="http://www.freehabbocredits.net/dent2.png"><img src="http://bestonlinegamesreview.com/wp-content/uploads/2016/01/Habbo-Group.gif">
 </div>
 <footer class="<?PHP echo htmlentities(trim($cms['themes'])); ?>" style="bottom: 0;position: fixed;text-align: center;width: 100%;color: #FFF;">
     <p>Ce site est propulsé par PlusCMS de Dodone</p>
 </footer>
</body>
</html>