2019-06-28 15:30:55 +00:00
|
|
|
<?php
|
2019-07-04 16:34:33 +00:00
|
|
|
/*
|
|
|
|
This code is Copyright(c) 2019 by ubergeek under the GPL 3 or later.
|
|
|
|
Parsedown is licensed under the MIT license.
|
|
|
|
*/
|
2019-06-28 15:30:55 +00:00
|
|
|
|
2019-07-01 00:32:30 +00:00
|
|
|
include('config.php');
|
2019-07-04 16:34:33 +00:00
|
|
|
include('parsedown-1.7.3/Parsedown.php');
|
2019-07-01 00:32:30 +00:00
|
|
|
|
2021-03-20 16:43:07 +00:00
|
|
|
$page = isset($_GET['page']) ? $_GET['page'] : 'main';
|
|
|
|
|
2021-03-20 16:53:54 +00:00
|
|
|
// Sanitize page request so we don't allow to read EVERY markdown file
|
|
|
|
// for example ../../../home/foobar/mysecretdocument
|
|
|
|
if (strpos($page, "../") !== false) {
|
2021-03-20 17:33:58 +00:00
|
|
|
header('HTTP/1.0 403 Forbidden');
|
|
|
|
exit();
|
2021-03-20 16:53:54 +00:00
|
|
|
}
|
2021-03-20 17:33:58 +00:00
|
|
|
$content_file = "articles/$page.md";
|
2021-03-20 16:53:54 +00:00
|
|
|
|
2021-03-21 09:46:18 +00:00
|
|
|
// When you need some debugging
|
|
|
|
//echo "<br>page: $page";
|
|
|
|
//echo "<br>content file: $content_file";
|
|
|
|
|
2019-07-04 16:34:33 +00:00
|
|
|
$Parsedown = new Parsedown();
|
|
|
|
$Parsedown->setSafeMode(true);
|
2019-06-28 15:30:55 +00:00
|
|
|
|
2021-01-12 13:27:16 +00:00
|
|
|
if(isset($_GET['style']))
|
|
|
|
$site_style = $_GET['style'];
|
|
|
|
else
|
|
|
|
$site_style="site";
|
2019-07-04 16:34:33 +00:00
|
|
|
|
2021-03-20 16:36:39 +00:00
|
|
|
$header = file_get_contents("includes/header.md");
|
|
|
|
$sidebar = file_get_contents("includes/sidebar.md");
|
2021-03-20 16:43:07 +00:00
|
|
|
$content = file_exists($content_file) ? file_get_contents($content_file) : str_replace('$page', "$page", file_get_contents("includes/404.md"));
|
2021-03-20 16:36:39 +00:00
|
|
|
$footer = file_get_contents("includes/footer.md");
|
2021-03-20 18:15:04 +00:00
|
|
|
|
|
|
|
// TODO: Stylesheet URL assumes wiki is not operate in subfolder
|
|
|
|
|
2019-06-29 02:49:58 +00:00
|
|
|
print "<!DOCTYPE html>
|
2019-06-30 17:11:12 +00:00
|
|
|
<html lang='en'>
|
2019-06-28 15:51:05 +00:00
|
|
|
<head>
|
2019-07-01 01:01:55 +00:00
|
|
|
<title>$site_name - $page</title>
|
2021-03-20 18:15:04 +00:00
|
|
|
<link rel='stylesheet' type='text/css' href='/includes/$site_style.css'>
|
2019-07-01 01:05:38 +00:00
|
|
|
</head>
|
2019-07-01 21:55:26 +00:00
|
|
|
<body>
|
|
|
|
<!-- Begin Header -->
|
|
|
|
|
|
|
|
<div id='header'>";
|
|
|
|
|
2019-07-04 16:34:33 +00:00
|
|
|
print $Parsedown->text($header);
|
|
|
|
|
2019-07-01 21:55:26 +00:00
|
|
|
print "
|
|
|
|
</div>
|
|
|
|
<!-- End Header -->
|
|
|
|
";
|
2019-06-30 02:22:37 +00:00
|
|
|
|
2019-07-01 00:35:39 +00:00
|
|
|
print "<hr>
|
2019-07-01 21:55:26 +00:00
|
|
|
<div id='body'>
|
|
|
|
|
|
|
|
<!-- Begin Sidebar -->
|
|
|
|
<div id='sidebar'>
|
|
|
|
";
|
2019-07-04 16:34:33 +00:00
|
|
|
|
|
|
|
echo $Parsedown->text($sidebar);
|
2019-06-30 02:22:37 +00:00
|
|
|
|
2019-07-01 21:55:26 +00:00
|
|
|
print " </div>
|
|
|
|
<!-- End Sidebar -->
|
|
|
|
|
|
|
|
<!-- Begin Body -->
|
|
|
|
<div id='content'>";
|
2019-06-30 02:22:37 +00:00
|
|
|
|
2019-07-04 16:34:33 +00:00
|
|
|
echo $Parsedown->text($content);
|
2019-06-30 02:22:37 +00:00
|
|
|
|
2019-07-01 21:55:26 +00:00
|
|
|
print " </div>
|
|
|
|
<!-- End Body -->
|
|
|
|
|
2019-07-01 00:32:30 +00:00
|
|
|
</div>
|
2019-07-01 21:55:26 +00:00
|
|
|
|
|
|
|
<!-- Begin Footer -->
|
|
|
|
<div id='footer'>
|
2019-07-02 01:11:01 +00:00
|
|
|
<hr>
|
2019-07-01 21:55:26 +00:00
|
|
|
";
|
2019-06-30 02:22:37 +00:00
|
|
|
|
2019-07-04 16:34:33 +00:00
|
|
|
echo $Parsedown->text($footer);
|
2019-06-28 15:51:05 +00:00
|
|
|
|
2019-07-01 21:55:26 +00:00
|
|
|
print " </div>
|
|
|
|
<!-- End Footer -->
|
|
|
|
|
2019-06-30 17:17:30 +00:00
|
|
|
</body>
|
2019-06-28 15:51:05 +00:00
|
|
|
</html>";
|
2019-06-28 15:30:55 +00:00
|
|
|
?>
|