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

View file

@ -85,7 +85,7 @@
} }
require ("includes/search-breadcrumbs-theme.php"); require ("includes/search-breadcrumbs-theme.php");
if (! preg_match (":^/((html/)?donors.php|(html/)?s(\.shtml)?(\?.*)?|(html/)?search(\.shtml)?(\?.*))$:", $_SERVER['REQUEST_URI']) && ! preg_match (":^4..$:", $_SERVER['REDIRECT_STATUS'])) { if (! preg_match (":^/((html/)?donors.php|(html/)?s(\.shtml)?(\?.*)?|(html/)?search(\.shtml)?(\?.*))$:", $_SERVER['REQUEST_URI']) && ! preg_match (":^4..$:", $_SERVER['REDIRECT_STATUS'])) {
require ("includes/readme-markdown.php"); require ("includes/readmes.php");
?> ?>
<div class="box boxpadding"> <div class="box boxpadding">
<?php } ?> <?php } ?>

View file

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

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
}
?>