-
Notifications
You must be signed in to change notification settings - Fork 1
/
init.php
executable file
·35 lines (27 loc) · 996 Bytes
/
init.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
<?php
$protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' ||
$_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://";
define('GRID_DIR', dirname(__FILE__));
define('GRID_PATH', dirname($_SERVER['PHP_SELF']));
define('GRID_URL', $protocol . $_SERVER['HTTP_HOST'] . GRID_PATH);
if (!file_exists(GRID_DIR . '/config.php')) {
if (is_writable(GRID_DIR)) {
copy(GRID_DIR . '/config-example.php', GRID_DIR . '/config.php');
} else {
die("Please create config.php (see: config-example.php).");
}
}
require_once GRID_DIR . '/config.php';
require_once GRID_DIR . '/library/autoload.php';
chdir(GRID_DIR);
$offset = (GRID_PATH == '/') ? 1 : strlen(GRID_PATH);
$url = parse_url($_SERVER['REQUEST_URI']);
$request_path = substr($url['path'], $offset);
if (GRID_PATH != '/' && $request_path != '/') {
$request_path = substr($request_path, 1);
}
global $grid;
$grid = new Grid();
$grid->setup($request_path, $_SERVER['REQUEST_METHOD']);
$grid->main();
?>