-
Notifications
You must be signed in to change notification settings - Fork 83
Expand file tree
/
Copy pathindex.php
More file actions
63 lines (54 loc) · 1.59 KB
/
index.php
File metadata and controls
63 lines (54 loc) · 1.59 KB
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
<?php
namespace docker {
function adminer_object() {
/**
* Prefills the “Server” field with the ADMINER_DEFAULT_SERVER environment variable.
*/
final class DefaultServerPlugin extends \Adminer\Plugin {
public function __construct(
private \Adminer\Adminer $adminer
) { }
public function loginFormField(...$args): string {
return (function (...$args): string {
$field = $this->loginFormField(...$args);
return \preg_replace_callback(
'/name="auth\[server\]" value="" title="(?:[^"]+)"/',
static function (array $matches): string {
return \str_replace(
'value=""',
\sprintf('value="%s"', ($_ENV['ADMINER_DEFAULT_SERVER'] ?: 'db')),
$matches[0],
);
},
$field,
);
})->call($this->adminer, ...$args);
}
}
$plugins = [];
foreach (glob('plugins-enabled/*.php') as $plugin) {
$plugins[] = require($plugin);
}
$adminer = new \Adminer\Plugins($plugins);
(function () {
$last = &$this->hooks['loginFormField'][\array_key_last($this->hooks['loginFormField'])];
if ($last instanceof \Adminer\Adminer) {
$defaultServerPlugin = new DefaultServerPlugin($last);
$this->plugins[] = $defaultServerPlugin;
$last = $defaultServerPlugin;
}
})->call($adminer);
return $adminer;
}
}
namespace {
if (basename($_SERVER['DOCUMENT_URI'] ?? $_SERVER['REQUEST_URI']) === 'adminer.css' && is_readable('adminer.css')) {
header('Content-Type: text/css');
readfile('adminer.css');
exit;
}
function adminer_object() {
return \docker\adminer_object();
}
require('adminer.php');
}