MyNoVi/index.php

50 lines
1.3 KiB
PHP
Raw Permalink Normal View History

2020-10-08 17:00:12 +02:00
<?php
require 'vendor/autoload.php';
require 'apps/apps.php';
if (in_array ("mod_rewrite", apache_get_modules()))
{
$urlRewrite = true;
} else {
$urlRewrite = false;
}
2020-10-13 17:20:49 +02:00
$dir = $_GET['dir'] ?? '';
2020-10-08 17:00:12 +02:00
$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 = '';
2020-10-13 17:20:49 +02:00
if (file_exists('content/index.md')) {
2020-10-08 17:00:12 +02:00
$file = 'index';
} else {
$file = 'default';
}
}
$content = file_get_contents('content/' . urldecode($dir) . '/' . urldecode($file) . '.md');
2020-10-13 17:20:49 +02:00
$options = array('selectors' => array('h2', 'h3'));
2020-10-08 17:00:12 +02:00
2020-10-14 12:18:12 +02:00
$Parsedown = new ExtendParsedownToc($options);
$body = $Parsedown->text($content);
$toc = $Parsedown->contentsList();
2020-10-08 17:00:12 +02:00
$body = str_replace("[ ]", '<input type="checkbox" disabled>', $body);
$body = str_replace("[x]", '<input type="checkbox" checked disabled>', $body);
2020-10-13 17:20:49 +02:00
$body = str_replace("</h2>", ' <a href="#" class="backTop">⬆️</a></h2>', $body);
$body = str_replace("</h3>", ' <a href="#" class="backTop">⬆️</a></h3>', $body);
2020-10-08 17:00:12 +02:00
require 'tpl/header.html';
require 'tpl/aside.html';
require 'tpl/main.html';
require 'tpl/footer.html';