Raspsnir/public_html/tetris/index.php

103 lines
4.3 KiB
PHP

<?php
session_start();
require_once '../includes/php/connexionbdd.php';
$bdd = connexionBD();
$req = $bdd->prepare("SELECT pseudo, score, date FROM tetris ORDER BY score DESC;");
$req->execute() or die(print_r($requete->errorInfo()));
$affichScore = "";
$id = 0;
while ($ligne = $req->fetch()) //Affichage du resultat de la requete
{
$pseudo = htmlentities($ligne["pseudo"], ENT_QUOTES);
$pseudoIMG = $pseudo;
$score = htmlentities($ligne["score"], ENT_QUOTES);
$date = date("d-M-Y", strtotime($ligne["date"]));
$id++;
if($_SESSION['pseudo'] == $pseudo)
{
$pseudo .= "<i style=\"color:grey;\"> - Vous</i>";
}
//Concaténation du resultat
$affichScore .= "<li class=\"collection-item avatar\"><img src=\"../wankuls/img/$pseudoIMG.png\" class=\"circle\"><span class=\"title\"><b>$pseudo</b></span><p>Score : $score<br/>Date : $date</p><a class=\"secondary-content\" id=\"n$id\"><b>$id</b></a></li>";
}
?>
<!DOCTYPE html>
<html lang="fr">
<head>
<?php include ($_SERVER['DOCUMENT_ROOT'].'/includes/header.php'); ?>
<link rel="stylesheet" href="blockrain.css"/>
<link rel="stylesheet" href="tetris.css"/>
<title>RASPSNIR - TETRIS</title>
</head>
<body>
<div id="modal4" class="modal">
<div class="modal-content">
<h4>Sauvegarde du score</h4>
<p>Clique ici pour valider la sauvegarde de ton score</p>
</div>
<div class="modal-footer">
<a id="ValidScore" class="modal-action modal-close waves-effect btn-flat">Valider</a>
</div>
</div>
<div class="container">
<div id="tetris" class="game"></div>
<div class="row">
<div class="col s6 offset-s3">
<div class="center-align">
<a style="margin-right: 10px;" id="playpause" class="btn-floating btn-large waves-effect waves-light red"><i class="material-icons">pause</i></a>
<a style="margin-right: 10px;" id="restart" class="btn-floating btn-large waves-effect waves-light blue"><i class="material-icons">replay</i></a>
<a id="perf" class="btn-floating btn-large waves-effect waves-light green"><i class="material-icons">web</i></a>
</div>
</div>
</div>
<div class="row">
<div class="col s12">
<div class="card white">
<div class="card-content black-text">
<h4>Mise à jour du score</h4>
<div class="row">
<?php
if(!isset($_SESSION['pseudo']))
{
echo '<div class="input-field col s6"><blockquote>Vous devez obligatoirement être connecté pour mettre en ligne votre score.</blockquote></div><div class="input-field col s6"><a class="waves-effect waves-light modal-trigger btn" href="#modal3">Connexion<i class="material-icons left">perm_identity</i></a></div>';
}
else
{
echo '<div class="input-field col s6"><blockquote>Cliquez-ici pour sauvegarder votre score :</blockquote></div><div class="input-field col s6"><a class="waves-effect waves-light modal-trigger btn" href="#modal4">Sauvegarder le score<i class="material-icons left">perm_identity</i></a></div>';
}
?>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col s12">
<ul class="collection with-header">
<li class="collection-header"><h4>Classement</h4></li>
<?php echo $affichScore; ?>
</ul>
</div>
</div>
</div>
<?php include ($_SERVER['DOCUMENT_ROOT'].'/includes/footer.php'); ?>
<script type="application/javascript" src="blockrain.jquery.js"></script>
<script type="application/javascript" src="tetris.js"></script>
</body>
</html>