From 0ae8cbf5c0b1a198b963490985b7738392ebcb97 Mon Sep 17 00:00:00 2001 From: ahriman Date: Mon, 3 Dec 2018 19:22:25 -0500 Subject: installed dokuwiki, added to navbar, updated news --- wiki/index.php | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 wiki/index.php (limited to 'wiki/index.php') diff --git a/wiki/index.php b/wiki/index.php new file mode 100644 index 0000000..689ce17 --- /dev/null +++ b/wiki/index.php @@ -0,0 +1,68 @@ + + */ +if(php_sapi_name() != 'cli-server') { + header("Location: doku.php"); + exit; +} + +# ROUTER starts below + +# avoid path traversal +$_SERVER['SCRIPT_NAME'] = str_replace('/../', '/', $_SERVER['SCRIPT_NAME']); + +# routing aka. rewriting +if(preg_match('/^\/_media\/(.*)/', $_SERVER['SCRIPT_NAME'], $m)) { + # media dispatcher + $_GET['media'] = $m[1]; + require $_SERVER['DOCUMENT_ROOT'] . '/lib/exe/fetch.php'; + +} else if(preg_match('/^\/_detail\/(.*)/', $_SERVER['SCRIPT_NAME'], $m)) { + # image detail view + $_GET['media'] = $m[1]; + require $_SERVER['DOCUMENT_ROOT'] . '/lib/exe/detail.php'; + +} else if(preg_match('/^\/_media\/(.*)/', $_SERVER['SCRIPT_NAME'], $m)) { + # exports + $_GET['do'] = 'export_' . $m[1]; + $_GET['id'] = $m[2]; + require $_SERVER['DOCUMENT_ROOT'] . '/doku.php'; + +} elseif($_SERVER['SCRIPT_NAME'] == '/index.php') { + # 404s are automatically mapped to index.php + if(isset($_SERVER['PATH_INFO'])) { + $_GET['id'] = $_SERVER['PATH_INFO']; + } + require $_SERVER['DOCUMENT_ROOT'] . '/doku.php'; + +} else if(file_exists($_SERVER['DOCUMENT_ROOT'] . $_SERVER['SCRIPT_NAME'])) { + # existing files + + # access limitiations + if(preg_match('/\/([\._]ht|README$|VERSION$|COPYING$)/', $_SERVER['SCRIPT_NAME']) or + preg_match('/^\/(data|conf|bin|inc)\//', $_SERVER['SCRIPT_NAME']) + ) { + die('Access denied'); + } + + if(substr($_SERVER['SCRIPT_NAME'], -4) == '.php') { + # php scripts + require $_SERVER['DOCUMENT_ROOT'] . $_SERVER['SCRIPT_NAME']; + } else { + # static files + return false; + } +} +# 404 -- cgit 1.4.1-2-gfad0 /p_sha1.c?id=d485588a07f9d4a477a7615fee926fcfee44b29e'>p_sha1.c
blob: 11adede3521823896bd686130f31f5ca342b01c8 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16