Repository navigation
Expand file tree
/
Copy pathbootstrap.php
More file actions
67 lines (59 loc) · 2.45 KB
/
Copy pathbootstrap.php
File metadata and controls
67 lines (59 loc) · 2.45 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
use CoreDB\Kernel\Database\DatabaseInstallationException;
use Src\Controller\InstallController;
include __DIR__ . '/vendor/autoload.php';
include __DIR__ . '/Kernel/CoreDB.php';
define("IS_CLI", php_sapi_name() === 'cli');
try {
if (is_file(__DIR__ . '/config/config.php')) {
include __DIR__ . '/config/config.php';
define("CONFIGURATON_LOADED", true);
} else {
define("CONFIGURATON_LOADED", false);
}
if (!IS_CLI) {
$host = \CoreDB::baseHost();
if (defined("TIMEZONE")) {
date_default_timezone_set(TIMEZONE);
}
define("BASE_URL", (@$_SERVER["REQUEST_SCHEME"] ?: "http") . "://" . $host . SITE_ROOT);
$httpAuthorizationHeader = @$_SERVER["HTTP_AUTHORIZATION"] ?: (
@$_SERVER["REDIRECT_HTTP_AUTHORIZATION"] ?: @$_SERVER["REDIRECT_REDIRECT_HTTP_AUTHORIZATION"]
);
if (defined("HTTP_AUTH_ENABLED") && HTTP_AUTH_ENABLED) {
if ($httpAuthorizationHeader && !@$_SERVER['PHP_AUTH_USER'] && !@$_SERVER['PHP_AUTH_PW']) {
list($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']) = explode(':', base64_decode(substr($httpAuthorizationHeader, 6)));
}
if (
@$_SERVER['PHP_AUTH_USER'] !== HTTP_AUTH_USERNAME ||
@$_SERVER['PHP_AUTH_PW'] !== HTTP_AUTH_PASSWORD
) {
header("WWW-Authenticate: Basic realm=\"Coredb Auth\"");
header("HTTP/1.0 401 Unauthorized");
die();
}
}
$headers = getallheaders();
if (!@$headers["Authorization"] && $httpAuthorizationHeader) {
$headers["Authorization"] = $httpAuthorizationHeader;
}
if (@$headers["Authorization"] && !isset($_COOKIE[session_name()])) {
$sessionId = str_replace("Bearer ", "", $headers["Authorization"]);
if (strlen($sessionId) > ini_get("session.sid_length")) {
$sessionId = md5($sessionId);
}
session_id($sessionId);
}
session_start();
if( defined("ENVIROMENT") && defined("SENTRY_DSN") && SENTRY_DSN && ENVIROMENT != "development"){
Sentry\init(['dsn' => SENTRY_DSN ]);
}
CoreDB\Kernel\Router::getInstance()->route();
}
} catch (DatabaseInstallationException $ex) {
if (!CONFIGURATON_LOADED) {
CoreDB::goTo(InstallController::getUrl());
} else {
echo $ex->getMessage();
}
}