if (!$result) {
echo "<p class='error'>" . error() . "\n";
} else {
- $connection2 = connect();
+ $connection2 = connect($adminer->credentials());
if (is_object($connection2)) {
$connection2->select_db(DB);
}
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";
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;
}
}
/** 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");
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;
}
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'");
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.');
}
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;
$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(); ?>>
$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"] != "") {
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.');
}
}
}
- 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.');
}
}
}
- 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.');
}
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;
}
- 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.');
}