Compare commits
6 Commits
abf209326c
...
8d5275e3a4
Author | SHA1 | Date |
---|---|---|
Blade of Darkness | 8d5275e3a4 | |
southerntofu | 549e014daa | |
southerntofu | 6d6093990d | |
southerntofu | 79b32dda8e | |
southerntofu | 708dc5a3f1 | |
southerntofu | 3c0a380ce3 |
|
@ -0,0 +1,26 @@
|
||||||
|
# thunix wiki
|
||||||
|
|
||||||
|
Requires a webserver and PHP. The web server needs to be configured to:
|
||||||
|
|
||||||
|
- serve wiki.php by default (not index.php)
|
||||||
|
- when a requested URL does not correspond to an actual file, pass the requested page to wiki.php?page=
|
||||||
|
|
||||||
|
On apache, this is achieved by provided [.htaccess](.htaccess). On nginx, you can do something like:
|
||||||
|
|
||||||
|
```
|
||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
root /var/www/wiki_webroot;
|
||||||
|
index wiki.php;
|
||||||
|
server_name _;
|
||||||
|
|
||||||
|
location ~ \.php$ {
|
||||||
|
include snippets/fastcgi-php.conf;
|
||||||
|
fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
|
||||||
|
}
|
||||||
|
|
||||||
|
location ~ ^/(.+)$ {
|
||||||
|
try_files $uri $uri/ /wiki.php?page=$1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
|
@ -5,7 +5,4 @@ $site_name="Thunix Wiki";
|
||||||
//Root for the site, in a browser
|
//Root for the site, in a browser
|
||||||
$site_root="https://wiki.thunix.net";
|
$site_root="https://wiki.thunix.net";
|
||||||
|
|
||||||
//Local base root for app files
|
|
||||||
$doc_root="/var/www/wiki.thunix.net/";
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
# 404
|
||||||
|
|
||||||
|
This page ("$page") does not exist.
|
23
wiki.php
23
wiki.php
|
@ -7,23 +7,28 @@ Parsedown is licensed under the MIT license.
|
||||||
include('config.php');
|
include('config.php');
|
||||||
include('parsedown-1.7.3/Parsedown.php');
|
include('parsedown-1.7.3/Parsedown.php');
|
||||||
|
|
||||||
$page = $_GET['page'];
|
$page = isset($_GET['page']) ? $_GET['page'] : 'main';
|
||||||
|
|
||||||
|
// Sanitize page request so we don't allow to read EVERY markdown file
|
||||||
|
// for example ../../../home/foobar/mysecretdocument
|
||||||
|
if (strpos($page, "../") !== false) {
|
||||||
|
header('HTTP/1.0 403 Forbidden');
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
$content_file = "articles/$page.md";
|
||||||
|
|
||||||
$Parsedown = new Parsedown();
|
$Parsedown = new Parsedown();
|
||||||
$Parsedown->setSafeMode(true);
|
$Parsedown->setSafeMode(true);
|
||||||
|
|
||||||
if ( $page == "") {
|
|
||||||
$page = "main";
|
|
||||||
}
|
|
||||||
|
|
||||||
if(isset($_GET['style']))
|
if(isset($_GET['style']))
|
||||||
$site_style = $_GET['style'];
|
$site_style = $_GET['style'];
|
||||||
else
|
else
|
||||||
$site_style="site";
|
$site_style="site";
|
||||||
|
|
||||||
$header = file_get_contents("$doc_root/includes/header.md");
|
$header = file_get_contents("includes/header.md");
|
||||||
$sidebar = file_get_contents("$doc_root/includes/sidebar.md");
|
$sidebar = file_get_contents("includes/sidebar.md");
|
||||||
$content = file_get_contents("$doc_root/articles/$page.md");
|
$content = file_exists($content_file) ? file_get_contents($content_file) : str_replace('$page', "$page", file_get_contents("includes/404.md"));
|
||||||
$footer = file_get_contents("$doc_root/includes/footer.md");
|
$footer = file_get_contents("includes/footer.md");
|
||||||
|
|
||||||
print "<!DOCTYPE html>
|
print "<!DOCTYPE html>
|
||||||
<html lang='en'>
|
<html lang='en'>
|
||||||
|
|
Loading…
Reference in New Issue