topmostfriend-website/public/changelog.php
2023-11-19 16:57:31 +00:00

41 lines
1.1 KiB
PHP

<?php
$_curr_page = 'changelog';
$title = 'Changelog';
$description = 'This page describes changes that have been made between versions of Top Most Friend.';
$files = glob('dl/*/changelog.txt');
rsort($files);
$indent = "\r\n ";
$body = "{$indent}<h2>{$title}</h2>"
. "{$indent}<p>{$description}</p>";
foreach($files as $fileName) {
$file = fopen($fileName, 'rb');
$header = trim(fgets($file));
if(empty($header))
continue;
[$version, $date] = explode(' - ', $header, 2);
$versionId = $version;
$date = strtotime($date);
$body .= sprintf('%s<h3 id="%s"><a href="#%s">%s &mdash; <time datetime="%s">%s</time></a></h3>', $indent, $versionId, $versionId, $version, date('c', $date), date('Y-m-d', $date));
while(($line = fgets($file)) !== false) {
$line = trim($line);
if(empty($line))
continue;
[$stamp, $line] = explode(' ', $line, 2);
$body .= sprintf('%s<p><code>%s</code> %s</p>', $indent, $stamp, $line);
}
fclose($file);
}
$body .= substr($indent, 0, -4);
require_once __DIR__ . '/_inc/out.php';