slackware.uk/html/includes/readmes.php

27 lines
1 KiB
PHP

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