mirror of
https://github.com/vrana/adminer.git
synced 2025-08-25 07:20:56 +02:00
Disallow using password-less databases
This commit is contained in:
@@ -227,8 +227,11 @@ if (isset($_GET["elastic"])) {
|
||||
function connect() {
|
||||
global $adminer;
|
||||
$connection = new Min_DB;
|
||||
$credentials = $adminer->credentials();
|
||||
if ($connection->connect($credentials[0], $credentials[1], $credentials[2])) {
|
||||
list($server, $username, $password) = $adminer->credentials();
|
||||
if ($password != "" && $connection->connect($server, $username, "")) {
|
||||
return lang('Database does not support password.');
|
||||
}
|
||||
if ($connection->connect($server, $username, $password)) {
|
||||
return $connection;
|
||||
}
|
||||
return $connection->error;
|
||||
|
@@ -610,7 +610,7 @@ if (isset($_GET["mongo"])) {
|
||||
$connection = new Min_DB;
|
||||
list($server, $username, $password) = $adminer->credentials();
|
||||
$options = array();
|
||||
if ($username != "") {
|
||||
if ($username . $password != "") {
|
||||
$options["username"] = $username;
|
||||
$options["password"] = $password;
|
||||
}
|
||||
@@ -620,6 +620,15 @@ if (isset($_GET["mongo"])) {
|
||||
}
|
||||
try {
|
||||
$connection->_link = $connection->connect("mongodb://$server", $options);
|
||||
if ($password != "") {
|
||||
$options["password"] = "";
|
||||
try {
|
||||
$connection->connect("mongodb://$server", $options);
|
||||
return lang('Database does not support password.');
|
||||
} catch (Exception $ex) {
|
||||
// this is what we want
|
||||
}
|
||||
}
|
||||
return $connection;
|
||||
} catch (Exception $ex) {
|
||||
return $ex->getMessage();
|
||||
|
@@ -248,6 +248,11 @@ if (isset($_GET["simpledb"])) {
|
||||
|
||||
|
||||
function connect() {
|
||||
global $adminer;
|
||||
list(, , $password) = $adminer->credentials();
|
||||
if ($password != "") {
|
||||
return lang('Database does not support password.');
|
||||
}
|
||||
return new Min_DB;
|
||||
}
|
||||
|
||||
|
@@ -240,6 +240,11 @@ if (isset($_GET["sqlite"]) || isset($_GET["sqlite2"])) {
|
||||
}
|
||||
|
||||
function connect() {
|
||||
global $adminer;
|
||||
list(, , $password) = $adminer->credentials();
|
||||
if ($password != "") {
|
||||
return lang('Database does not support password.');
|
||||
}
|
||||
return new Min_DB;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user