-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.php
54 lines (39 loc) · 1.31 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
<?php
/** @var rex_addon $this */
// Adminer extension, the function is called automatically by adminer
function adminer_object()
{
// adminer throws warning "A non-numeric value encountered" in PHP 7
error_reporting(error_reporting() & ~E_WARNING & ~E_NOTICE);
return new rex_adminer();
}
$databases = [];
foreach (rex::getProperty('db') as $id => $db) {
if (empty($db['host']) || empty($db['name'])) {
continue;
}
// multiple databases with same name are not supported
if (isset($databases[$db['name']])) {
continue;
}
$db['id'] = $id;
$databases[$db['name']] = $db;
}
$database = rex_get('db', 'string');
$database = isset($databases[$database]) ? $databases[$database] : reset($databases);
$this->setProperty('databases', $databases);
$this->setProperty('database', $database);
// auto login and db selection
$_GET['username'] = '';
$_GET['db'] = $database['name'];
rex_response::cleanOutputBuffers();
// add page param to all adminer urls
ob_start(function ($output) {
return preg_replace('#(?<==(?:"|\'))index\.php\?(?=username=&db=|file=[^&]*&version=)#', 'index.php?page=adminer&', $output);
});
include __DIR__ .'/../vendor/adminer.php';
// make sure the output buffer callback is called
while (ob_get_level()) {
ob_end_flush();
}
exit;