-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
69 lines (54 loc) · 1.48 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
function adminer_object() {
$server = $_SERVER;
$hostname = $server['SERVER_NAME'];
// required to run any plugin
include_once "./plugins/plugin.php";
class AdminerExtend extends AdminerPlugin
{
protected $hostname = 'localhost.com';
public function setHostname($hostname) {
$this->hostname = $hostname;
}
public static function isDevHost($hostname) {
return (preg_match('/localhost/i', $hostname));
}
public function autoLogin($username) {
if (isset($_REQUEST['username'])) {
return;
}
if (self::isDevHost($this->hostname)) {
header('Location: ' . $_SERVER['SCRIPT_NAME'] . '?username=' . $username);
exit();
}
}
public function credentials() {
if (self::isDevHost($this->hostname)) {
return array('127.0.0.1', 'admin', 'abc123');
}
return array();
}
}
// autoloader
foreach (glob("plugins/*.php") as $filename) {
include_once "./$filename";
}
$plugins = array(
// specify enabled plugins here
new AdminerEzHead,
new AdminerEzTablesTree,
new AdminerJsonViewerColumn,
);
if (AdminerExtend::isDevHost($hostname)) {
$plugins[] = new AdminerSchemaLog;
}
/**
* myadminer customization including plugins
*/
$myAdminer = new AdminerExtend($plugins);
$myAdminer->setHostname($hostname);
$myAdminer->autoLogin('admin');
return $myAdminer;
}
// include original Adminer or Adminer Editor
include "./adminer.php";