forked from agentejo/cockpit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
executable file
·37 lines (27 loc) · 1.1 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
<?php
define('COCKPIT_ADMIN', 1);
// set default timezone
date_default_timezone_set('UTC');
// handle php webserver
if (PHP_SAPI == 'cli-server' && is_file(__DIR__.parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH))) {
return false;
}
// bootstrap cockpit
require(__DIR__.'/bootstrap.php');
# admin route
if (COCKPIT_ADMIN && !defined('COCKPIT_ADMIN_ROUTE')) {
$route = preg_replace('#'.preg_quote(COCKPIT_BASE_URL, '#').'#', '', parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH), 1);
define('COCKPIT_ADMIN_ROUTE', $route == '' ? '/' : $route);
}
if (COCKPIT_API_REQUEST) {
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Credentials: true");
header("Access-Control-Max-Age: 1000");
header("Access-Control-Allow-Headers: X-Requested-With, Content-Type, Origin, Cache-Control, Pragma, Authorization, Accept, Accept-Encoding");
header("Access-Control-Allow-Methods: PUT, POST, GET, OPTIONS, DELETE");
if ($_SERVER["REQUEST_METHOD"] == "OPTIONS") {
exit(0);
}
}
// run backend
$cockpit->set('route', COCKPIT_ADMIN_ROUTE)->trigger("admin.init")->run();