-
-
Notifications
You must be signed in to change notification settings - Fork 194
/
index.php
62 lines (49 loc) · 1.63 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
56
57
58
59
60
61
62
<?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(), '7.2', '<')) {
http_response_code(500);
$body = "Sorry, this version of PHP (".phpversion().") is not supported. This probably means that you should update your server to the latest stable PHP release.";
$heading = "PHP Version not supported";
$helplink = '<a href="http://docs.withknown.com/en/latest/install/requirements/" target="_blank">Read system requirements</a>';
include dirname(__FILE__) . '/statics/error-page.php';
exit;
}
// Load the idno framework
require_once dirname(__FILE__) . '/Idno/start.php';
// Get page routes
$routes = \Idno\Core\Idno::site()->routes();
// 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);