forked from aikar/timings
-
Notifications
You must be signed in to change notification settings - Fork 1
/
init.php
58 lines (52 loc) · 1.67 KB
/
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
/*
* Aikar's Minecraft Timings Parser
*
* Written by Aikar <aikar@aikar.co>
* http://aikar.co
* http://starlis.com
*
* @license MIT
*/
namespace Starlis\Timings;
chdir(__DIR__);
define('ROOT_DIR', __DIR__);
// Get configuration first
global $ini;
$ini = parse_ini_file("config.ini", true);
if (file_exists("config.dev.ini")) {
$ini = array_merge($ini, parse_ini_file("config.dev.ini", true));
}
header("Content-Type: text/html");
$dirName = basename(__DIR__);
define('TIMINGS_ENV', $dirName === 'prod' || $dirName === 'v2' ? 'prod' : $ini["environment"]);
define('MAX_CACHE_BYTES', 1024 * 512);
if ($ini['trusted_ip'] === $_SERVER['REMOTE_ADDR'] || gethostbyname("aikarip") === $_SERVER['REMOTE_ADDR']) {
error_reporting(E_ALL & ~E_NOTICE);
ini_set('display_errors', true);
define('DEBUGGING', true);
} else {
define('DEBUGGING', false);
}
if (TIMINGS_ENV === 'dev') {
define('BASE_URL', $ini["base_url_dev"]);
define('BASE_URL_VIEW', $ini["base_url_view_dev"]);
} else {
define('BASE_URL', $ini["base_url_prod"]);
define('BASE_URL_VIEW', $ini["base_url_view_prod"]);
}
require_once __DIR__ . '/vendor/autoload.php';
require_once __DIR__ . "/lib/util.php";
// To make it a little harder to try to exploit the uploader, implement a closed source version
// of the security class if it exists, else fall back to the simple rules.
if (!empty($ini['custom_security'])) {
// should error if misconfigured
/** @noinspection PhpIncludeInspection */
require_once $ini['custom_security'];
}
libxml_disable_entity_loader(true);
if (empty($ini["storage_path"])) {
$ini["storage_path"] = $ini['tmp_path'];
}
define('TMP_PATH', $ini['tmp_path']);
define('STORAGE_PATH', $ini['storage_path']);