mirror of
https://github.com/vrana/adminer.git
synced 2025-08-06 06:37:33 +02:00
Doc-comments: Format
This commit is contained in:
@@ -83,8 +83,7 @@ if (!defined('Adminer\DRIVER')) {
|
|||||||
return (bool) $this->link;
|
return (bool) $this->link;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Set the client character set
|
/** Set the client character set */
|
||||||
*/
|
|
||||||
function set_charset(string $charset): bool {
|
function set_charset(string $charset): bool {
|
||||||
if (function_exists('mysql_set_charset')) {
|
if (function_exists('mysql_set_charset')) {
|
||||||
if (mysql_set_charset($charset, $this->link)) {
|
if (mysql_set_charset($charset, $this->link)) {
|
||||||
@@ -126,8 +125,6 @@ if (!defined('Adminer\DRIVER')) {
|
|||||||
/** @var resource */ private $result;
|
/** @var resource */ private $result;
|
||||||
/** @var int */ private $offset = 0;
|
/** @var int */ private $offset = 0;
|
||||||
|
|
||||||
/** Constructor
|
|
||||||
*/
|
|
||||||
function __construct(resource $result) {
|
function __construct(resource $result) {
|
||||||
$this->result = $result;
|
$this->result = $result;
|
||||||
$this->num_rows = mysql_num_rows($result);
|
$this->num_rows = mysql_num_rows($result);
|
||||||
@@ -157,8 +154,7 @@ if (!defined('Adminer\DRIVER')) {
|
|||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Free result set
|
/** Free result set */
|
||||||
*/
|
|
||||||
function __destruct() {
|
function __destruct() {
|
||||||
mysql_free_result($this->result);
|
mysql_free_result($this->result);
|
||||||
}
|
}
|
||||||
@@ -355,14 +351,12 @@ if (!defined('Adminer\DRIVER')) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** Escape database identifier
|
/** Escape database identifier */
|
||||||
*/
|
|
||||||
function idf_escape(string $idf): string {
|
function idf_escape(string $idf): string {
|
||||||
return "`" . str_replace("`", "``", $idf) . "`";
|
return "`" . str_replace("`", "``", $idf) . "`";
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get escaped table name
|
/** Get escaped table name */
|
||||||
*/
|
|
||||||
function table(string $idf): string {
|
function table(string $idf): string {
|
||||||
return idf_escape($idf);
|
return idf_escape($idf);
|
||||||
}
|
}
|
||||||
@@ -434,8 +428,7 @@ if (!defined('Adminer\DRIVER')) {
|
|||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get logged user
|
/** Get logged user */
|
||||||
*/
|
|
||||||
function logged_user(): string {
|
function logged_user(): string {
|
||||||
return get_val("SELECT USER()");
|
return get_val("SELECT USER()");
|
||||||
}
|
}
|
||||||
@@ -628,15 +621,13 @@ if (!defined('Adminer\DRIVER')) {
|
|||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Find out if database is information_schema
|
/** Find out if database is information_schema */
|
||||||
*/
|
|
||||||
function information_schema(string $db): bool {
|
function information_schema(string $db): bool {
|
||||||
return ($db == "information_schema")
|
return ($db == "information_schema")
|
||||||
|| (min_version(5.5) && $db == "performance_schema");
|
|| (min_version(5.5) && $db == "performance_schema");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get escaped error message
|
/** Get escaped error message */
|
||||||
*/
|
|
||||||
function error(): string {
|
function error(): string {
|
||||||
global $connection;
|
global $connection;
|
||||||
return h(preg_replace('~^You have an error.*syntax to use~U', "Syntax error", $connection->error));
|
return h(preg_replace('~^You have an error.*syntax to use~U', "Syntax error", $connection->error));
|
||||||
@@ -680,8 +671,7 @@ if (!defined('Adminer\DRIVER')) {
|
|||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Generate modifier for auto increment column
|
/** Generate modifier for auto increment column */
|
||||||
*/
|
|
||||||
function auto_increment(): string {
|
function auto_increment(): string {
|
||||||
$auto_increment_index = " PRIMARY KEY";
|
$auto_increment_index = " PRIMARY KEY";
|
||||||
// don't overwrite primary key by auto_increment
|
// don't overwrite primary key by auto_increment
|
||||||
@@ -959,8 +949,7 @@ if (!defined('Adminer\DRIVER')) {
|
|||||||
return ($where || $table_status["Engine"] != "InnoDB" ? null : $table_status["Rows"]);
|
return ($where || $table_status["Engine"] != "InnoDB" ? null : $table_status["Rows"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get SQL command to create table
|
/** Get SQL command to create table */
|
||||||
*/
|
|
||||||
function create_sql(string $table, bool $auto_increment, string $style): string {
|
function create_sql(string $table, bool $auto_increment, string $style): string {
|
||||||
$return = get_val("SHOW CREATE TABLE " . table($table), 1);
|
$return = get_val("SHOW CREATE TABLE " . table($table), 1);
|
||||||
if (!$auto_increment) {
|
if (!$auto_increment) {
|
||||||
@@ -969,20 +958,17 @@ if (!defined('Adminer\DRIVER')) {
|
|||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get SQL command to truncate table
|
/** Get SQL command to truncate table */
|
||||||
*/
|
|
||||||
function truncate_sql(string $table): string {
|
function truncate_sql(string $table): string {
|
||||||
return "TRUNCATE " . table($table);
|
return "TRUNCATE " . table($table);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get SQL command to change database
|
/** Get SQL command to change database */
|
||||||
*/
|
|
||||||
function use_sql(string $database): string {
|
function use_sql(string $database): string {
|
||||||
return "USE " . idf_escape($database);
|
return "USE " . idf_escape($database);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get SQL commands to create triggers
|
/** Get SQL commands to create triggers */
|
||||||
*/
|
|
||||||
function trigger_sql(string $table): string {
|
function trigger_sql(string $table): string {
|
||||||
$return = "";
|
$return = "";
|
||||||
foreach (get_rows("SHOW TRIGGERS LIKE " . q(addcslashes($table, "%_\\")), null, "-- ") as $row) {
|
foreach (get_rows("SHOW TRIGGERS LIKE " . q(addcslashes($table, "%_\\")), null, "-- ") as $row) {
|
||||||
@@ -1061,8 +1047,7 @@ if (!defined('Adminer\DRIVER')) {
|
|||||||
return queries("KILL " . number($val));
|
return queries("KILL " . number($val));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Return query to get connection ID
|
/** Return query to get connection ID */
|
||||||
*/
|
|
||||||
function connection_id(): string {
|
function connection_id(): string {
|
||||||
return "SELECT CONNECTION_ID()";
|
return "SELECT CONNECTION_ID()";
|
||||||
}
|
}
|
||||||
@@ -1083,8 +1068,7 @@ if (!defined('Adminer\DRIVER')) {
|
|||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get values of user defined type
|
/** Get values of user defined type */
|
||||||
*/
|
|
||||||
function type_values(int $id): string {
|
function type_values(int $id): string {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
@@ -1096,14 +1080,12 @@ if (!defined('Adminer\DRIVER')) {
|
|||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get current schema
|
/** Get current schema */
|
||||||
*/
|
|
||||||
function get_schema(): string {
|
function get_schema(): string {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Set current schema
|
/** Set current schema */
|
||||||
*/
|
|
||||||
function set_schema(string $schema, Db $connection2 = null): bool {
|
function set_schema(string $schema, Db $connection2 = null): bool {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@@ -34,8 +34,7 @@ class Adminer {
|
|||||||
return password_file($create);
|
return password_file($create);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Return key used to group brute force attacks; behind a reverse proxy, you want to return the last part of X-Forwarded-For
|
/** Return key used to group brute force attacks; behind a reverse proxy, you want to return the last part of X-Forwarded-For */
|
||||||
*/
|
|
||||||
function bruteForceKey(): string {
|
function bruteForceKey(): string {
|
||||||
return $_SERVER["REMOTE_ADDR"];
|
return $_SERVER["REMOTE_ADDR"];
|
||||||
}
|
}
|
||||||
@@ -47,8 +46,7 @@ class Adminer {
|
|||||||
return h($server);
|
return h($server);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Identifier of selected database
|
/** Identifier of selected database */
|
||||||
*/
|
|
||||||
function database(): string {
|
function database(): string {
|
||||||
// should be used everywhere instead of DB
|
// should be used everywhere instead of DB
|
||||||
return DB;
|
return DB;
|
||||||
@@ -75,8 +73,7 @@ class Adminer {
|
|||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Headers to send before HTML output
|
/** Headers to send before HTML output */
|
||||||
*/
|
|
||||||
function headers(): void {
|
function headers(): void {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,8 +109,7 @@ class Adminer {
|
|||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Print login form
|
/** Print login form */
|
||||||
*/
|
|
||||||
function loginForm(): void {
|
function loginForm(): void {
|
||||||
global $drivers;
|
global $drivers;
|
||||||
echo "<table class='layout'>\n";
|
echo "<table class='layout'>\n";
|
||||||
@@ -245,8 +241,7 @@ class Adminer {
|
|||||||
return shorten_utf8(trim($query), 1000);
|
return shorten_utf8(trim($query), 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Print HTML code just before the Execute button in SQL command
|
/** Print HTML code just before the Execute button in SQL command */
|
||||||
*/
|
|
||||||
function sqlPrintAfter(): void {
|
function sqlPrintAfter(): void {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1029,8 +1024,7 @@ class Adminer {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Print databases list in menu
|
/** Print databases list in menu */
|
||||||
*/
|
|
||||||
function databasesPrint(string $missing): void {
|
function databasesPrint(string $missing): void {
|
||||||
global $adminer, $connection;
|
global $adminer, $connection;
|
||||||
$databases = $this->databases();
|
$databases = $this->databases();
|
||||||
|
@@ -13,8 +13,7 @@ abstract class SqlDb {
|
|||||||
/** @var string */ public $error; // last error message
|
/** @var string */ public $error; // last error message
|
||||||
/** @var Result|bool */ protected $multi; // used for multiquery
|
/** @var Result|bool */ protected $multi; // used for multiquery
|
||||||
|
|
||||||
/** Connect to server
|
/** Connect to server */
|
||||||
*/
|
|
||||||
abstract function connect(string $server, string $username, string $password): bool;
|
abstract function connect(string $server, string $username, string $password): bool;
|
||||||
|
|
||||||
/** Quote string to use in SQL
|
/** Quote string to use in SQL
|
||||||
@@ -22,8 +21,7 @@ abstract class SqlDb {
|
|||||||
*/
|
*/
|
||||||
abstract function quote(string $string): string;
|
abstract function quote(string $string): string;
|
||||||
|
|
||||||
/** Select database
|
/** Select database */
|
||||||
*/
|
|
||||||
abstract function select_db(string $database): bool;
|
abstract function select_db(string $database): bool;
|
||||||
|
|
||||||
/** Send query
|
/** Send query
|
||||||
@@ -45,8 +43,7 @@ abstract class SqlDb {
|
|||||||
return $this->multi;
|
return $this->multi;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Fetch next resultset
|
/** Fetch next resultset */
|
||||||
*/
|
|
||||||
function next_result(): bool {
|
function next_result(): bool {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@@ -125,8 +125,7 @@ const thousandsSeparator = '" . js_escape(lang(',')) . "';")
|
|||||||
define('Adminer\PAGE_HEADER', 1);
|
define('Adminer\PAGE_HEADER', 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Send HTTP headers
|
/** Send HTTP headers */
|
||||||
*/
|
|
||||||
function page_headers(): void {
|
function page_headers(): void {
|
||||||
global $adminer;
|
global $adminer;
|
||||||
header("Content-Type: text/html; charset=utf-8");
|
header("Content-Type: text/html; charset=utf-8");
|
||||||
@@ -172,8 +171,7 @@ function get_nonce(): string {
|
|||||||
return $nonce;
|
return $nonce;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Print flash and error messages
|
/** Print flash and error messages */
|
||||||
*/
|
|
||||||
function page_messages(string $error): void {
|
function page_messages(string $error): void {
|
||||||
global $adminer;
|
global $adminer;
|
||||||
$uri = preg_replace('~^[^?]*~', '', $_SERVER["REQUEST_URI"]);
|
$uri = preg_replace('~^[^?]*~', '', $_SERVER["REQUEST_URI"]);
|
||||||
|
@@ -3,15 +3,13 @@ namespace Adminer;
|
|||||||
|
|
||||||
$drivers = array();
|
$drivers = array();
|
||||||
|
|
||||||
/** Add a driver
|
/** Add a driver */
|
||||||
*/
|
|
||||||
function add_driver(string $id, string $name): void {
|
function add_driver(string $id, string $name): void {
|
||||||
global $drivers;
|
global $drivers;
|
||||||
$drivers[$id] = $name;
|
$drivers[$id] = $name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get driver name
|
/** Get driver name */
|
||||||
*/
|
|
||||||
function get_driver(string $id): string {
|
function get_driver(string $id): string {
|
||||||
global $drivers;
|
global $drivers;
|
||||||
return $drivers[$id];
|
return $drivers[$id];
|
||||||
@@ -33,8 +31,7 @@ abstract class SqlDriver {
|
|||||||
/** @var string */ public $enumLength = "'(?:''|[^'\\\\]|\\\\.)*'"; // regular expression for parsing enum lengths
|
/** @var string */ public $enumLength = "'(?:''|[^'\\\\]|\\\\.)*'"; // regular expression for parsing enum lengths
|
||||||
/** @var list<string> */ public $generated = array(); // allowed types of generated columns
|
/** @var list<string> */ public $generated = array(); // allowed types of generated columns
|
||||||
|
|
||||||
/** Create object for performing database operations
|
/** Create object for performing database operations */
|
||||||
*/
|
|
||||||
function __construct(Db $connection) {
|
function __construct(Db $connection) {
|
||||||
$this->conn = $connection;
|
$this->conn = $connection;
|
||||||
}
|
}
|
||||||
@@ -134,8 +131,7 @@ abstract class SqlDriver {
|
|||||||
) . $this->insertReturning($table));
|
) . $this->insertReturning($table));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get RETURNING clause for INSERT queries (PostgreSQL specific)
|
/** Get RETURNING clause for INSERT queries (PostgreSQL specific) */
|
||||||
*/
|
|
||||||
function insertReturning(string $table): string {
|
function insertReturning(string $table): string {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
@@ -186,8 +182,7 @@ abstract class SqlDriver {
|
|||||||
return $idf;
|
return $idf;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Convert operator so it can be used in search
|
/** Convert operator so it can be used in search */
|
||||||
*/
|
|
||||||
function convertOperator(string $operator): string {
|
function convertOperator(string $operator): string {
|
||||||
return $operator;
|
return $operator;
|
||||||
}
|
}
|
||||||
@@ -202,8 +197,7 @@ abstract class SqlDriver {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Quote binary string
|
/** Quote binary string */
|
||||||
*/
|
|
||||||
function quoteBinary(string $s): string {
|
function quoteBinary(string $s): string {
|
||||||
return q($s);
|
return q($s);
|
||||||
}
|
}
|
||||||
@@ -220,8 +214,7 @@ abstract class SqlDriver {
|
|||||||
function tableHelp(string $name, bool $is_view = false) {
|
function tableHelp(string $name, bool $is_view = false) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Check if C-style escapes are supported
|
/** Check if C-style escapes are supported */
|
||||||
*/
|
|
||||||
function hasCStyleEscapes(): bool {
|
function hasCStyleEscapes(): bool {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@@ -217,8 +217,7 @@ function get_partitions_info(string $table): array {
|
|||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Filter length value including enums
|
/** Filter length value including enums */
|
||||||
*/
|
|
||||||
function process_length(string $length): string {
|
function process_length(string $length): string {
|
||||||
global $driver;
|
global $driver;
|
||||||
$enum_length = $driver->enumLength;
|
$enum_length = $driver->enumLength;
|
||||||
@@ -491,8 +490,7 @@ function create_routine($routine, array $row): string {
|
|||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Remove current user definer from SQL command
|
/** Remove current user definer from SQL command */
|
||||||
*/
|
|
||||||
function remove_definer(string $query): string {
|
function remove_definer(string $query): string {
|
||||||
return preg_replace('~^([A-Z =]+) DEFINER=`' . preg_replace('~@(.*)~', '`@`(%|\1)', logged_user()) . '`~', '\1', $query); //! proper escaping of user
|
return preg_replace('~^([A-Z =]+) DEFINER=`' . preg_replace('~@(.*)~', '`@`(%|\1)', logged_user()) . '`~', '\1', $query); //! proper escaping of user
|
||||||
}
|
}
|
||||||
@@ -531,8 +529,7 @@ function tar_file(string $filename, $tmp_file): void {
|
|||||||
echo str_repeat("\0", 511 - ($tmp_file->size + 511) % 512);
|
echo str_repeat("\0", 511 - ($tmp_file->size + 511) % 512);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get INI bytes value
|
/** Get INI bytes value */
|
||||||
*/
|
|
||||||
function ini_bytes(string $ini): int {
|
function ini_bytes(string $ini): int {
|
||||||
$val = ini_get($ini);
|
$val = ini_get($ini);
|
||||||
switch (strtolower(substr($val, -1))) {
|
switch (strtolower(substr($val, -1))) {
|
||||||
@@ -584,8 +581,7 @@ function db_size(string $db): string {
|
|||||||
return format_number($return);
|
return format_number($return);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Print SET NAMES if utf8mb4 might be needed
|
/** Print SET NAMES if utf8mb4 might be needed */
|
||||||
*/
|
|
||||||
function set_utf8mb4(string $create): void {
|
function set_utf8mb4(string $create): void {
|
||||||
global $connection;
|
global $connection;
|
||||||
static $set = false;
|
static $set = false;
|
||||||
|
@@ -3,8 +3,7 @@ namespace Adminer;
|
|||||||
|
|
||||||
// This file is used both in Adminer and Adminer Editor.
|
// This file is used both in Adminer and Adminer Editor.
|
||||||
|
|
||||||
/** Get database connection
|
/** Get database connection */
|
||||||
*/
|
|
||||||
function connection(): Db {
|
function connection(): Db {
|
||||||
// can be used in customization, $connection is minified
|
// can be used in customization, $connection is minified
|
||||||
global $connection;
|
global $connection;
|
||||||
@@ -27,8 +26,7 @@ function driver() {
|
|||||||
return $driver;
|
return $driver;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get Adminer version
|
/** Get Adminer version */
|
||||||
*/
|
|
||||||
function version(): string {
|
function version(): string {
|
||||||
global $VERSION;
|
global $VERSION;
|
||||||
return $VERSION;
|
return $VERSION;
|
||||||
@@ -45,15 +43,13 @@ function idf_unescape(string $idf): string {
|
|||||||
return str_replace($last . $last, $last, substr($idf, 1, -1));
|
return str_replace($last . $last, $last, substr($idf, 1, -1));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Shortcut for $connection->quote($string)
|
/** Shortcut for $connection->quote($string) */
|
||||||
*/
|
|
||||||
function q(string $string): string {
|
function q(string $string): string {
|
||||||
global $connection;
|
global $connection;
|
||||||
return $connection->quote($string);
|
return $connection->quote($string);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Escape string to use inside ''
|
/** Escape string to use inside '' */
|
||||||
*/
|
|
||||||
function escape_string(string $val): string {
|
function escape_string(string $val): string {
|
||||||
return substr(q($val), 1, -1);
|
return substr(q($val), 1, -1);
|
||||||
}
|
}
|
||||||
@@ -69,14 +65,12 @@ function idx(?array $array, $key, $default = null) {
|
|||||||
return ($array && array_key_exists($key, $array) ? $array[$key] : $default);
|
return ($array && array_key_exists($key, $array) ? $array[$key] : $default);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Remove non-digits from a string
|
/** Remove non-digits from a string */
|
||||||
*/
|
|
||||||
function number(string $val): string {
|
function number(string $val): string {
|
||||||
return preg_replace('~[^0-9]+~', '', $val);
|
return preg_replace('~[^0-9]+~', '', $val);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get regular expression to match numeric types
|
/** Get regular expression to match numeric types */
|
||||||
*/
|
|
||||||
function number_type(): string {
|
function number_type(): string {
|
||||||
return '((?<!o)int(?!er)|numeric|real|float|double|decimal|money)'; // not point, not interval
|
return '((?<!o)int(?!er)|numeric|real|float|double|decimal|money)'; // not point, not interval
|
||||||
}
|
}
|
||||||
@@ -102,8 +96,7 @@ function remove_slashes(array $process, bool $filter = false): void {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Escape or unescape string to use inside form []
|
/** Escape or unescape string to use inside form [] */
|
||||||
*/
|
|
||||||
function bracket_escape(string $idf, bool $back = false): string {
|
function bracket_escape(string $idf, bool $back = false): string {
|
||||||
// escape brackets inside name="x[]"
|
// escape brackets inside name="x[]"
|
||||||
static $trans = array(':' => ':1', ']' => ':2', '[' => ':3', '"' => ':4');
|
static $trans = array(':' => ':1', ']' => ':2', '[' => ':3', '"' => ':4');
|
||||||
@@ -128,21 +121,18 @@ function min_version($version, $maria_db = "", Db $connection2 = null): bool {
|
|||||||
return $version && version_compare($server_info, $version) >= 0;
|
return $version && version_compare($server_info, $version) >= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get connection charset
|
/** Get connection charset */
|
||||||
*/
|
|
||||||
function charset(Db $connection): string {
|
function charset(Db $connection): string {
|
||||||
return (min_version("5.5.3", 0, $connection) ? "utf8mb4" : "utf8"); // SHOW CHARSET would require an extra query
|
return (min_version("5.5.3", 0, $connection) ? "utf8mb4" : "utf8"); // SHOW CHARSET would require an extra query
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get INI boolean value
|
/** Get INI boolean value */
|
||||||
*/
|
|
||||||
function ini_bool(string $ini): bool {
|
function ini_bool(string $ini): bool {
|
||||||
$val = ini_get($ini);
|
$val = ini_get($ini);
|
||||||
return (preg_match('~^(on|true|yes)$~i', $val) || (int) $val); // boolean values set by php_value are strings
|
return (preg_match('~^(on|true|yes)$~i', $val) || (int) $val); // boolean values set by php_value are strings
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Check if SID is necessary
|
/** Check if SID is necessary */
|
||||||
*/
|
|
||||||
function sid(): bool {
|
function sid(): bool {
|
||||||
static $return;
|
static $return;
|
||||||
if ($return === null) { // restart_session() defines SID
|
if ($return === null) { // restart_session() defines SID
|
||||||
@@ -151,8 +141,7 @@ function sid(): bool {
|
|||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Set password to session
|
/** Set password to session */
|
||||||
*/
|
|
||||||
function set_password(string $vendor, string $server, string $username, ?string $password): void {
|
function set_password(string $vendor, string $server, string $username, ?string $password): void {
|
||||||
$_SESSION["pwds"][$vendor][$server][$username] = ($_COOKIE["adminer_key"] && is_string($password)
|
$_SESSION["pwds"][$vendor][$server][$username] = ($_COOKIE["adminer_key"] && is_string($password)
|
||||||
? array(encrypt_string($password, $_COOKIE["adminer_key"]))
|
? array(encrypt_string($password, $_COOKIE["adminer_key"]))
|
||||||
@@ -258,8 +247,7 @@ function unique_array(array $row, array $indexes) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Escape column key used in where()
|
/** Escape column key used in where() */
|
||||||
*/
|
|
||||||
function escape_key(string $key): string {
|
function escape_key(string $key): string {
|
||||||
if (preg_match('(^([\w(]+)(' . str_replace("_", ".*", preg_quote(idf_escape("_"))) . ')([ \w)]+)$)', $key, $match)) { //! columns looking like functions
|
if (preg_match('(^([\w(]+)(' . str_replace("_", ".*", preg_quote(idf_escape("_"))) . ')([ \w)]+)$)', $key, $match)) { //! columns looking like functions
|
||||||
return $match[1] . idf_escape(idf_unescape($match[2])) . $match[3]; //! SQL injection
|
return $match[1] . idf_escape(idf_unescape($match[2])) . $match[3]; //! SQL injection
|
||||||
@@ -369,16 +357,14 @@ function save_settings(array $settings, string $cookie = "adminer_settings"): vo
|
|||||||
cookie($cookie, http_build_query($settings + get_settings($cookie)));
|
cookie($cookie, http_build_query($settings + get_settings($cookie)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Restart stopped session
|
/** Restart stopped session */
|
||||||
*/
|
|
||||||
function restart_session(): void {
|
function restart_session(): void {
|
||||||
if (!ini_bool("session.use_cookies") && (!function_exists('session_status') || session_status() == 1)) { // 1 - PHP_SESSION_NONE, session_status() available since PHP 5.4
|
if (!ini_bool("session.use_cookies") && (!function_exists('session_status') || session_status() == 1)) { // 1 - PHP_SESSION_NONE, session_status() available since PHP 5.4
|
||||||
session_start();
|
session_start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Stop session if possible
|
/** Stop session if possible */
|
||||||
*/
|
|
||||||
function stop_session(bool $force = false): void {
|
function stop_session(bool $force = false): void {
|
||||||
$use_cookies = ini_bool("session.use_cookies");
|
$use_cookies = ini_bool("session.use_cookies");
|
||||||
if (!$use_cookies || $force) {
|
if (!$use_cookies || $force) {
|
||||||
@@ -404,8 +390,7 @@ function set_session(string $key, $val) {
|
|||||||
$_SESSION[$key][DRIVER][SERVER][$_GET["username"]] = $val; // used also in auth.inc.php
|
$_SESSION[$key][DRIVER][SERVER][$_GET["username"]] = $val; // used also in auth.inc.php
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get authenticated URL
|
/** Get authenticated URL */
|
||||||
*/
|
|
||||||
function auth_url(string $vendor, string $server, string $username, string $db = null): string {
|
function auth_url(string $vendor, string $server, string $username, string $db = null): string {
|
||||||
global $drivers;
|
global $drivers;
|
||||||
$uri = remove_from_uri(implode("|", array_keys($drivers))
|
$uri = remove_from_uri(implode("|", array_keys($drivers))
|
||||||
@@ -425,8 +410,7 @@ function auth_url(string $vendor, string $server, string $username, string $db =
|
|||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Find whether it is an AJAX request
|
/** Find whether it is an AJAX request */
|
||||||
*/
|
|
||||||
function is_ajax(): bool {
|
function is_ajax(): bool {
|
||||||
return ($_SERVER["HTTP_X_REQUESTED_WITH"] == "XMLHttpRequest");
|
return ($_SERVER["HTTP_X_REQUESTED_WITH"] == "XMLHttpRequest");
|
||||||
}
|
}
|
||||||
@@ -448,8 +432,7 @@ function redirect(string $location, string $message = null): void {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Execute query and redirect if successful
|
/** Execute query and redirect if successful */
|
||||||
*/
|
|
||||||
function query_redirect(string $query, string $location, string $message, bool $redirect = true, bool $execute = true, bool $failed = false, string $time = ""): bool {
|
function query_redirect(string $query, string $location, string $message, bool $redirect = true, bool $execute = true, bool $failed = false, string $time = ""): bool {
|
||||||
global $connection, $error, $adminer;
|
global $connection, $error, $adminer;
|
||||||
if ($execute) {
|
if ($execute) {
|
||||||
@@ -502,8 +485,7 @@ function apply_queries(string $query, array $tables, callable $escape = 'Adminer
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Redirect by remembered queries
|
/** Redirect by remembered queries */
|
||||||
*/
|
|
||||||
function queries_redirect(string $location, string $message, bool $redirect): bool {
|
function queries_redirect(string $location, string $message, bool $redirect): bool {
|
||||||
$queries = implode("\n", Queries::$queries);
|
$queries = implode("\n", Queries::$queries);
|
||||||
$time = format_time(Queries::$start);
|
$time = format_time(Queries::$start);
|
||||||
@@ -518,14 +500,12 @@ function format_time(float $start): string {
|
|||||||
return lang('%.3f s', max(0, microtime(true) - $start));
|
return lang('%.3f s', max(0, microtime(true) - $start));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get relative REQUEST_URI
|
/** Get relative REQUEST_URI */
|
||||||
*/
|
|
||||||
function relative_uri(): string {
|
function relative_uri(): string {
|
||||||
return str_replace(":", "%3a", preg_replace('~^[^?]*/([^?]*)~', '\1', $_SERVER["REQUEST_URI"]));
|
return str_replace(":", "%3a", preg_replace('~^[^?]*/([^?]*)~', '\1', $_SERVER["REQUEST_URI"]));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Remove parameter from query string
|
/** Remove parameter from query string */
|
||||||
*/
|
|
||||||
function remove_from_uri(string $param = ""): string {
|
function remove_from_uri(string $param = ""): string {
|
||||||
return substr(preg_replace("~(?<=[?&])($param" . (SID ? "" : "|" . session_name()) . ")=[^&]*&~", '', relative_uri() . "&"), 0, -1);
|
return substr(preg_replace("~(?<=[?&])($param" . (SID ? "" : "|" . session_name()) . ")=[^&]*&~", '', relative_uri() . "&"), 0, -1);
|
||||||
}
|
}
|
||||||
@@ -569,22 +549,19 @@ function get_file(string $key, bool $decompress = false, string $delimiter = "")
|
|||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Determine upload error
|
/** Determine upload error */
|
||||||
*/
|
|
||||||
function upload_error(int $error): string {
|
function upload_error(int $error): string {
|
||||||
$max_size = ($error == UPLOAD_ERR_INI_SIZE ? ini_get("upload_max_filesize") : 0); // post_max_size is checked in index.php
|
$max_size = ($error == UPLOAD_ERR_INI_SIZE ? ini_get("upload_max_filesize") : 0); // post_max_size is checked in index.php
|
||||||
return ($error ? lang('Unable to upload a file.') . ($max_size ? " " . lang('Maximum allowed file size is %sB.', $max_size) : "") : lang('File does not exist.'));
|
return ($error ? lang('Unable to upload a file.') . ($max_size ? " " . lang('Maximum allowed file size is %sB.', $max_size) : "") : lang('File does not exist.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Create repeat pattern for preg
|
/** Create repeat pattern for preg */
|
||||||
*/
|
|
||||||
function repeat_pattern(string $pattern, int $length): string {
|
function repeat_pattern(string $pattern, int $length): string {
|
||||||
// fix for Compilation failed: number too big in {} quantifier
|
// fix for Compilation failed: number too big in {} quantifier
|
||||||
return str_repeat("$pattern{0,65535}", $length / 65535) . "$pattern{0," . ($length % 65535) . "}"; // can create {0,0} which is OK
|
return str_repeat("$pattern{0,65535}", $length / 65535) . "$pattern{0," . ($length % 65535) . "}"; // can create {0,0} which is OK
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Check whether the string is in UTF-8
|
/** Check whether the string is in UTF-8 */
|
||||||
*/
|
|
||||||
function is_utf8(string $val): bool {
|
function is_utf8(string $val): bool {
|
||||||
// don't print control chars except \t\r\n
|
// don't print control chars except \t\r\n
|
||||||
return (preg_match('~~u', $val) && !preg_match('~[\0-\x8\xB\xC\xE-\x1F]~', $val));
|
return (preg_match('~~u', $val) && !preg_match('~[\0-\x8\xB\xC\xE-\x1F]~', $val));
|
||||||
@@ -607,8 +584,7 @@ function format_number($val): string {
|
|||||||
return strtr(number_format($val, 0, ".", lang(',')), preg_split('~~u', lang('0123456789'), -1, PREG_SPLIT_NO_EMPTY));
|
return strtr(number_format($val, 0, ".", lang(',')), preg_split('~~u', lang('0123456789'), -1, PREG_SPLIT_NO_EMPTY));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Generate friendly URL
|
/** Generate friendly URL */
|
||||||
*/
|
|
||||||
function friendly_url(string $val): string {
|
function friendly_url(string $val): string {
|
||||||
// used for blobs and export
|
// used for blobs and export
|
||||||
return preg_replace('~\W~i', '-', $val);
|
return preg_replace('~\W~i', '-', $val);
|
||||||
@@ -699,8 +675,7 @@ function apply_sql_function(string $function, string $column): string {
|
|||||||
return ($function ? ($function == "unixepoch" ? "DATETIME($column, '$function')" : ($function == "count distinct" ? "COUNT(DISTINCT " : strtoupper("$function(")) . "$column)") : $column);
|
return ($function ? ($function == "unixepoch" ? "DATETIME($column, '$function')" : ($function == "count distinct" ? "COUNT(DISTINCT " : strtoupper("$function(")) . "$column)") : $column);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get path of the temporary directory
|
/** Get path of the temporary directory */
|
||||||
*/
|
|
||||||
function get_temp_dir(): string {
|
function get_temp_dir(): string {
|
||||||
$return = ini_get("upload_tmp_dir"); // session_save_path() may contain other storage path
|
$return = ini_get("upload_tmp_dir"); // session_save_path() may contain other storage path
|
||||||
if (!$return) {
|
if (!$return) {
|
||||||
@@ -737,8 +712,7 @@ function file_open_lock(string $filename) {
|
|||||||
return $fp;
|
return $fp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Write and unlock a file
|
/** Write and unlock a file */
|
||||||
*/
|
|
||||||
function file_write_unlock(resource $fp, string $data): void {
|
function file_write_unlock(resource $fp, string $data): void {
|
||||||
rewind($fp);
|
rewind($fp);
|
||||||
fwrite($fp, $data);
|
fwrite($fp, $data);
|
||||||
@@ -746,8 +720,7 @@ function file_write_unlock(resource $fp, string $data): void {
|
|||||||
file_unlock($fp);
|
file_unlock($fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Unlock and close a file
|
/** Unlock and close a file */
|
||||||
*/
|
|
||||||
function file_unlock(resource $fp): void {
|
function file_unlock(resource $fp): void {
|
||||||
flock($fp, LOCK_UN);
|
flock($fp, LOCK_UN);
|
||||||
fclose($fp);
|
fclose($fp);
|
||||||
@@ -832,8 +805,7 @@ function select_value($val, string $link, array $field, int $text_length): strin
|
|||||||
return $adminer->selectVal($return, $link, $field, $val);
|
return $adminer->selectVal($return, $link, $field, $val);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Check whether the string is e-mail address
|
/** Check whether the string is e-mail address */
|
||||||
*/
|
|
||||||
function is_mail(?string $email): bool {
|
function is_mail(?string $email): bool {
|
||||||
$atom = '[-a-z0-9!#$%&\'*+/=?^_`{|}~]'; // characters of local-name
|
$atom = '[-a-z0-9!#$%&\'*+/=?^_`{|}~]'; // characters of local-name
|
||||||
$domain = '[a-z0-9]([-a-z0-9]{0,61}[a-z0-9])'; // one domain component
|
$domain = '[a-z0-9]([-a-z0-9]{0,61}[a-z0-9])'; // one domain component
|
||||||
@@ -841,8 +813,7 @@ function is_mail(?string $email): bool {
|
|||||||
return is_string($email) && preg_match("(^$pattern(,\\s*$pattern)*\$)i", $email);
|
return is_string($email) && preg_match("(^$pattern(,\\s*$pattern)*\$)i", $email);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Check whether the string is URL address
|
/** Check whether the string is URL address */
|
||||||
*/
|
|
||||||
function is_url(string $string): bool {
|
function is_url(string $string): bool {
|
||||||
$domain = '[a-z0-9]([-a-z0-9]{0,61}[a-z0-9])'; // one domain component //! IDN
|
$domain = '[a-z0-9]([-a-z0-9]{0,61}[a-z0-9])'; // one domain component //! IDN
|
||||||
return preg_match("~^(https?)://($domain?\\.)+$domain(:\\d+)?(/.*)?(\\?.*)?(#.*)?\$~i", $string); //! restrict path, query and fragment characters
|
return preg_match("~^(https?)://($domain?\\.)+$domain(:\\d+)?(/.*)?(\\?.*)?(#.*)?\$~i", $string); //! restrict path, query and fragment characters
|
||||||
@@ -894,23 +865,19 @@ function slow_query(string $query): array {
|
|||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Generate BREACH resistant CSRF token
|
/** Generate BREACH resistant CSRF token */
|
||||||
*/
|
|
||||||
function get_token(): string {
|
function get_token(): string {
|
||||||
$rand = rand(1, 1e6);
|
$rand = rand(1, 1e6);
|
||||||
return ($rand ^ $_SESSION["token"]) . ":$rand";
|
return ($rand ^ $_SESSION["token"]) . ":$rand";
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Verify if supplied CSRF token is valid
|
/** Verify if supplied CSRF token is valid */
|
||||||
*/
|
|
||||||
function verify_token(): bool {
|
function verify_token(): bool {
|
||||||
list($token, $rand) = explode(":", $_POST["token"]);
|
list($token, $rand) = explode(":", $_POST["token"]);
|
||||||
return ($rand ^ $_SESSION["token"]) == $token;
|
return ($rand ^ $_SESSION["token"]) == $token;
|
||||||
}
|
}
|
||||||
|
|
||||||
// used in compiled version
|
// used in compiled version
|
||||||
/**
|
|
||||||
*/
|
|
||||||
function lzw_decompress(string $binary): string {
|
function lzw_decompress(string $binary): string {
|
||||||
// convert binary string to codes
|
// convert binary string to codes
|
||||||
$dictionary_count = 256;
|
$dictionary_count = 256;
|
||||||
|
@@ -1,20 +1,17 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace Adminer;
|
namespace Adminer;
|
||||||
|
|
||||||
/** Return <script> element
|
/** Return <script> element */
|
||||||
*/
|
|
||||||
function script(string $source, string $trailing = "\n"): string {
|
function script(string $source, string $trailing = "\n"): string {
|
||||||
return "<script" . nonce() . ">$source</script>$trailing";
|
return "<script" . nonce() . ">$source</script>$trailing";
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Return <script src> element
|
/** Return <script src> element */
|
||||||
*/
|
|
||||||
function script_src(string $url): string {
|
function script_src(string $url): string {
|
||||||
return "<script src='" . h($url) . "'" . nonce() . "></script>\n";
|
return "<script src='" . h($url) . "'" . nonce() . "></script>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get a nonce="" attribute with CSP nonce
|
/** Get a nonce="" attribute with CSP nonce */
|
||||||
*/
|
|
||||||
function nonce(): string {
|
function nonce(): string {
|
||||||
return ' nonce="' . get_nonce() . '"';
|
return ' nonce="' . get_nonce() . '"';
|
||||||
}
|
}
|
||||||
@@ -36,20 +33,17 @@ function input_token(string $special = ""): string {
|
|||||||
return input_hidden("token", ($special ?: $token));
|
return input_hidden("token", ($special ?: $token));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get a target="_blank" attribute
|
/** Get a target="_blank" attribute */
|
||||||
*/
|
|
||||||
function target_blank(): string {
|
function target_blank(): string {
|
||||||
return ' target="_blank" rel="noreferrer noopener"';
|
return ' target="_blank" rel="noreferrer noopener"';
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Escape for HTML
|
/** Escape for HTML */
|
||||||
*/
|
|
||||||
function h(string $string): string {
|
function h(string $string): string {
|
||||||
return str_replace("\0", "�", htmlspecialchars($string, ENT_QUOTES, 'utf-8'));
|
return str_replace("\0", "�", htmlspecialchars($string, ENT_QUOTES, 'utf-8'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Convert \n to <br>
|
/** Convert \n to <br> */
|
||||||
*/
|
|
||||||
function nl_br(string $string): string {
|
function nl_br(string $string): string {
|
||||||
return str_replace("\n", "<br>", $string); // nl2br() uses XHTML before PHP 5.3
|
return str_replace("\n", "<br>", $string); // nl2br() uses XHTML before PHP 5.3
|
||||||
}
|
}
|
||||||
@@ -116,14 +110,12 @@ function html_radios(string $name, array $options, string $value = ""): string {
|
|||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get onclick confirmation
|
/** Get onclick confirmation */
|
||||||
*/
|
|
||||||
function confirm(string $message = "", string $selector = "qsl('input')"): string {
|
function confirm(string $message = "", string $selector = "qsl('input')"): string {
|
||||||
return script("$selector.onclick = () => confirm('" . ($message ? js_escape($message) : lang('Are you sure?')) . "');", "");
|
return script("$selector.onclick = () => confirm('" . ($message ? js_escape($message) : lang('Are you sure?')) . "');", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Print header for hidden fieldset (close by </div></fieldset>)
|
/** Print header for hidden fieldset (close by </div></fieldset>) */
|
||||||
*/
|
|
||||||
function print_fieldset(string $id, string $legend, bool $visible = false): void {
|
function print_fieldset(string $id, string $legend, bool $visible = false): void {
|
||||||
echo "<fieldset><legend>";
|
echo "<fieldset><legend>";
|
||||||
echo "<a href='#fieldset-$id'>$legend</a>";
|
echo "<a href='#fieldset-$id'>$legend</a>";
|
||||||
@@ -132,20 +124,17 @@ function print_fieldset(string $id, string $legend, bool $visible = false): void
|
|||||||
echo "<div id='fieldset-$id'" . ($visible ? "" : " class='hidden'") . ">\n";
|
echo "<div id='fieldset-$id'" . ($visible ? "" : " class='hidden'") . ">\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Return class='active' if $bold is true
|
/** Return class='active' if $bold is true */
|
||||||
*/
|
|
||||||
function bold(bool $bold, string $class = ""): string {
|
function bold(bool $bold, string $class = ""): string {
|
||||||
return ($bold ? " class='active $class'" : ($class ? " class='$class'" : ""));
|
return ($bold ? " class='active $class'" : ($class ? " class='$class'" : ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Escape string for JavaScript apostrophes
|
/** Escape string for JavaScript apostrophes */
|
||||||
*/
|
|
||||||
function js_escape(string $string): string {
|
function js_escape(string $string): string {
|
||||||
return addcslashes($string, "\r\n'\\/"); // slash for <script>
|
return addcslashes($string, "\r\n'\\/"); // slash for <script>
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Generate page number for pagination
|
/** Generate page number for pagination */
|
||||||
*/
|
|
||||||
function pagination(int $page, int $current): string {
|
function pagination(int $page, int $current): string {
|
||||||
return " " . ($page == $current
|
return " " . ($page == $current
|
||||||
? $page + 1
|
? $page + 1
|
||||||
@@ -172,8 +161,7 @@ function hidden_fields(array $process, array $ignore = array(), string $prefix =
|
|||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Print hidden fields for GET forms
|
/** Print hidden fields for GET forms */
|
||||||
*/
|
|
||||||
function hidden_fields_get(): void {
|
function hidden_fields_get(): void {
|
||||||
echo (sid() ? input_hidden(session_name(), session_id()) : '');
|
echo (sid() ? input_hidden(session_name(), session_id()) : '');
|
||||||
echo (SERVER !== null ? input_hidden(DRIVER, SERVER) : "");
|
echo (SERVER !== null ? input_hidden(DRIVER, SERVER) : "");
|
||||||
@@ -478,8 +466,7 @@ function edit_form(string $table, array $fields, $row, bool $update): void {
|
|||||||
echo "</form>\n";
|
echo "</form>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get button with icon
|
/** Get button with icon */
|
||||||
*/
|
|
||||||
function icon(string $icon, string $name, string $html, string $title): string {
|
function icon(string $icon, string $name, string $html, string $title): string {
|
||||||
return "<button type='submit' name='$name' title='" . h($title) . "' class='icon icon-$icon'><span>$html</span></button>";
|
return "<button type='submit' name='$name' title='" . h($title) . "' class='icon icon-$icon'><span>$html</span></button>";
|
||||||
}
|
}
|
||||||
|
@@ -51,8 +51,7 @@ $langs = array(
|
|||||||
'zh-tw' => '繁體中文', // http://tzangms.com
|
'zh-tw' => '繁體中文', // http://tzangms.com
|
||||||
);
|
);
|
||||||
|
|
||||||
/** Get current language
|
/** Get current language */
|
||||||
*/
|
|
||||||
function get_lang(): string {
|
function get_lang(): string {
|
||||||
global $LANG;
|
global $LANG;
|
||||||
return $LANG;
|
return $LANG;
|
||||||
|
@@ -9,8 +9,6 @@ class TmpFile {
|
|||||||
$this->handler = tmpfile();
|
$this->handler = tmpfile();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
function write(string $contents): void {
|
function write(string $contents): void {
|
||||||
$this->size += strlen($contents);
|
$this->size += strlen($contents);
|
||||||
fwrite($this->handler, $contents);
|
fwrite($this->handler, $contents);
|
||||||
|
@@ -6,8 +6,6 @@ namespace Adminer;
|
|||||||
* @link http://www.coolcode.cn/?action=show&id=128
|
* @link http://www.coolcode.cn/?action=show&id=128
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
function int32(int $n): int {
|
function int32(int $n): int {
|
||||||
while ($n >= 2147483648) {
|
while ($n >= 2147483648) {
|
||||||
$n -= 4294967296;
|
$n -= 4294967296;
|
||||||
@@ -43,8 +41,6 @@ function str2long(string $s, bool $w): array {
|
|||||||
return $v;
|
return $v;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
function xxtea_mx(int $z, int $y, int $sum, int $k): int {
|
function xxtea_mx(int $z, int $y, int $sum, int $k): int {
|
||||||
return int32((($z >> 5 & 0x7FFFFFF) ^ $y << 2) + (($y >> 3 & 0x1FFFFFFF) ^ $z << 4)) ^ int32(($sum ^ $y) + ($k ^ $z));
|
return int32((($z >> 5 & 0x7FFFFFF) ^ $y << 2) + (($y >> 3 & 0x1FFFFFFF) ^ $z << 4)) ^ int32(($sum ^ $y) + ($k ^ $z));
|
||||||
}
|
}
|
||||||
|
@@ -1,8 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace Adminer;
|
namespace Adminer;
|
||||||
|
|
||||||
/** Encode e-mail header in UTF-8
|
/** Encode e-mail header in UTF-8 */
|
||||||
*/
|
|
||||||
function email_header(string $header): string {
|
function email_header(string $header): string {
|
||||||
// iconv_mime_encode requires iconv, imap_8bit requires IMAP extension
|
// iconv_mime_encode requires iconv, imap_8bit requires IMAP extension
|
||||||
return "=?UTF-8?B?" . base64_encode($header) . "?="; //! split long lines
|
return "=?UTF-8?B?" . base64_encode($header) . "?="; //! split long lines
|
||||||
|
@@ -65,8 +65,6 @@ if (isset($_GET["elastic"])) {
|
|||||||
return $this->rootQuery($path, $content, $method);
|
return $this->rootQuery($path, $content, $method);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
function connect(string $server, string $username, string $password): bool {
|
function connect(string $server, string $username, string $password): bool {
|
||||||
preg_match('~^(https?://)?(.*)~', $server, $match);
|
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]";
|
||||||
|
@@ -18,8 +18,7 @@ CREATE TABLE login (
|
|||||||
class AdminerLoginTable {
|
class AdminerLoginTable {
|
||||||
protected $database;
|
protected $database;
|
||||||
|
|
||||||
/** Set database of login table
|
/** Set database of login table */
|
||||||
*/
|
|
||||||
function __construct(string $database) {
|
function __construct(string $database) {
|
||||||
$this->database = $database;
|
$this->database = $database;
|
||||||
}
|
}
|
||||||
|
@@ -10,8 +10,6 @@
|
|||||||
class AdminerTinymce {
|
class AdminerTinymce {
|
||||||
protected $path;
|
protected $path;
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
function __construct(string $path = "tiny_mce/tiny_mce.js") {
|
function __construct(string $path = "tiny_mce/tiny_mce.js") {
|
||||||
$this->path = $path;
|
$this->path = $path;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user