mirror of
https://github.com/vrana/adminer.git
synced 2025-08-16 11:34:10 +02:00
Plugins: Load config from adminer-plugins.php
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -6,3 +6,4 @@
|
|||||||
/editor*.php
|
/editor*.php
|
||||||
/vendor/
|
/vendor/
|
||||||
adminer-plugins/
|
adminer-plugins/
|
||||||
|
adminer-plugins.php
|
||||||
|
@@ -6,7 +6,8 @@
|
|||||||
- CSS: Allow more custom styles with dark mode (bug #925)
|
- CSS: Allow more custom styles with dark mode (bug #925)
|
||||||
- IMAP: New plugin driver created for fun
|
- IMAP: New plugin driver created for fun
|
||||||
- Plugins: autoload plugins from adminer-plugins/
|
- Plugins: autoload plugins from adminer-plugins/
|
||||||
- Plugins: configure plugins with adminer-plugins/config.php
|
- Plugins: configure plugins with adminer-plugins.php
|
||||||
|
- Plugins: Display loaded plugins in server overview
|
||||||
|
|
||||||
## Adminer 5.0.6 (released 2025-03-17)
|
## Adminer 5.0.6 (released 2025-03-17)
|
||||||
- Align numbers right (bug #912)
|
- Align numbers right (bug #912)
|
||||||
|
12
README.md
12
README.md
@@ -32,19 +32,19 @@ To use a plugin, simply upload it to `adminer-plugins/` next to `adminer.php`.
|
|||||||
|
|
||||||
```
|
```
|
||||||
- adminer.php
|
- adminer.php
|
||||||
- adminer-plugins
|
- adminer-plugins/
|
||||||
- config.php
|
|
||||||
- dump-xml.php
|
- dump-xml.php
|
||||||
- login-password-less.php
|
- login-password-less.php
|
||||||
|
- ...
|
||||||
|
- adminer-plugins.php
|
||||||
```
|
```
|
||||||
|
|
||||||
Some plugins require configuration. To use them, you need to create another file in `adminer-plugins/`:
|
Some plugins require configuration. To use them, create file `adminer-plugins.php`. You can also specify loading order here.
|
||||||
|
|
||||||
```php
|
```php
|
||||||
<?php // config.php
|
<?php // adminer-plugins.php
|
||||||
require_once __DIR__ . "/login-password-less.php";
|
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
new AdminerLoginPasswordLess('$2y$07$Czp9G/aLi3AnaUqpvkF05OHO1LMizrAgMLvnaOdvQovHaRv28XDhG'),
|
new AdminerLoginPasswordLess('$2y$07$Czp9G/aLi3AnaUqpvkF05OHO1LMizrAgMLvnaOdvQovHaRv28XDhG'),
|
||||||
|
// You can specify all plugins here or just the ones needing configuration.
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
@@ -80,7 +80,7 @@ include "./include/adminer.inc.php";
|
|||||||
|
|
||||||
if (function_exists('adminer_object')) {
|
if (function_exists('adminer_object')) {
|
||||||
$adminer = adminer_object();
|
$adminer = adminer_object();
|
||||||
} elseif (file_exists("adminer-plugins/")) {
|
} elseif (is_dir("adminer-plugins") || file_exists("adminer-plugins.php")) {
|
||||||
include "./include/plugins.inc.php";
|
include "./include/plugins.inc.php";
|
||||||
$adminer = new Plugins(null);
|
$adminer = new Plugins(null);
|
||||||
} else {
|
} else {
|
||||||
|
@@ -10,12 +10,16 @@ class Plugins extends Adminer {
|
|||||||
function __construct($plugins) {
|
function __construct($plugins) {
|
||||||
if ($plugins === null) {
|
if ($plugins === null) {
|
||||||
$plugins = array();
|
$plugins = array();
|
||||||
foreach (glob("adminer-plugins/*.php") as $filename) {
|
$basename = "adminer-plugins";
|
||||||
$include = include_once "./$filename";
|
if (is_dir($basename)) {
|
||||||
if (is_array($include)) { // example: return array(new AdminerLoginOtp($secret))
|
foreach (glob("$basename/*.php") as $filename) {
|
||||||
foreach ($include as $plugin) {
|
$include = include_once "./$filename";
|
||||||
$plugins[get_class($plugin)] = $plugin;
|
}
|
||||||
}
|
}
|
||||||
|
if (file_exists("$basename.php")) {
|
||||||
|
$include = include_once "./$basename.php"; // example: return array(new AdminerLoginOtp($secret))
|
||||||
|
foreach ($include as $plugin) {
|
||||||
|
$plugins[get_class($plugin)] = $plugin;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreach (get_declared_classes() as $class) {
|
foreach (get_declared_classes() as $class) {
|
||||||
|
Reference in New Issue
Block a user