This repository has been archived by the owner on Apr 13, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathconfig.inc.php
65 lines (48 loc) · 1.53 KB
/
config.inc.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
<?php
include 'config.sample.inc.php';
if (!isset($_ENV['MYSQL_HOST']) && isset($_ENV['MYSQL_PORT_3306_TCP_ADDR'])) {
$_ENV['MYSQL_HOST'] = $_ENV['MYSQL_PORT_3306_TCP_ADDR'];
}
$hosts = isset($_ENV['MYSQL_HOST']) ? $_ENV['MYSQL_HOST'] : 'mysql';
foreach (explode(',', $hosts) as $index => $host) {
$config = &$cfg['Servers'][$index + 1];
// split into host[:port], user and pass
list($host, $user, $password) = explode(';', $host, 3) + [1 => '', 2 => ''];
if (strpos($host, ':') !== false) {
list($host, $port) = explode(':', $host);
$config['port'] = $port;
}
$config['host'] = $host;
if($user) {
$config['user'] = $user;
}
if($password) {
$config['auth_type'] = 'config';
$config['password'] = $password;
}
$config['AllowNoPassword'] = true;
$config = array_map('trim', $config);
}
if (isset($_ENV['ALLOW_ARBITRARY'])) {
$cfg['AllowArbitraryServer'] = (bool)$_ENV['ALLOW_ARBITRARY'];
}
if (isset($_ENV['ABSOLUTE_URI'])) {
$cfg['PmaAbsoluteUri'] = $_ENV['ABSOLUTE_URI'];
}
if (isset($_ENV['SESSION_TIMEOUT'])) {
$cfg['LoginCookieValidity'] = $_ENV['SESSION_TIMEOUT'];
ini_set('session.gc_maxlifetime', $_ENV['SESSION_TIMEOUT']);
}
$file_with_secret = 'config.inc.secret.php';
if (!file_exists($file_with_secret)) {
$secret = hash('sha512', openssl_random_pseudo_bytes(1000));
file_put_contents(
$file_with_secret,
"<?php \$cfg['blowfish_secret'] = '$secret';"
);
}
include $file_with_secret;
if (isset($_ENV['JSON_CONFIG'])) {
$custom = json_decode($_ENV['JSON_CONFIG'], true);
$cfg = array_merge($cfg, $custom);
}