Also display README and README.TXT before directory listing.

This commit is contained in:
Darren 'Tadgy' Austin 2025-10-06 19:30:06 +01:00
commit 9ee4a4bf5a
3 changed files with 28 additions and 15 deletions

27
html/includes/readmes.php Normal file
View file

@ -0,0 +1,27 @@
<?php
$path = parse_url ('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], PHP_URL_PATH);
if (is_dir ('/data/mirrors' . $path)) {
if (file_exists ('/data/mirrors' . $path . 'README.md')) {
require ('includes/Parsedown.php');
$readme = file_get_contents ('/data/mirrors' . $path . 'README.md');
$Parsedown = new Parsedown();
$file = "README.md";
} elseif (file_exists ('/data/mirrors' . $path . 'README')) {
$readme = file_get_contents ('/data/mirrors' . $path . 'README');
$file = "README";
} elseif (file_exists ('/data/mirrors' . $path . 'README.TXT')) {
$readme = file_get_contents ('/data/mirrors' . $path . 'README.TXT');
$file = "README.TXT";
}
}
if (isset ($file)) {
?>
<div class="box boxpadding">
<div class="heading bold centre" id="headingtext">Content of directory's <?php print ($file); ?></div>
<hr width="80%">
<?php $file == "README.md" ? print ($Parsedown->text ($readme)) : print ('<pre>' . $readme . '</pre>'); ?>
</div>
<br>
<?php
}
?>