1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-08 23:57:29 +02:00

Store information about vendor

This commit is contained in:
Jakub Vrana
2025-03-16 18:53:49 +01:00
parent 6d71cd678e
commit 777d5dca0e
4 changed files with 33 additions and 29 deletions

View File

@@ -999,11 +999,12 @@ class Adminer {
$output = ""; $output = "";
foreach ((array) $_SESSION["pwds"] as $vendor => $servers) { foreach ((array) $_SESSION["pwds"] as $vendor => $servers) {
foreach ($servers as $server => $usernames) { foreach ($servers as $server => $usernames) {
$name = h(get_setting("vendor-$server") ?: $drivers[$vendor]);
foreach ($usernames as $username => $password) { foreach ($usernames as $username => $password) {
if ($password !== null) { if ($password !== null) {
$dbs = $_SESSION["db"][$vendor][$server][$username]; $dbs = $_SESSION["db"][$vendor][$server][$username];
foreach (($dbs ? array_keys($dbs) : array("")) as $db) { foreach (($dbs ? array_keys($dbs) : array("")) as $db) {
$output .= "<li><a href='" . h(auth_url($vendor, $server, $username, $db)) . "'>($drivers[$vendor]) " . h($username . ($server != "" ? "@" . $this->serverName($server) : "") . ($db != "" ? " - $db" : "")) . "</a>\n"; $output .= "<li><a href='" . h(auth_url($vendor, $server, $username, $db)) . "'>($name) " . h($username . ($server != "" ? "@" . $this->serverName($server) : "") . ($db != "" ? " - $db" : "")) . "</a>\n";
} }
} }
} }

View File

@@ -169,6 +169,9 @@ if (isset($_GET["username"]) && is_string(get_password())) {
if ($adminer->operators === null) { if ($adminer->operators === null) {
$adminer->operators = $driver->operators; $adminer->operators = $driver->operators;
} }
if (isset($connection->maria)) {
save_settings(array("vendor-" . SERVER => $drivers[DRIVER]));
}
} }
} }

View File

@@ -120,34 +120,6 @@ function referencable_primary($self) {
return $return; return $return;
} }
/** Get settings stored in a cookie
* @param string
* @return array
*/
function get_settings($cookie) {
parse_str($_COOKIE[$cookie], $settings);
return $settings;
}
/** Get setting stored in a cookie
* @param string
* @param string
* @return mixed
*/
function get_setting($key, $cookie = "adminer_settings") {
$settings = get_settings($cookie);
return $settings[$key];
}
/** Store settings to a cookie
* @param array
* @param string
* @return bool
*/
function save_settings($settings, $cookie = "adminer_settings") {
return cookie($cookie, http_build_query($settings + get_settings($cookie)));
}
/** Print SQL <textarea> tag /** Print SQL <textarea> tag
* @param string * @param string
* @param string or array in which case [0] of every element is used * @param string or array in which case [0] of every element is used

View File

@@ -372,6 +372,34 @@ function cookie($name, $value, $lifetime = 2592000) {
); );
} }
/** Get settings stored in a cookie
* @param string
* @return array
*/
function get_settings($cookie) {
parse_str($_COOKIE[$cookie], $settings);
return $settings;
}
/** Get setting stored in a cookie
* @param string
* @param string
* @return mixed
*/
function get_setting($key, $cookie = "adminer_settings") {
$settings = get_settings($cookie);
return $settings[$key];
}
/** Store settings to a cookie
* @param array
* @param string
* @return bool
*/
function save_settings($settings, $cookie = "adminer_settings") {
return cookie($cookie, http_build_query($settings + get_settings($cookie)));
}
/** Restart stopped session /** Restart stopped session
* @return null * @return null
*/ */