-
-
Notifications
You must be signed in to change notification settings - Fork 38
/
index.php
118 lines (98 loc) · 4.26 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<?php
/***********************************************************************
| Cerb(tm) developed by Webgroup Media, LLC.
|-----------------------------------------------------------------------
| All source code & content (c) Copyright 2002-2019, Webgroup Media LLC
| unless specifically noted otherwise.
|
| This source code is released under the Devblocks Public License.
| The latest version of this license can be found here:
| http://cerb.ai/license
|
| By using this software, you acknowledge having read this license
| and agree to be bound thereby.
| ______________________________________________________________________
| http://cerb.ai http://webgroup.media
***********************************************************************/
/*
* IMPORTANT LICENSING NOTE from your friends at Cerb
*
* Sure, it would be really easy to just cheat and edit this file to use
* Cerb without paying for a license. We trust you anyway.
*
* It takes a significant amount of time and money to develop, maintain,
* and support high-quality enterprise software with a dedicated team.
* For Cerb's entire history we've avoided taking money from outside
* investors, and instead we've relied on actual sales from satisfied
* customers to keep the project running.
*
* We've never believed in hiding our source code out of paranoia over not
* getting paid. We want you to have the full source code and be able to
* make the tweaks your organization requires to get more done -- despite
* having less of everything than you might need (time, people, money,
* energy). We shouldn't be your bottleneck.
*
* As a legitimate license owner, your feedback will help steer the project.
* We'll also prioritize your issues, and work closely with you to make sure
* your teams' needs are being met.
*
* - Jeff Standen and Dan Hildebrandt
* Founders at Webgroup Media LLC; Developers of Cerb
*/
if(version_compare(PHP_VERSION, "8.2", "<")) {
http_response_code(500);
die("Cerb requires PHP 8.2 or later.");
}
if(!extension_loaded('mysqli')) {
http_response_code(500);
die("Cerb requires the 'mysqli' PHP extension. Please enable it.");
}
require(getcwd() . '/framework.config.php');
require(DEVBLOCKS_PATH . 'Devblocks.class.php');
// If this is our first run, redirect to the installer
if('' == APP_DB_HOST
|| '' == APP_DB_DATABASE
|| DevblocksPlatform::isDatabaseEmpty()) {
DevblocksPlatform::init();
$url_writer = DevblocksPlatform::services()->url();
$base_url = rtrim(preg_replace("/index\.php\/$/i",'',$url_writer->write('',true)),"/");
DevblocksPlatform::redirectURL($base_url.'/install/index.php');
}
require(APP_PATH . '/api/Application.class.php');
DevblocksPlatform::init();
DevblocksPlatform::setHandlerSession('Cerb_DevblocksSessionHandler');
// Request
$request = DevblocksPlatform::readRequest();
DevblocksPlatform::setStateless(in_array($request->path[0] ?? null, Cerb_DevblocksSessionHandler::getStatelessUris()));
if(DevblocksPlatform::isStateless()) {
$_SESSION = [];
} else {
DevblocksPlatform::services()->session();
}
// CSP
DevblocksPlatform::services()->http()->setHeader('Content-Security-Policy', CerberusApplication::getCspPolicy());
// Do we need an update first?
if(!DevblocksPlatform::versionConsistencyCheck()) {
if(0 != strcasecmp($request->path[0] ?? '',"update")) {
DevblocksPlatform::redirect(new DevblocksHttpResponse(array('update','locked')));
exit;
}
}
// Localization
DevblocksPlatform::setDateTimeFormat(DevblocksPlatform::getPluginSetting('cerberusweb.core', CerberusSettings::TIME_FORMAT, CerberusSettingsDefaults::TIME_FORMAT));
// Locale
DevblocksPlatform::setLocale((isset($_SESSION['locale']) && !empty($_SESSION['locale'])) ? $_SESSION['locale'] : 'en_US');
// Timezone
DevblocksPlatform::setTimezone();
// Time format
if(isset($_SESSION['time_format']))
DevblocksPlatform::setDateTimeFormat($_SESSION['time_format']);
// Initialize Logging
$timeout = ini_get('max_execution_time');
$logger = DevblocksPlatform::services()->log();
$logger->info("[Devblocks] ** Platform starting (".date("r").") **");
$logger->info('[Devblocks] Time Limit: '. (($timeout) ? $timeout : 'unlimited') ." secs");
$logger->info('[Devblocks] Memory Limit: '. ini_get('memory_limit'));
// [JAS]: HTTP Request (App->Platform)
CerberusApplication::processRequest($request);
exit;