Created
May 11, 2021 14:49
-
-
Save L-P/91b095a679042170644aee28ee91bc6a to your computer and use it in GitHub Desktop.
Adminer auto-login
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace docker { | |
function adminer_object() { | |
require_once('plugins/plugin.php'); | |
class Adminer extends \AdminerPlugin { | |
function login($login, $password) { | |
return true; | |
} | |
} | |
$plugins = []; | |
foreach (glob('plugins-enabled/*.php') as $plugin) { | |
$plugins[] = require($plugin); | |
} | |
return new Adminer($plugins); | |
} | |
} | |
namespace { | |
if (basename($_SERVER['DOCUMENT_URI']) === 'adminer.css' && is_readable('adminer.css')) { | |
header('Content-Type: text/css'); | |
readfile('adminer.css'); | |
exit; | |
} | |
function adminer_object() { | |
return \docker\adminer_object(); | |
} | |
if ($_SERVER['QUERY_STRING'] === '' || empty($_COOKIE['adminer_permanent'])) { | |
$_POST['auth'] = [ | |
'driver' => 'pgsql', | |
'server' => $_ENV['ADMINER_DEFAULT_SERVER'], | |
'username' => $_ENV['ADMINER_DEFAULT_USERNAME'], | |
'password' => $_ENV['ADMINER_DEFAULT_PASSWORD'], | |
'db' => $_ENV['ADMINER_DEFAULT_DATABASE'], | |
'permanent' => 1, | |
]; | |
} | |
require('adminer.php'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment