Current directory: /home/klas4s23/domains/585455.klas4s23.mid-ica.nl/public_html/Gastenboek/uploads
<?php
session_start();
include "db.php";
// Check if user is logged in and is admin
if (!isset($_SESSION['user_id']) || !isset($_SESSION['is_admin']) || $_SESSION['is_admin'] != 1) {
header("Location: login.php");
exit();
}
$list_id = isset($_GET['list_id']) ? (int)$_GET['list_id'] : 0;
if ($list_id <= 0) {
header("Location: admin.php");
exit();
}
// Get list details
try {
$stmt = $conn->prepare("
SELECT wl.*, u.username as creator_username
FROM word_lists wl
JOIN users u ON wl.user_id = u.id
WHERE wl.id = ?
");
$stmt->execute([$list_id]);
$list = $stmt->fetch();
if (!$list) {
header("Location: admin.php");
exit();
}
// Get list words
$stmt = $conn->prepare("SELECT * FROM list_words WHERE list_id = ? ORDER BY id");
$stmt->execute([$list_id]);
$words = $stmt->fetchAll();
} catch (PDOException $e) {
echo "Error: " . $e->getMessage();
exit();
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>View List - Admin Panel - ELearner</title>
<link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css" rel="stylesheet">
<link rel="stylesheet" href="styles.css">
<link rel="stylesheet" href="font-styles.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css">
</head>
<body class="bg-gray-100 min-h-screen">
<div class="container mx-auto px-4 py-4 sm:py-8">
<header class="bg-white rounded-lg shadow-md p-4 sm:p-6 mb-6 sm:mb-8">
<div class="flex flex-wrap items-center justify-between">
<div class="flex items-center">
<a href="homepage.php">
<img src="images/icon-e-learner-blue.png" alt="ELearner Logo" class="h-10 sm:h-12 mr-3 sm:mr-4">
</a>
<div>
<h1 class="text-2xl sm:text-3xl font-bold text-blue-600">ELearner</h1>
<p class="text-sm sm:text-base text-gray-600">Admin Panel - View List</p>
</div>
</div>
<nav id="desktopMenu" class="hidden md:block">
<ul class="flex space-x-4 sm:space-x-6">
<li><a href="homepage.php" class="text-blue-500 font-medium hover:underline">Home</a></li>
<li><a href="index.php" class="text-blue-500 font-medium hover:underline">Vocabulary Tool</a></li>
<li><a href="my_lists.php" class="text-blue-500 font-medium hover:underline">My Lists</a></li>
<li><a href="list_hub.php" class="text-blue-500 font-medium hover:underline">List Hub</a></li>
<li><a href="profile.php" class="text-blue-500 font-medium hover:underline">My Profile</a></li>
<li><a href="admin.php" class="text-purple-500 font-medium hover:underline">Admin</a></li>
<li><a href="logout.php" class="text-red-500 font-medium hover:underline">Logout</a></li>
<li>
<button id="fontToggleBtn" class="bg-purple-500 text-white px-3 py-1 rounded hover:bg-purple-600">
Toggle Font
</button>
</li>
</ul>
</nav>
<!-- Mobile menu button -->
<button id="mobileMenuBtn" class="md:hidden p-2 rounded text-blue-600 hover:bg-blue-100">
<svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h16M4 18h16"></path>
</svg>
</button>
</div>
<!-- Mobile menu, hidden by default -->
<nav id="mobileMenu" class="md:hidden hidden mt-4 pb-2">
<ul class="flex flex-col space-y-3">
<li><a href="homepage.php" class="block text-blue-500 font-medium hover:underline">Home</a></li>
<li><a href="index.php" class="block text-blue-500 font-medium hover:underline">Vocabulary Tool</a></li>
<li><a href="my_lists.php" class="block text-blue-500 font-medium hover:underline">My Lists</a></li>
<li><a href="list_hub.php" class="block text-blue-500 font-medium hover:underline">List Hub</a></li>
<li><a href="profile.php" class="block text-blue-500 font-medium hover:underline">My Profile</a></li>
<li><a href="admin.php" class="block text-purple-500 font-medium hover:underline">Admin</a></li>
<li><a href="logout.php" class="block text-red-500 font-medium hover:underline">Logout</a></li>
<li>
<button id="mobileFontToggleBtn" class="bg-purple-500 text-white px-3 py-1 rounded hover:bg-purple-600">
Toggle Font
</button>
</li>
</ul>
</nav>
</header>
<main class="bg-white rounded-lg shadow-md p-4 sm:p-6">
<div class="flex justify-between items-center mb-6">
<h2 class="text-xl sm:text-2xl font-bold">List: <?= htmlspecialchars($list['name']) ?></h2>
<a href="admin_user_lists.php?user_ids=<?= $list['user_id'] ?>" class="text-blue-500 hover:underline">
<i class="fas fa-arrow-left mr-1"></i> Back to User Lists
</a>
</div>
<div class="bg-gray-50 p-4 rounded-lg mb-6">
<div class="grid grid-cols-1 md:grid-cols-3 gap-4">
<div>
<p class="text-sm text-gray-600">Creator:</p>
<p class="font-medium"><?= htmlspecialchars($list['creator_username']) ?> (ID: <?= $list['user_id'] ?>)</p>
</div>
<div>
<p class="text-sm text-gray-600">Created:</p>
<p class="font-medium"><?= date('F j, Y, g:i a', strtotime($list['created_at'])) ?></p>
</div>
<div>
<p class="text-sm text-gray-600">Status:</p>
<p class="font-medium">
<?php if ($list['public']): ?>
<span class="text-green-600"><i class="fas fa-globe mr-1"></i> Public</span>
<?php else: ?>
<span class="text-gray-600"><i class="fas fa-lock mr-1"></i> Private</span>
<?php endif; ?>
<?php if ($list['is_copy']): ?>
<span class="text-orange-600 ml-2"><i class="fas fa-copy mr-1"></i> Copied</span>
<?php endif; ?>
<?php if ($list['score'] !== null): ?>
<span class="ml-2 <?= $list['score'] >= 80 ? 'text-green-600' : ($list['score'] >= 50 ? 'text-yellow-600' : 'text-red-600') ?>">
<i class="fas fa-chart-line mr-1"></i> Score: <?= $list['score'] ?>%
</span>
<?php endif; ?>
</p>
</div>
</div>
</div>
<h3 class="text-lg font-bold mb-4">Words (<?= count($words) ?>)</h3>
<?php if (empty($words)): ?>
<div class="text-center py-6 bg-gray-50 rounded">
<p class="text-gray-500">This list doesn't contain any words.</p>
</div>
<?php else: ?>
<div class="overflow-x-auto">
<table class="min-w-full bg-white border">
<thead>
<tr class="bg-gray-200 text-gray-700">
<th class="py-2 px-4 border-b text-left">ID</th>
<th class="py-2 px-4 border-b text-left">Dutch</th>
<th class="py-2 px-4 border-b text-left">English</th>
</tr>
</thead>
<tbody>
<?php foreach ($words as $word): ?>
<tr class="hover:bg-gray-50">
<td class="py-2 px-4 border-b"><?= $word['id'] ?></td>
<td class="py-2 px-4 border-b"><?= htmlspecialchars($word['dutch']) ?></td>
<td class="py-2 px-4 border-b"><?= htmlspecialchars($word['english']) ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?php endif; ?>
</main>
</div>
<script>
// Mobile menu toggle
document.getElementById("mobileMenuBtn").addEventListener("click", function() {
const mobileMenu = document.getElementById("mobileMenu");
mobileMenu.classList.toggle("hidden");
});
// Copy font toggle functionality to mobile button
if (document.getElementById("mobileFontToggleBtn")) {
document.getElementById("mobileFontToggleBtn").addEventListener("click", function() {
document.getElementById("fontToggleBtn").click();
});
}
</script>
<script src="font-toggle.js"></script>
</body>
</html>