-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.php
54 lines (45 loc) · 1.92 KB
/
main.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
<?php
namespace PvPGNTracker;
use \PvPGNTracker\Libraries\Config;
use \PvPGNTracker\Libraries\Router;
use \PvPGNTracker\Libraries\VersionInfo;
function main()
{
if (!file_exists( __DIR__ . '/../lib/autoload.php'))
{
http_response_code(500);
exit('Server misconfigured. Please run `composer install`.');
}
require(__DIR__ . '/../lib/autoload.php');
date_default_timezone_set('Etc/UTC');
Config::load();
\PvPGNTracker\Libraries\ExceptionHandler::register();
VersionInfo::$version = VersionInfo::get();
if (Config::$root['maintenance']['enable'])
{
Router::$routes = [
['#.*#', 'Maintenance', ['MaintenanceHtml'], Config::$root['maintenance']['message']],
];
}
else
{
Router::$routes = [
['#^/$#', 'RedirectSoft', ['RedirectSoftHtml'], '/servers'],
['#^/search/?$#', 'Search', ['SearchHtml']],
['#^/server/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\:\d{1,5})/?.*\.html?$#', 'Server\\View', ['Server\\ViewHtml']],
['#^/server/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\:\d{1,5})/?.*\.json$#', 'Server\\View', ['Server\\ViewJson']],
['#^/server/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\:\d{1,5})/?.*\.txt$#', 'Server\\View', ['Server\\ViewPlain']],
['#^/server/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\:\d{1,5})/?#', 'Server\\View', ['Server\\ViewHtml', 'Server\\ViewJson', 'Server\\ViewPlain']],
['#^/servers/?$#', 'Servers', ['ServersHtml', 'ServersJson', 'ServersPlain']],
['#^/servers\.html?$#', 'Servers', ['ServersHtml']],
['#^/servers\.json$#', 'Servers', ['ServersJson']],
['#^/servers\.txt$#', 'Servers', ['ServersPlain']],
['#^/status/?$#', 'RedirectSoft', ['RedirectSoftHtml'], '/status.json'],
['#^/status\.json$#', 'Status', ['StatusJson']],
['#^/status\.txt$#', 'Status', ['StatusPlain']],
];
Router::$route_not_found = ['PageNotFound', ['PageNotFoundHtml', 'PageNotFoundJson', 'PageNotFoundPlain']];
}
Router::invoke();
}
main();