-
Notifications
You must be signed in to change notification settings - Fork 13
/
index.php
69 lines (57 loc) · 2.17 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
68
69
<?php
namespace docker {
function adminer_object()
{
require_once('plugins/plugin.php');
class Adminer extends \AdminerPlugin
{
function _callParent($function, $args)
{
if ($function === 'loginForm') {
ob_start();
$return = \Adminer::loginForm();
$form = ob_get_clean();
// Set default values via env vars.
$defaultDbDriver = getenv('ADMINER_DEFAULT_DB_DRIVER') ?: 'server';
$defaultDbHost = getenv('ADMINER_DEFAULT_DB_HOST') ?: '';
$defaultDb = getenv('ADMINER_DEFAULT_DB_NAME') ?: '';
$defaultDbDriver = $defaultDbDriver == 'mysql' ? 'server' : $defaultDbDriver;
echo str_replace(
[
'name="auth[server]" value="" title="hostname[:port]"',
'value="' . $defaultDbDriver . '"',
'selected="">MySQL',
'name="auth[db]" value=""'
],
[
'name="auth[server]" value="' . $defaultDbHost . '" title="hostname[:port]"',
'value="' . $defaultDbDriver . '" selected="selected"',
'>MySQL',
'name="auth[db]" value="' . $defaultDb . '"'
],
$form
);
return $return;
}
return parent::_callParent($function, $args);
}
}
$plugins = [];
foreach (glob('plugins-enabled/*.php') as $plugin) {
$plugins[] = require($plugin);
}
return new Adminer($plugins);
}
}
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');
}