mirror of
https://github.com/vrana/adminer.git
synced 2026-03-25 14:00:05 +01:00
Compare commits
71 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
39b339b1b5 | ||
|
|
de4104f70d | ||
|
|
aeee1c1991 | ||
|
|
21d3a31503 | ||
|
|
e4ac9d611e | ||
|
|
bdc28bc959 | ||
|
|
83301e37da | ||
|
|
1b2354cdae | ||
|
|
a5faea641a | ||
|
|
9f4a51819e | ||
|
|
04473a21c8 | ||
|
|
9d1451e659 | ||
|
|
1879da5ad8 | ||
|
|
e471d8b0cf | ||
|
|
5b9f0186a8 | ||
|
|
da1ffdd34e | ||
|
|
56c18bcca0 | ||
|
|
948d57bb63 | ||
|
|
1a6735cac7 | ||
|
|
8e865cd650 | ||
|
|
864d831463 | ||
|
|
f61b085422 | ||
|
|
0ddb097cb6 | ||
|
|
2674250862 | ||
|
|
6f6f576c41 | ||
|
|
ecd9c74c99 | ||
|
|
2ea1f8a88c | ||
|
|
691edde5fc | ||
|
|
554e43aae4 | ||
|
|
503d83599c | ||
|
|
a7a704c818 | ||
|
|
d356091c2f | ||
|
|
a5ec07a77d | ||
|
|
68e8b5bf69 | ||
|
|
9c5215cf77 | ||
|
|
e6fe48516e | ||
|
|
58ff31a15d | ||
|
|
ca7c4d90e1 | ||
|
|
605ed2dcab | ||
|
|
76a8dbfb98 | ||
|
|
cca4d26784 | ||
|
|
80f9278d34 | ||
|
|
c1838743ed | ||
|
|
eb614963f8 | ||
|
|
1109ca6389 | ||
|
|
3856d0563e | ||
|
|
a49fcf4799 | ||
|
|
53d7e31bf6 | ||
|
|
15f4183fa6 | ||
|
|
e6be47941b | ||
|
|
240c8fc5e7 | ||
|
|
57c5370c67 | ||
|
|
489f78c21c | ||
|
|
6c8de72707 | ||
|
|
4d0e79234c | ||
|
|
c7ede7331e | ||
|
|
c5f3707bb9 | ||
|
|
1c008b7d71 | ||
|
|
c2be05f0e9 | ||
|
|
eaad45a781 | ||
|
|
9a5b8f1f92 | ||
|
|
1b43a6f034 | ||
|
|
fdc2326376 | ||
|
|
08f93d6d09 | ||
|
|
4fbe8ebf5a | ||
|
|
86285dcf34 | ||
|
|
26c4057946 | ||
|
|
d15d0b2ef3 | ||
|
|
bd1dffe086 | ||
|
|
4918ba407f | ||
|
|
46638ebd9a |
4
.github/workflows/ci.yml
vendored
4
.github/workflows/ci.yml
vendored
@@ -3,6 +3,7 @@ name: CI
|
||||
on:
|
||||
pull_request:
|
||||
branches: [ master ]
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build-test:
|
||||
@@ -13,5 +14,6 @@ jobs:
|
||||
- uses: php-actions/composer@v6
|
||||
- uses: php-actions/phpcs@v1
|
||||
with:
|
||||
path: adminer/
|
||||
path: .
|
||||
standard: phpcs.xml
|
||||
- uses: php-actions/phpstan@v3
|
||||
|
||||
41
CHANGELOG.md
41
CHANGELOG.md
@@ -1,3 +1,37 @@
|
||||
## Adminer 5.4.2 (released 2026-02-08)
|
||||
- Avoid denial-of-service via version check (GHSA-q4f2-39gr-45jh, regression from 4.6.2)
|
||||
- Pretty print JSON in edit
|
||||
- Support multiline generated values in alter table
|
||||
- Link //domain.tld values
|
||||
- Improve print of nested tables
|
||||
- Hide sort links on unsortable columns
|
||||
- Display uneditable fields in edit form
|
||||
- Shorten all but numeric and date types in select
|
||||
- Fix escaping spaces in cookie value (bug #1208)
|
||||
- Don't quote comma in TSV export (bug #1238)
|
||||
- MariaDB: Don't display checks with the same name from another table (bug #1135)
|
||||
- PostgreSQL: Offer foreign keys in create table
|
||||
- PostgreSQL: Add missing parentheses to CHECK export
|
||||
- PostgreSQL: Allow creating NOT DEFERRABLE foreign keys
|
||||
- PostgreSQL: Remove duplicate DEFERRABLE in foreign key export
|
||||
- PostgreSQL: Add schema to sequence and view export
|
||||
- PostgreSQL: Fix definition of complex generated columns
|
||||
- PostgreSQL: Mark unique partial indexes as unique (bug #1172)
|
||||
- PostgreSQL: Fix namespace in inheritance links (bug #1221)
|
||||
- non-PostgreSQL: Display NOT NULL checks (bug #1237)
|
||||
- ClickHouse: Fix offset (bug #1188)
|
||||
- ClickHouse: Fix list of tables (bug #1176)
|
||||
- Plugins: Methods showVariables() and showStatus() (bug #1157)
|
||||
- Plugins: Allow to be in any namespace
|
||||
- New plugin: IGDB driver
|
||||
|
||||
## Adminer 5.4.1 (released 2025-09-26)
|
||||
- SQL command: Unlink NULL primary keys
|
||||
- Do not quote 0 in CSV export
|
||||
- Warn about exceeded upload_max_filesize in imports
|
||||
- Prolong queries saved from SQL command to URL (bug #1154)
|
||||
- MySQL: Fix displaying routine definition (bug #1156, regression from 5.4.0)
|
||||
|
||||
## Adminer 5.4.0 (released 2025-09-08)
|
||||
- Allow specifying operator in search anywhere
|
||||
- Do not order descending in GROUP BY select
|
||||
@@ -25,7 +59,7 @@
|
||||
- PostgreSQL: Fix calling functions returing table
|
||||
- PostgreSQL: Don't treat user types containing 'file' as blobs (bug #1118)
|
||||
- PostgreSQL: Export DROP and CREATE DATABASE (bug #1140)
|
||||
- PostgreSQL 11-: Avoid duplicate oid in table status (bug #1089)
|
||||
- PostgreSQL 11-: Avoid duplicate oid in table status (bug #1089, regression from 5.3.0)
|
||||
- Elasticsearch: Support dropping aliases
|
||||
- Plugins: Methods afterConnect(), processList() and killProcess()
|
||||
- New plugin: Display row numbers in select (bug #1106)
|
||||
@@ -149,8 +183,8 @@
|
||||
- MariaDB: Fix creating and altering generated columns (bug #897)
|
||||
- PostgreSQL: Fix "where" and "order" privileges (bug #902, regression from 5.0.2)
|
||||
- SQLite: Fix creating table in compiled version (bug #901, regression from 5.0.0)
|
||||
- Elastic: Do not pass null values on insert (PR #892)
|
||||
- Elastic: Fix displaying sparse rows (PR #893)
|
||||
- Elasticsearch: Do not pass null values on insert (PR #892)
|
||||
- Elasticsearch: Fix displaying sparse rows (PR #893)
|
||||
- Plugins: Add method dumpFooter()
|
||||
|
||||
## Adminer 5.0.2 (released 2025-03-10)
|
||||
@@ -231,6 +265,7 @@
|
||||
- SQLite: Fix expressions in default values (bug SF-860)
|
||||
- MS SQL: Foreign keys in non-default schema (bug SF-833)
|
||||
- Oracle: Include tables granted by other user
|
||||
- Elasticsearch: Move to plugin
|
||||
- MongoDB: Execute commands against the selected DB
|
||||
|
||||
## Adminer 4.15.0
|
||||
|
||||
@@ -36,7 +36,7 @@ if (!$error && $_POST) {
|
||||
}
|
||||
}
|
||||
|
||||
$query = (isset($_GET["callf"]) ? "SELECT " : "CALL ") . ($routine["returns"]["type"] == "record" ? "* FROM " : "") . table($PROCEDURE) . "(" . implode(", ", $call) . ")";
|
||||
$query = (isset($_GET["callf"]) ? "SELECT " : "CALL ") . (idx($routine["returns"], "type") == "record" ? "* FROM " : "") . table($PROCEDURE) . "(" . implode(", ", $call) . ")";
|
||||
$start = microtime(true);
|
||||
$result = connection()->multi_query($query);
|
||||
$affected = connection()->affected_rows; // getting warnings overwrites this
|
||||
|
||||
@@ -80,14 +80,27 @@ if (adminer()->homepage()) {
|
||||
echo '<thead><tr class="wrap">';
|
||||
echo '<td><input id="check-all" type="checkbox" class="jsonly">' . script("qs('#check-all').onclick = partial(formCheck, /^(tables|views)\[/);", "");
|
||||
echo '<th>' . lang('Table');
|
||||
echo '<td>' . lang('Engine') . doc_link(array('sql' => 'storage-engines.html'));
|
||||
echo '<td>' . lang('Collation') . doc_link(array('sql' => 'charset-charsets.html', 'mariadb' => 'supported-character-sets-and-collations/'));
|
||||
echo '<td>' . lang('Data Length') . doc_link(array('sql' => 'show-table-status.html', 'pgsql' => 'functions-admin.html#FUNCTIONS-ADMIN-DBOBJECT', 'oracle' => 'REFRN20286'));
|
||||
echo '<td>' . lang('Index Length') . doc_link(array('sql' => 'show-table-status.html', 'pgsql' => 'functions-admin.html#FUNCTIONS-ADMIN-DBOBJECT'));
|
||||
echo '<td>' . lang('Data Free') . doc_link(array('sql' => 'show-table-status.html'));
|
||||
echo '<td>' . lang('Auto Increment') . doc_link(array('sql' => 'example-auto-increment.html', 'mariadb' => 'auto_increment/'));
|
||||
echo '<td>' . lang('Rows') . doc_link(array('sql' => 'show-table-status.html', 'pgsql' => 'catalog-pg-class.html#CATALOG-PG-CLASS', 'oracle' => 'REFRN20286'));
|
||||
echo (support("comment") ? '<td>' . lang('Comment') . doc_link(array('sql' => 'show-table-status.html', 'pgsql' => 'functions-info.html#FUNCTIONS-INFO-COMMENT-TABLE')) : '');
|
||||
$columns = array("Engine" => array(lang('Engine') . doc_link(array('sql' => 'storage-engines.html'))));
|
||||
if (collations()) {
|
||||
$columns["Collation"] = array(lang('Collation') . doc_link(array('sql' => 'charset-charsets.html', 'mariadb' => 'supported-character-sets-and-collations/')));
|
||||
}
|
||||
if (function_exists('Adminer\alter_table')) {
|
||||
$columns["Data_length"] = array(lang('Data Length') . doc_link(array('sql' => 'show-table-status.html', 'pgsql' => 'functions-admin.html#FUNCTIONS-ADMIN-DBOBJECT', 'oracle' => 'REFRN20286')), "create", lang('Alter table'));
|
||||
}
|
||||
if (support('indexes')) {
|
||||
$columns["Index_length"] = array(lang('Index Length') . doc_link(array('sql' => 'show-table-status.html', 'pgsql' => 'functions-admin.html#FUNCTIONS-ADMIN-DBOBJECT')), "indexes", lang('Alter indexes'));
|
||||
}
|
||||
$columns["Data_free"] = array(lang('Data Free') . doc_link(array('sql' => 'show-table-status.html')), "edit", lang('New item'));
|
||||
if (function_exists('Adminer\alter_table')) {
|
||||
$columns["Auto_increment"] = array(lang('Auto Increment') . doc_link(array('sql' => 'example-auto-increment.html', 'mariadb' => 'auto_increment/')), "auto_increment=1&create", lang('Alter table'));
|
||||
}
|
||||
$columns["Rows"] = array(lang('Rows') . doc_link(array('sql' => 'show-table-status.html', 'pgsql' => 'catalog-pg-class.html#CATALOG-PG-CLASS', 'oracle' => 'REFRN20286')), "select", lang('Select data'));
|
||||
if (support("comment")) {
|
||||
$columns["Comment"] = array(lang('Comment') . doc_link(array('sql' => 'show-table-status.html', 'pgsql' => 'functions-info.html#FUNCTIONS-INFO-COMMENT-TABLE')));
|
||||
}
|
||||
foreach ($columns as $column) {
|
||||
echo "<td>$column[0]";
|
||||
}
|
||||
echo "</thead>\n";
|
||||
|
||||
$tables = 0;
|
||||
@@ -101,26 +114,15 @@ if (adminer()->homepage()) {
|
||||
echo '<td colspan="6">' . (support("view") ? "<a href='" . h(ME) . "view=" . urlencode($name) . "' title='" . lang('Alter view') . "'>$title</a>" : $title);
|
||||
echo '<td align="right"><a href="' . h(ME) . "select=" . urlencode($name) . '" title="' . lang('Select data') . '">?</a>';
|
||||
} else {
|
||||
foreach (
|
||||
array(
|
||||
"Engine" => array(),
|
||||
"Collation" => array(),
|
||||
"Data_length" => array("create", lang('Alter table')),
|
||||
"Index_length" => array("indexes", lang('Alter indexes')),
|
||||
"Data_free" => array("edit", lang('New item')),
|
||||
"Auto_increment" => array("auto_increment=1&create", lang('Alter table')),
|
||||
"Rows" => array("select", lang('Select data')),
|
||||
) as $key => $link
|
||||
) {
|
||||
foreach ($columns as $key => $column) {
|
||||
$id = " id='$key-" . h($name) . "'";
|
||||
echo ($link ? "<td align='right'>" . (support("table") || $key == "Rows" || (support("indexes") && $key != "Data_length")
|
||||
? "<a href='" . h(ME . "$link[0]=") . urlencode($name) . "'$id title='$link[1]'>?</a>"
|
||||
: "<span$id>?</span>"
|
||||
) : "<td id='$key-" . h($name) . "'>");
|
||||
echo ($column[1]
|
||||
? "<td align='right'><a href='" . h(ME . "$column[1]=") . urlencode($name) . "'$id title='$column[2]'>?</a>"
|
||||
: "<td id='$key-" . h($name) . "'>"
|
||||
);
|
||||
}
|
||||
$tables++;
|
||||
}
|
||||
echo (support("comment") ? "<td id='Comment-" . h($name) . "'>" : "");
|
||||
echo "\n";
|
||||
}
|
||||
|
||||
@@ -128,7 +130,7 @@ if (adminer()->homepage()) {
|
||||
echo "<td>" . h(JUSH == "sql" ? get_val("SELECT @@default_storage_engine") : "");
|
||||
echo "<td>" . h(db_collation(DB, collations()));
|
||||
foreach (array("Data_length", "Index_length", "Data_free") as $key) {
|
||||
echo "<td align='right' id='sum-$key'>";
|
||||
echo ($columns[$key] ? "<td align='right' id='sum-$key'>" : "");
|
||||
}
|
||||
echo "\n";
|
||||
|
||||
@@ -136,21 +138,20 @@ if (adminer()->homepage()) {
|
||||
echo script("ajaxSetHtml('" . js_escape(ME) . "script=db');");
|
||||
echo "</div>\n";
|
||||
if (!information_schema(DB)) {
|
||||
echo "<div class='footer'><div>\n";
|
||||
$vacuum = "<input type='submit' value='" . lang('Vacuum') . "'> " . on_help("'VACUUM'");
|
||||
$optimize = "<input type='submit' name='optimize' value='" . lang('Optimize') . "'> " . on_help(JUSH == "sql" ? "'OPTIMIZE TABLE'" : "'VACUUM OPTIMIZE'");
|
||||
echo "<fieldset><legend>" . lang('Selected') . " <span id='selected'></span></legend><div>"
|
||||
. (JUSH == "sqlite" ? $vacuum . "<input type='submit' name='check' value='" . lang('Check') . "'> " . on_help("'PRAGMA integrity_check'")
|
||||
$print = (JUSH == "sqlite" ? $vacuum . "<input type='submit' name='check' value='" . lang('Check') . "'> " . on_help("'PRAGMA integrity_check'")
|
||||
: (JUSH == "pgsql" ? $vacuum . $optimize
|
||||
: (JUSH == "sql" ? "<input type='submit' value='" . lang('Analyze') . "'> " . on_help("'ANALYZE TABLE'")
|
||||
. $optimize
|
||||
. "<input type='submit' name='check' value='" . lang('Check') . "'> " . on_help("'CHECK TABLE'")
|
||||
. "<input type='submit' name='repair' value='" . lang('Repair') . "'> " . on_help("'REPAIR TABLE'")
|
||||
: "")))
|
||||
. "<input type='submit' name='truncate' value='" . lang('Truncate') . "'> " . on_help(JUSH == "sqlite" ? "'DELETE'" : "'TRUNCATE" . (JUSH == "pgsql" ? "'" : " TABLE'")) . confirm()
|
||||
. "<input type='submit' name='drop' value='" . lang('Drop') . "'>" . on_help("'DROP TABLE'") . confirm() . "\n";
|
||||
. (function_exists('Adminer\truncate_tables') ? "<input type='submit' name='truncate' value='" . lang('Truncate') . "'> " . on_help(JUSH == "sqlite" ? "'DELETE'" : "'TRUNCATE" . (JUSH == "pgsql" ? "'" : " TABLE'")) . confirm() : "")
|
||||
. (function_exists('Adminer\drop_tables') ? "<input type='submit' name='drop' value='" . lang('Drop') . "'>" . on_help("'DROP TABLE'") . confirm() : "");
|
||||
echo ($print ? "<div class='footer'><div>\n<fieldset><legend>" . lang('Selected') . " <span id='selected'></span></legend><div>$print\n</div></fieldset>\n" : "");
|
||||
|
||||
$databases = (support("scheme") ? adminer()->schemas() : adminer()->databases());
|
||||
echo "</div></fieldset>\n";
|
||||
$script = "";
|
||||
if (count($databases) != 1 && JUSH != "sqlite") {
|
||||
echo "<fieldset><legend>" . lang('Move to other database') . " <span id='selected3'></span></legend><div>";
|
||||
@@ -173,7 +174,7 @@ if (adminer()->homepage()) {
|
||||
echo script("tableCheck();");
|
||||
}
|
||||
|
||||
echo "<p class='links'><a href='" . h(ME) . "create='>" . lang('Create table') . "</a>\n";
|
||||
echo (function_exists('Adminer\alter_table') ? "<p class='links'><a href='" . h(ME) . "create='>" . lang('Create table') . "</a>\n" : '');
|
||||
echo (support("view") ? "<a href='" . h(ME) . "view='>" . lang('Create view') . "</a>\n" : "");
|
||||
|
||||
if (support("routine")) {
|
||||
|
||||
@@ -893,36 +893,27 @@ if (!defined('Adminer\DRIVER')) {
|
||||
* @return Routine
|
||||
*/
|
||||
function routine(string $name, string $type): array {
|
||||
$aliases = array("bool", "boolean", "integer", "double precision", "real", "dec", "numeric", "fixed", "national char", "national varchar");
|
||||
$space = "(?:\\s|/\\*[\s\S]*?\\*/|(?:#|-- )[^\n]*\n?|--\r?\n)";
|
||||
$enum = driver()->enumLength;
|
||||
$type_pattern = "((" . implode("|", array_merge(array_keys(driver()->types()), $aliases)) . ")\\b(?:\\s*\\(((?:[^'\")]|$enum)++)\\))?"
|
||||
. "\\s*(zerofill\\s*)?(unsigned(?:\\s+zerofill)?)?)(?:\\s*(?:CHARSET|CHARACTER\\s+SET)\\s*['\"]?([^'\"\\s,]+)['\"]?)?(?:\\s*COLLATE\\s*['\"]?([^'\"\\s,]+)['\"]?)?"; //! store COLLATE
|
||||
$pattern = "$space*(" . ($type == "FUNCTION" ? "" : driver()->inout) . ")?\\s*(?:`((?:[^`]|``)*)`\\s*|\\b(\\S+)\\s+)$type_pattern";
|
||||
$create = get_val("SHOW CREATE $type " . idf_escape($name), 2);
|
||||
preg_match("~\\(((?:$pattern\\s*,?)*)\\)\\s*" . ($type == "FUNCTION" ? "RETURNS\\s+$type_pattern\\s+" : "") . "(.*)~is", $create, $match);
|
||||
$fields = array();
|
||||
preg_match_all("~$pattern\\s*,?~is", $match[1], $matches, PREG_SET_ORDER);
|
||||
foreach ($matches as $param) {
|
||||
$fields[] = array(
|
||||
"field" => str_replace("``", "`", $param[2]) . $param[3],
|
||||
"type" => strtolower($param[5]),
|
||||
"length" => preg_replace_callback("~$enum~s", 'Adminer\normalize_enum', $param[6]),
|
||||
"unsigned" => strtolower(preg_replace('~\s+~', ' ', trim("$param[8] $param[7]"))),
|
||||
"null" => true,
|
||||
"full_type" => $param[4],
|
||||
"inout" => strtoupper($param[1]),
|
||||
"collation" => strtolower($param[9]),
|
||||
);
|
||||
$fields = get_rows("SELECT
|
||||
PARAMETER_NAME field,
|
||||
DATA_TYPE type,
|
||||
CHARACTER_MAXIMUM_LENGTH length,
|
||||
REGEXP_REPLACE(DTD_IDENTIFIER, '^[^ ]+ ', '') `unsigned`,
|
||||
1 `null`,
|
||||
DTD_IDENTIFIER full_type,
|
||||
PARAMETER_MODE `inout`,
|
||||
CHARACTER_SET_NAME collation
|
||||
FROM information_schema.PARAMETERS
|
||||
WHERE SPECIFIC_SCHEMA = DATABASE() AND ROUTINE_TYPE = '$type' AND SPECIFIC_NAME = " . q($name) . "
|
||||
ORDER BY ORDINAL_POSITION");
|
||||
$return = connection()->query("SELECT ROUTINE_COMMENT comment, ROUTINE_DEFINITION definition, 'SQL' language
|
||||
FROM information_schema.ROUTINES
|
||||
WHERE ROUTINE_SCHEMA = DATABASE() AND ROUTINE_TYPE = '$type' AND ROUTINE_NAME = " . q($name))->fetch_assoc();
|
||||
if ($fields && $fields[0]['field'] == '') {
|
||||
$return['returns'] = array_shift($fields);
|
||||
}
|
||||
return array(
|
||||
"fields" => $fields,
|
||||
"comment" => get_val("SELECT ROUTINE_COMMENT FROM information_schema.ROUTINES WHERE ROUTINE_SCHEMA = DATABASE() AND ROUTINE_NAME = " . q($name)),
|
||||
) + ($type != "FUNCTION" ? array("definition" => $match[11]) : array(
|
||||
"returns" => array("type" => $match[12], "length" => $match[13], "unsigned" => $match[15], "collation" => $match[16]),
|
||||
"definition" => $match[17],
|
||||
"language" => "SQL", // available in information_schema.ROUTINES.BODY_STYLE
|
||||
));
|
||||
$return['fields'] = $fields;
|
||||
/** @phpstan-var Routine */
|
||||
return $return;
|
||||
}
|
||||
|
||||
/** Get list of routines
|
||||
|
||||
@@ -334,11 +334,11 @@ if (isset($_GET["pgsql"])) {
|
||||
}
|
||||
|
||||
function inheritsFrom(string $table): array {
|
||||
return get_vals("SELECT relname FROM pg_class JOIN pg_inherits ON inhparent = oid WHERE inhrelid = " . $this->tableOid($table) . " ORDER BY 1");
|
||||
return get_rows("SELECT relname AS table, nspname AS ns FROM pg_class JOIN pg_inherits ON inhparent = oid JOIN pg_namespace ON relnamespace = pg_namespace.oid WHERE inhrelid = " . $this->tableOid($table) . " ORDER BY 2, 1");
|
||||
}
|
||||
|
||||
function inheritedTables(string $table): array {
|
||||
return get_vals("SELECT relname FROM pg_inherits JOIN pg_class ON inhrelid = oid WHERE inhparent = " . $this->tableOid($table) . " ORDER BY 1");
|
||||
return get_rows("SELECT relname AS table, nspname AS ns FROM pg_inherits JOIN pg_class ON inhrelid = oid JOIN pg_namespace ON relnamespace = pg_namespace.oid WHERE inhparent = " . $this->tableOid($table) . " ORDER BY 2, 1");
|
||||
}
|
||||
|
||||
function partitionsInfo(string $table): array {
|
||||
@@ -487,17 +487,19 @@ AND relnamespace = " . driver()->nsOid . "
|
||||
format_type(a.atttypid, a.atttypmod) AS full_type,
|
||||
pg_get_expr(d.adbin, d.adrelid) AS default,
|
||||
a.attnotnull::int,
|
||||
i.indrelid AS primary,
|
||||
col_description(a.attrelid, a.attnum) AS comment" . (min_version(10) ? ",
|
||||
a.attidentity" . (min_version(12) ? ",
|
||||
a.attgenerated" : "") : "") . "
|
||||
FROM pg_attribute a
|
||||
LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid AND a.attnum = d.adnum
|
||||
LEFT JOIN pg_index i ON a.attrelid = i.indrelid AND a.attnum = ANY(i.indkey) AND i.indisprimary
|
||||
WHERE a.attrelid = " . driver()->tableOid($table) . "
|
||||
AND NOT a.attisdropped
|
||||
AND a.attnum > 0
|
||||
ORDER BY a.attnum") as $row
|
||||
) {
|
||||
//! collation, primary
|
||||
//! collation
|
||||
preg_match('~([^([]+)(\((.*)\))?([a-z ]+)?((\[[0-9]*])*)$~', $row["full_type"], $match);
|
||||
list(, $type, $length, $row["length"], $addon, $array) = $match;
|
||||
$row["length"] .= $array;
|
||||
@@ -517,7 +519,7 @@ ORDER BY a.attnum") as $row
|
||||
$row["auto_increment"] = $row['attidentity'] || preg_match('~^nextval\(~i', $row["default"])
|
||||
|| preg_match('~^unique_rowid\(~', $row["default"]); // CockroachDB
|
||||
$row["privileges"] = array("insert" => 1, "select" => 1, "update" => 1, "where" => 1, "order" => 1);
|
||||
if (preg_match('~(.+)::[^,)]+(.*)~', $row["default"], $match)) {
|
||||
if (!$row['generated'] && preg_match('~(.+)::[^,)]+(.*)~', $row["default"], $match)) {
|
||||
$row["default"] = ($match[1] == "NULL" ? null : idf_unescape($match[1]) . $match[2]);
|
||||
}
|
||||
$return[$row["field"]] = $row;
|
||||
@@ -539,7 +541,7 @@ WHERE indrelid = $table_oid
|
||||
ORDER BY indisprimary DESC, indisunique DESC", $connection2) as $row
|
||||
) {
|
||||
$relname = $row["relname"];
|
||||
$return[$relname]["type"] = ($row["partial"] ? "INDEX" : ($row["indisprimary"] ? "PRIMARY" : ($row["indisunique"] ? "UNIQUE" : "INDEX")));
|
||||
$return[$relname]["type"] = ($row["indisprimary"] ? "PRIMARY" : ($row["indisunique"] ? "UNIQUE" : "INDEX"));
|
||||
$return[$relname]["columns"] = array();
|
||||
$return[$relname]["descs"] = array();
|
||||
$return[$relname]["algorithm"] = $row["amname"];
|
||||
@@ -559,12 +561,13 @@ ORDER BY indisprimary DESC, indisunique DESC", $connection2) as $row
|
||||
function foreign_keys($table) {
|
||||
$return = array();
|
||||
foreach (
|
||||
get_rows("SELECT conname, condeferrable::int AS deferrable, pg_get_constraintdef(oid) AS definition
|
||||
get_rows("SELECT conname, condeferrable::int AS deferrable, condeferred::int AS deferred, pg_get_constraintdef(oid) AS definition
|
||||
FROM pg_constraint
|
||||
WHERE conrelid = " . driver()->tableOid($table) . "
|
||||
AND contype = 'f'::char
|
||||
ORDER BY conkey, conname") as $row
|
||||
) {
|
||||
$row['deferrable'] = ($row['deferrable'] ? '' : 'NOT ') . 'DEFERRABLE' . ($row['deferred'] ? ' INITIALLY DEFERRED' : '');
|
||||
if (preg_match('~FOREIGN KEY\s*\((.+)\)\s*REFERENCES (.+)\((.+)\)(.*)$~iA', $row['definition'], $match)) {
|
||||
$row['source'] = array_map('Adminer\idf_unescape', array_map('trim', explode(',', $match[1])));
|
||||
if (preg_match('~^(("([^"]|"")+"|[^"]+)\.)?"?("([^"]|"")+"|[^"]+)$~', $match[2], $match2)) {
|
||||
@@ -910,7 +913,7 @@ AND typelem = 0"
|
||||
ksort($fkeys);
|
||||
|
||||
foreach ($fkeys as $fkey_name => $fkey) {
|
||||
$return .= "ALTER TABLE ONLY " . idf_escape($status['nspname']) . "." . idf_escape($status['Name']) . " ADD CONSTRAINT " . idf_escape($fkey_name) . " $fkey[definition] " . ($fkey['deferrable'] ? 'DEFERRABLE' : 'NOT DEFERRABLE') . ";\n";
|
||||
$return .= "ALTER TABLE ONLY " . idf_escape($status['nspname']) . "." . idf_escape($status['Name']) . " ADD CONSTRAINT " . idf_escape($fkey_name) . " $fkey[definition];\n";
|
||||
}
|
||||
|
||||
return ($return ? "$return\n" : $return);
|
||||
@@ -921,9 +924,10 @@ AND typelem = 0"
|
||||
$sequences = array();
|
||||
|
||||
$status = table_status1($table);
|
||||
$ns = idf_escape($status['nspname']);
|
||||
if (is_view($status)) {
|
||||
$view = view($table);
|
||||
return rtrim("CREATE VIEW " . idf_escape($table) . " AS $view[select]", ";");
|
||||
return rtrim("CREATE VIEW $ns." . idf_escape($table) . " AS $view[select]", ";");
|
||||
}
|
||||
$fields = fields($table);
|
||||
|
||||
@@ -931,7 +935,7 @@ AND typelem = 0"
|
||||
return false;
|
||||
}
|
||||
|
||||
$return = "CREATE TABLE " . idf_escape($status['nspname']) . "." . idf_escape($status['Name']) . " (\n ";
|
||||
$return = "CREATE TABLE $ns." . idf_escape($status['Name']) . " (\n ";
|
||||
|
||||
// fields' definitions
|
||||
foreach ($fields as $field) {
|
||||
@@ -947,8 +951,8 @@ AND typelem = 0"
|
||||
? "SELECT *, cache_size AS cache_value FROM pg_sequences WHERE schemaname = current_schema() AND sequencename = " . q(idf_unescape($sequence_name))
|
||||
: "SELECT * FROM $sequence_name"
|
||||
), null, "-- "));
|
||||
$sequences[] = ($style == "DROP+CREATE" ? "DROP SEQUENCE IF EXISTS $sequence_name;\n" : "")
|
||||
. "CREATE SEQUENCE $sequence_name INCREMENT $sq[increment_by] MINVALUE $sq[min_value] MAXVALUE $sq[max_value]"
|
||||
$sequences[] = ($style == "DROP+CREATE" ? "DROP SEQUENCE IF EXISTS $ns.$sequence_name;\n" : "")
|
||||
. "CREATE SEQUENCE $ns.$sequence_name INCREMENT $sq[increment_by] MINVALUE $sq[min_value] MAXVALUE $sq[max_value]"
|
||||
. ($auto_increment && $sq['last_value'] ? " START " . ($sq["last_value"] + 1) : "")
|
||||
. " CACHE $sq[cache_value];"
|
||||
;
|
||||
@@ -969,7 +973,7 @@ AND typelem = 0"
|
||||
}
|
||||
|
||||
foreach (driver()->checkConstraints($table) as $conname => $consrc) {
|
||||
$return_parts[] = "CONSTRAINT " . idf_escape($conname) . " CHECK $consrc";
|
||||
$return_parts[] = "CONSTRAINT " . idf_escape($conname) . " CHECK ($consrc)";
|
||||
}
|
||||
$return .= implode(",\n ", $return_parts) . "\n)";
|
||||
|
||||
@@ -984,12 +988,12 @@ AND typelem = 0"
|
||||
|
||||
// comments for table & fields
|
||||
if ($status['Comment']) {
|
||||
$return .= "\n\nCOMMENT ON TABLE " . idf_escape($status['nspname']) . "." . idf_escape($status['Name']) . " IS " . q($status['Comment']) . ";";
|
||||
$return .= "\n\nCOMMENT ON TABLE $ns." . idf_escape($status['Name']) . " IS " . q($status['Comment']) . ";";
|
||||
}
|
||||
|
||||
foreach ($fields as $field_name => $field) {
|
||||
if ($field['comment']) {
|
||||
$return .= "\n\nCOMMENT ON COLUMN " . idf_escape($status['nspname']) . "." . idf_escape($status['Name']) . "." . idf_escape($field_name) . " IS " . q($field['comment']) . ";";
|
||||
$return .= "\n\nCOMMENT ON COLUMN $ns." . idf_escape($status['Name']) . "." . idf_escape($field_name) . " IS " . q($field['comment']) . ";";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ $where = (isset($_GET["select"])
|
||||
);
|
||||
$update = (isset($_GET["select"]) ? $_POST["edit"] : $where);
|
||||
foreach ($fields as $name => $field) {
|
||||
if (!isset($field["privileges"][$update ? "update" : "insert"]) || adminer()->fieldName($field) == "" || $field["generated"]) {
|
||||
if ((!$update && !isset($field["privileges"]["insert"])) || adminer()->fieldName($field) == "") {
|
||||
unset($fields[$name]);
|
||||
}
|
||||
}
|
||||
@@ -65,9 +65,7 @@ if ($_POST && !$error && !isset($_GET["select"])) {
|
||||
}
|
||||
|
||||
$row = null;
|
||||
if ($_POST["save"]) {
|
||||
$row = (array) $_POST["fields"];
|
||||
} elseif ($where) {
|
||||
if ($where) {
|
||||
$select = array();
|
||||
foreach ($fields as $name => $field) {
|
||||
if (isset($field["privileges"]["select"])) {
|
||||
@@ -113,4 +111,8 @@ if (!support("table") && !$fields) { // used by Mongo and SimpleDB
|
||||
}
|
||||
}
|
||||
|
||||
if ($_POST["save"]) {
|
||||
$row = (array) $_POST["fields"] + ($row ? $row : array());
|
||||
}
|
||||
|
||||
edit_form($TABLE, $fields, $row, $update, $error);
|
||||
|
||||
@@ -34,7 +34,8 @@ if ($_GET["file"] == "default.css") {
|
||||
../externals/jush/modules/jush-sqlite.js;
|
||||
../externals/jush/modules/jush-mssql.js;
|
||||
../externals/jush/modules/jush-oracle.js;
|
||||
../externals/jush/modules/jush-simpledb.js', 'minify_js'));
|
||||
../externals/jush/modules/jush-simpledb.js;
|
||||
../externals/jush/modules/jush-igdb.js', 'minify_js'));
|
||||
} elseif ($_GET["file"] == "logo.png") {
|
||||
header("Content-Type: image/png");
|
||||
echo compile_file('../adminer/static/logo.png');
|
||||
|
||||
@@ -103,10 +103,11 @@ foreach ($row["source"] as $key => $val) {
|
||||
<p>
|
||||
<label><?php echo lang('ON DELETE'); ?>: <?php echo html_select("on_delete", array(-1 => "") + explode("|", driver()->onActions), $row["on_delete"]); ?></label>
|
||||
<label><?php echo lang('ON UPDATE'); ?>: <?php echo html_select("on_update", array(-1 => "") + explode("|", driver()->onActions), $row["on_update"]); ?></label>
|
||||
<?php echo (DRIVER === 'pgsql' ? html_select("deferrable", array('NOT DEFERRABLE', 'DEFERRABLE', 'DEFERRABLE INITIALLY DEFERRED'), $row["deferrable"]) . ' ' : ''); ?>
|
||||
<?php echo doc_link(array(
|
||||
'sql' => "innodb-foreign-key-constraints.html",
|
||||
'mariadb' => "foreign-keys/",
|
||||
'pgsql' => "sql-createtable.html#SQL-CREATETABLE-REFERENCES",
|
||||
'pgsql' => "sql-createtable.html#SQL-CREATETABLE-PARMS-REFERENCES",
|
||||
'mssql' => "t-sql/statements/create-table-transact-sql",
|
||||
'oracle' => "SQLRF01111",
|
||||
)); ?>
|
||||
|
||||
@@ -140,7 +140,7 @@ class Adminer {
|
||||
echo "<table class='layout'>\n";
|
||||
// this is matched by compile.php
|
||||
echo adminer()->loginFormField('driver', '<tr><th>' . lang('System') . '<td>', html_select("auth[driver]", SqlDriver::$drivers, DRIVER, "loginDriver(this);"));
|
||||
echo adminer()->loginFormField('server', '<tr><th>' . lang('Server') . '<td>', '<input name="auth[server]" value="' . h(SERVER) . '" title="hostname[:port]" placeholder="localhost" autocapitalize="off">');
|
||||
echo adminer()->loginFormField('server', '<tr><th>' . lang('Server') . '<td>', '<input name="auth[server]" value="' . h(SERVER) . '" title="' . lang('hostname[:port] or :socket') . '" placeholder="localhost" autocapitalize="off">');
|
||||
// this is matched by compile.php
|
||||
echo adminer()->loginFormField('username', '<tr><th>' . lang('Username') . '<td>', '<input name="auth[username]" id="username" autofocus value="' . h($_GET["username"]) . '" autocomplete="username" autocapitalize="off">' . script("const authDriver = qs('#username').form['auth[driver]']; authDriver && authDriver.onchange();"));
|
||||
echo adminer()->loginFormField('password', '<tr><th>' . lang('Password') . '<td>', '<input type="password" name="auth[password]" autocomplete="current-password">');
|
||||
@@ -201,10 +201,12 @@ class Adminer {
|
||||
$is_view = false;
|
||||
if (support("table")) {
|
||||
$is_view = is_view($tableStatus);
|
||||
if (!$is_view) {
|
||||
if ($is_view) {
|
||||
if (support("view")) {
|
||||
$links["view"] = lang('Alter view');
|
||||
}
|
||||
} elseif (function_exists('Adminer\alter_table')) {
|
||||
$links["create"] = lang('Alter table');
|
||||
} elseif (support("view")) {
|
||||
$links["view"] = lang('Alter view');
|
||||
}
|
||||
}
|
||||
if ($set !== null) {
|
||||
@@ -286,7 +288,7 @@ class Adminer {
|
||||
|
||||
/** Get a link to use in select table
|
||||
* @param string $val raw value of the field
|
||||
* @param Field $field
|
||||
* @param array{type: string} $field
|
||||
* @return string|void null to create the default link
|
||||
*/
|
||||
function selectLink(?string $val, array $field) {
|
||||
@@ -295,7 +297,7 @@ class Adminer {
|
||||
/** Value printed in select table
|
||||
* @param ?string $val HTML-escaped value to print
|
||||
* @param ?string $link link to foreign key
|
||||
* @param Field $field
|
||||
* @param array{type: string} $field
|
||||
* @param string $original original value before applying editVal() and escaping
|
||||
*/
|
||||
function selectVal(?string $val, ?string $link, array $field, ?string $original): string {
|
||||
@@ -311,7 +313,7 @@ class Adminer {
|
||||
}
|
||||
|
||||
/** Value conversion used in select and edit
|
||||
* @param Field $field
|
||||
* @param array{type: string} $field
|
||||
*/
|
||||
function editVal(?string $val, array $field): ?string {
|
||||
return $val;
|
||||
@@ -423,7 +425,7 @@ class Adminer {
|
||||
echo "<div>(<i>" . implode("</i>, <i>", array_map('Adminer\h', $index["columns"])) . "</i>) AGAINST";
|
||||
echo " <input type='search' name='fulltext[$i]' value='" . h(idx($_GET["fulltext"], $i)) . "'>";
|
||||
echo script("qsl('input').oninput = selectFieldChange;", "");
|
||||
echo checkbox("boolean[$i]", 1, isset($_GET["boolean"][$i]), "BOOL");
|
||||
echo (JUSH == 'sql' ? checkbox("boolean[$i]", 1, isset($_GET["boolean"][$i]), "BOOL") : '');
|
||||
echo "</div>\n";
|
||||
}
|
||||
}
|
||||
@@ -674,7 +676,7 @@ class Adminer {
|
||||
$return = "<a href='#$id' class='toggle'>" . lang('Warnings') . "</a>, $return<div id='$id' class='hidden'>\n$warnings</div>\n";
|
||||
}
|
||||
return " <span class='time'>" . @date("H:i:s") . "</span>" // @ - time zone may be not set
|
||||
. " $return<div id='$sql_id' class='hidden'><pre><code class='jush-" . JUSH . "'>" . shorten_utf8($query, 1000) . "</code></pre>"
|
||||
. " $return<div id='$sql_id' class='hidden'><pre><code class='jush-" . JUSH . "'>" . shorten_utf8($query, 1e4) . "</code></pre>"
|
||||
. ($time ? " <span class='time'>($time)</span>" : '')
|
||||
. (support("sql") ? '<p><a href="' . h(str_replace("db=" . urlencode(DB), "db=" . urlencode($_GET["db"]), ME) . 'sql=&history=' . (count($history[$_GET["db"]]) - 1)) . '">' . lang('Edit') . '</a>' : '')
|
||||
. '</div>'
|
||||
@@ -1020,7 +1022,7 @@ class Adminer {
|
||||
$actions[] = "<a href='" . h(ME) . "dump=" . urlencode(isset($_GET["table"]) ? $_GET["table"] : $_GET["select"]) . "' id='dump'" . bold(isset($_GET["dump"])) . ">" . lang('Export') . "</a>";
|
||||
}
|
||||
$in_db = $_GET["ns"] !== "" && !$missing && DB != "";
|
||||
if ($in_db) {
|
||||
if ($in_db && function_exists('Adminer\alter_table')) {
|
||||
$actions[] = '<a href="' . h(ME) . 'create="' . bold($_GET["create"] === "") . ">" . lang('Create table') . "</a>";
|
||||
}
|
||||
echo ($actions ? "<p class='links'>\n" . implode("\n", $actions) . "\n" : "");
|
||||
@@ -1134,6 +1136,20 @@ class Adminer {
|
||||
echo "</ul>\n";
|
||||
}
|
||||
|
||||
/** Get server variables
|
||||
* @return list<string[]> [[$name, $value]]
|
||||
*/
|
||||
function showVariables(): array {
|
||||
return show_variables();
|
||||
}
|
||||
|
||||
/** Get status variables
|
||||
* @return list<string[]> [[$name, $value]]
|
||||
*/
|
||||
function showStatus(): array {
|
||||
return show_status();
|
||||
}
|
||||
|
||||
/** Get process list
|
||||
* @return list<string[]> [$row]
|
||||
*/
|
||||
|
||||
@@ -29,16 +29,6 @@ if (isset($_GET["file"])) {
|
||||
include "../adminer/file.inc.php";
|
||||
}
|
||||
|
||||
if ($_GET["script"] == "version") {
|
||||
$filename = get_temp_dir() . "/adminer.version";
|
||||
@unlink($filename); // it may not be writable by us, @ - it may not exist
|
||||
$fp = file_open_lock($filename);
|
||||
if ($fp) {
|
||||
file_write_unlock($fp, serialize(array("signature" => $_POST["signature"], "version" => $_POST["version"])));
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
// Adminer doesn't use any global variables; they used to be declared here
|
||||
|
||||
if (!$_SERVER["REQUEST_URI"]) { // IIS 5 compatibility
|
||||
@@ -61,7 +51,11 @@ if (!defined("SID")) {
|
||||
}
|
||||
|
||||
// disable magic quotes to be able to use database escaping function
|
||||
remove_slashes(array(&$_GET, &$_POST, &$_COOKIE), $filter);
|
||||
if (function_exists("get_magic_quotes_gpc") && get_magic_quotes_gpc()) {
|
||||
$_GET = remove_slashes($_GET, $filter);
|
||||
$_POST = remove_slashes($_POST, $filter);
|
||||
$_COOKIE = remove_slashes($_COOKIE, $filter);
|
||||
}
|
||||
if (function_exists("get_magic_quotes_runtime") && get_magic_quotes_runtime()) {
|
||||
set_magic_quotes_runtime(false);
|
||||
}
|
||||
|
||||
@@ -62,24 +62,8 @@ function page_header(string $title, string $error = "", $breadcrumb = array(), s
|
||||
adminer()->bodyClass();
|
||||
echo "'>\n";
|
||||
$filename = get_temp_dir() . "/adminer.version";
|
||||
if (!$_COOKIE["adminer_version"] && function_exists('openssl_verify') && file_exists($filename) && filemtime($filename) + 86400 > time()) { // 86400 - 1 day in seconds
|
||||
$version = unserialize(file_get_contents($filename));
|
||||
$public = "-----BEGIN PUBLIC KEY-----
|
||||
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwqWOVuF5uw7/+Z70djoK
|
||||
RlHIZFZPO0uYRezq90+7Amk+FDNd7KkL5eDve+vHRJBLAszF/7XKXe11xwliIsFs
|
||||
DFWQlsABVZB3oisKCBEuI71J4kPH8dKGEWR9jDHFw3cWmoH3PmqImX6FISWbG3B8
|
||||
h7FIx3jEaw5ckVPVTeo5JRm/1DZzJxjyDenXvBQ/6o9DgZKeNDgxwKzH+sw9/YCO
|
||||
jHnq1cFpOIISzARlrHMa/43YfeNRAm/tsBXjSxembBPo7aQZLAWHmaj5+K19H10B
|
||||
nCpz9Y++cipkVEiKRGih4ZEvjoFysEOdRLj6WiD/uUNky4xGeA6LaJqh5XpkFkcQ
|
||||
fQIDAQAB
|
||||
-----END PUBLIC KEY-----
|
||||
";
|
||||
if (openssl_verify($version["version"], base64_decode($version["signature"]), $public) == 1) {
|
||||
$_COOKIE["adminer_version"] = $version["version"]; // doesn't need to send to the browser
|
||||
}
|
||||
}
|
||||
echo script("mixin(document.body, {onkeydown: bodyKeydown, onclick: bodyClick"
|
||||
. (isset($_COOKIE["adminer_version"]) ? "" : ", onload: partial(verifyVersion, '" . VERSION . "', '" . js_escape(ME) . "', '" . get_token() . "')")
|
||||
. (isset($_COOKIE["adminer_version"]) ? "" : ", onload: partial(verifyVersion, '" . VERSION . "')")
|
||||
. "});
|
||||
document.body.classList.replace('nojs', 'js');
|
||||
const offlineMessage = '" . js_escape(lang('You are offline.')) . "';
|
||||
@@ -153,8 +137,8 @@ function csp(): array {
|
||||
return array(
|
||||
array(
|
||||
"script-src" => "'self' 'unsafe-inline' 'nonce-" . get_nonce() . "' 'strict-dynamic'", // 'self' is a fallback for browsers not supporting 'strict-dynamic', 'unsafe-inline' is a fallback for browsers not supporting 'nonce-'
|
||||
"connect-src" => "'self'",
|
||||
"frame-src" => "https://www.adminer.org",
|
||||
"connect-src" => "'self' https://www.adminer.org",
|
||||
"frame-src" => "'none'",
|
||||
"object-src" => "'none'",
|
||||
"base-uri" => "'none'",
|
||||
"form-action" => "'self'",
|
||||
|
||||
@@ -19,6 +19,7 @@ abstract class SqlDriver {
|
||||
|
||||
/** @var Db */ protected $conn;
|
||||
/** @var int[][] */ protected $types = array(); // [$group => [$type => $maximum_unsigned_length, ...], ...]
|
||||
/** @var string */ public $delimiter = ";";
|
||||
/** @var string[] */ public $insertFunctions = array(); // ["$type|$type2" => "$function/$function2"] functions used in edit and insert
|
||||
/** @var string[] */ public $editFunctions = array(); // ["$type|$type2" => "$function/$function2"] functions used in edit only
|
||||
/** @var list<string> */ public $unsigned = array(); // number variants
|
||||
@@ -190,7 +191,7 @@ abstract class SqlDriver {
|
||||
}
|
||||
|
||||
/** Convert value returned by database to actual value
|
||||
* @param Field $field
|
||||
* @param array{type: string} $field
|
||||
*/
|
||||
function value(?string $val, array $field): ?string {
|
||||
return (method_exists($this->conn, 'value') ? $this->conn->value($val, $field) : $val);
|
||||
@@ -214,14 +215,14 @@ abstract class SqlDriver {
|
||||
}
|
||||
|
||||
/** Get tables this table inherits from
|
||||
* @return list<string>
|
||||
* @return list<array{table: string, ns: string}>
|
||||
*/
|
||||
function inheritsFrom(string $table): array {
|
||||
return array();
|
||||
}
|
||||
|
||||
/** Get inherited tables
|
||||
* @return list<string>
|
||||
* @return list<array{table: string, ns: string}>
|
||||
*/
|
||||
function inheritedTables(string $table): array {
|
||||
return array();
|
||||
@@ -268,10 +269,10 @@ abstract class SqlDriver {
|
||||
// MariaDB contains CHECK_CONSTRAINTS.TABLE_NAME, MySQL and PostrgreSQL not
|
||||
return get_key_vals("SELECT c.CONSTRAINT_NAME, CHECK_CLAUSE
|
||||
FROM INFORMATION_SCHEMA.CHECK_CONSTRAINTS c
|
||||
JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS t ON c.CONSTRAINT_SCHEMA = t.CONSTRAINT_SCHEMA AND c.CONSTRAINT_NAME = t.CONSTRAINT_NAME
|
||||
JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS t ON c.CONSTRAINT_SCHEMA = t.CONSTRAINT_SCHEMA AND c.CONSTRAINT_NAME = t.CONSTRAINT_NAME" . ($this->conn->flavor == 'maria' ? " AND c.TABLE_NAME = t.TABLE_NAME" : "") . "
|
||||
WHERE c.CONSTRAINT_SCHEMA = " . q($_GET["ns"] != "" ? $_GET["ns"] : DB) . "
|
||||
AND t.TABLE_NAME = " . q($table) . "
|
||||
AND CHECK_CLAUSE NOT LIKE '% IS NOT NULL'", $this->conn); // ignore default IS NOT NULL checks in PostrgreSQL
|
||||
AND t.TABLE_NAME = " . q($table) . (JUSH == "pgsql" ? "
|
||||
AND CHECK_CLAUSE NOT LIKE '% IS NOT NULL'" : ""), $this->conn); // ignore default IS NOT NULL checks in PostrgreSQL
|
||||
}
|
||||
|
||||
/** Get all fields in the current schema
|
||||
|
||||
@@ -72,25 +72,18 @@ function print_select_result($result, ?Db $connection2 = null, array $orgtables
|
||||
} else {
|
||||
$link = ME . "edit=" . urlencode($links[$key]);
|
||||
foreach ($indexes[$links[$key]] as $col => $j) {
|
||||
if ($row[$j] === null) {
|
||||
$link = "";
|
||||
break;
|
||||
}
|
||||
$link .= "&where" . urlencode("[" . bracket_escape($col) . "]") . "=" . urlencode($row[$j]);
|
||||
}
|
||||
}
|
||||
} elseif (is_url($val)) {
|
||||
$link = $val;
|
||||
}
|
||||
if ($val === null) {
|
||||
$val = "<i>NULL</i>";
|
||||
} elseif ($blobs[$key] && !is_utf8($val)) {
|
||||
$val = "<i>" . lang('%d byte(s)', strlen($val)) . "</i>"; //! link to download
|
||||
} else {
|
||||
$val = h($val);
|
||||
if ($types[$key] == 254) { // 254 - char
|
||||
$val = "<code>$val</code>";
|
||||
}
|
||||
}
|
||||
if ($link) {
|
||||
$val = "<a href='" . h($link) . "'" . (is_url($link) ? target_blank() : '') . ">$val</a>";
|
||||
}
|
||||
$field = array(
|
||||
'type' => ($blobs[$key] ? 'blob' : ($types[$key] == 254 ? 'char' : '')),
|
||||
);
|
||||
$val = select_value($val, $link, $field, null);
|
||||
// https://dev.mysql.com/doc/dev/mysql-server/latest/field__types_8h.html
|
||||
echo "<td" . ($types[$key] <= 9 || $types[$key] == 246 ? " class='number'" : "") . ">$val";
|
||||
}
|
||||
@@ -246,15 +239,18 @@ function process_field(array $field, array $type_field): array {
|
||||
* @param Field $field
|
||||
*/
|
||||
function default_value(array $field): string {
|
||||
$default = $field["default"];
|
||||
if ($field["default"] === null) {
|
||||
return "";
|
||||
}
|
||||
$default = str_replace("\r", "", $field["default"]);
|
||||
$generated = $field["generated"];
|
||||
return ($default === null ? "" : (in_array($generated, driver()->generated)
|
||||
? (JUSH == "mssql" ? " AS ($default)" . ($generated == "VIRTUAL" ? "" : " $generated") . "" : " GENERATED ALWAYS AS ($default) $generated")
|
||||
return (in_array($generated, driver()->generated)
|
||||
? (JUSH == "mssql" ? " AS ($default)" . ($generated == "VIRTUAL" ? "" : " $generated") : " GENERATED ALWAYS AS ($default) $generated")
|
||||
: " DEFAULT " . (!preg_match('~^GENERATED ~i', $default) && (preg_match('~char|binary|text|json|enum|set~', $field["type"]) || preg_match('~^(?![a-z])~i', $default))
|
||||
? (JUSH == "sql" && preg_match('~text|json~', $field["type"]) ? "(" . q($default) . ")" : q($default)) // MySQL requires () around default value of text column
|
||||
: str_ireplace("current_timestamp()", "CURRENT_TIMESTAMP", (JUSH == "sqlite" ? "($default)" : $default))
|
||||
)
|
||||
));
|
||||
);
|
||||
}
|
||||
|
||||
/** Get type class to use in CSS
|
||||
@@ -325,7 +321,9 @@ function edit_fields(array $fields, array $collations, $type = "TABLE", array $f
|
||||
? html_select("fields[$i][generated]", array_merge(array("", "DEFAULT"), driver()->generated), $field["generated"]) . " "
|
||||
: checkbox("fields[$i][generated]", 1, $field["generated"], "", "", "", "label-default")
|
||||
);
|
||||
echo "<input name='fields[$i][default]' value='" . h($field["default"]) . "' aria-labelledby='label-default'>";
|
||||
$attrs = " name='fields[$i][default]' aria-labelledby='label-default'";
|
||||
$value = h($field["default"]);
|
||||
echo (preg_match('~\n~', $field["default"]) ? "<textarea$attrs rows='2' cols='30' style='vertical-align: bottom;'>\n$value</textarea>" : "<input$attrs value='$value'>"); // \n to preserve the leading newline
|
||||
echo (support("comment") ? "<td$comment_class><input name='fields[$i][comment]' value='" . h($field["comment"]) . "' data-maxlength='" . (min_version(5.5) ? 1024 : 255) . "' aria-labelledby='label-comment'>" : "");
|
||||
}
|
||||
echo "<td>";
|
||||
@@ -487,6 +485,7 @@ function format_foreign_key(array $foreign_key): string {
|
||||
. " (" . implode(", ", array_map('Adminer\idf_escape', $foreign_key["target"])) . ")" //! reuse $name - check in older MySQL versions
|
||||
. (preg_match("~^(" . driver()->onActions . ")\$~", $foreign_key["on_delete"]) ? " ON DELETE $foreign_key[on_delete]" : "")
|
||||
. (preg_match("~^(" . driver()->onActions . ")\$~", $foreign_key["on_update"]) ? " ON UPDATE $foreign_key[on_update]" : "")
|
||||
. ($foreign_key["deferrable"] ? " $foreign_key[deferrable]" : "")
|
||||
;
|
||||
}
|
||||
|
||||
@@ -507,20 +506,6 @@ function tar_file(string $filename, $tmp_file): void {
|
||||
echo str_repeat("\0", 511 - ($tmp_file->size + 511) % 512);
|
||||
}
|
||||
|
||||
/** Get INI bytes value */
|
||||
function ini_bytes(string $ini): int {
|
||||
$val = ini_get($ini);
|
||||
switch (strtolower(substr($val, -1))) {
|
||||
case 'g':
|
||||
$val = (int) $val * 1024; // no break
|
||||
case 'm':
|
||||
$val = (int) $val * 1024; // no break
|
||||
case 'k':
|
||||
$val = (int) $val * 1024;
|
||||
}
|
||||
return $val;
|
||||
}
|
||||
|
||||
/** Create link to database documentation
|
||||
* @param string[] $paths JUSH => $path
|
||||
* @param string $text HTML code
|
||||
|
||||
@@ -76,24 +76,19 @@ function number_type(): string {
|
||||
}
|
||||
|
||||
/** Disable magic_quotes_gpc
|
||||
* @param list<array> $process e.g. [&$_GET, &$_POST, &$_COOKIE]
|
||||
* @param mixed[] $values
|
||||
* @param bool $filter whether to leave values as is
|
||||
* @return void modified in place
|
||||
* @return mixed[]
|
||||
*/
|
||||
function remove_slashes(array $process, bool $filter = false): void {
|
||||
if (function_exists("get_magic_quotes_gpc") && get_magic_quotes_gpc()) {
|
||||
while (list($key, $val) = each($process)) {
|
||||
foreach ($val as $k => $v) {
|
||||
unset($process[$key][$k]);
|
||||
if (is_array($v)) {
|
||||
$process[$key][stripslashes($k)] = $v;
|
||||
$process[] = &$process[$key][stripslashes($k)];
|
||||
} else {
|
||||
$process[$key][stripslashes($k)] = ($filter ? $v : stripslashes($v));
|
||||
}
|
||||
}
|
||||
}
|
||||
function remove_slashes(array $values, bool $filter = false): array {
|
||||
$return = array();
|
||||
foreach ($values as $key => $val) {
|
||||
$return[stripslashes($key)] = (is_array($val)
|
||||
? remove_slashes($val, $filter)
|
||||
: ($filter ? $val : stripslashes($val))
|
||||
);
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
/** Escape or unescape string to use inside form [] */
|
||||
@@ -128,6 +123,20 @@ function ini_bool(string $ini): bool {
|
||||
return (preg_match('~^(on|true|yes)$~i', $val) || (int) $val); // boolean values set by php_value are strings
|
||||
}
|
||||
|
||||
/** Get INI bytes value */
|
||||
function ini_bytes(string $ini): int {
|
||||
$val = ini_get($ini);
|
||||
switch (strtolower(substr($val, -1))) {
|
||||
case 'g':
|
||||
$val = (int) $val * 1024; // no break
|
||||
case 'm':
|
||||
$val = (int) $val * 1024; // no break
|
||||
case 'k':
|
||||
$val = (int) $val * 1024;
|
||||
}
|
||||
return $val;
|
||||
}
|
||||
|
||||
/** Check if SID is necessary */
|
||||
function sid(): bool {
|
||||
static $return;
|
||||
@@ -230,7 +239,7 @@ function get_rows(string $query, ?Db $connection2 = null, string $error = "<p cl
|
||||
*/
|
||||
function unique_array(?array $row, array $indexes) {
|
||||
foreach ($indexes as $index) {
|
||||
if (preg_match("~PRIMARY|UNIQUE~", $index["type"])) {
|
||||
if (preg_match("~PRIMARY|UNIQUE~", $index["type"]) && !$index["partial"]) {
|
||||
$return = array();
|
||||
foreach ($index["columns"] as $key) {
|
||||
if (!isset($row[$key])) { // NULL is ambiguous
|
||||
@@ -320,7 +329,7 @@ function convert_fields(array $columns, array $fields, array $select = array()):
|
||||
*/
|
||||
function cookie(string $name, ?string $value, int $lifetime = 2592000): void {
|
||||
header(
|
||||
"Set-Cookie: $name=" . urlencode($value)
|
||||
"Set-Cookie: $name=" . rawurlencode($value)
|
||||
. ($lifetime ? "; expires=" . gmdate("D, d M Y H:i:s", time() + $lifetime) . " GMT" : "")
|
||||
. "; path=" . preg_replace('~\?.*~', '', $_SERVER["REQUEST_URI"])
|
||||
. (HTTPS ? "; secure" : "")
|
||||
@@ -461,7 +470,7 @@ function queries(string $query) {
|
||||
if (!Queries::$start) {
|
||||
Queries::$start = microtime(true);
|
||||
}
|
||||
Queries::$queries[] = (preg_match('~;$~', $query) ? "DELIMITER ;;\n$query;\nDELIMITER " : $query) . ";";
|
||||
Queries::$queries[] = (driver()->delimiter != ';' ? $query : (preg_match('~;$~', $query) ? "DELIMITER ;;\n$query;\nDELIMITER " : $query) . ";");
|
||||
return connection()->query($query);
|
||||
}
|
||||
|
||||
@@ -642,12 +651,13 @@ function dump_headers(string $identifier, bool $multi_table = false): string {
|
||||
* @param string[] $row
|
||||
*/
|
||||
function dump_csv(array $row): void {
|
||||
$tsv = $_POST["format"] == "tsv";
|
||||
foreach ($row as $key => $val) {
|
||||
if (preg_match('~["\n,;\t]|^0|\.\d*0$~', $val) || $val === "") {
|
||||
if (preg_match('~["\n]|^0[^.]|\.\d*0$|' . ($tsv ? '\t' : '[,;]|^$') . '~', $val)) {
|
||||
$row[$key] = '"' . str_replace('"', '""', $val) . '"';
|
||||
}
|
||||
}
|
||||
echo implode(($_POST["format"] == "csv" ? "," : ($_POST["format"] == "tsv" ? "\t" : ";")), $row) . "\r\n";
|
||||
echo implode(($_POST["format"] == "csv" ? "," : ($tsv ? "\t" : ";")), $row) . "\r\n";
|
||||
}
|
||||
|
||||
/** Apply SQL function
|
||||
@@ -751,19 +761,35 @@ function rand_string(): string {
|
||||
}
|
||||
|
||||
/** Format value to use in select
|
||||
* @param string|string[] $val
|
||||
* @param Field $field
|
||||
* @param string|string[]|list<string[]> $val
|
||||
* @param array{type: string} $field
|
||||
* @param ?numeric-string $text_length
|
||||
* @return string HTML
|
||||
*/
|
||||
function select_value($val, string $link, array $field, ?string $text_length): string {
|
||||
if (is_array($val)) {
|
||||
$return = "";
|
||||
foreach ($val as $k => $v) {
|
||||
$return .= "<tr>"
|
||||
. ($val != array_values($val) ? "<th>" . h($k) : "")
|
||||
. "<td>" . select_value($v, $link, $field, $text_length)
|
||||
;
|
||||
if (array_filter($val, 'is_array') == array_values($val)) { // list of arrays
|
||||
$keys = array();
|
||||
foreach ($val as $v) {
|
||||
$keys += array_fill_keys(array_keys($v), null);
|
||||
}
|
||||
foreach (array_keys($keys) as $k) {
|
||||
$return .= "<th>" . h($k);
|
||||
}
|
||||
foreach ($val as $v) {
|
||||
$return .= "<tr>";
|
||||
foreach (array_merge($keys, $v) as $v2) {
|
||||
$return .= "<td>" . select_value($v2, $link, $field, $text_length);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
foreach ($val as $k => $v) {
|
||||
$return .= "<tr>"
|
||||
. ($val != array_values($val) ? "<th>" . h($k) : "")
|
||||
. "<td>" . select_value($v, $link, $field, $text_length)
|
||||
;
|
||||
}
|
||||
}
|
||||
return "<table>$return</table>";
|
||||
}
|
||||
@@ -778,7 +804,7 @@ function select_value($val, string $link, array $field, ?string $text_length): s
|
||||
$link = $val; // IE 11 and all modern browsers hide referrer
|
||||
}
|
||||
}
|
||||
$return = adminer()->editVal($val, $field);
|
||||
$return = adminer()->editVal(driver()->value($val, $field), $field);
|
||||
if ($return !== null) {
|
||||
if (!is_utf8($return)) {
|
||||
$return = "\0"; // htmlspecialchars of binary data returns an empty string
|
||||
@@ -792,7 +818,7 @@ function select_value($val, string $link, array $field, ?string $text_length): s
|
||||
}
|
||||
|
||||
/** Check whether the field type is blob or equivalent
|
||||
* @param Field $field
|
||||
* @param array{type: string} $field
|
||||
*/
|
||||
function is_blob(array $field): bool {
|
||||
return preg_match('~blob|bytea|raw|file~', $field["type"]) && !in_array($field["type"], idx(driver()->structuredTypes(), lang('User types'), array()));
|
||||
@@ -809,14 +835,14 @@ function is_mail(?string $email): bool {
|
||||
/** Check whether the string is URL address */
|
||||
function is_url(?string $string): bool {
|
||||
$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
|
||||
}
|
||||
|
||||
/** Check if field should be shortened
|
||||
* @param Field $field
|
||||
* @param array{type: string} $field
|
||||
*/
|
||||
function is_shortable(array $field): bool {
|
||||
return preg_match('~char|text|json|lob|geometry|point|linestring|polygon|string|bytea|hstore~', $field["type"]);
|
||||
return !preg_match('~' . number_type() . '|date|time|year~', $field["type"]);
|
||||
}
|
||||
|
||||
/** Split server into host and (port or socket)
|
||||
|
||||
@@ -176,6 +176,20 @@ function hidden_fields_get(): void {
|
||||
echo input_hidden("username", $_GET["username"]);
|
||||
}
|
||||
|
||||
/** Get <input type='file'> */
|
||||
function file_input(string $input): string {
|
||||
$max_file_uploads = "max_file_uploads";
|
||||
$max_file_uploads_value = ini_get($max_file_uploads);
|
||||
$upload_max_filesize = "upload_max_filesize";
|
||||
$upload_max_filesize_value = ini_get($upload_max_filesize);
|
||||
return (ini_bool("file_uploads")
|
||||
? $input . script("qsl('input[type=\"file\"]').onchange = partialArg(fileChange, "
|
||||
. "$max_file_uploads_value, '" . lang('Increase %s.', "$max_file_uploads = $max_file_uploads_value") . "', " // ignore post_max_size because it is for all form fields together and bytes computing would be necessary
|
||||
. ini_bytes("upload_max_filesize") . ", '" . lang('Increase %s.', "$upload_max_filesize = $upload_max_filesize_value") . "')")
|
||||
: lang('File uploads are disabled.')
|
||||
);
|
||||
}
|
||||
|
||||
/** Print enum or set input field
|
||||
* @param 'radio'|'checkbox' $type
|
||||
* @param Field $field
|
||||
@@ -202,9 +216,12 @@ function input(array $field, $value, ?string $function, ?bool $autofocus = false
|
||||
$name = h(bracket_escape($field["field"]));
|
||||
echo "<td class='function'>";
|
||||
if (is_array($value) && !$function) {
|
||||
$value = json_encode($value, 128 | 64 | 256); // 128 - JSON_PRETTY_PRINT, 64 - JSON_UNESCAPED_SLASHES, 256 - JSON_UNESCAPED_UNICODE available since PHP 5.4
|
||||
$function = "json";
|
||||
}
|
||||
$json = ($function == "json" || preg_match('~^jsonb?$~', $field["type"]));
|
||||
if ($json && $value != '' && (JUSH != "pgsql" || $field["type"] != "json")) {
|
||||
$value = json_encode(is_array($value) ? $value : json_decode($value), 128 | 64 | 256); // 128 - JSON_PRETTY_PRINT, 64 - JSON_UNESCAPED_SLASHES, 256 - JSON_UNESCAPED_UNICODE available since PHP 5.4
|
||||
}
|
||||
$reset = (JUSH == "mssql" && $field["auto_increment"]);
|
||||
if ($reset && !$_POST["save"]) {
|
||||
$function = null;
|
||||
@@ -215,8 +232,7 @@ function input(array $field, $value, ?string $function, ?bool $autofocus = false
|
||||
$field["type"] = "enum";
|
||||
$field["length"] = $enums;
|
||||
}
|
||||
$disabled = stripos($field["default"], "GENERATED ALWAYS AS ") === 0 ? " disabled=''" : "";
|
||||
$attrs = " name='fields[$name]" . ($field["type"] == "enum" || $field["type"] == "set" ? "[]" : "") . "'$disabled" . ($autofocus ? " autofocus" : "");
|
||||
$attrs = " name='fields[$name]" . ($field["type"] == "enum" || $field["type"] == "set" ? "[]" : "") . "'" . ($autofocus ? " autofocus" : "");
|
||||
echo driver()->unconvertFunction($field) . " ";
|
||||
$table = $_GET["edit"] ?: $_GET["select"];
|
||||
if ($field["type"] == "enum") {
|
||||
@@ -224,7 +240,7 @@ function input(array $field, $value, ?string $function, ?bool $autofocus = false
|
||||
} else {
|
||||
$has_function = (in_array($function, $functions) || isset($functions[$function]));
|
||||
echo (count($functions) > 1
|
||||
? "<select name='function[$name]'$disabled>" . optionlist($functions, $function === null || $has_function ? $function : "") . "</select>"
|
||||
? "<select name='function[$name]'>" . optionlist($functions, $function === null || $has_function ? $function : "") . "</select>"
|
||||
. on_help("event.target.value.replace(/^SQL\$/, '')", 1)
|
||||
. script("qsl('select').onchange = functionChange;", "")
|
||||
: h(reset($functions))
|
||||
@@ -239,7 +255,7 @@ function input(array $field, $value, ?string $function, ?bool $autofocus = false
|
||||
echo enum_input("checkbox", $attrs, $field, (is_string($value) ? explode(",", $value) : $value));
|
||||
} elseif (is_blob($field) && ini_bool("file_uploads")) {
|
||||
echo "<input type='file' name='fields-$name'>";
|
||||
} elseif ($function == "json" || preg_match('~^jsonb?$~', $field["type"])) {
|
||||
} elseif ($json) {
|
||||
echo "<textarea$attrs cols='50' rows='12' class='jush-js'>" . h($value) . '</textarea>';
|
||||
} elseif (($text = preg_match('~text|lob|memo~i', $field["type"])) || preg_match("~\n~", $value)) {
|
||||
if ($text && JUSH != "sqlite") {
|
||||
@@ -287,15 +303,15 @@ function input(array $field, $value, ?string $function, ?bool $autofocus = false
|
||||
* @return mixed false to leave the original value
|
||||
*/
|
||||
function process_input(array $field) {
|
||||
if (stripos($field["default"], "GENERATED ALWAYS AS ") === 0) {
|
||||
return;
|
||||
}
|
||||
$idf = bracket_escape($field["field"]);
|
||||
$function = idx($_POST["function"], $idf);
|
||||
$value = idx($_POST["fields"], $idf);
|
||||
if ($value === null) {
|
||||
return false;
|
||||
}
|
||||
if ($field["type"] == "enum" || driver()->enumLength($field)) {
|
||||
$value = $value[0];
|
||||
if ($value == "orig") {
|
||||
$value = idx($value, 0);
|
||||
if ($value == "orig" || !$value) {
|
||||
return false;
|
||||
}
|
||||
if ($value == "null") {
|
||||
@@ -380,6 +396,7 @@ function edit_form(string $table, array $fields, $row, ?bool $update, string $er
|
||||
return;
|
||||
}
|
||||
echo "<form action='' method='post' enctype='multipart/form-data' id='form'>\n";
|
||||
$editable = false;
|
||||
if (!$fields) {
|
||||
echo "<p class='error'>" . lang('You have no privileges to update this table.') . "\n";
|
||||
} else {
|
||||
@@ -410,30 +427,35 @@ function edit_form(string $table, array $fields, $row, ?bool $update, string $er
|
||||
if (!$_POST["save"] && is_string($value)) {
|
||||
$value = adminer()->editVal($value, $field);
|
||||
}
|
||||
$function = ($_POST["save"]
|
||||
? idx($_POST["function"], $name, "")
|
||||
: ($update && preg_match('~^CURRENT_TIMESTAMP~i', $field["on_update"])
|
||||
? "now"
|
||||
: ($value === false ? null : ($value !== null ? '' : 'NULL'))
|
||||
)
|
||||
);
|
||||
if (!$_POST && !$update && $value == $field["default"] && preg_match('~^[\w.]+\(~', $value)) {
|
||||
$function = "SQL";
|
||||
}
|
||||
if (preg_match("~time~", $field["type"]) && preg_match('~^CURRENT_TIMESTAMP~i', $value)) {
|
||||
$value = "";
|
||||
$function = "now";
|
||||
}
|
||||
if ($field["type"] == "uuid" && $value == "uuid()") {
|
||||
$value = "";
|
||||
$function = "uuid";
|
||||
}
|
||||
if ($autofocus !== false) {
|
||||
$autofocus = ($field["auto_increment"] || $function == "now" || $function == "uuid" ? null : true); // null - don't autofocus this input but check the next one
|
||||
}
|
||||
input($field, $value, $function, $autofocus);
|
||||
if ($autofocus) {
|
||||
$autofocus = false;
|
||||
if (($update && !isset($field["privileges"]["update"])) || $field["generated"]) {
|
||||
echo "<td class='function'><td>" . select_value($value, '', $field, null);
|
||||
} else {
|
||||
$editable = true;
|
||||
$function = ($_POST["save"]
|
||||
? idx($_POST["function"], $name, "")
|
||||
: ($update && preg_match('~^CURRENT_TIMESTAMP~i', $field["on_update"])
|
||||
? "now"
|
||||
: ($value === false ? null : ($value !== null ? '' : 'NULL'))
|
||||
)
|
||||
);
|
||||
if (!$_POST && !$update && $value == $field["default"] && preg_match('~^[\w.]+\(~', $value)) {
|
||||
$function = "SQL";
|
||||
}
|
||||
if (preg_match("~time~", $field["type"]) && preg_match('~^CURRENT_TIMESTAMP~i', $value)) {
|
||||
$value = "";
|
||||
$function = "now";
|
||||
}
|
||||
if ($field["type"] == "uuid" && $value == "uuid()") {
|
||||
$value = "";
|
||||
$function = "uuid";
|
||||
}
|
||||
if ($autofocus !== false) {
|
||||
$autofocus = ($field["auto_increment"] || $function == "now" || $function == "uuid" ? null : true); // null - don't autofocus this input but check the next one
|
||||
}
|
||||
input($field, $value, $function, $autofocus);
|
||||
if ($autofocus) {
|
||||
$autofocus = false;
|
||||
}
|
||||
}
|
||||
echo "\n";
|
||||
}
|
||||
@@ -449,7 +471,7 @@ function edit_form(string $table, array $fields, $row, ?bool $update, string $er
|
||||
echo "</table>\n";
|
||||
}
|
||||
echo "<p>\n";
|
||||
if ($fields) {
|
||||
if ($editable) {
|
||||
echo "<input type='submit' value='" . lang('Save') . "'>\n";
|
||||
if (!isset($_GET["select"])) {
|
||||
echo "<input type='submit' name='insert' value='" . ($update
|
||||
|
||||
@@ -17,12 +17,12 @@ class Plugins {
|
||||
$basename = "adminer-plugins";
|
||||
if (is_dir($basename)) {
|
||||
foreach (glob("$basename/*.php") as $filename) {
|
||||
$include = include_once "./$filename";
|
||||
$this->includeOnce($filename);
|
||||
}
|
||||
}
|
||||
$help = " href='https://www.adminer.org/plugins/#use'" . target_blank();
|
||||
if (file_exists("$basename.php")) {
|
||||
$include = include_once "./$basename.php"; // example: return array(new AdminerLoginOtp($secret))
|
||||
$include = $this->includeOnce("$basename.php"); // example: return array(new AdminerLoginOtp($secret));
|
||||
if (is_array($include)) {
|
||||
foreach ($include as $plugin) {
|
||||
$plugins[get_class($plugin)] = $plugin;
|
||||
@@ -32,7 +32,7 @@ class Plugins {
|
||||
}
|
||||
}
|
||||
foreach (get_declared_classes() as $class) {
|
||||
if (!$plugins[$class] && preg_match('~^Adminer\w~i', $class)) {
|
||||
if (!$plugins[$class] && (preg_match('~^Adminer\w~i', $class) || is_subclass_of($class, 'Adminer\Plugin'))) {
|
||||
// we need to use reflection because PHP 7.1 throws ArgumentCountError for missing arguments but older versions issue a warning
|
||||
$reflection = new \ReflectionClass($class);
|
||||
$constructor = $reflection->getConstructor();
|
||||
@@ -59,6 +59,13 @@ class Plugins {
|
||||
}
|
||||
}
|
||||
|
||||
/** Separate function to not overwrite local variables
|
||||
* @return array<object>|true
|
||||
*/
|
||||
function includeOnce(string $filename) {
|
||||
return include_once "./$filename";
|
||||
}
|
||||
|
||||
/**
|
||||
* @param literal-string $name
|
||||
* @param mixed[] $params
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
namespace Adminer;
|
||||
|
||||
const VERSION = "5.4.0";
|
||||
const VERSION = "5.4.2";
|
||||
|
||||
@@ -13,6 +13,7 @@ Lang::$translations = array(
|
||||
'Logged as: %s' => 'Přihlášen jako: %s',
|
||||
'Logout successful.' => 'Odhlášení proběhlo v pořádku.',
|
||||
'Thanks for using Adminer, consider <a href="https://www.adminer.org/en/donation/">donating</a>.' => 'Díky za použití Admineru, <a href="https://www.adminer.org/cs/donation/">přispějte</a> na vývoj.',
|
||||
'hostname[:port] or :socket' => 'hostname[:port] nebo :socket',
|
||||
'Invalid credentials.' => 'Neplatné přihlašovací údaje.',
|
||||
'There is a space in the input password which might be the cause.' => 'Problém může být, že je v zadaném hesle mezera.',
|
||||
'Adminer does not support accessing a database without a password, <a href="https://www.adminer.org/en/password/"%s>more information</a>.' => 'Adminer nepodporuje přístup k databázi bez hesla, <a href="https://www.adminer.org/cs/password/"%s>více informací</a>.',
|
||||
|
||||
@@ -13,6 +13,7 @@ Lang::$translations = array(
|
||||
'Logged as: %s' => 'Xx: %s',
|
||||
'Logout successful.' => 'Xx.',
|
||||
'Thanks for using Adminer, consider <a href="https://www.adminer.org/en/donation/">donating</a>.' => 'Xx <a href="https://www.adminer.org/en/donation/">xx</a>.',
|
||||
'hostname[:port] or :socket' => 'xx',
|
||||
'Invalid credentials.' => 'Xx.',
|
||||
'There is a space in the input password which might be the cause.' => 'Xx.',
|
||||
'Adminer does not support accessing a database without a password, <a href="https://www.adminer.org/en/password/"%s>more information</a>.' => 'Xx, <a href="https://www.adminer.org/en/password/"%s>xx</a>.',
|
||||
|
||||
@@ -353,17 +353,14 @@ if (!$columns && support("table")) {
|
||||
$desc = "&desc%5B0%5D=1";
|
||||
echo "<th id='th[" . h(bracket_escape($key)) . "]'>" . script("mixin(qsl('th'), {onmouseover: partial(columnMouse), onmouseout: partial(columnMouse, ' hidden')});", "");
|
||||
$fun = apply_sql_function($val["fun"], $name); //! columns looking like functions
|
||||
$sortable = isset($field["privileges"]["order"]) || $fun;
|
||||
$sortable = isset($field["privileges"]["order"]) || $fun != $name;
|
||||
echo ($sortable ? "<a href='" . h($href . ($order[0] == $column || $order[0] == $key ? $desc : '')) . "'>$fun</a>" : $fun); // $order[0] == $key - COUNT(*)
|
||||
echo "<span class='column hidden'>";
|
||||
if ($sortable) {
|
||||
echo "<a href='" . h($href . $desc) . "' title='" . lang('descending') . "' class='text'> ↓</a>";
|
||||
}
|
||||
$menu = ($sortable ? "<a href='" . h($href . $desc) . "' title='" . lang('descending') . "' class='text'> ↓</a>" : '');
|
||||
if (!$val["fun"] && isset($field["privileges"]["where"])) {
|
||||
echo '<a href="#fieldset-search" title="' . lang('Search') . '" class="text jsonly"> =</a>';
|
||||
echo script("qsl('a').onclick = partial(selectSearch, '" . js_escape($key) . "');");
|
||||
$menu .= '<a href="#fieldset-search" title="' . lang('Search') . '" class="text jsonly"> =</a>';
|
||||
$menu .= script("qsl('a').onclick = partial(selectSearch, '" . js_escape($key) . "');");
|
||||
}
|
||||
echo "</span>";
|
||||
echo ($menu ? "<span class='column hidden'>$menu</span>" : "");
|
||||
}
|
||||
$functions[$key] = $val["fun"];
|
||||
next($select);
|
||||
@@ -417,7 +414,6 @@ if (!$columns && support("table")) {
|
||||
if (isset($names[$key])) {
|
||||
$column = current($select);
|
||||
$field = (array) $fields[$key];
|
||||
$val = driver()->value($val, $field);
|
||||
if ($val != "" && (!isset($email_fields[$key]) || $email_fields[$key] != "")) {
|
||||
$email_fields[$key] = (is_mail($val) ? $names[$key] : ""); //! filled e-mails can be contained on other pages
|
||||
}
|
||||
@@ -503,7 +499,7 @@ if (!$columns && support("table")) {
|
||||
if (intval($found_rows) < max(1e4, 2 * ($page + 1) * $limit)) {
|
||||
// slow with big tables
|
||||
$found_rows = first(slow_query(count_rows($TABLE, $where, $is_group, $group)));
|
||||
} else {
|
||||
} elseif (JUSH == 'sql' || JUSH == 'pgsql') {
|
||||
$exact_count = false;
|
||||
}
|
||||
}
|
||||
@@ -595,9 +591,10 @@ if (!$columns && support("table")) {
|
||||
echo "<a href='#import'>" . lang('Import') . "</a>";
|
||||
echo script("qsl('a').onclick = partial(toggle, 'import');", "");
|
||||
echo "<span id='import'" . ($_POST["import"] ? "" : " class='hidden'") . ">: ";
|
||||
echo "<input type='file' name='csv_file'> ";
|
||||
echo html_select("separator", array("csv" => "CSV,", "csv;" => "CSV;", "tsv" => "TSV"), $adminer_import["format"]);
|
||||
echo " <input type='submit' name='import' value='" . lang('Import') . "'>";
|
||||
echo file_input("<input type='file' name='csv_file'> "
|
||||
. html_select("separator", array("csv" => "CSV,", "csv;" => "CSV;", "tsv" => "TSV"), $adminer_import["format"])
|
||||
. " <input type='submit' name='import' value='" . lang('Import') . "'>")
|
||||
;
|
||||
echo "</span>";
|
||||
}
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ if (!$error && $_POST) {
|
||||
}
|
||||
|
||||
$space = "(?:\\s|/\\*[\s\S]*?\\*/|(?:#|$line_comment)[^\n]*\n?|--\r?\n)";
|
||||
$delimiter = ";";
|
||||
$delimiter = driver()->delimiter;
|
||||
$offset = 0;
|
||||
$empty = true;
|
||||
$connection2 = connect(); // connection for exploring indexes and EXPLAIN (to not replace FOUND_ROWS()) //! PDO - silent error
|
||||
@@ -250,15 +250,9 @@ if (!isset($_GET["import"])) {
|
||||
echo lang('Limit rows') . ": <input type='number' name='limit' class='size' value='" . h($_POST ? $_POST["limit"] : $_GET["limit"]) . "'>\n";
|
||||
|
||||
} else {
|
||||
echo "<fieldset><legend>" . lang('File upload') . "</legend><div>";
|
||||
$gz = (extension_loaded("zlib") ? "[.gz]" : "");
|
||||
$max_file_uploads = "max_file_uploads";
|
||||
$max_file_uploads_value = ini_get($max_file_uploads);
|
||||
echo (ini_bool("file_uploads")
|
||||
? "SQL$gz (< " . ini_get("upload_max_filesize") . "B): <input type='file' name='sql_file[]' multiple>\n" // ignore post_max_size because it is for all form fields together and bytes computing would be necessary
|
||||
. script("qsl('input').onchange = partialArg(fileChange, $max_file_uploads_value, '" . lang('Increase %s.', "$max_file_uploads = $max_file_uploads_value") . "')") . $execute
|
||||
: lang('File uploads are disabled.')
|
||||
);
|
||||
echo "<fieldset><legend>" . lang('File upload') . "</legend><div>";
|
||||
echo file_input("SQL$gz: <input type='file' name='sql_file[]' multiple>\n$execute");
|
||||
echo "</div></fieldset>\n";
|
||||
$importServerPath = adminer()->importServerPath();
|
||||
if ($importServerPath) {
|
||||
|
||||
@@ -57,6 +57,7 @@ input.wayoff { left: -1000px; position: absolute; }
|
||||
.date { color: #7F007F; }
|
||||
.enum { color: #007F7F; }
|
||||
.binary { color: red; }
|
||||
.odds tbody tr { background: var(--bg); }
|
||||
.odds tbody tr:nth-child(2n) { background: #F5F5F5; }
|
||||
.js .checkable .checked td, .js .checkable .checked th { background: var(--lit); }
|
||||
.time { color: silver; font-size: 70%; }
|
||||
|
||||
@@ -662,24 +662,29 @@ function indexesAddColumn(prefix) {
|
||||
* @param string
|
||||
*/
|
||||
function sqlSubmit(form, root) {
|
||||
if (encodeURIComponent(form['query'].value).length < 500) {
|
||||
form.action = root
|
||||
+ '&sql=' + encodeURIComponent(form['query'].value)
|
||||
+ (form['limit'].value ? '&limit=' + +form['limit'].value : '')
|
||||
+ (form['error_stops'].checked ? '&error_stops=1' : '')
|
||||
+ (form['only_errors'].checked ? '&only_errors=1' : '')
|
||||
;
|
||||
const action = root
|
||||
+ '&sql=' + encodeURIComponent(form['query'].value)
|
||||
+ (form['limit'].value ? '&limit=' + +form['limit'].value : '')
|
||||
+ (form['error_stops'].checked ? '&error_stops=1' : '')
|
||||
+ (form['only_errors'].checked ? '&only_errors=1' : '')
|
||||
;
|
||||
if ((document.location.origin + document.location.pathname + action).length < 2000) { // reasonable minimum is 2048
|
||||
form.action = action;
|
||||
}
|
||||
}
|
||||
|
||||
/** Check if PHP can handle the uploaded files
|
||||
* @param Event
|
||||
* @param number
|
||||
* @param string
|
||||
* @param number
|
||||
* @param string
|
||||
* @param Event
|
||||
*/
|
||||
function fileChange(event, maxFileUploads, message) {
|
||||
if (event.target.files.length > maxFileUploads) {
|
||||
alert(message);
|
||||
function fileChange(event, count, countMessage, size, sizeMessage) {
|
||||
if (event.target.files.length > count) {
|
||||
alert(countMessage);
|
||||
} else if (Array.from(event.target.files).reduce((sum, file) => sum + file.size, 0) > size) {
|
||||
alert(sizeMessage);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -96,29 +96,15 @@ function cookie(assign, days) {
|
||||
|
||||
/** Verify current Adminer version
|
||||
* @param string
|
||||
* @param string own URL base
|
||||
* @param string
|
||||
*/
|
||||
function verifyVersion(current, url, token) {
|
||||
function verifyVersion(current) {
|
||||
cookie('adminer_version=0', 1);
|
||||
const iframe = document.createElement('iframe');
|
||||
iframe.src = 'https://www.adminer.org/version/?current=' + current;
|
||||
iframe.frameBorder = 0;
|
||||
iframe.marginHeight = 0;
|
||||
iframe.scrolling = 'no';
|
||||
iframe.style.width = '7ex';
|
||||
iframe.style.height = '1.25em';
|
||||
iframe.style.display = 'none';
|
||||
addEventListener('message', event => {
|
||||
if (event.origin == 'https://www.adminer.org') {
|
||||
const match = /version=(.+)/.exec(event.data);
|
||||
if (match) {
|
||||
cookie('adminer_version=' + match[1], 1);
|
||||
ajax(url + 'script=version', () => { }, event.data + '&token=' + token);
|
||||
}
|
||||
}
|
||||
}, false);
|
||||
qs('#version').appendChild(iframe);
|
||||
// do not send X-Requested-With to avoid preflight
|
||||
fetch('https://www.adminer.org/version/?current=' + current).then(async response => {
|
||||
const json = await response.json();
|
||||
cookie('adminer_version=' + (json.version || current), 7); // empty if there's no newer version
|
||||
qs('#version').textContent = json.version;
|
||||
});
|
||||
}
|
||||
|
||||
/** Get value of select
|
||||
|
||||
@@ -27,12 +27,13 @@ if ($fields) {
|
||||
}
|
||||
|
||||
/** Print links to tables
|
||||
* @param list<string> $tables
|
||||
* @param list<array{table: string, ns: string}> $tables
|
||||
*/
|
||||
function tables_links(array $tables): void {
|
||||
echo "<ul>\n";
|
||||
foreach ($tables as $table) {
|
||||
echo "<li><a href='" . h(ME . "table=" . urlencode($table)) . "'>" . h($table) . "</a>";
|
||||
foreach ($tables as $row) {
|
||||
$link = preg_replace('~ns=[^&]*~', "ns=" . urlencode($row["ns"]), ME);
|
||||
echo "<li><a href='" . h($link . "table=" . urlencode($row["table"])) . "'>" . ($row["ns"] != $_GET["ns"] ? "<b>" . h($row["ns"]) . "</b>." : "") . h($row["table"]) . "</a>";
|
||||
}
|
||||
echo "</ul>\n";
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace Adminer;
|
||||
$status = isset($_GET["status"]);
|
||||
page_header($status ? lang('Status') : lang('Variables'));
|
||||
|
||||
$variables = ($status ? show_status() : show_variables());
|
||||
$variables = ($status ? adminer()->showStatus() : adminer()->showVariables());
|
||||
if (!$variables) {
|
||||
echo "<p class='message'>" . lang('No rows.') . "\n";
|
||||
} else {
|
||||
|
||||
@@ -47,7 +47,7 @@ function put_file($match) {
|
||||
// check function definition in drivers
|
||||
if ($vendor != "mysql") {
|
||||
preg_match_all(
|
||||
'~\bfunction ([^(]+)~',
|
||||
'~\bfunction (?!alter_table|drop_tables|truncate_tables)([^(]+)~', // used for feature detection
|
||||
preg_replace('~class Driver.*\n\t}~sU', '', file_get_contents(__DIR__ . "/adminer/drivers/mysql.inc.php")),
|
||||
$matches
|
||||
); //! respect context (extension, class)
|
||||
@@ -98,7 +98,7 @@ function put_file($match) {
|
||||
echo "lang() not found\n";
|
||||
}
|
||||
} else {
|
||||
$return = preg_replace('~// not used in a single language version from here\n.*~s', '', $return);
|
||||
$return = preg_replace('~// not used in a single language version from here.*~s', '', $return);
|
||||
$return = preg_replace_callback('~(\$pos = (.+\n).+;)~sU', function ($match) {
|
||||
return "\$pos = $match[2]\t\t\t: " . (preg_match("~'$_SESSION[lang]'.* \\? (.+)\n~U", $match[1], $match2) ? $match2[1] : "1") . "\n\t\t);";
|
||||
}, $return);
|
||||
|
||||
@@ -33,7 +33,11 @@
|
||||
"php": ">=7.4"
|
||||
},
|
||||
"scripts": {
|
||||
"clean": "rm -f adminer*.php editor*.php",
|
||||
"compile": "@php compile.php"
|
||||
"check": [
|
||||
"phpcs",
|
||||
"phpstan analyse -c phpstan.neon"
|
||||
],
|
||||
"compile": "@php compile.php",
|
||||
"clean": "rm -f adminer*.php editor*.php"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -185,7 +185,7 @@ table#table thead .checked th {
|
||||
padding: 3rem 0 1.5rem;
|
||||
}
|
||||
|
||||
#menu p, #logins, #tables {
|
||||
#menu p, #tables {
|
||||
padding: .8em 0em 1.2rem;
|
||||
}
|
||||
|
||||
@@ -237,6 +237,14 @@ table#table thead .checked th {
|
||||
background: initial;
|
||||
}
|
||||
|
||||
#logins ul {
|
||||
padding: 3rem 0 1rem;
|
||||
}
|
||||
|
||||
#logins ul li {
|
||||
margin-bottom: .5rem;
|
||||
}
|
||||
|
||||
/*
|
||||
* Elements
|
||||
*/
|
||||
|
||||
@@ -43,8 +43,8 @@ function send_mail(string $email, string $subject, string $message, string $from
|
||||
}
|
||||
|
||||
/** Check whether the column looks like boolean
|
||||
* @param Field $field single field returned from fields()
|
||||
* @param array{type: string} $field single field returned from fields()
|
||||
*/
|
||||
function like_bool(array $field): bool {
|
||||
return preg_match("~bool|(tinyint|bit)\\(1\\)~", $field["full_type"]);
|
||||
return preg_match("~bool|bit~", $field["type"]);
|
||||
}
|
||||
|
||||
@@ -53,13 +53,3 @@ function whisperClick(event) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/** Add new attachment field
|
||||
* @this HTMLInputElement
|
||||
*/
|
||||
function emailFileChange() {
|
||||
const el = this.cloneNode(true);
|
||||
this.onchange = () => { };
|
||||
el.value = '';
|
||||
this.parentNode.appendChild(el);
|
||||
}
|
||||
|
||||
2
externals/jush
vendored
2
externals/jush
vendored
Submodule externals/jush updated: c6618a3016...66b81c4444
@@ -10,7 +10,6 @@ parameters:
|
||||
|
||||
# not real problems
|
||||
- identifier: include.fileNotFound # includes in include/ relative from index.php
|
||||
- identifier: includeOnce.fileNotFound # ./adminer-plugins.php
|
||||
- "~^Function (set_magic_quotes_runtime|mysql_)~" # PHP < 7 functions
|
||||
- "~an unknown class OCI-?Lob~" # this looks like PHPStan bug
|
||||
- "~^Variable \\$error might not be defined~" # declared in bootstrap.inc.php
|
||||
|
||||
@@ -16,7 +16,7 @@ class AdminerDesigns extends Adminer\Plugin {
|
||||
$this->designs = $designs;
|
||||
}
|
||||
|
||||
function headers() {
|
||||
function afterConnect() {
|
||||
if (isset($_POST["design"]) && Adminer\verify_token()) {
|
||||
Adminer\restart_session();
|
||||
$_SESSION["design"] = $_POST["design"];
|
||||
|
||||
@@ -15,14 +15,17 @@ if (isset($_GET["clickhouse"])) {
|
||||
function rootQuery($db, $query) {
|
||||
$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',
|
||||
'content' => $query,
|
||||
'header' => array(
|
||||
'Content-Type: application/x-www-form-urlencoded',
|
||||
'X-ClickHouse-Format: JSONCompact',
|
||||
),
|
||||
'ignore_errors' => 1,
|
||||
'follow_location' => 0,
|
||||
'max_redirects' => 0,
|
||||
))));
|
||||
|
||||
if ($file === false || !preg_match('~^HTTP/[0-9.]+ 2~i', $http_response_header[0])) {
|
||||
if ($file === false || preg_match('~^HTTP/[0-9.]+ 403~i', $http_response_header[0])) {
|
||||
$this->error = lang('Invalid credentials.');
|
||||
return false;
|
||||
}
|
||||
@@ -45,11 +48,18 @@ if (isset($_GET["clickhouse"])) {
|
||||
}
|
||||
}
|
||||
}
|
||||
// 400 == Syntax error
|
||||
// 404 == Unknown expression identifier
|
||||
// 500 == Column 'x' is not under aggregate function and not in GROUP BY keys
|
||||
if (preg_match('~^HTTP/[0-9.]+ [45]~i', $http_response_header[0])) {
|
||||
$this->error = $return['exception'];
|
||||
return false;
|
||||
}
|
||||
return new Result($return);
|
||||
}
|
||||
|
||||
function isQuerySelectLike($query) {
|
||||
return (bool) preg_match('~^(select|show)~i', $query);
|
||||
return (bool) preg_match('~^\s*(select|show|with)~i', $query);
|
||||
}
|
||||
|
||||
function query($query, $unbuffered = false) {
|
||||
@@ -75,7 +85,7 @@ if (isset($_GET["clickhouse"])) {
|
||||
|
||||
class Result {
|
||||
public $num_rows, $columns, $meta;
|
||||
private $rows, $offset = 0;
|
||||
private $rows = array(), $offset = 0;
|
||||
|
||||
function __construct($result) {
|
||||
foreach ($result['data'] as $item) {
|
||||
@@ -243,7 +253,7 @@ if (isset($_GET["clickhouse"])) {
|
||||
}
|
||||
|
||||
function limit($query, $where, $limit, $offset = 0, $separator = " ") {
|
||||
return " $query$where" . ($limit ? $separator . "LIMIT $limit" . ($offset ? ", $offset" : "") : "");
|
||||
return " $query$where" . ($limit ? $separator . "LIMIT " . ($offset ? "$offset, " : "") . $limit : "");
|
||||
}
|
||||
|
||||
function limit1($table, $query, $where, $separator = "\n") {
|
||||
@@ -274,7 +284,7 @@ if (isset($_GET["clickhouse"])) {
|
||||
|
||||
function table_status($name = "", $fast = false) {
|
||||
$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) . ($name != "" ? " AND name = " . q($name) : ""));
|
||||
foreach ($tables as $table) {
|
||||
$return[$table['name']] = array(
|
||||
'Name' => $table['name'],
|
||||
|
||||
@@ -409,7 +409,7 @@ if (isset($_GET["elastic"])) {
|
||||
}
|
||||
|
||||
function view(string $name): array {
|
||||
$return = connection()->rootQuery("_alias/" . urlencode($name) . "");
|
||||
$return = connection()->rootQuery("_alias/" . urlencode($name));
|
||||
return array("select" => implode("\n", array_keys($return)));
|
||||
}
|
||||
|
||||
|
||||
436
plugins/drivers/igdb.php
Normal file
436
plugins/drivers/igdb.php
Normal file
@@ -0,0 +1,436 @@
|
||||
<?php
|
||||
/** Driver for https://api-docs.igdb.com/
|
||||
* @link https://demo.adminer.org/igdb/?igdb=IGDB&db=api
|
||||
* username: your Client-ID
|
||||
* password: your access token from https://id.twitch.tv/oauth2/token
|
||||
* @link https://www.adminer.org/static/plugins/igdb.png
|
||||
*/
|
||||
|
||||
namespace Adminer;
|
||||
|
||||
add_driver("igdb", "APICalypse");
|
||||
|
||||
if (isset($_GET["igdb"])) {
|
||||
define('Adminer\DRIVER', "igdb");
|
||||
|
||||
class Db extends SqlDb {
|
||||
public $extension = "json";
|
||||
public $server_info = "v4";
|
||||
private $username;
|
||||
private $password;
|
||||
|
||||
function attach($server, $username, $password): string {
|
||||
$this->username = $username;
|
||||
$this->password = $password;
|
||||
return '';
|
||||
}
|
||||
|
||||
function select_db($database) {
|
||||
return ($database == "api");
|
||||
}
|
||||
|
||||
function request($endpoint, $query, $method = 'POST') {
|
||||
$context = stream_context_create(array('http' => array(
|
||||
'method' => $method,
|
||||
'header' => array(
|
||||
"Content-Type: text/plain",
|
||||
"Client-ID: $this->username",
|
||||
"Authorization: Bearer $this->password",
|
||||
),
|
||||
'content' => $query,
|
||||
'ignore_errors' => true,
|
||||
)));
|
||||
$response = file_get_contents("https://api.igdb.com/v4/$endpoint", false, $context);
|
||||
$return = json_decode($response, true);
|
||||
if ($http_response_header[0] != 'HTTP/1.1 200 OK') {
|
||||
if (is_array($return)) {
|
||||
foreach (is_array($return[0]) ? $return : array($return) as $rows) {
|
||||
foreach ($rows as $key => $val) {
|
||||
$this->error .= '<b>' . h($key) . ':</b> ' . (is_url($val) ? '<a href="' . h($val) . '"' . target_blank() . '>' . h($val) . '</a>' : h($val)) . '<br>';
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->error = htmlspecialchars(strip_tags($response), 0, null, false);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
function query($query, $unbuffered = false) {
|
||||
if (preg_match('~^SELECT COUNT\(\*\) FROM (\w+)( WHERE ((MATCH \(search\) AGAINST \((.+)\))|.+))?$~', $query, $match)) {
|
||||
return new Result(array($this->request("$match[1]/count", ($match[5] ? 'search "' . addcslashes($match[5], '\\"') . '";'
|
||||
: ($match[3] ? 'where ' . str_replace(' AND ', ' & ', $match[3]) . ';'
|
||||
: ''
|
||||
)))));
|
||||
}
|
||||
if (preg_match('~^\s*(GET|POST|DELETE)\s+([\w/?=]+)\s*;\s*(.*)$~s', $query, $match)) {
|
||||
$endpoint = $match[2];
|
||||
$response = $this->request($endpoint, $match[3], $match[1]);
|
||||
if ($response === false) {
|
||||
return $response;
|
||||
}
|
||||
$return = new Result(is_array($response[0]) ? $response : array($response));
|
||||
$return->table = $endpoint;
|
||||
if ($endpoint == 'multiquery') {
|
||||
$return->results = $response;
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
$this->error = "Syntax:<br>POST <endpoint>; fields ...;";
|
||||
return false;
|
||||
}
|
||||
|
||||
function store_result() {
|
||||
if ($this->multi && ($result = current($this->multi->results))) {
|
||||
echo "<h3>" . h($result['name']) . "</h3>\n";
|
||||
$this->multi->__construct($result['count'] ? array(array('count' => $result['count'])) : $result['result']);
|
||||
}
|
||||
return $this->multi;
|
||||
}
|
||||
|
||||
function next_result(): bool {
|
||||
return $this->multi && next($this->multi->results);
|
||||
}
|
||||
|
||||
function quote($string): string {
|
||||
return $string;
|
||||
}
|
||||
}
|
||||
|
||||
class Result {
|
||||
public $num_rows;
|
||||
public $table;
|
||||
public $results = array();
|
||||
private $result;
|
||||
private $fields;
|
||||
|
||||
function __construct($result) {
|
||||
$keys = array();
|
||||
foreach ($result as $i => $row) {
|
||||
foreach ($row as $key => $val) {
|
||||
$keys[$key] = null;
|
||||
if (is_array($val) && is_int($val[0])) {
|
||||
$result[$i][$key] = "(" . implode(",", $val) . ")";
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach ($result as $i => $row) {
|
||||
$result[$i] = array_merge($keys, $row);
|
||||
}
|
||||
$this->result = $result;
|
||||
$this->num_rows = count($result);
|
||||
$this->fields = array_keys(idx($result, 0, array()));
|
||||
}
|
||||
|
||||
function fetch_assoc() {
|
||||
$row = current($this->result);
|
||||
next($this->result);
|
||||
return $row;
|
||||
}
|
||||
|
||||
function fetch_row() {
|
||||
$row = $this->fetch_assoc();
|
||||
return ($row ? array_values($row) : false);
|
||||
}
|
||||
|
||||
function fetch_field(): \stdClass {
|
||||
$field = current($this->fields);
|
||||
next($this->fields);
|
||||
return ($field != '' ? (object) array('name' => $field, 'type' => 15, 'charsetnr' => 0, 'orgtable' => $this->table) : false);
|
||||
}
|
||||
}
|
||||
|
||||
class Driver extends SqlDriver {
|
||||
static $extensions = array("json");
|
||||
static $jush = "igdb";
|
||||
private static $docsFilename = __DIR__ . DIRECTORY_SEPARATOR . 'igdb-api.html';
|
||||
|
||||
public $delimiter = ";;";
|
||||
public $operators = array("=", "<", ">", "<=", ">=", "!=", "~");
|
||||
|
||||
public $tables = array();
|
||||
public $links = array();
|
||||
public $fields = array();
|
||||
public $foreignKeys = array();
|
||||
public $foundRows = null;
|
||||
|
||||
static function connect(string $server, string $username, string $password) {
|
||||
if (!file_exists(self::$docsFilename)) {
|
||||
return "Download https://api-docs.igdb.com/ and save it as " . self::$docsFilename; // copy() doesn't work - bot protection
|
||||
}
|
||||
return parent::connect($server, $username, $password);
|
||||
}
|
||||
|
||||
function __construct($connection) {
|
||||
parent::__construct($connection);
|
||||
libxml_use_internal_errors(true);
|
||||
$dom = new \DOMDocument();
|
||||
$dom->loadHTMLFile(self::$docsFilename);
|
||||
$xpath = new \DOMXPath($dom);
|
||||
$els = $xpath->query('//div[@class="content"]/*');
|
||||
$link = '';
|
||||
foreach ($els as $i => $el) {
|
||||
if ($el->tagName == 'h2') {
|
||||
$link = $el->getAttribute('id');
|
||||
}
|
||||
if ($el->nodeValue == 'Request Path') {
|
||||
$table = preg_replace('~^https://api.igdb.com/v4/~', '', $els[$i+1]->firstElementChild->nodeValue);
|
||||
$comment = $els[$i-1]->tagName == 'p' ? $els[$i-1]->nodeValue : '';
|
||||
if (preg_match('~^DEPRECATED!~', $comment)) {
|
||||
continue;
|
||||
}
|
||||
$this->fields[$table]['id'] = array('full_type' => 'bigint', 'comment' => '');
|
||||
$this->links[$link] = $table;
|
||||
$this->tables[$table] = array('Name' => $table, 'Comment' => $comment);
|
||||
foreach ($xpath->query('tbody/tr', $els[$i+2]) as $tr) {
|
||||
$tds = $xpath->query('td', $tr);
|
||||
$field = $tds[0]->nodeValue;
|
||||
$comment = $tds[2]->nodeValue;
|
||||
if ($field != 'checksum' && $field != 'content_descriptions' && !preg_match('~^DEPRECATED!~', $comment)) {
|
||||
$this->fields[$table][$field] = array(
|
||||
'full_type' => str_replace(' ', ' ', $tds[1]->nodeValue),
|
||||
'comment' => str_replace(' ', ' ', $comment),
|
||||
);
|
||||
$ref = $xpath->query('a/@href', $tds[1]);
|
||||
if (count($ref) && !in_array($ref[0]->value, array('#game-version-feature-enums', '#tag-numbers'))) {
|
||||
$this->foreignKeys[$table][$field] = substr($ref[0]->value, 1);
|
||||
} elseif ($field === 'game_id') { // game_time_to_beats, popularity_primitives
|
||||
$this->foreignKeys[$table][$field] = 'game';
|
||||
}
|
||||
}
|
||||
}
|
||||
uksort($this->fields[$table], function ($a, $b) use ($table) {
|
||||
return (($b == 'id') - ($a == 'id'))
|
||||
?: (($b == 'name') - ($a == 'name'))
|
||||
?: (($a == 'updated_at') - ($b == 'updated_at'))
|
||||
?: (($a == 'created_at') - ($b == 'created_at'))
|
||||
?: (!idx($this->foreignKeys[$table], $b) - !idx($this->foreignKeys[$table], $a))
|
||||
?: ($a < $b ? -1 : 1)
|
||||
;
|
||||
});
|
||||
}
|
||||
}
|
||||
$this->tables['webhooks'] = array('Name' => 'webhooks', 'Comment' => 'Webhooks allow us to push data to you when it is added, updated, or deleted');
|
||||
$this->links['webhooks'] = 'webhooks';
|
||||
$this->fields['webhooks'] = array(
|
||||
'endpoint' => array(
|
||||
'full_type' => 'String',
|
||||
'comment' => 'Specify what type of data you want from your webhook',
|
||||
'privileges' => array('insert' => 1),
|
||||
),
|
||||
'id' => array('comment' => 'A unique ID for the webhook'),
|
||||
'url' => array(
|
||||
'full_type' => 'String',
|
||||
'length' => '100',
|
||||
'comment' => 'Your prepared url that is ready to accept data from us',
|
||||
'privileges' => array('select' => 1, 'insert' => 1),
|
||||
),
|
||||
'method' => array(
|
||||
'full_type' => 'enum',
|
||||
'length' => "('create','delete','update')",
|
||||
'comment' => 'The type of data you are expecting to your url, there are three types of methods',
|
||||
'privileges' => array('insert' => 1),
|
||||
),
|
||||
'category' => array('comment' => 'Based on the endpoint you chose'),
|
||||
'sub_category' => array('comment' => 'Based on your method (can be 0, 1, 2)'),
|
||||
'active' => array('comment' => 'Is the webhook currently active'),
|
||||
'api_key' => array('comment' => 'Displays the api key the webhook is connected to'),
|
||||
'secret' => array(
|
||||
'full_type' => 'String',
|
||||
'comment' => 'Your “secret” password for your webhook',
|
||||
'privileges' => array('select' => 1, 'insert' => 1),
|
||||
),
|
||||
'created_at' => array('comment' => 'Created at date'),
|
||||
'updated_at' => array('comment' => 'Updated at date'),
|
||||
);
|
||||
}
|
||||
|
||||
function select($table, $select, $where, $group, $order = array(), $limit = 1, $page = 0, $print = false) {
|
||||
$query = '';
|
||||
$search = preg_match('~^MATCH \(search\) AGAINST \((.+)\)$~', $where[0], $match);
|
||||
if ($search) {
|
||||
$query = 'search "' . addcslashes($match[1], '\\"') . "\";\n";
|
||||
unset($where[0]);
|
||||
}
|
||||
foreach ($where as $i => $val) {
|
||||
$where[$i] = str_replace(' OR ', ' | ', $val);
|
||||
}
|
||||
$columns = ($select != array('*') ? $select : array_keys($this->fields[$table]));
|
||||
$common = ($where ? "\nwhere " . implode(" & ", $where) . ";" : "");
|
||||
if ($table != 'webhooks') {
|
||||
$query .= "fields " . implode(",", $select) . ";"
|
||||
. ($select == array('*') ? "\nexclude checksum;" : "")
|
||||
. $common
|
||||
. ($order ? "\nsort " . strtolower(implode(",", $order)) . ";" : "")
|
||||
. "\nlimit $limit;"
|
||||
. ($page ? "\noffset " . ($page * $limit) . ";" : "")
|
||||
;
|
||||
}
|
||||
$start = microtime(true);
|
||||
$multi = (!$search && $table != 'webhooks' && array_key_exists($table, driver()->tables));
|
||||
$method = ($table == 'webhooks' ? 'GET' : 'POST');
|
||||
$realQuery = str_replace("*;\nexclude checksum", implode(',', $columns), $query); // exclude deprecated columns
|
||||
$return = ($multi
|
||||
? $this->conn->request('multiquery', "query $table \"result\" { $realQuery };\nquery $table/count \"count\" { $common };")
|
||||
: $this->conn->request($table, $realQuery, $method)
|
||||
);
|
||||
if ($print) {
|
||||
echo adminer()->selectQuery("$method $table;\n$query", $start);
|
||||
}
|
||||
if ($return === false) {
|
||||
return $return;
|
||||
}
|
||||
$this->foundRows = ($multi ? $return[1]['count'] : null);
|
||||
$return = ($multi ? $return[0]['result'] : $return);
|
||||
if ($return && $table != 'webhooks') {
|
||||
$return[0] = array_merge(array_fill_keys($columns, null), $return[0]);
|
||||
}
|
||||
return new Result($return);
|
||||
}
|
||||
|
||||
function insert($table, $set) {
|
||||
$content = array();
|
||||
foreach ($set as $key => $val) {
|
||||
if ($key != 'endpoint') {
|
||||
$content[] = urlencode($key) . '=' . urlencode($val);
|
||||
}
|
||||
}
|
||||
return queries("POST $set[endpoint]/$table; " . implode('&', $content));
|
||||
}
|
||||
|
||||
function delete($table, $queryWhere, $limit = 0) {
|
||||
preg_match_all('~\bid = (\d+)~', $queryWhere, $matches);
|
||||
$this->conn->affected_rows = 0;
|
||||
foreach ($matches[1] as $id) {
|
||||
$result = queries("DELETE $table/$id;");
|
||||
if (!$result) {
|
||||
return false;
|
||||
}
|
||||
$row = $result->fetch_row();
|
||||
if (!$row[0]) {
|
||||
$this->conn->error = "ID $id not found.";
|
||||
return false;
|
||||
}
|
||||
$this->conn->affected_rows++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function value($val, $field): ?string {
|
||||
return ($val && in_array($field['full_type'], array('Unix Time Stamp', 'datetime')) ? str_replace(' 00:00:00', '', gmdate('Y-m-d H:i:s', $val)) : $val);
|
||||
}
|
||||
|
||||
function tableHelp($name, $is_view = false) {
|
||||
return strtolower("https://api-docs.igdb.com/#" . array_search($name, $this->links));
|
||||
}
|
||||
}
|
||||
|
||||
function logged_user() {
|
||||
return $_GET["username"];
|
||||
}
|
||||
|
||||
function get_databases($flush) {
|
||||
return array("api");
|
||||
}
|
||||
|
||||
function collations() {
|
||||
return array();
|
||||
}
|
||||
|
||||
function db_collation($db, $collations) {
|
||||
}
|
||||
|
||||
function information_schema($db) {
|
||||
}
|
||||
|
||||
function indexes($table, $connection2 = null) {
|
||||
$return = array(array("type" => "PRIMARY", "columns" => array("id")));
|
||||
if (in_array($table, array('characters', 'collections', 'games', 'platforms', 'themes'))) { // https://api-docs.igdb.com/#search-1
|
||||
$return[] = array("type" => "FULLTEXT", "columns" => array("search"));
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
function fields($table) {
|
||||
$return = array();
|
||||
foreach (driver()->fields[$table] ?: array() as $key => $val) {
|
||||
$type = strtolower(preg_replace('~ .*~', '', $val['full_type']));
|
||||
$return[$key] = $val + array(
|
||||
"field" => $key,
|
||||
"type" => ($type == 'reference' ? 'int' : $type), // align right reference columns
|
||||
"privileges" => array("select" => 1) + ($table == 'webhooks' ? array() : array("where" => 1, "order" => 1)),
|
||||
);
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
function convert_field($field) {
|
||||
}
|
||||
|
||||
function unconvert_field($field, $return) {
|
||||
return $return;
|
||||
}
|
||||
|
||||
function limit($query, $where, $limit, $offset = 0, $separator = " ") {
|
||||
return $query;
|
||||
}
|
||||
|
||||
function idf_escape($idf) {
|
||||
return $idf;
|
||||
}
|
||||
|
||||
function table($idf) {
|
||||
return idf_escape($idf);
|
||||
}
|
||||
|
||||
function foreign_keys($table) {
|
||||
$return = array();
|
||||
foreach (driver()->foreignKeys[$table] ?: array() as $key => $val) {
|
||||
$return[] = array(
|
||||
'table' => driver()->links[$val],
|
||||
'source' => array($key),
|
||||
'target' => array('id'),
|
||||
);
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
function tables_list() {
|
||||
return array_fill_keys(array_keys(table_status()), 'table');
|
||||
}
|
||||
|
||||
function table_status($name = "", $fast = false) {
|
||||
$tables = driver()->tables;
|
||||
return ($name != '' ? ($tables[$name] ? array($name => $tables[$name]) : array()) : $tables);
|
||||
}
|
||||
|
||||
function count_tables($databases) {
|
||||
return array(reset($databases) => count(tables_list()));
|
||||
}
|
||||
|
||||
function error() {
|
||||
return connection()->error;
|
||||
}
|
||||
|
||||
function is_view($table_status) {
|
||||
return false;
|
||||
}
|
||||
|
||||
function found_rows($table_status, $where) {
|
||||
return driver()->foundRows;
|
||||
}
|
||||
|
||||
function fk_support($table_status) {
|
||||
return true;
|
||||
}
|
||||
|
||||
function last_id($result): string {
|
||||
$row = $result->fetch_assoc();
|
||||
return (string) $row['id'];
|
||||
}
|
||||
|
||||
function support($feature) {
|
||||
return in_array($feature, array('columns', 'comment', 'sql', 'table'));
|
||||
}
|
||||
}
|
||||
@@ -11,23 +11,23 @@ class AdminerEnumOption extends Adminer\Plugin {
|
||||
function editInput($table, $field, $attrs, $value) {
|
||||
if ($field["type"] == "enum") {
|
||||
$options = array();
|
||||
$selected = $value;
|
||||
$selected = "val-$value";
|
||||
if (isset($_GET["select"])) {
|
||||
$options[-1] = Adminer\lang('original');
|
||||
if ($selected === null) {
|
||||
$selected = -1;
|
||||
$options["orig"] = Adminer\lang('original');
|
||||
if ($value === null) {
|
||||
$selected = "orig";
|
||||
}
|
||||
}
|
||||
if ($field["null"]) {
|
||||
$options[""] = "NULL";
|
||||
if ($selected === null) {
|
||||
$selected = "";
|
||||
$options["null"] = "NULL";
|
||||
if ($value === null) {
|
||||
$selected = "null";
|
||||
}
|
||||
}
|
||||
preg_match_all("~'((?:[^']|'')*)'~", $field["length"], $matches);
|
||||
foreach ($matches[1] as $val) {
|
||||
$val = stripcslashes(str_replace("''", "'", $val));
|
||||
$options[$val] = $val;
|
||||
$options["val-$val"] = $val;
|
||||
}
|
||||
return "<select$attrs>" . Adminer\optionlist($options, $selected, 1) . "</select>"; // 1 - use keys
|
||||
}
|
||||
|
||||
@@ -13,7 +13,10 @@ class AdminerRowNumbers extends Adminer\Plugin {
|
||||
}
|
||||
|
||||
function backwardKeysPrint($backwardKeys, $row) {
|
||||
static $n = $_GET["page"] * Adminer\adminer()->selectLimitProcess();
|
||||
static $n;
|
||||
if (!$n) {
|
||||
$n = $_GET["page"] * Adminer\adminer()->selectLimitProcess();
|
||||
}
|
||||
$n++;
|
||||
echo "$n.\n";
|
||||
}
|
||||
|
||||
@@ -11,13 +11,12 @@ class AdminerVersionGithub extends Adminer\Plugin {
|
||||
function head($dark = null) {
|
||||
?>
|
||||
<script <?php echo Adminer\nonce(); ?>>
|
||||
verifyVersion = (current, url, token) => {
|
||||
verifyVersion = current => {
|
||||
// dummy value to prevent repeated verifications after AJAX failure
|
||||
cookie('adminer_version=0', 1);
|
||||
ajax('https://api.github.com/repos/vrana/adminer/releases/latest', request => {
|
||||
const response = JSON.parse(request.responseText);
|
||||
const version = response.tag_name.replace(/^v/, '');
|
||||
// we don't save to adminer.version because the response is not signed; also GitHub can handle our volume of requests
|
||||
// we don't display the version here because we don't have version_compare(); design.inc.php will display it on the next load
|
||||
cookie('adminer_version=' + version, 1);
|
||||
}, null, null);
|
||||
|
||||
@@ -349,7 +349,7 @@
|
||||
<tr><td>clickAndWait</td><td>//input[@value='Save']</td><td></td></tr>
|
||||
<tr><td>verifyTextPresent</td><td>Indexes have been altered.</td><td></td></tr>
|
||||
<tr><td>click</td><td>link=New item</td><td></td></tr>
|
||||
<tr><td>verifyTextNotPresent</td><td>stored</td><td></td></tr>
|
||||
<tr><td>verifyElementNotPresent</td><td>fields[stored]</td><td></td></tr>
|
||||
<tr><td>type</td><td>name=fields[normal]</td><td>20</td></tr>
|
||||
<tr><td>click</td><td>//input[@value='Save']</td><td></td></tr>
|
||||
<tr><td>verifyTextPresent</td><td>220</td><td></td></tr>
|
||||
|
||||
@@ -412,8 +412,8 @@
|
||||
<tr><td>clickAndWait</td><td>//input[@value='Save']</td><td></td></tr>
|
||||
<tr><td>verifyTextPresent</td><td>Indexes have been altered.</td><td></td></tr>
|
||||
<tr><td>click</td><td>link=New item</td><td></td></tr>
|
||||
<tr><td>verifyTextNotPresent</td><td>virtual</td><td></td></tr>
|
||||
<tr><td>verifyTextNotPresent</td><td>stored</td><td></td></tr>
|
||||
<tr><td>verifyElementNotPresent</td><td>fields[virtual]</td><td></td></tr>
|
||||
<tr><td>verifyElementNotPresent</td><td>fields[stored]</td><td></td></tr>
|
||||
<tr><td>type</td><td>name=fields[normal]</td><td>20</td></tr>
|
||||
<tr><td>click</td><td>//input[@value='Save']</td><td></td></tr>
|
||||
<tr><td>verifyTextPresent</td><td>120</td><td></td></tr>
|
||||
|
||||
@@ -282,8 +282,8 @@
|
||||
<tr><td>clickAndWait</td><td>//input[@value='Save']</td><td></td></tr>
|
||||
<tr><td>verifyTextPresent</td><td>Indexes have been altered.</td><td></td></tr>
|
||||
<tr><td>click</td><td>link=New item</td><td></td></tr>
|
||||
<tr><td>verifyTextNotPresent</td><td>virtual</td><td></td></tr>
|
||||
<tr><td>verifyTextNotPresent</td><td>stored</td><td></td></tr>
|
||||
<tr><td>verifyElementNotPresent</td><td>fields[virtual]</td><td></td></tr>
|
||||
<tr><td>verifyElementNotPresent</td><td>fields[stored]</td><td></td></tr>
|
||||
<tr><td>type</td><td>name=fields[normal]</td><td>20</td></tr>
|
||||
<tr><td>click</td><td>//input[@value='Save']</td><td></td></tr>
|
||||
<tr><td>verifyTextPresent</td><td>120</td><td></td></tr>
|
||||
|
||||
@@ -418,8 +418,8 @@
|
||||
<tr><td>clickAndWait</td><td>//input[@value='Save']</td><td></td></tr>
|
||||
<tr><td>verifyTextPresent</td><td>Indexes have been altered.</td><td></td></tr>
|
||||
<tr><td>click</td><td>link=New item</td><td></td></tr>
|
||||
<tr><td>verifyTextNotPresent</td><td>virtual</td><td></td></tr>
|
||||
<tr><td>verifyTextNotPresent</td><td>stored</td><td></td></tr>
|
||||
<tr><td>verifyElementNotPresent</td><td>fields[virtual]</td><td></td></tr>
|
||||
<tr><td>verifyElementNotPresent</td><td>fields[stored]</td><td></td></tr>
|
||||
<tr><td>type</td><td>name=fields[normal]</td><td>20</td></tr>
|
||||
<tr><td>click</td><td>//input[@value='Save']</td><td></td></tr>
|
||||
<tr><td>verifyTextPresent</td><td>120</td><td></td></tr>
|
||||
|
||||
@@ -358,7 +358,7 @@
|
||||
<tr><td>clickAndWait</td><td>//input[@value='Save']</td><td></td></tr>
|
||||
<tr><td>verifyTextPresent</td><td>Indexes have been altered.</td><td></td></tr>
|
||||
<tr><td>click</td><td>link=New item</td><td></td></tr>
|
||||
<tr><td>verifyTextNotPresent</td><td>stored</td><td></td></tr>
|
||||
<tr><td>verifyElementNotPresent</td><td>fields[stored]</td><td></td></tr>
|
||||
<tr><td>type</td><td>name=fields[normal]</td><td>20</td></tr>
|
||||
<tr><td>click</td><td>//input[@value='Save']</td><td></td></tr>
|
||||
<tr><td>verifyTextPresent</td><td>220</td><td></td></tr>
|
||||
|
||||
@@ -288,7 +288,7 @@
|
||||
<tr><td>clickAndWait</td><td>//input[@value='Save']</td><td></td></tr>
|
||||
<tr><td>verifyTextPresent</td><td>Indexes have been altered.</td><td></td></tr>
|
||||
<tr><td>click</td><td>link=New item</td><td></td></tr>
|
||||
<tr><td>verifyTextNotPresent</td><td>stored</td><td></td></tr>
|
||||
<tr><td>verifyElementNotPresent</td><td>fields[stored]</td><td></td></tr>
|
||||
<tr><td>type</td><td>name=fields[normal]</td><td>20</td></tr>
|
||||
<tr><td>click</td><td>//input[@value='Save']</td><td></td></tr>
|
||||
<tr><td>verifyTextPresent</td><td>220</td><td></td></tr>
|
||||
|
||||
Reference in New Issue
Block a user