forked from agentejo/cockpit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
34 lines (24 loc) · 952 Bytes
/
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
<?php
define('COCKPIT_ADMIN', 1);
date_default_timezone_set('UTC');
// $_SERVER['PATH_INFO'] fix for nginx >:-/
if (!isset($_SERVER['PATH_INFO']) && strpos($_SERVER['REQUEST_URI'], $_SERVER['PHP_SELF'])===0) {
$_URI = preg_replace('/\?(.*)/', '', $_SERVER['REQUEST_URI']);
$_SELF = $_SERVER['PHP_SELF'];
$_PATH = substr($_URI, strlen($_SELF));
if ($_PATH && $_PATH[0] == '/') $_SERVER['PATH_INFO'] = $_PATH;
}
require(__DIR__.'/bootstrap.php');
$cockpit->on("after", function() use($cockpit) {
switch ($cockpit->response->status) {
case 500:
case 404:
if ($cockpit->req_is('ajax')) {
$cockpit->response->body = '{"error": "'.$cockpit->response->status.'"}';
} else {
$cockpit->response->body = $cockpit->view("cockpit:views/errors/{$cockpit->response->status}.php");
}
break;
}
});
$cockpit->trigger("admin.init")->run();