Current directory: /home/klas4s23/domains/585455.klas4s23.mid-ica.nl/public_html/Gastenboek/uploads
<?php
session_start();
if (!isset($_SESSION['user_id'])) {
header("Location: login.php");
exit();
}
include 'db_conn.php';
$user_id = $_SESSION['user_id'];
$sql = "
SELECT e_learning_lists.*,
e_learning_users.username,
s.last_played,
s.score,
s.total_questions
FROM e_learning_lists
JOIN e_learning_users ON e_learning_lists.user_id = e_learning_users.id
LEFT JOIN (
SELECT list_id,
MAX(last_played) AS last_played,
score,
total_questions
FROM e_learning_scores
WHERE user_id = ?
GROUP BY list_id
) s ON e_learning_lists.id = s.list_id
WHERE e_learning_lists.publicity = 'public'
ORDER BY e_learning_lists.id DESC";
$stmt = $conn->prepare($sql);
$stmt->bind_param("i", $user_id);
$stmt->execute();
$result = $stmt->get_result();
$allLists = $result->fetch_all(MYSQLI_ASSOC);
$conn->close();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta author="Rick Deurloo">
<meta name="description" content="Website description">
<meta name="keywords" content="Website keywords">
<link rel="stylesheet" href="https://site-assets.fontawesome.com/releases/v6.7.2/css/all.css">
<link rel="stylesheet" href="https://site-assets.fontawesome.com/releases/v6.7.2/css/sharp-thin.css">
<link rel="stylesheet" href="https://site-assets.fontawesome.com/releases/v6.7.2/css/sharp-solid.css">
<link rel="stylesheet" href="https://site-assets.fontawesome.com/releases/v6.7.2/css/sharp-regular.css">
<link rel="stylesheet" href="https://site-assets.fontawesome.com/releases/v6.7.2/css/sharp-light.css">
<link rel="stylesheet" href="./styles/dist/css/style.css">
<link rel="icon" href="./assets/favicon-en.png" data-translate-image="favicon">
<title data-translate="exploreTitle">English e-learning | Explore</title>
</head>
<body class="explore-page">
<?php include './php-components/header.php'; ?>
<main class="explore-main">
<div class="explore-header">
<div class="header-text">
<h1 data-translate="exploreLists">Explore Lists</h1>
<p data-translate="subTitleExplore">Discover word lists created by other users</p>
</div>
<div class="search">
<input type="text" id="search-lists" data-translate-placeholder="searchPlaceholder" placeholder="Search lists by title or username">
<button><i class="fa-solid fa-sharp fa-magnifying-glass"></i></button>
</div>
</div>
<div class="lists-container">
<?php foreach ($allLists as $list): ?>
<div class="list">
<a href="list-page.php?id=<?php echo $list['id']; ?>" class="list-thumbnail"
style="background: repeating-linear-gradient(45deg, white, white 10px, <?php echo $list['color']; ?> 10px, <?php echo $list['color']; ?> 20px);">
<div class="last-score">
<?php if (!empty($list['last_played']) && !empty($list['score']) && !empty($list['total_questions'])): ?>
<span data-translate="lastPlayed">Last played:</span><br><?php echo date('d-m-Y', strtotime($list['last_played'])); ?> | <?php echo $list['score']; ?>/<?php echo $list['total_questions']; ?>
<?php else: ?>
<span data-translate="notPlayed">Not played</span>
<?php endif; ?>
</div>
</a>
<div class="list-wrapper">
<div class="list-sub-wrapper">
<div class="list-title"><?php echo htmlspecialchars($list['list_title']); ?></div>
<div class="list-creator">
<i class="fa-solid fa-user"></i>
<span><?php echo htmlspecialchars($list['username']); ?></span>
</div>
</div>
</div>
</div>
<?php endforeach; ?>
</div>
</main>
<script src="./js/general.js"></script>
<script src="./js/translation.js"></script>
<script src="./js/search.js"></script>
</body>
</html>