Files
Thomas a184c31cca Software
v0.0..1
2025-10-05 14:58:05 +02:00

42 lines
1.1 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
require_once __DIR__ . '/guard.php';
require_login();
try {
$db = new PDO('sqlite:' . dirname(__DIR__) . '/data/app.db');
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$db->exec('CREATE TABLE IF NOT EXISTS points (user_login TEXT PRIMARY KEY, display_name TEXT, points INTEGER DEFAULT 0)');
$rows = $db->query('SELECT user_login, display_name, points FROM points ORDER BY points DESC LIMIT 200')->fetchAll(PDO::FETCH_ASSOC);
} catch (Exception $e) {
die('Database error: ' . htmlspecialchars($e->getMessage()));
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Loyalty Points</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="wrap">
<div class="card">
<h2>🏆 Loyalty Points Top</h2>
<table>
<tr>
<th>#</th>
<th>Bruger</th>
<th>Point</th>
</tr>
<?php foreach ($rows as $i => $r): ?>
<tr>
<td><?= $i + 1 ?></td>
<td>@<?= htmlspecialchars($r['display_name'] ?: $r['user_login']) ?></td>
<td><?= (int)$r['points'] ?></td>
</tr>
<?php endforeach; ?>
</table>
</div>
</div>
</body>
</html>