Import postgresql plugin

This commit is contained in:
Marek Miklewicz
2026-07-04 16:00:04 +02:00
commit ddc971567f
74 changed files with 18735 additions and 0 deletions
+14
View File
@@ -0,0 +1,14 @@
Bundled Adminer binary for deterministic plugin installs.
- Version: 5.4.2 (pgsql-only build)
- Source repo/tag: https://github.com/vrana/adminer/tree/v5.4.2
- Build command: `php compile.php pgsql`
- Output file: `adminer-5.4.2-pgsql.php`
- SHA256: 059505abc2b56487d78bbfbeb9485ed8c6a10fe357f4ddec9fc69b1043bff4af
- Bundled extension file: `adminer-extension.php`
- Extension SHA256: 6e2f098b172838ccb3736506867396dc0954a6383fdd7b7c5e7739ab21baafeb
The installer `scripts/setup/adminer_install.sh` verifies both checksums before
copying files to:
- `/var/www/html/adminer/adminer-core.php`
- `/var/www/html/adminer/adminer-extension.php`
+2
View File
@@ -0,0 +1,2 @@
6e2f098b172838ccb3736506867396dc0954a6383fdd7b7c5e7739ab21baafeb adminer-extension.php
059505abc2b56487d78bbfbeb9485ed8c6a10fe357f4ddec9fc69b1043bff4af adminer-5.4.2-pgsql.php
File diff suppressed because one or more lines are too long
+101
View File
@@ -0,0 +1,101 @@
<?php
declare(strict_types=1);
function da_adminer_sso_auth(): ?array
{
$auth = $GLOBALS['da_adminer_sso_auth'] ?? null;
if (!is_array($auth)) {
return null;
}
$user = isset($auth['user']) && is_string($auth['user']) ? trim($auth['user']) : '';
$password = isset($auth['password']) && is_string($auth['password']) ? $auth['password'] : '';
$database = isset($auth['database']) && is_string($auth['database']) ? $auth['database'] : '';
if ($user === '' || $password === '') {
return null;
}
return [
'user' => $user,
'password' => $password,
'database' => $database,
];
}
function da_adminer_bootstrap_auth(array $auth): void
{
$user = isset($auth['user']) && is_string($auth['user']) ? trim($auth['user']) : '';
$password = isset($auth['password']) && is_string($auth['password']) ? $auth['password'] : '';
$database = isset($auth['database']) && is_string($auth['database']) ? trim($auth['database']) : '';
if ($user === '' || $password === '') {
return;
}
$driver = 'pgsql';
$server = 'localhost';
$_GET[$driver] = $server;
$_GET['username'] = $user;
if ($database !== '' && (!isset($_GET['db']) || !is_string($_GET['db']) || $_GET['db'] === '')) {
$_GET['db'] = $database;
}
if (!isset($_SESSION['pwds']) || !is_array($_SESSION['pwds'])) {
$_SESSION['pwds'] = [];
}
$_SESSION['pwds'][$driver][$server][$user] = $password;
if ($database !== '') {
if (!isset($_SESSION['db']) || !is_array($_SESSION['db'])) {
$_SESSION['db'] = [];
}
$_SESSION['db'][$driver][$server][$user][$database] = true;
}
}
function adminer_object()
{
static $bootstrapped = false;
if (!$bootstrapped) {
$auth = da_adminer_sso_auth();
if ($auth !== null) {
da_adminer_bootstrap_auth($auth);
}
$bootstrapped = true;
}
if (!class_exists('DirectAdminAdminerExtension', false)) {
class DirectAdminAdminerExtension extends \Adminer\Adminer
{
public function credentials()
{
$auth = da_adminer_sso_auth();
if ($auth !== null) {
return ['localhost', (string)$auth['user'], (string)$auth['password']];
}
$username = isset($_GET['username']) && is_string($_GET['username']) ? $_GET['username'] : '';
$password = \Adminer\get_password();
if (!is_string($password)) {
$password = '';
}
return ['localhost', $username, $password];
}
public function loginFormField($name, $heading, $value)
{
if ($name === 'driver') {
return "<tr style='display:none'><th></th><td><input type='hidden' name='auth[driver]' value='pgsql'></td></tr>\n";
}
if ($name === 'server') {
return "<tr style='display:none'><th></th><td><input type='hidden' name='auth[server]' value='localhost'></td></tr>\n";
}
return parent::loginFormField($name, $heading, $value);
}
}
}
return new DirectAdminAdminerExtension();
}