-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathbootstrap.php
More file actions
49 lines (40 loc) · 1.93 KB
/
Copy pathbootstrap.php
File metadata and controls
49 lines (40 loc) · 1.93 KB
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
<?php
declare(strict_types=1);
$configPath = __DIR__ . '/config.php';
if (!is_file($configPath)) {
throw new RuntimeException('Missing config.php. Please create config.php before running the app.');
}
$GLOBALS['app_config_path'] = $configPath;
$GLOBALS['app_config'] = require $configPath;
$timezone = (string) ($GLOBALS['app_config']['app']['timezone'] ?? 'UTC');
date_default_timezone_set($timezone);
if (session_status() !== PHP_SESSION_ACTIVE) {
$sessionConfig = $GLOBALS['app_config'];
$sessionBaseUrl = trim((string) ($sessionConfig['app']['base_url'] ?? ''), '/');
$sessionNamespace = trim((string) ($sessionConfig['app']['session_namespace'] ?? ''));
$sessionInstallPath = str_replace('\\', '/', (string) (realpath(__DIR__) ?: __DIR__));
$sessionSeed = $sessionNamespace !== ''
? 'namespace:' . $sessionNamespace
: implode('|', [
'base:' . strtolower($sessionBaseUrl),
'public:' . strtolower(trim((string) ($sessionConfig['app']['public_url'] ?? ''))),
'path:' . strtolower($sessionInstallPath),
]);
session_name('DLSESSID' . substr(hash('sha256', $sessionSeed), 0, 16));
$cookieParams = session_get_cookie_params();
$cookieParams['path'] = $sessionBaseUrl === '' ? '/' : '/' . $sessionBaseUrl;
$cookieParams['httponly'] = true;
$cookieParams['samesite'] = 'Lax';
if ((!empty($_SERVER['HTTPS']) && strtolower((string) $_SERVER['HTTPS']) !== 'off')
|| strtolower((string) ($_SERVER['HTTP_X_FORWARDED_PROTO'] ?? '')) === 'https'
|| (string) ($_SERVER['SERVER_PORT'] ?? '') === '443') {
$cookieParams['secure'] = true;
}
session_set_cookie_params($cookieParams);
session_start();
}
require_once __DIR__ . '/includes/functions.php';
require_once __DIR__ . '/includes/db.php';
require_once __DIR__ . '/includes/schema_update.php';
ensure_schema_updated_on_bootstrap();
require_once __DIR__ . '/includes/layout.php';