forked from idno/known
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
55 lines (43 loc) · 1.21 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
/**
* Known index page and router.
* It all starts here!
*
* If you're wondering what this is all about, you could do worse than
* check out the README.md file.
*
* Project homepage: https://withknown.com/
* Project repo: https://github.com/idno/known
*
* @package idno
* @subpackage core
*/
// Check PHP version first of all
if (version_compare(phpversion(), '5.4', '<')) {
header('Location: warmup/');
exit;
}
// Load the idno framework
require_once(dirname(__FILE__) . '/Idno/start.php');
// Get page routes
$routes = \Idno\Core\Idno::site()->pagehandlers;
// Get subdirectory
$url = \Idno\Core\Idno::site()->config()->getURL();
$path = parse_url($url, PHP_URL_PATH);
if (substr($path, -1) == '/') {
$path = substr($path, 0, -1);
}
if (!empty($path)) {
if (!empty($routes['/'])) {
$routes[$path . '/'] = $routes['/'];
}
}
// Manage routing
\Idno\Core\PageHandler::hook('404', function ($params = array()) {
http_response_code(404);
$t = \Idno\Core\Idno::site()->template();
// Take over page detection
\Idno\Core\Idno::site()->template()->autodetectTemplateType();
(new \Idno\Pages\Homepage())->noContent();
});
\Idno\Core\PageHandler::serve($routes);