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

Use private visibility

This commit is contained in:
Jakub Vrana
2025-03-11 07:46:31 +01:00
parent ebd5f19dd4
commit 607febea8e
13 changed files with 197 additions and 182 deletions

View File

@@ -8,11 +8,12 @@ if (isset($_GET["clickhouse"])) {
if (ini_bool('allow_url_fopen')) {
class Db {
var $extension = "JSON", $server_info, $errno, $_result, $error, $_url;
var $extension = "JSON", $server_info, $errno, $error;
private $result, $url;
var $_db = 'default';
function rootQuery($db, $query) {
$file = @file_get_contents("$this->_url/?database=$db", false, stream_context_create(array('http' => array(
$file = @file_get_contents("$this->url/?database=$db", false, stream_context_create(array('http' => array(
'method' => 'POST',
'content' => $this->isQuerySelectLike($query) ? "$query FORMAT JSONCompact" : $query,
'header' => 'Content-type: application/x-www-form-urlencoded',
@@ -57,7 +58,7 @@ if (isset($_GET["clickhouse"])) {
function connect($server, $username, $password) {
preg_match('~^(https?://)?(.*)~', $server, $match);
$this->_url = ($match[1] ?: "http://") . urlencode($username) . ":" . urlencode($password) . "@$match[2]";
$this->url = ($match[1] ?: "http://") . urlencode($username) . ":" . urlencode($password) . "@$match[2]";
$return = $this->query('SELECT 1');
return (bool) $return;
}
@@ -72,11 +73,11 @@ if (isset($_GET["clickhouse"])) {
}
function multi_query($query) {
return $this->_result = $this->query($query);
return $this->result = $this->query($query);
}
function store_result() {
return $this->_result;
return $this->result;
}
function next_result() {
@@ -90,7 +91,8 @@ if (isset($_GET["clickhouse"])) {
}
class Result {
var $num_rows, $_rows, $columns, $meta, $_offset = 0;
var $num_rows, $columns, $meta;
private $rows, $offset = 0;
function __construct($result) {
foreach ($result['data'] as $item) {
@@ -98,28 +100,28 @@ if (isset($_GET["clickhouse"])) {
foreach ($item as $key => $val) {
$row[$key] = is_scalar($val) ? $val : json_encode($val, 256); // 256 - JSON_UNESCAPED_UNICODE
}
$this->_rows[] = $row;
$this->rows[] = $row;
}
$this->num_rows = $result['rows'];
$this->meta = $result['meta'];
$this->columns = array_column($this->meta, 'name');
reset($this->_rows);
reset($this->rows);
}
function fetch_assoc() {
$row = current($this->_rows);
next($this->_rows);
$row = current($this->rows);
next($this->rows);
return $row === false ? false : array_combine($this->columns, $row);
}
function fetch_row() {
$row = current($this->_rows);
next($this->_rows);
$row = current($this->rows);
next($this->rows);
return $row;
}
function fetch_field() {
$column = $this->_offset++;
$column = $this->offset++;
$return = new \stdClass;
if ($column < count($this->columns)) {
$return->name = $this->meta[$column]['name'];

View File

@@ -9,7 +9,8 @@ if (isset($_GET["elastic"])) {
if (ini_bool('allow_url_fopen')) {
class Db {
var $extension = "JSON", $server_info, $errno, $error, $_url;
var $extension = "JSON", $server_info, $errno, $error;
private $url;
/**
* @param string $path
@@ -18,7 +19,7 @@ if (isset($_GET["elastic"])) {
* @return array|false
*/
function rootQuery($path, array $content = null, $method = 'GET') {
$file = @file_get_contents("$this->_url/" . ltrim($path, '/'), false, stream_context_create(array('http' => array(
$file = @file_get_contents("$this->url/" . ltrim($path, '/'), false, stream_context_create(array('http' => array(
'method' => $method,
'content' => $content !== null ? json_encode($content) : null,
'header' => $content !== null ? 'Content-Type: application/json' : array(),
@@ -78,7 +79,7 @@ if (isset($_GET["elastic"])) {
*/
function connect($server, $username, $password) {
preg_match('~^(https?://)?(.*)~', $server, $match);
$this->_url = ($match[1] ?: "http://") . urlencode($username) . ":" . urlencode($password) . "@$match[2]";
$this->url = ($match[1] ?: "http://") . urlencode($username) . ":" . urlencode($password) . "@$match[2]";
$return = $this->query('');
if ($return) {
$this->server_info = $return['version']['number'];
@@ -96,18 +97,19 @@ if (isset($_GET["elastic"])) {
}
class Result {
var $num_rows, $_rows;
var $num_rows;
private $rows;
function __construct($rows) {
$this->num_rows = count($rows);
$this->_rows = $rows;
$this->rows = $rows;
reset($this->_rows);
reset($this->rows);
}
function fetch_assoc() {
$return = current($this->_rows);
next($this->_rows);
$return = current($this->rows);
next($this->rows);
return $return;
}

View File

@@ -18,8 +18,9 @@ if (isset($_GET["firebird"])) {
$affected_rows,
$errno,
$error,
$_link, $_result
$_link
;
private $result;
function connect($server, $username, $password) {
$this->_link = ibase_connect($server, $username, $password);
@@ -58,11 +59,11 @@ if (isset($_GET["firebird"])) {
}
function multi_query($query) {
return $this->_result = $this->query($query);
return $this->result = $this->query($query);
}
function store_result() {
return $this->_result;
return $this->result;
}
function next_result() {
@@ -80,23 +81,24 @@ if (isset($_GET["firebird"])) {
}
class Result {
var $num_rows, $_result, $_offset = 0;
var $num_rows;
private $result, $offset = 0;
function __construct($result) {
$this->_result = $result;
$this->result = $result;
// $this->num_rows = ibase_num_rows($result);
}
function fetch_assoc() {
return ibase_fetch_assoc($this->_result);
return ibase_fetch_assoc($this->result);
}
function fetch_row() {
return ibase_fetch_row($this->_result);
return ibase_fetch_row($this->result);
}
function fetch_field() {
$field = ibase_field_info($this->_result, $this->_offset++);
$field = ibase_field_info($this->result, $this->offset++);
return (object) array(
'name' => $field['name'],
'orgname' => $field['name'],
@@ -106,7 +108,7 @@ if (isset($_GET["firebird"])) {
}
function __destruct() {
ibase_free_result($this->_result);
ibase_free_result($this->result);
}
}

View File

@@ -8,7 +8,8 @@ if (isset($_GET["simpledb"])) {
if (class_exists('SimpleXMLElement') && ini_bool('allow_url_fopen')) {
class Db {
var $extension = "SimpleXML", $server_info = '2009-04-15', $error, $timeout, $next, $affected_rows, $_result;
var $extension = "SimpleXML", $server_info = '2009-04-15', $error, $timeout, $next, $affected_rows;
private $result;
function select_db($database) {
return ($database == "domain");
@@ -38,11 +39,11 @@ if (isset($_GET["simpledb"])) {
}
function multi_query($query) {
return $this->_result = $this->query($query);
return $this->result = $this->query($query);
}
function store_result() {
return $this->_result;
return $this->result;
}
function next_result() {
@@ -55,7 +56,8 @@ if (isset($_GET["simpledb"])) {
}
class Result {
var $num_rows, $_rows = array(), $_offset = 0;
var $num_rows;
private $rows = array(), $offset = 0;
function __construct($result) {
foreach ($result as $item) {
@@ -73,14 +75,14 @@ if (isset($_GET["simpledb"])) {
$row[$name] = $value;
}
}
$this->_rows[] = $row;
$this->rows[] = $row;
foreach ($row as $key => $val) {
if (!isset($this->_rows[0][$key])) {
$this->_rows[0][$key] = null;
if (!isset($this->rows[0][$key])) {
$this->rows[0][$key] = null;
}
}
}
$this->num_rows = count($this->_rows);
$this->num_rows = count($this->rows);
}
function _processValue($element) {
@@ -88,15 +90,15 @@ if (isset($_GET["simpledb"])) {
}
function fetch_assoc() {
$row = current($this->_rows);
$row = current($this->rows);
if (!$row) {
return $row;
}
$return = array();
foreach ($this->_rows[0] as $key => $val) {
foreach ($this->rows[0] as $key => $val) {
$return[$key] = $row[$key];
}
next($this->_rows);
next($this->rows);
return $return;
}
@@ -109,8 +111,8 @@ if (isset($_GET["simpledb"])) {
}
function fetch_field() {
$keys = array_keys($this->_rows[0]);
return (object) array('name' => $keys[$this->_offset++]);
$keys = array_keys($this->rows[0]);
return (object) array('name' => $keys[$this->offset++]);
}
}
}