You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
123 lines
4.8 KiB
123 lines
4.8 KiB
<?php
|
|
// Check if a theme is posted, set a cookie
|
|
if (isset($_POST['theme'])) {
|
|
$theme = $_POST['theme'];
|
|
// Set a cookie to remember the theme for 30 jours
|
|
setcookie('theme', $theme, time() + (30 * 24 * 60 * 60), "/");
|
|
} elseif (isset($_COOKIE['theme'])) {
|
|
$theme = $_COOKIE['theme'];
|
|
} else {
|
|
$theme = 'dark-mode'; // Default theme is dark
|
|
}
|
|
?>
|
|
|
|
<!DOCTYPE html>
|
|
<html lang="fr">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Wiki Fantasy</title>
|
|
<link id="favicon" rel="icon" href="../images/iconeSombre.ico" /> <!-- Par défaut sombre -->
|
|
<link rel="stylesheet" href="../styles/styleAccueil.css"> <!-- Import de accueil.css -->
|
|
<script defer src="../script/theme-toggle.js"></script>
|
|
</head>
|
|
<body class="<?php echo htmlspecialchars($theme); ?>">
|
|
<div class="container">
|
|
<div class="header">
|
|
<div class="nav">
|
|
<a href="favorite.html"><img src="../images/coeur.svg" alt="coeur" width="67px" height="67px" onmousedown="return false"></a>
|
|
<img id="theme-icon" src="../images/light.svg" alt="toggle theme" width="72px" height="37px" onmousedown="return false" onclick="toggleTheme()">
|
|
<a href="quiz.html"><img src="../images/quizz.svg" alt="quizz" width="51px" height="82px" onmousedown="return false"></a>
|
|
</div>
|
|
<div class="logo">
|
|
<a href="accueil.html"><img src="../images/WIKIFANTASY.png" alt="Logo" width="227px" height="106px" onmousedown="return false"></a>
|
|
</div>
|
|
<div class="user">
|
|
<a href="profil.html"><img src="../images/user_dark.png" alt="user" width="70px" height="70px" onmousedown="return false"></a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<?php
|
|
// Open the file 'citation.txt'
|
|
$file = '../citation.txt';
|
|
$citations = file($file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
|
|
|
|
$citationDuJour = null;
|
|
$suggestions = [];
|
|
|
|
// Parcourir les citations pour détecter la citation du jour
|
|
foreach ($citations as $citation) {
|
|
$parts = explode(';', $citation);
|
|
|
|
// Vérifier si la citation commence par 'µ' (pour la citation du jour)
|
|
if (strpos(trim($parts[0]), 'µ') === 0) {
|
|
$citationDuJour = $parts; // Stocker la citation du jour
|
|
} else {
|
|
$suggestions[] = $parts; // Ajouter les autres citations aux suggestions
|
|
}
|
|
}
|
|
|
|
// Sélectionner un maximum de 10 citations aléatoires pour les suggestions, en vérifiant les doublons
|
|
shuffle($suggestions);
|
|
|
|
// Retirer la citation du jour si elle est présente dans les suggestions
|
|
$suggestions = array_filter($suggestions, function($suggestion) use ($citationDuJour) {
|
|
return count($suggestion) == 5 && !($suggestion[0] === trim($citationDuJour[1]));
|
|
});
|
|
|
|
// Limiter à 10 suggestions
|
|
$suggestions = array_slice($suggestions, 0, 10);
|
|
|
|
echo "<div class='citations-section'>";
|
|
|
|
// Afficher la citation du jour
|
|
if ($citationDuJour) {
|
|
$quote = htmlspecialchars(trim(substr($citationDuJour[1], 1))); // Retirer le symbole µ
|
|
$movie = htmlspecialchars(trim($citationDuJour[2]));
|
|
$character = htmlspecialchars(trim($citationDuJour[3]));
|
|
$year = htmlspecialchars(trim($citationDuJour[4]));
|
|
$imagePath = htmlspecialchars(trim($citationDuJour[5]));
|
|
|
|
echo "<h2>Citation du jour</h2>";
|
|
echo "<div class='citation-container citation-du-jour'>";
|
|
echo "<img src='$imagePath' alt='$movie' class='citation-image'>";
|
|
echo "<div class='text-content'>";
|
|
echo "<p class='quote'>\"$quote\"</p>";
|
|
echo "<p class='movie'>- $movie</p>";
|
|
echo "<p class='character'>Personnage : $character</p>";
|
|
echo "<p class='year'>Année : $year</p>";
|
|
echo "</div>";
|
|
echo "</div>";
|
|
} else {
|
|
echo "<p class='error'>Aucune citation du jour n'a été trouvée.</p>";
|
|
}
|
|
|
|
if (!empty($suggestions)) {
|
|
echo "<h2>Suggestions</h2>";
|
|
echo "<div class='suggestions-container'>"; // Conteneur pour gérer les colonnes
|
|
foreach ($suggestions as $suggestion) {
|
|
$quote = htmlspecialchars(trim($suggestion[0]));
|
|
$movie = htmlspecialchars(trim($suggestion[1]));
|
|
$character = htmlspecialchars(trim($suggestion[2]));
|
|
$year = htmlspecialchars(trim($suggestion[3]));
|
|
$imagePath = htmlspecialchars(trim($suggestion[4]));
|
|
|
|
echo "<div class='citation-container suggestion'>";
|
|
echo "<img src='$imagePath' alt='$movie' class='citation-image'>";
|
|
echo "<div class='text-content'>";
|
|
echo "<p class='quote'>\"$quote\"</p>";
|
|
echo "<p class='movie'>- $movie</p>";
|
|
echo "<p class='character'>Personnage : $character</p>";
|
|
echo "<p class='year'>Année : $year</p>";
|
|
echo "</div>";
|
|
echo "</div>";
|
|
}
|
|
echo "</div>"; // Fin du conteneur suggestions
|
|
}
|
|
|
|
echo "</div>"; // Fin de la section des citations
|
|
?>
|
|
</body>
|
|
</html>
|