49 lines
1.3 KiB
PHP
49 lines
1.3 KiB
PHP
<?php
|
|
require 'vendor/autoload.php';
|
|
require 'apps/apps.php';
|
|
|
|
if (in_array ("mod_rewrite", apache_get_modules()))
|
|
{
|
|
$urlRewrite = true;
|
|
} else {
|
|
$urlRewrite = false;
|
|
}
|
|
|
|
$dir = $_GET['dir'] ?? '';
|
|
$file = $_GET['file'] ?? '';
|
|
|
|
if (!empty($dir)) {
|
|
$dir = filter_input(INPUT_GET, 'dir', FILTER_SANITIZE_STRING);
|
|
}
|
|
|
|
if (isset($file)) {
|
|
$file = filter_input(INPUT_GET, 'file', FILTER_SANITIZE_STRING);
|
|
}
|
|
|
|
if (empty($file) || !file_exists('content/' . urldecode($dir) . '/' . urldecode($file) . '.md')) {
|
|
$dir = '';
|
|
if (file_exists('content/index.md')) {
|
|
$file = 'index';
|
|
} else {
|
|
$file = 'default';
|
|
|
|
}
|
|
}
|
|
|
|
$content = file_get_contents('content/' . urldecode($dir) . '/' . urldecode($file) . '.md');
|
|
$options = array('selectors' => array('h2', 'h3'));
|
|
|
|
$Parsedown = new ExtendParsedownToc($options);
|
|
|
|
$body = $Parsedown->text($content);
|
|
$toc = $Parsedown->contentsList();
|
|
|
|
$body = str_replace("[ ]", '<input type="checkbox" disabled>', $body);
|
|
$body = str_replace("[x]", '<input type="checkbox" checked disabled>', $body);
|
|
$body = str_replace("</h2>", ' <a href="#" class="backTop">⬆️</a></h2>', $body);
|
|
$body = str_replace("</h3>", ' <a href="#" class="backTop">⬆️</a></h3>', $body);
|
|
|
|
require 'tpl/header.html';
|
|
require 'tpl/aside.html';
|
|
require 'tpl/main.html';
|
|
require 'tpl/footer.html';
|