-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
67 lines (52 loc) · 1.96 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
define("IS_LOCAL", !isset($_SERVER['HTTP_X_FORWARDED_FOR'])
&& isset($_SERVER['REMOTE_ADDR'])
&& in_array($_SERVER['REMOTE_ADDR'], ['127.0.0.1', '::1'], true));
define("ADMINER_HTTPS_REDIRECT", isset($_ENV["ADMINER_HTTPS_REDIRECT"]) ? $_ENV["ADMINER_HTTPS_REDIRECT"] : IS_LOCAL);
// Redirect to HTTPS if HTTPS_REDIRECT is defined in environment variables
if (ADMINER_HTTPS_REDIRECT === 'true' && (empty($_SERVER['HTTPS']) || $_SERVER['HTTPS'] === 'off')) {
header('HTTP/1.1 301 Moved Permanently');
header('Location: https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
exit();
}
define('ASSETS_VERSION', '1');
if (empty($_GET['file'])) {
ob_start(function ($s) {
return preg_replace_callback('#(<(link|script)\s[^>]*(href|src)=")(adminer\.css|static/.+)(\?v=\d+)?"#U', function ($m) {
return $m[1] . '?file=' . urlencode($m[4]) . '&version=' . ASSETS_VERSION . '"';
}, $s);
}, 4096);
} elseif (preg_match('#^(default|adminer|static(/\w[\w.-]*)+)\.(\w+)\z#', $_GET['file'], $m)) {
if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
header('HTTP/1.1 304 Not Modified');
exit;
}
header('Expires: ' . gmdate('D, d M Y H:i:s', strtotime('1 month')) . ' GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
$types = ['css' => 'text/css', 'js' => 'text/javascript', 'gif' => 'image/gif', 'png' => 'image/png'];
if (isset($types[$m[3]])) {
header('Content-Type: ' . $types[$m[3]]);
}
@readfile(__DIR__ . '/' . $_GET['file']);
exit;
}
function adminer_object()
{
include_once __DIR__ . '/plugins/plugin.php';
foreach (glob(__DIR__ . '/plugins/*.php') as $filename) {
include_once $filename;
}
$plugins = [
new AdminerWasmer,
new AdminerDisableJush,
new AdminerAutocomplete,
new AdminerSaveMenuPos,
new AdminerRemoteColor,
new AdminerDumpJson,
new AdminerDumpPhpPrototype,
new AdminerTablesFilter,
new AdminerLoginWithoutCredentials,
];
return new AdminerPlugin($plugins);
}
include __DIR__ . '/adminer.php';