mirror of
https://github.com/vrana/adminer.git
synced 2025-08-07 15:16:44 +02:00
Pass credentials to connect()
This commit is contained in:
@@ -40,7 +40,7 @@ if (!$error && $_POST) {
|
||||
if (!$result) {
|
||||
echo "<p class='error'>" . error() . "\n";
|
||||
} else {
|
||||
$connection2 = connect();
|
||||
$connection2 = connect($adminer->credentials());
|
||||
if (is_object($connection2)) {
|
||||
$connection2->select_db(DB);
|
||||
}
|
||||
|
@@ -421,10 +421,10 @@ if (isset($_GET["mongo"])) {
|
||||
return $credentials[1];
|
||||
}
|
||||
|
||||
function connect() {
|
||||
function connect($credentials) {
|
||||
global $adminer;
|
||||
$connection = new Db;
|
||||
list($server, $username, $password) = $adminer->credentials();
|
||||
list($server, $username, $password) = $credentials;
|
||||
|
||||
if ($server == "") {
|
||||
$server = "localhost:27017";
|
||||
|
@@ -280,15 +280,11 @@ if (isset($_GET["mssql"])) {
|
||||
return ($_GET["ns"] != "" ? idf_escape($_GET["ns"]) . "." : "") . idf_escape($idf);
|
||||
}
|
||||
|
||||
function connect() {
|
||||
global $adminer;
|
||||
function connect($credentials) {
|
||||
$connection = new Db;
|
||||
$credentials = $adminer->credentials();
|
||||
|
||||
if ($credentials[0] == "") {
|
||||
$credentials[0] = "localhost:1433";
|
||||
}
|
||||
|
||||
if ($connection->connect($credentials[0], $credentials[1], $credentials[2])) {
|
||||
return $connection;
|
||||
}
|
||||
|
@@ -421,12 +421,11 @@ if (!defined('Adminer\DRIVER')) {
|
||||
}
|
||||
|
||||
/** Connect to the database
|
||||
* @param array [$server, $username, $password]
|
||||
* @return mixed Db or string for error
|
||||
*/
|
||||
function connect() {
|
||||
global $adminer;
|
||||
function connect($credentials) {
|
||||
$connection = new Db;
|
||||
$credentials = $adminer->credentials();
|
||||
if ($connection->connect($credentials[0], $credentials[1], $credentials[2])) {
|
||||
$connection->set_charset(charset($connection)); // available in MySQLi since PHP 5.0.5
|
||||
$connection->query("SET sql_quote_show_create = 1, autocommit = 1");
|
||||
|
@@ -211,10 +211,8 @@ if (isset($_GET["oracle"])) {
|
||||
return idf_escape($idf);
|
||||
}
|
||||
|
||||
function connect() {
|
||||
global $adminer;
|
||||
function connect($credentials) {
|
||||
$connection = new Db;
|
||||
$credentials = $adminer->credentials();
|
||||
if ($connection->connect($credentials[0], $credentials[1], $credentials[2])) {
|
||||
return $connection;
|
||||
}
|
||||
|
@@ -312,10 +312,8 @@ if (isset($_GET["pgsql"])) {
|
||||
return idf_escape($idf);
|
||||
}
|
||||
|
||||
function connect() {
|
||||
global $adminer;
|
||||
function connect($credentials) {
|
||||
$connection = new Db;
|
||||
$credentials = $adminer->credentials();
|
||||
if ($connection->connect($credentials[0], $credentials[1], $credentials[2])) {
|
||||
if (min_version(9, 0, $connection)) {
|
||||
$connection->query("SET application_name = 'Adminer'");
|
||||
|
@@ -190,9 +190,8 @@ if (isset($_GET["sqlite"])) {
|
||||
return idf_escape($idf);
|
||||
}
|
||||
|
||||
function connect() {
|
||||
global $adminer;
|
||||
list(, , $password) = $adminer->credentials();
|
||||
function connect($credentials) {
|
||||
list(, , $password) = $credentials;
|
||||
if ($password != "") {
|
||||
return lang('Database does not support password.');
|
||||
}
|
||||
|
@@ -163,7 +163,7 @@ if (isset($_GET["username"]) && is_string(get_password())) {
|
||||
auth_error(lang('Connecting to privileged ports is not allowed.'));
|
||||
}
|
||||
check_invalid_login();
|
||||
$connection = connect();
|
||||
$connection = connect($adminer->credentials());
|
||||
$driver = new Driver($connection);
|
||||
if ($adminer->operators === null) {
|
||||
$adminer->operators = $driver->operators;
|
||||
|
@@ -1302,7 +1302,7 @@ function slow_query($query) {
|
||||
$db = $adminer->database();
|
||||
$timeout = $adminer->queryTimeout();
|
||||
$slow_query = $driver->slowQuery($query, $timeout);
|
||||
if (!$slow_query && support("kill") && is_object($connection2 = connect()) && ($db == "" || $connection2->select_db($db))) {
|
||||
if (!$slow_query && support("kill") && is_object($connection2 = connect($adminer->credentials())) && ($db == "" || $connection2->select_db($db))) {
|
||||
$kill = $connection2->result(connection_id()); // MySQL and MySQLi can use thread_id but it's not in PDO_MySQL
|
||||
?>
|
||||
<script<?php echo nonce(); ?>>
|
||||
|
@@ -52,7 +52,7 @@ if (!$error && $_POST) {
|
||||
$delimiter = ";";
|
||||
$offset = 0;
|
||||
$empty = true;
|
||||
$connection2 = connect(); // connection for exploring indexes and EXPLAIN (to not replace FOUND_ROWS()) //! PDO - silent error
|
||||
$connection2 = connect($adminer->credentials()); // connection for exploring indexes and EXPLAIN (to not replace FOUND_ROWS()) //! PDO - silent error
|
||||
if (is_object($connection2) && DB != "") {
|
||||
$connection2->select_db(DB);
|
||||
if ($_GET["ns"] != "") {
|
||||
|
@@ -234,10 +234,9 @@ if (isset($_GET["clickhouse"])) {
|
||||
return apply_queries("DROP TABLE", $tables);
|
||||
}
|
||||
|
||||
function connect() {
|
||||
$adminer = adminer();
|
||||
function connect($credentials) {
|
||||
$connection = new Db;
|
||||
list($server, $username, $password) = $adminer->credentials();
|
||||
list($server, $username, $password) = $credentials;
|
||||
if (!preg_match('~^(https?://)?[-a-z\d.]+(:\d+)?$~', $server)) {
|
||||
return lang('Invalid server.');
|
||||
}
|
||||
|
@@ -286,10 +286,10 @@ if (isset($_GET["elastic"])) {
|
||||
}
|
||||
}
|
||||
|
||||
function connect() {
|
||||
function connect($credentials) {
|
||||
$connection = new Db;
|
||||
|
||||
list($server, $username, $password) = adminer()->credentials();
|
||||
list($server, $username, $password) = $credentials;
|
||||
if (!preg_match('~^(https?://)?[-a-z\d.]+(:\d+)?$~', $server)) {
|
||||
return lang('Invalid server.');
|
||||
}
|
||||
|
@@ -273,10 +273,10 @@ if (isset($_GET["elastic5"])) {
|
||||
}
|
||||
}
|
||||
|
||||
function connect() {
|
||||
function connect($credentials) {
|
||||
$connection = new Db;
|
||||
|
||||
list($server, $username, $password) = adminer()->credentials();
|
||||
list($server, $username, $password) = $credentials;
|
||||
if (!preg_match('~^(https?://)?[-a-z\d.]+(:\d+)?$~', $server)) {
|
||||
return lang('Invalid server.');
|
||||
}
|
||||
|
@@ -131,10 +131,8 @@ if (isset($_GET["firebird"])) {
|
||||
return idf_escape($idf);
|
||||
}
|
||||
|
||||
function connect() {
|
||||
$adminer = adminer();
|
||||
function connect($credentials) {
|
||||
$connection = new Db;
|
||||
$credentials = $adminer->credentials();
|
||||
if ($connection->connect($credentials[0], $credentials[1], $credentials[2])) {
|
||||
return $connection;
|
||||
}
|
||||
|
@@ -251,9 +251,8 @@ if (isset($_GET["simpledb"])) {
|
||||
|
||||
|
||||
|
||||
function connect() {
|
||||
$adminer = adminer();
|
||||
list($host, , $password) = $adminer->credentials();
|
||||
function connect($credentials) {
|
||||
list($host, , $password) = $credentials;
|
||||
if (!preg_match('~^(https?://)?[-a-z\d.]+(:\d+)?$~', $host)) {
|
||||
return lang('Invalid server.');
|
||||
}
|
||||
|
Reference in New Issue
Block a user