Skip to content

Instantly share code, notes, and snippets.

@L-P
Created May 11, 2021 14:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save L-P/91b095a679042170644aee28ee91bc6a to your computer and use it in GitHub Desktop.
Save L-P/91b095a679042170644aee28ee91bc6a to your computer and use it in GitHub Desktop.
Adminer auto-login
<?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