define('Adminer\DRIVER', "mssql");
if (extension_loaded("sqlsrv") && $_GET["ext"] != "pdo") {
class Db extends SqlDb {
- public $extension = "sqlsrv";
+ public string $extension = "sqlsrv";
private $link, $result;
private function get_error() {
return $this->convert(sqlsrv_fetch_array($this->result, SQLSRV_FETCH_NUMERIC));
}
- function fetch_field(): object {
+ function fetch_field(): \stdClass {
if (!$this->fields) {
$this->fields = sqlsrv_field_metadata($this->result);
}
if (extension_loaded("pdo_sqlsrv")) {
class Db extends MssqlDb {
- public $extension = "PDO_SQLSRV";
+ public string $extension = "PDO_SQLSRV";
function connect(string $server, string $username, string $password): bool {
$this->dsn("sqlsrv:Server=" . str_replace(":", ",", $server), $username, $password);
} elseif (extension_loaded("pdo_dblib")) {
class Db extends MssqlDb {
- public $extension = "PDO_DBLIB";
+ public string $extension = "PDO_DBLIB";
function connect(string $server, string $username, string $password): bool {
$this->dsn("dblib:charset=utf8;host=" . str_replace(":", ";unix_socket=", preg_replace('~:(\d)~', ';port=\1', $server)), $username, $password);
class Driver extends SqlDriver {
- static $possibleDrivers = array("SQLSRV", "PDO_SQLSRV", "PDO_DBLIB");
- static $jush = "mssql";
+ static array $possibleDrivers = array("SQLSRV", "PDO_SQLSRV", "PDO_DBLIB");
+ static string $jush = "mssql";
- public $editFunctions = array(
+ public array $editFunctions = array(
array(
"date|time" => "getdate",
), array(
)
);
- public $operators = array("=", "<", ">", "<=", ">=", "!=", "LIKE", "LIKE %%", "IN", "IS NULL", "NOT LIKE", "NOT IN", "IS NOT NULL");
- public $functions = array("len", "lower", "round", "upper");
- public $grouping = array("avg", "count", "count distinct", "max", "min", "sum");
- public $onActions = "NO ACTION|CASCADE|SET NULL|SET DEFAULT";
- public $generated = array("PERSISTED", "VIRTUAL");
+ public array $operators = array("=", "<", ">", "<=", ">=", "!=", "LIKE", "LIKE %%", "IN", "IS NULL", "NOT LIKE", "NOT IN", "IS NOT NULL");
+ public array $functions = array("len", "lower", "round", "upper");
+ public array $grouping = array("avg", "count", "count distinct", "max", "min", "sum");
+ public array $generated = array("PERSISTED", "VIRTUAL");
+ public string $onActions = "NO ACTION|CASCADE|SET NULL|SET DEFAULT";
function __construct(Db $connection) {
parent::__construct($connection);
// MySQLi supports everything, MySQL doesn't support multiple result sets, PDO_MySQL doesn't support orgtable
if (extension_loaded("mysqli") && $_GET["ext"] != "pdo") {
class Db extends \MySQLi {
- public $extension = "MySQLi", $flavor = '';
+ public string $extension = "MySQLi", $flavor = '';
function __construct() {
parent::init();
} elseif (extension_loaded("mysql") && !((ini_bool("sql.safe_mode") || ini_bool("mysql.allow_local_infile")) && extension_loaded("pdo_mysql"))) {
class Db extends SqlDb {
- private resource $link;
+ /** @var resource */ private $link;
function connect(string $server, string $username, string $password): bool {
if (ini_bool("mysql.allow_local_infile")) {
class Result {
public int $num_rows; // number of rows in the result
- private resource $result;
+ /** @var resource */ private $result;
private int $offset = 0;
- function __construct(resource $result) {
+ /** @param resource $result */
+ function __construct($result) {
$this->result = $result;
$this->num_rows = mysql_num_rows($result);
}
}
/** Fetch next field
- * @return object properties: name, type (0 number, 15 varchar, 254 char), charsetnr (63 binary); optionally: table, orgtable, orgname
+ * @return \stdClass properties: name, type (0 number, 15 varchar, 254 char), charsetnr (63 binary); optionally: table, orgtable, orgname
*/
- function fetch_field(): object {
+ function fetch_field(): \stdClass {
$return = mysql_fetch_field($this->result, $this->offset++); // offset required under certain conditions
$return->orgtable = $return->table;
$return->charsetnr = ($return->blob ? 63 : 0);
} elseif (extension_loaded("pdo_mysql")) {
class Db extends PdoDb {
- public $extension = "PDO_MySQL";
+ public string $extension = "PDO_MySQL";
function connect(string $server, string $username, string $password): bool {
global $adminer;
define('Adminer\DRIVER', "oracle");
if (extension_loaded("oci8") && $_GET["ext"] != "pdo") {
class Db extends SqlDb {
- public $extension = "oci8";
+ public string $extension = "oci8";
public $_current_db;
private $link;
return $this->convert(oci_fetch_row($this->result));
}
- function fetch_field(): object {
+ function fetch_field(): \stdClass {
$column = $this->offset++;
$return = new \stdClass;
$return->name = oci_field_name($this->result, $column);
} elseif (extension_loaded("pdo_oci")) {
class Db extends PdoDb {
- public $extension = "PDO_OCI";
+ public string $extension = "PDO_OCI";
public $_current_db;
function connect(string $server, string $username, string $password): bool {
class Driver extends SqlDriver {
- static $possibleDrivers = array("OCI8", "PDO_OCI");
- static $jush = "oracle";
+ static array $possibleDrivers = array("OCI8", "PDO_OCI");
+ static string $jush = "oracle";
- public $editFunctions = array(
+ public array $editFunctions = array(
array( //! no parentheses
"date" => "current_date",
"timestamp" => "current_timestamp",
)
);
- public $operators = array("=", "<", ">", "<=", ">=", "!=", "LIKE", "LIKE %%", "IN", "IS NULL", "NOT LIKE", "NOT IN", "IS NOT NULL", "SQL");
- public $functions = array("length", "lower", "round", "upper");
- public $grouping = array("avg", "count", "count distinct", "max", "min", "sum");
+ public array $operators = array("=", "<", ">", "<=", ">=", "!=", "LIKE", "LIKE %%", "IN", "IS NULL", "NOT LIKE", "NOT IN", "IS NOT NULL", "SQL");
+ public array $functions = array("length", "lower", "round", "upper");
+ public array $grouping = array("avg", "count", "count distinct", "max", "min", "sum");
function __construct(Db $connection) {
parent::__construct($connection);
define('Adminer\DRIVER', "pgsql");
if (extension_loaded("pgsql") && $_GET["ext"] != "pdo") {
class Db extends SqlDb {
- public $extension = "PgSQL", $timeout;
+ public string $extension = "PgSQL";
+ public int $timeout;
private $link, $string, $database = true;
function _error($errno, $error) {
return pg_fetch_row($this->result);
}
- function fetch_field(): object {
+ function fetch_field(): \stdClass {
$column = $this->offset++;
$return = new \stdClass;
$return->orgtable = pg_field_table($this->result, $column);
} elseif (extension_loaded("pdo_pgsql")) {
class Db extends PdoDb {
- public $extension = "PDO_PgSQL", $timeout;
+ public string $extension = "PDO_PgSQL";
+ public int $timeout;
function connect(string $server, string $username, string $password): bool {
global $adminer;
class Driver extends SqlDriver {
- static $possibleDrivers = array("PgSQL", "PDO_PgSQL");
- static $jush = "pgsql";
+ static array $possibleDrivers = array("PgSQL", "PDO_PgSQL");
+ static string $jush = "pgsql";
- public $operators = array("=", "<", ">", "<=", ">=", "!=", "~", "!~", "LIKE", "LIKE %%", "ILIKE", "ILIKE %%", "IN", "IS NULL", "NOT LIKE", "NOT IN", "IS NOT NULL"); // no "SQL" to avoid CSRF
- public $functions = array("char_length", "lower", "round", "to_hex", "to_timestamp", "upper");
- public $grouping = array("avg", "count", "count distinct", "max", "min", "sum");
+ public array $operators = array("=", "<", ">", "<=", ">=", "!=", "~", "!~", "LIKE", "LIKE %%", "ILIKE", "ILIKE %%", "IN", "IS NULL", "NOT LIKE", "NOT IN", "IS NOT NULL"); // no "SQL" to avoid CSRF
+ public array $functions = array("char_length", "lower", "round", "to_hex", "to_timestamp", "upper");
+ public array $grouping = array("avg", "count", "count distinct", "max", "min", "sum");
function __construct(Db $connection) {
parent::__construct($connection);
if (class_exists("SQLite3") && $_GET["ext"] != "pdo") {
abstract class SqliteDb extends SqlDb {
- public $extension = "SQLite3";
+ public string $extension = "SQLite3";
private $link;
function connect(string $filename, string $username = '', string $password = ''): bool {
return $this->result->fetchArray(SQLITE3_NUM);
}
- function fetch_field(): object {
+ function fetch_field(): \stdClass {
$column = $this->offset++;
$type = $this->result->columnType($column);
return (object) array(
} elseif (extension_loaded("pdo_sqlite")) {
abstract class SqliteDb extends PdoDb {
- public $extension = "PDO_SQLite";
+ public string $extension = "PDO_SQLite";
function connect(string $filename, string $username = '', string $password = ''): bool {
$this->dsn(DRIVER . ":$filename", "", "");
class Driver extends SqlDriver {
- static $possibleDrivers = array("SQLite3", "PDO_SQLite");
- static $jush = "sqlite";
+ static array $possibleDrivers = array("SQLite3", "PDO_SQLite");
+ static string $jush = "sqlite";
- protected $types = array(array("integer" => 0, "real" => 0, "numeric" => 0, "text" => 0, "blob" => 0));
+ protected array $types = array(array("integer" => 0, "real" => 0, "numeric" => 0, "text" => 0, "blob" => 0));
- public $editFunctions = array(
+ public array $editFunctions = array(
array(
// "text" => "date('now')/time('now')/datetime('now')",
), array(
)
);
- public $operators = array("=", "<", ">", "<=", ">=", "!=", "LIKE", "LIKE %%", "IN", "IS NULL", "NOT LIKE", "NOT IN", "IS NOT NULL", "SQL"); // REGEXP can be user defined function
- public $functions = array("hex", "length", "lower", "round", "unixepoch", "upper");
- public $grouping = array("avg", "count", "count distinct", "group_concat", "max", "min", "sum");
+ public array $operators = array("=", "<", ">", "<=", ">=", "!=", "LIKE", "LIKE %%", "IN", "IS NULL", "NOT LIKE", "NOT IN", "IS NOT NULL", "SQL"); // REGEXP can be user defined function
+ public array $functions = array("hex", "length", "lower", "round", "unixepoch", "upper");
+ public array $grouping = array("avg", "count", "count distinct", "group_concat", "max", "min", "sum");
function __construct(Db $connection) {
parent::__construct($connection);
/** Move fields up and down or add field
* @param Field[] $fields
*/
-function process_fields(&array $fields): bool {
+function process_fields(array &$fields): bool {
$offset = 0;
if ($_POST["up"]) {
$last = 0;
* @param list<string> $tables
* @param callable(string):string $escape
*/
-function apply_queries(string $query, array $tables, callable $escape = 'Adminer\table'): bool {
+function apply_queries(string $query, array $tables, $escape = 'Adminer\table'): bool {
foreach ($tables as $table) {
if (!queries("$query " . $escape($table))) {
return false;
return $fp;
}
-/** Write and unlock a file */
-function file_write_unlock(resource $fp, string $data): void {
+/** Write and unlock a file
+* @param resource $fp
+*/
+function file_write_unlock($fp, string $data): void {
rewind($fp);
fwrite($fp, $data);
ftruncate($fp, strlen($data));
file_unlock($fp);
}
-/** Unlock and close a file */
-function file_unlock(resource $fp): void {
+/** Unlock and close a file
+* @param resource $fp
+*/
+function file_unlock($fp): void {
flock($fp, LOCK_UN);
fclose($fp);
}
return $this->fetch(\PDO::FETCH_NUM);
}
- function fetch_field(): object {
+ function fetch_field(): \stdClass {
$row = (object) $this->getColumnMeta($this->_offset++);
$type = $row->pdo_type;
$row->type = ($type == \PDO::PARAM_INT ? 0 : 15);
namespace Adminer;
class TmpFile {
- private resource $handler;
+ /** @var resource */ private $handler;
/** @visibility protected(set) */ public int $size;
function __construct() {
paths:
- adminer/include/pdo.inc.php
- adminer/drivers/*
-
+
-
message: "~ to an undefined ~" # PostgreSQL has this in its version of Db
path: adminer/drivers/pgsql.inc.php
scanFiles:
- compile.php # compile_file()
excludePaths:
+ - adminer/adminer-plugins/
- adminer/lang/
- adminer/adminer-plugins.php
- adminer/designs.php
- adminer/sqlite.php
phpVersion:
- min: 70100
+ min: 70400
max: 80499
typeAliases:
if (ini_bool('allow_url_fopen')) {
class Db extends SqlDb {
- public $extension = "JSON";
+ public string $extension = "JSON";
public $_db = 'default';
private $url;
return $row;
}
- function fetch_field(): object {
+ function fetch_field(): \stdClass {
$column = $this->offset++;
$return = new \stdClass;
if ($column < count($this->columns)) {
}
class Driver extends SqlDriver {
- static $possibleDrivers = array("allow_url_fopen");
- static $jush = "clickhouse";
+ static array $possibleDrivers = array("allow_url_fopen");
+ static string $jush = "clickhouse";
- public $operators = array("=", "<", ">", "<=", ">=", "!=", "~", "!~", "LIKE", "LIKE %%", "IN", "IS NULL", "NOT LIKE", "NOT IN", "IS NOT NULL", "SQL");
- public $grouping = array("avg", "count", "count distinct", "max", "min", "sum");
+ public array $operators = array("=", "<", ">", "<=", ">=", "!=", "~", "!~", "LIKE", "LIKE %%", "IN", "IS NULL", "NOT LIKE", "NOT IN", "IS NOT NULL", "SQL");
+ public array $grouping = array("avg", "count", "count distinct", "max", "min", "sum");
function __construct(Db $connection) {
parent::__construct($connection);
if (ini_bool('allow_url_fopen')) {
class Db extends SqlDb {
- public $extension = "JSON";
+ public string $extension = "JSON";
private $url;
/**
}
class Driver extends SqlDriver {
- static $possibleDrivers = array("json + allow_url_fopen");
- static $jush = "elastic";
+ static array $possibleDrivers = array("json + allow_url_fopen");
+ static string $jush = "elastic";
- public $editFunctions = array(array("json"));
- public $operators = array("=", "must", "should", "must_not");
+ public array $editFunctions = array(array("json"));
+ public array $operators = array("=", "must", "should", "must_not");
function __construct(Db $connection) {
parent::__construct($connection);
if (extension_loaded("interbase")) {
class Db extends SqlDb {
- public $extension = "Firebird", $_link;
+ public string $extension = "Firebird", $_link;
function connect(string $server, string $username, string $password): bool {
$this->_link = ibase_connect($server, $username, $password);
return ibase_fetch_row($this->result);
}
- function fetch_field(): object {
+ function fetch_field(): \stdClass {
$field = ibase_field_info($this->result, $this->offset++);
return (object) array(
'name' => $field['name'],
class Driver extends SqlDriver {
- static $possibleDrivers = array("interbase");
- static $jush = "firebird";
+ static array $possibleDrivers = array("interbase");
+ static string $jush = "firebird";
- public $operators = array("=");
+ public array $operators = array("=");
}
if (extension_loaded("imap")) {
class Db extends SqlDb {
- public $extension = "IMAP";
+ public string $extension = "IMAP";
public $server_info = "?"; // imap_mailboxmsginfo() or imap_check() don't return anything useful
private $mailbox;
private $imap;
return ($row ? array_values($row) : false);
}
- function fetch_field(): object {
+ function fetch_field(): \stdClass {
$field = current($this->fields);
next($this->fields);
return ($field != '' ? (object) array('name' => $field, 'type' => 15, 'charsetnr' => 0) : false);
}
class Driver extends SqlDriver {
- static $possibleDrivers = array("imap");
- static $jush = "imap";
- public $editFunctions = array(array("json"));
+ static array $possibleDrivers = array("imap");
+ static string $jush = "imap";
+ public array $editFunctions = array(array("json"));
}
function logged_user() {
if (class_exists('MongoDB\Driver\Manager')) {
class Db extends SqlDb {
- public $extension = "MongoDB", $server_info = MONGODB_VERSION, $last_id;
+ public string $extension = "MongoDB", $server_info = MONGODB_VERSION, $last_id;
public \MongoDB\Driver\Manager $_link;
public $_db, $_db_name;
return array_values($return);
}
- function fetch_field(): object {
+ function fetch_field(): \stdClass {
$keys = array_keys($this->rows[0]);
$name = $keys[$this->offset++];
return (object) array(
class Driver extends SqlDriver {
- static $possibleDrivers = array("mongodb");
- static $jush = "mongo";
+ static array $possibleDrivers = array("mongodb");
+ static string $jush = "mongo";
- public $editFunctions = array(array("json"));
+ public array $editFunctions = array(array("json"));
- public $operators = array(
+ public array $operators = array(
"=",
"!=",
">",
if (class_exists('SimpleXMLElement') && ini_bool('allow_url_fopen')) {
class Db extends SqlDb {
- public $extension = "SimpleXML", $server_info = '2009-04-15', $timeout, $next;
+ public string $extension = "SimpleXML", $server_info = '2009-04-15', $timeout, $next;
function select_db(string $database): bool {
return ($database == "domain");
return array_values($return);
}
- function fetch_field(): object {
+ function fetch_field(): \stdClass {
$keys = array_keys($this->rows[0]);
return (object) array('name' => $keys[$this->offset++], 'type' => 15, 'charsetnr' => 0);
}
class Driver extends SqlDriver {
- static $possibleDrivers = array("SimpleXML + allow_url_fopen");
- static $jush = "simpledb";
+ static array $possibleDrivers = array("SimpleXML + allow_url_fopen");
+ static string $jush = "simpledb";
- public $operators = array("=", "<", ">", "<=", ">=", "!=", "LIKE", "LIKE %%", "IN", "IS NULL", "NOT LIKE", "IS NOT NULL");
- public $grouping = array("count");
+ public array $operators = array("=", "<", ">", "<=", ">=", "!=", "LIKE", "LIKE %%", "IN", "IS NULL", "NOT LIKE", "IS NOT NULL");
+ public array $grouping = array("count");
public $primary = "itemName()";