forked from IlchCMS/Ilch-2.0
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
71 lines (56 loc) · 1.92 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
63
64
65
66
67
68
69
70
71
<?php
/**
* @copyright Ilch 2
* @package ilch
*/
define('PHPVERSION', '7.4');
if (!version_compare(PHP_VERSION, PHPVERSION, '>=')) {
die('Ilch CMS 2 needs at least php version ' . PHPVERSION);
}
@ini_set('display_errors', 'on');
error_reporting(E_ALL);
$isHttps = $_SERVER['HTTPS'] ?? $_SERVER['HTTP_X_FORWARDED_PROTO'] ?? null;
$isHttps = $isHttps && (strcasecmp('on', $isHttps) == 0 || strcasecmp('https', $isHttps) == 0);
define('ISHTTPSPAGE', $isHttps);
session_set_cookie_params([
'lifetime' => 0,
'path' => '/',
'domain' => $_SERVER['SERVER_NAME'],
'samesite' => 'Lax',
'secure' => ISHTTPSPAGE,
'httponly' => true,
]);
session_start();
header('Content-Type: text/html; charset=utf-8');
$serverTimeZone = @date_default_timezone_get();
date_default_timezone_set('UTC');
define('VERSION', '2.2.6');
define('SERVER_TIMEZONE', $serverTimeZone);
define('DEFAULT_MODULE', 'page');
define('DEFAULT_LAYOUT', 'index');
define('DEBUG_MODE', true);
// Path could not be under root.
define('ROOT_PATH', __DIR__);
define('APPLICATION_PATH', __DIR__ . '/application');
define('CONFIG_PATH', APPLICATION_PATH);
$rewriteBaseParts = explode('index.php', str_replace('Index.php', 'index.php', $_SERVER['PHP_SELF']));
$rewriteBaseParts = rtrim(reset($rewriteBaseParts), '/');
define('REWRITE_BASE', $rewriteBaseParts);
$protocol = ISHTTPSPAGE ? 'https' : 'http';
define('BASE_URL', $protocol . '://' . $_SERVER['HTTP_HOST'] . REWRITE_BASE);
//Get Platform-Version from User-Agent Client Hints
header("Accept-CH: Sec-CH-UA, Sec-CH-UA-Platform-Version");
// register autoloaders
require ROOT_PATH . '/vendor/autoload.php';
$loader = new \Ilch\Loader();
if (DEBUG_MODE) {
\Ilch\DebugBar::init();
}
\Ilch\Registry::set('startTime', microtime(true));
try {
$page = new \Ilch\Page();
$page->loadCms();
$page->loadPage();
} catch (Exception $ex) {
print 'An unexpected error occurred: <pre>' . $ex->getMessage() . '</pre>';
}