mirror of
https://github.com/vrana/adminer.git
synced 2025-08-08 07:36:44 +02:00
Avoid global variables in plugins drivers
This commit is contained in:
@@ -210,7 +210,7 @@ if (isset($_GET["clickhouse"])) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function connect() {
|
function connect() {
|
||||||
global $adminer;
|
$adminer = adminer();
|
||||||
$connection = new Min_DB;
|
$connection = new Min_DB;
|
||||||
list($server, $username, $password) = $adminer->credentials();
|
list($server, $username, $password) = $adminer->credentials();
|
||||||
if (!preg_match('~^(https?://)?[-a-z\d.]+(:\d+)?$~', $server)) {
|
if (!preg_match('~^(https?://)?[-a-z\d.]+(:\d+)?$~', $server)) {
|
||||||
@@ -223,7 +223,7 @@ if (isset($_GET["clickhouse"])) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function get_databases($flush) {
|
function get_databases($flush) {
|
||||||
global $connection;
|
$connection = connection();
|
||||||
$result = get_rows('SHOW DATABASES');
|
$result = get_rows('SHOW DATABASES');
|
||||||
|
|
||||||
$return = array();
|
$return = array();
|
||||||
@@ -250,7 +250,7 @@ if (isset($_GET["clickhouse"])) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function logged_user() {
|
function logged_user() {
|
||||||
global $adminer;
|
$adminer = adminer();
|
||||||
$credentials = $adminer->credentials();
|
$credentials = $adminer->credentials();
|
||||||
return $credentials[1];
|
return $credentials[1];
|
||||||
}
|
}
|
||||||
@@ -270,7 +270,7 @@ if (isset($_GET["clickhouse"])) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function table_status($name = "", $fast = false) {
|
function table_status($name = "", $fast = false) {
|
||||||
global $connection;
|
$connection = connection();
|
||||||
$return = array();
|
$return = array();
|
||||||
$tables = get_rows("SELECT name, engine FROM system.tables WHERE database = " . q($connection->_db));
|
$tables = get_rows("SELECT name, engine FROM system.tables WHERE database = " . q($connection->_db));
|
||||||
foreach ($tables as $table) {
|
foreach ($tables as $table) {
|
||||||
@@ -340,7 +340,7 @@ if (isset($_GET["clickhouse"])) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function error() {
|
function error() {
|
||||||
global $connection;
|
$connection = connection();
|
||||||
return h($connection->error);
|
return h($connection->error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -59,7 +59,7 @@ if (isset($_GET["elastic"])) {
|
|||||||
function query($path, array $content = null, $method = 'GET') {
|
function query($path, array $content = null, $method = 'GET') {
|
||||||
// Support for global search through all tables
|
// Support for global search through all tables
|
||||||
if ($path != "" && $path[0] == "S" && preg_match('/SELECT 1 FROM ([^ ]+) WHERE (.+) LIMIT ([0-9]+)/', $path, $matches)) {
|
if ($path != "" && $path[0] == "S" && preg_match('/SELECT 1 FROM ([^ ]+) WHERE (.+) LIMIT ([0-9]+)/', $path, $matches)) {
|
||||||
global $driver;
|
$driver = get_driver();
|
||||||
|
|
||||||
$where = explode(" AND ", $matches[2]);
|
$where = explode(" AND ", $matches[2]);
|
||||||
|
|
||||||
|
@@ -54,7 +54,7 @@ if (isset($_GET["elastic5"])) {
|
|||||||
function query($path, $content = array(), $method = 'GET') {
|
function query($path, $content = array(), $method = 'GET') {
|
||||||
// Support for global search through all tables
|
// Support for global search through all tables
|
||||||
if ($path != "" && $path[0] == "S" && preg_match('/SELECT 1 FROM ([^ ]+) WHERE (.+) LIMIT ([0-9]+)/', $path, $matches)) {
|
if ($path != "" && $path[0] == "S" && preg_match('/SELECT 1 FROM ([^ ]+) WHERE (.+) LIMIT ([0-9]+)/', $path, $matches)) {
|
||||||
global $driver;
|
$driver = get_driver();
|
||||||
|
|
||||||
$where = explode(" AND ", $matches[2]);
|
$where = explode(" AND ", $matches[2]);
|
||||||
|
|
||||||
|
@@ -126,7 +126,7 @@ if (isset($_GET["firebird"])) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function connect() {
|
function connect() {
|
||||||
global $adminer;
|
$adminer = adminer();
|
||||||
$connection = new Min_DB;
|
$connection = new Min_DB;
|
||||||
$credentials = $adminer->credentials();
|
$credentials = $adminer->credentials();
|
||||||
if ($connection->connect($credentials[0], $credentials[1], $credentials[2])) {
|
if ($connection->connect($credentials[0], $credentials[1], $credentials[2])) {
|
||||||
@@ -158,13 +158,13 @@ if (isset($_GET["firebird"])) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function logged_user() {
|
function logged_user() {
|
||||||
global $adminer;
|
$adminer = adminer();
|
||||||
$credentials = $adminer->credentials();
|
$credentials = $adminer->credentials();
|
||||||
return $credentials[1];
|
return $credentials[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
function tables_list() {
|
function tables_list() {
|
||||||
global $connection;
|
$connection = connection();
|
||||||
$query = 'SELECT RDB$RELATION_NAME FROM rdb$relations WHERE rdb$system_flag = 0';
|
$query = 'SELECT RDB$RELATION_NAME FROM rdb$relations WHERE rdb$system_flag = 0';
|
||||||
$result = ibase_query($connection->_link, $query);
|
$result = ibase_query($connection->_link, $query);
|
||||||
$return = array();
|
$return = array();
|
||||||
@@ -180,7 +180,7 @@ if (isset($_GET["firebird"])) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function table_status($name = "", $fast = false) {
|
function table_status($name = "", $fast = false) {
|
||||||
global $connection;
|
$connection = connection();
|
||||||
$return = array();
|
$return = array();
|
||||||
$data = tables_list();
|
$data = tables_list();
|
||||||
foreach ($data as $index => $val) {
|
foreach ($data as $index => $val) {
|
||||||
@@ -205,7 +205,7 @@ if (isset($_GET["firebird"])) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function fields($table) {
|
function fields($table) {
|
||||||
global $connection;
|
$connection = connection();
|
||||||
$return = array();
|
$return = array();
|
||||||
$query = 'SELECT r.RDB$FIELD_NAME AS field_name,
|
$query = 'SELECT r.RDB$FIELD_NAME AS field_name,
|
||||||
r.RDB$DESCRIPTION AS field_description,
|
r.RDB$DESCRIPTION AS field_description,
|
||||||
@@ -287,7 +287,7 @@ ORDER BY RDB$INDEX_SEGMENTS.RDB$FIELD_POSITION';
|
|||||||
}
|
}
|
||||||
|
|
||||||
function error() {
|
function error() {
|
||||||
global $connection;
|
$connection = connection();
|
||||||
return h($connection->error);
|
return h($connection->error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -121,7 +121,7 @@ if (isset($_GET["simpledb"])) {
|
|||||||
public $primary = "itemName()";
|
public $primary = "itemName()";
|
||||||
|
|
||||||
function _chunkRequest($ids, $action, $params, $expand = array()) {
|
function _chunkRequest($ids, $action, $params, $expand = array()) {
|
||||||
global $connection;
|
$connection = connection();
|
||||||
foreach (array_chunk($ids, 25) as $chunk) {
|
foreach (array_chunk($ids, 25) as $chunk) {
|
||||||
$params2 = $params;
|
$params2 = $params;
|
||||||
foreach ($chunk as $i => $id) {
|
foreach ($chunk as $i => $id) {
|
||||||
@@ -151,7 +151,7 @@ if (isset($_GET["simpledb"])) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function select($table, $select, $where, $group, $order = array(), $limit = 1, $page = 0, $print = false) {
|
function select($table, $select, $where, $group, $order = array(), $limit = 1, $page = 0, $print = false) {
|
||||||
global $connection;
|
$connection = connection();
|
||||||
$connection->next = $_GET["next"];
|
$connection->next = $_GET["next"];
|
||||||
$return = parent::select($table, $select, $where, $group, $order, $limit, $page, $print);
|
$return = parent::select($table, $select, $where, $group, $order, $limit, $page, $print);
|
||||||
$connection->next = 0;
|
$connection->next = 0;
|
||||||
@@ -247,7 +247,7 @@ if (isset($_GET["simpledb"])) {
|
|||||||
|
|
||||||
|
|
||||||
function connect() {
|
function connect() {
|
||||||
global $adminer;
|
$adminer = adminer();
|
||||||
list($host, , $password) = $adminer->credentials();
|
list($host, , $password) = $adminer->credentials();
|
||||||
if (!preg_match('~^(https?://)?[-a-z\d.]+(:\d+)?$~', $host)) {
|
if (!preg_match('~^(https?://)?[-a-z\d.]+(:\d+)?$~', $host)) {
|
||||||
return lang('Invalid server.');
|
return lang('Invalid server.');
|
||||||
@@ -263,7 +263,7 @@ if (isset($_GET["simpledb"])) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function logged_user() {
|
function logged_user() {
|
||||||
global $adminer;
|
$adminer = adminer();
|
||||||
$credentials = $adminer->credentials();
|
$credentials = $adminer->credentials();
|
||||||
return $credentials[1];
|
return $credentials[1];
|
||||||
}
|
}
|
||||||
@@ -280,7 +280,7 @@ if (isset($_GET["simpledb"])) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function tables_list() {
|
function tables_list() {
|
||||||
global $connection;
|
$connection = connection();
|
||||||
$return = array();
|
$return = array();
|
||||||
foreach (sdb_request_all('ListDomains', 'DomainName') as $table) {
|
foreach (sdb_request_all('ListDomains', 'DomainName') as $table) {
|
||||||
$return[(string) $table] = 'table';
|
$return[(string) $table] = 'table';
|
||||||
@@ -320,7 +320,7 @@ if (isset($_GET["simpledb"])) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function error() {
|
function error() {
|
||||||
global $connection;
|
$connection = connection();
|
||||||
return h($connection->error);
|
return h($connection->error);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -410,7 +410,8 @@ if (isset($_GET["simpledb"])) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function sdb_request($action, $params = array()) {
|
function sdb_request($action, $params = array()) {
|
||||||
global $adminer, $connection;
|
$adminer = adminer();
|
||||||
|
$connection = connection();
|
||||||
list($host, $params['AWSAccessKeyId'], $secret) = $adminer->credentials();
|
list($host, $params['AWSAccessKeyId'], $secret) = $adminer->credentials();
|
||||||
$params['Action'] = $action;
|
$params['Action'] = $action;
|
||||||
$params['Timestamp'] = gmdate('Y-m-d\TH:i:s+00:00');
|
$params['Timestamp'] = gmdate('Y-m-d\TH:i:s+00:00');
|
||||||
|
Reference in New Issue
Block a user