<?php
require_once('core.php');
$SelectHotel = $bdd->prepare('SELECT * FROM pluscms_hotel WHERE id = 1');
$SelectHotel->execute();
$Client = $SelectHotel->fetch();
if($_SESSION['id'] > 0) { 
  $base = md5(uniqid()); 
  $SelectionDuMembre = $bdd->prepare("UPDATE users SET auth_ticket = ? WHERE id = ?"); 
  $SelectionDuMembre->execute(array($base, $U['id']));
}
if(!isset($_SESSION['id']))
{
  header('Location: index');
  exit();
}
?>
<?PHP if ($Client['hotel'] == "ouvert") { ?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title><?php echo htmlspecialchars(trim($cms['nom_hotel'])); ?>: Hôtel</title>
    <link rel="stylesheet" href="web/flashclient/css/hotel.css" type="text/css" />
    <script src="web/flashclient/js/jquery.js" type="text/javascript"></script>
    <script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
    <script src="web/flashclient/js/swfobject.js" type="text/javascript"></script>
    <script src="web/flashclient/js/habboapi.js" type="text/javascript"></script>
<script type="text/javascript">
var flashvars = {
      "client.allow.cross.domain" : "1",
      "client.notify.cross.domain" : "0",
      "connection.info.host" : "<?php echo trim($Client['ip']); ?>",
      "connection.info.port" : "<?php echo intval(trim($Client['port'])); ?>",
      "site.url" : "<?php echo htmlspecialchars(trim($cms['lien'])); ?>",
      "url.prefix" : "<?php echo htmlspecialchars(trim($cms['lien'])); ?>",
      "client.reload.url" : "hotel",
      "client.fatal.error.url" : "hotel",
      "client.connection.failed.url" : "hotel",
      "external.variables.txt" : "<?php echo htmlspecialchars(trim($Client['variable'])); ?>",
      "external.texts.txt" : "<?php echo htmlspecialchars(trim($Client['text'])); ?>",
	    "external.figurepartlist.txt" : "<?php echo htmlspecialchars(trim($Client['figuredata'])); ?>",
      "external.override.variables.txt" : "<?php echo htmlspecialchars(trim($Client['override'])); ?>",
      "productdata.load.url" : "<?php echo htmlspecialchars(trim($Client['producdata'])); ?>",
      "furnidata.load.url" : "<?php echo htmlspecialchars(trim($Client['furnidata'])); ?>",
      "use.sso.ticket" : "1",
      "sso.ticket" : "<?php echo $base; ?>",
      "processlog.enabled" : "0",
      "account_id" : "<?php echo intval(trim($U['id'])); ?>",
      "client.starting" : "Chargement de l'hôtel en cours...",
      "client.starting.revolving": "Nous faisons avancer la science.\/Regarde à gauche, regarde à droite, cligne des yeux deux fois et voilà!\/J'adore ton t-shirt.\/Chut! J'essaye de me concentrer là-haut!\/Ce n'est pas toi, c'est moi.\/Le temps est juste une illusion.",
      "flash.client.url" : "<?php echo htmlspecialchars(trim($Client['base'])); ?>",
      "user.hash" : "",
      "has.identity" : "0",
      "flash.client.origin" : "popup"
    };
    </script>

    <script type="text/javascript">
    var params =
    {
      "base": "<?php echo htmlspecialchars(trim($Client['base'])); ?>",
      "allowScriptAccess": "always",
      "menu": "false",
      "wmode": "opaque"
    };
    var clientUrl = "<?php echo htmlspecialchars(trim($Client['habbo_base'])); ?>";
    swfobject.embedSWF(clientUrl, "flash-container", "100%", "100%", "10.0.0", "web/flashclient/expressInstall.swf", flashvars, params);
    
	</script>
    <style type="text/css" media="screen">
      #flash-container {
        visibility: hidden
      }
    </style>
  </head>
    <body>
    <div id="client-ui">
      <div style="margin-bottom: 0px; position: fixed; z-index: 10;" class="alert alert-dismissible alert-primary">
        <a onclick="toggleFullScreen()" style="margin-top: -10px; margin-left: -11px; background-color: #FE9901;" class="btn btn-success">
          <span class="glyphicon glyphicon-fullscreen" aria-hidden="true"></span>
        </a>
      </div>
      <div id="flash-wrapper">
        <div id="flash-container">
          <div id="content" style="width: 400px; margin: 20px auto 0 auto; display: none">
            <p>FLASH NOT INSTALLED</p>
            <p>
              <a href="https://www.adobe.com/go/getflashplayer"></a>
            </p>
          </div>
        </div>
      </div>
      <div id="content" class="client-content"></div>
      <iframe id="page-content" class="hidden" allowtransparency="true" frameborder="0" src="about:blank"></iframe>
    </div>
  </body>
</html>
<?PHP } elseif ($Client['hotel'] == "fermer") { ?>
<!DOCTYPE html>
<html>
<head><a href="https://www.adobe.com/go/getflashplayer"></a>
<meta charset="utf-8">
  <title><?PHP echo htmlspecialchars(trim($cms['nom_hotel'])); ?> - Hotel</title>
</head>
<body style="background-color: rgba(0, 0, 0, 0.95);">
<div style="width: 970px;margin-right: auto;margin-left: auto;">
  <img src="http://hsource.fr/font/habbo_new/<?PHP echo htmlspecialchars(trim($cms['nom_hotel'])); ?>.gif"><br>
</div>
<div style="text-align: center;width: 970px;margin-left: auto;margin-right: auto;background-color: rgba(214, 20, 20, 0.8);border-radius: 5px;padding: 10px;margin-top: auto;">
<img src="web/img/maintenance/Frank_horsligne.gif">
<h1 style="color: #FFF;text-transform: uppercase;font-weight: 600;font-family: sans-serif;">Hôtel Hors-ligne</h1><br>
</div>
</body>
</html>
<?PHP } ?>
