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

if (file_exists($f)) {
require_once('../app/php/pdo.php');
} else {
  header('Refresh: 0;URL=index.php');
}

if (isset($_POST['valider'])) {
  if (!empty($_POST['lien']) && !empty($_POST['nom'])) {
    $lien = htmlspecialchars(trim($_POST['lien']));
    $nom = htmlspecialchars(trim($_POST['nom']));
    $UPConfig = $bdd->prepare('UPDATE pluscms_configuration SET lien = ?, nom_hotel = ? WHERE id = ?');
    $UPConfig->execute(array($lien,$nom,1));
    header('Location: etape3.php');
  } else {
    $message = "Merci de remplir tous les champs.";
  }
}
?>
<!DOCTYPE html>
<html lang="en">

  <head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>PlusCMS - Installation</title>

    <!-- Bootstrap core CSS -->
    <link href="vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">

    <!-- Custom styles for this template -->
    <style>
      body {
        padding-top: 54px;
      }
      @media (min-width: 992px) {
        body {
          padding-top: 56px;
        }
      }

    </style>

  </head>

  <body>

    <!-- Navigation -->
    <nav class="navbar navbar-expand-lg navbar-dark bg-dark fixed-top">
      <div class="container">
        <a class="navbar-brand" href="#">PlusCMS</a>
        <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
          <span class="navbar-toggler-icon"></span>
        </button>
      </div>
    </nav>

    <!-- Page Content -->
    <div class="container">
      <div class="row">
        <div class="col-lg-12 text-center">
          <h1 class="mt-5">Etape 2 de l'installation</h1>
          <p class="lead">Configuration du site</p>
          <?PHP if(isset($message)) { ?><p class="lead" style="color: green;"><?PHP echo $message; ?></p><?PHP } ?>
          <div class="well" style="width: 500px;position: relative;margin-left: auto;margin-right: auto;">
          <form method="post">
            <div class="form-group">
              <label class="control-label" for="inputLarge">Adresse du site web (pas de / à la fin)</label>
              <input class="form-control input-lg" name="lien" value="http://<?PHP echo $_SERVER['SERVER_NAME']; ?>" placeholder="https://.." type="text" id="inputLarge">
            </div>
            <div class="form-group">
              <label class="control-label" for="inputLarge">Nom de votre hôtel </label>
              <input class="form-control input-lg" name="nom" value="Habbo" placeholder="Habbo" type="text" id="inputLarge">
            </div>
            <button name="valider" type="submit" class="btn btn-primary">Valider</button>
            </form>
          </div>
          <ul class="list-unstyled">
            <li>Ce système d'installation est destiné à PlusCMS par Dodone.</li>
          </ul>
        </div>
      </div>
    </div>

    <!-- Bootstrap core JavaScript -->
    <script src="vendor/jquery/jquery.min.js"></script>
    <script src="vendor/bootstrap/js/bootstrap.bundle.min.js"></script>

  </body>

</html>
