Move away from madness

This commit is contained in:
2025-09-13 22:58:19 +02:00
parent fbcf64fff2
commit 1bba146344
112 changed files with 654 additions and 73 deletions
+35
View File
@@ -0,0 +1,35 @@
<?php
declare(strict_types=1);
use Twig\Environment;
use Twig\Loader\FilesystemLoader;
require 'vendor/autoload.php';
$twig = new Environment(new FilesystemLoader('./templates'));
$score = realpath('./scores/' . ($_GET['score'] ?? ''));
$scoreValid = false !== $score
&& str_starts_with($score, realpath('./scores'))
&& is_file($score)
&& str_ends_with($score, '.md');
$allAvailableScores = array_map(
fn (string $filePath) => basename($filePath, '.md'),
glob('./scores/*.md')
);
if (!$scoreValid) {
echo $twig->render('index.html.twig', ['scores' => $allAvailableScores, 'title' => 'Available Scores']);
exit(0);
}
$markdown = file_get_contents($score);
$parsedown = new Parsedown();
$html = $parsedown->text($markdown);
echo $twig->render('score.html.twig', [
'score' => $html,
'scores' => $allAvailableScores,
'title' => basename($score, '.md'),
]);