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

Specify coding style and follow it

This commit is contained in:
Jakub Vrana
2025-03-05 09:14:49 +01:00
parent 422668f2d7
commit c52ba0308e
27 changed files with 226 additions and 126 deletions

View File

@@ -7,7 +7,7 @@ end_of_line = lf
insert_final_newline = true insert_final_newline = true
trim_trailing_whitespace = true trim_trailing_whitespace = true
[*.{php,css,js}] [*.{php,css,js,xml}]
indent_style = tab indent_style = tab
[*.json] [*.json]

View File

@@ -101,9 +101,10 @@ echo
$first_row = pre_tr($match[2]); $first_row = pre_tr($match[2]);
return "<table>\n" . ($match[1] ? "<thead>$first_row</thead>\n" : $first_row) . pre_tr($match[4]) . "\n</table>"; return "<table>\n" . ($match[1] ? "<thead>$first_row</thead>\n" : $first_row) . pre_tr($match[4]) . "\n</table>";
}, },
preg_replace('~(\n( -|mysql)&gt; )(.+)~', "\\1<code class='jush-sql'>\\3</code>", preg_replace(
preg_replace('~(.+)\n---+\n~', "<b>\\1</b>\n", '~(\n( -|mysql)&gt; )(.+)~',
h($routine['comment']) "\\1<code class='jush-sql'>\\3</code>",
))); preg_replace('~(.+)\n---+\n~', "<b>\\1</b>\n", h($routine['comment']))
));
?> ?>
</pre> </pre>

View File

@@ -188,8 +188,8 @@ foreach ($engines as $engine) {
<div class="scrollable"> <div class="scrollable">
<table id="edit-fields" class="nowrap"> <table id="edit-fields" class="nowrap">
<?php <?php
edit_fields($row["fields"], $collations, "TABLE", $foreign_keys); edit_fields($row["fields"], $collations, "TABLE", $foreign_keys);
?> ?>
</table> </table>
<?php echo script("editFields();"); ?> <?php echo script("editFields();"); ?>
</div> </div>
@@ -197,16 +197,16 @@ edit_fields($row["fields"], $collations, "TABLE", $foreign_keys);
<?php echo lang('Auto Increment'); ?>: <input type="number" name="Auto_increment" class="size" value="<?php echo h($row["Auto_increment"]); ?>"> <?php echo lang('Auto Increment'); ?>: <input type="number" name="Auto_increment" class="size" value="<?php echo h($row["Auto_increment"]); ?>">
<?php echo checkbox("defaults", 1, ($_POST ? $_POST["defaults"] : adminer_setting("defaults")), lang('Default values'), "columnShow(this.checked, 5)", "jsonly"); ?> <?php echo checkbox("defaults", 1, ($_POST ? $_POST["defaults"] : adminer_setting("defaults")), lang('Default values'), "columnShow(this.checked, 5)", "jsonly"); ?>
<?php <?php
$comments = ($_POST ? $_POST["comments"] : adminer_setting("comments")); $comments = ($_POST ? $_POST["comments"] : adminer_setting("comments"));
echo (support("comment") echo (support("comment")
? checkbox("comments", 1, $comments, lang('Comment'), "editingCommentsClick(this, true);", "jsonly") ? checkbox("comments", 1, $comments, lang('Comment'), "editingCommentsClick(this, true);", "jsonly")
. ' ' . (preg_match('~\n~', $row["Comment"]) . ' ' . (preg_match('~\n~', $row["Comment"])
? "<textarea name='Comment' rows='2' cols='20'" . ($comments ? "" : " class='hidden'") . ">" . h($row["Comment"]) . "</textarea>" ? "<textarea name='Comment' rows='2' cols='20'" . ($comments ? "" : " class='hidden'") . ">" . h($row["Comment"]) . "</textarea>"
: '<input name="Comment" value="' . h($row["Comment"]) . '" data-maxlength="' . (min_version(5.5) ? 2048 : 60) . '"' . ($comments ? "" : " class='hidden'") . '>' : '<input name="Comment" value="' . h($row["Comment"]) . '" data-maxlength="' . (min_version(5.5) ? 2048 : 60) . '"' . ($comments ? "" : " class='hidden'") . '>'
) )
: '') : '')
; ;
?> ?>
<p> <p>
<input type="submit" value="<?php echo lang('Save'); ?>"> <input type="submit" value="<?php echo lang('Save'); ?>">
<?php } ?> <?php } ?>
@@ -224,13 +224,13 @@ if (support("partitioning")) {
<table id="partition-table"<?php echo ($partition_table ? "" : " class='hidden'"); ?>> <table id="partition-table"<?php echo ($partition_table ? "" : " class='hidden'"); ?>>
<thead><tr><th><?php echo lang('Partition name'); ?><th><?php echo lang('Values'); ?></thead> <thead><tr><th><?php echo lang('Partition name'); ?><th><?php echo lang('Values'); ?></thead>
<?php <?php
foreach ($row["partition_names"] as $key => $val) { foreach ($row["partition_names"] as $key => $val) {
echo '<tr>'; echo '<tr>';
echo '<td><input name="partition_names[]" value="' . h($val) . '" autocapitalize="off">'; echo '<td><input name="partition_names[]" value="' . h($val) . '" autocapitalize="off">';
echo ($key == count($row["partition_names"]) - 1 ? script("qsl('input').oninput = partitionNameChange;") : ''); echo ($key == count($row["partition_names"]) - 1 ? script("qsl('input').oninput = partitionNameChange;") : '');
echo '<td><input name="partition_values[]" value="' . h($row["partition_values"][$key]) . '">'; echo '<td><input name="partition_values[]" value="' . h($row["partition_values"][$key]) . '">';
} }
?> ?>
</table> </table>
</div></fieldset> </div></fieldset>
<?php <?php

View File

@@ -376,7 +376,6 @@ if (isset($_GET["mongo"])) {
"(date)>=", "(date)>=",
"(date)<=", "(date)<=",
); );
} }
function table($idf) { function table($idf) {

View File

@@ -367,8 +367,7 @@ WHERE o.schema_id = SCHEMA_ID(" . q(get_schema()) . ") AND o.type IN ('S', 'U',
FROM sys.indexes i FROM sys.indexes i
INNER JOIN sys.index_columns ic ON i.object_id = ic.object_id AND i.index_id = ic.index_id INNER JOIN sys.index_columns ic ON i.object_id = ic.object_id AND i.index_id = ic.index_id
INNER JOIN sys.columns c ON ic.object_id = c.object_id AND ic.column_id = c.column_id INNER JOIN sys.columns c ON ic.object_id = c.object_id AND ic.column_id = c.column_id
WHERE OBJECT_NAME(i.object_id) = " . q($table) WHERE OBJECT_NAME(i.object_id) = " . q($table), $connection2) as $row) {
, $connection2) as $row) {
$name = $row["name"]; $name = $row["name"];
$return[$name]["type"] = ($row["is_primary_key"] ? "PRIMARY" : ($row["is_unique"] ? "UNIQUE" : "INDEX")); $return[$name]["type"] = ($row["is_primary_key"] ? "PRIMARY" : ($row["is_unique"] ? "UNIQUE" : "INDEX"));
$return[$name]["lengths"] = array(); $return[$name]["lengths"] = array();

View File

@@ -1152,7 +1152,7 @@ if (!defined("DRIVER")) {
/** Return query to get connection ID /** Return query to get connection ID
* @return string * @return string
*/ */
function connection_id(){ function connection_id() {
return "SELECT CONNECTION_ID()"; return "SELECT CONNECTION_ID()";
} }

View File

@@ -902,7 +902,7 @@ AND typelem = 0"
return queries("SELECT pg_terminate_backend(" . number($val) . ")"); return queries("SELECT pg_terminate_backend(" . number($val) . ")");
} }
function connection_id(){ function connection_id() {
return "SELECT pg_backend_pid()"; return "SELECT pg_backend_pid()";
} }

View File

@@ -10,7 +10,8 @@ if ($_POST && !$error) {
$tables = array_flip((array) $_POST["tables"]) + array_flip((array) $_POST["data"]); $tables = array_flip((array) $_POST["tables"]) + array_flip((array) $_POST["data"]);
$ext = dump_headers( $ext = dump_headers(
(count($tables) == 1 ? key($tables) : DB), (count($tables) == 1 ? key($tables) : DB),
(DB == "" || count($tables) > 1)); (DB == "" || count($tables) > 1)
);
$is_sql = preg_match('~sql~', $_POST["format"]); $is_sql = preg_match('~sql~', $_POST["format"]);
if ($is_sql) { if ($is_sql) {

View File

@@ -16,11 +16,21 @@ if ($_GET["file"] == "favicon.ico") {
} else { } else {
header("Content-Type: image/gif"); header("Content-Type: image/gif");
switch ($_GET["file"]) { switch ($_GET["file"]) {
case "plus.gif": echo compile_file('../adminer/static/plus.gif'); break; case "plus.gif":
case "cross.gif": echo compile_file('../adminer/static/cross.gif'); break; echo compile_file('../adminer/static/plus.gif');
case "up.gif": echo compile_file('../adminer/static/up.gif'); break; break;
case "down.gif": echo compile_file('../adminer/static/down.gif'); break; case "cross.gif":
case "arrow.gif": echo compile_file('../adminer/static/arrow.gif'); break; echo compile_file('../adminer/static/cross.gif');
break;
case "up.gif":
echo compile_file('../adminer/static/up.gif');
break;
case "down.gif":
echo compile_file('../adminer/static/down.gif');
break;
case "arrow.gif":
echo compile_file('../adminer/static/arrow.gif');
break;
} }
} }
exit; exit;

View File

@@ -370,9 +370,11 @@ function edit_fields($fields, $collations, $type = "TABLE", $foreign_keys = arra
<?php echo ($type == "PROCEDURE" ? "<td>" . html_select("fields[$i][inout]", explode("|", $inout), $field["inout"]) : ""); ?> <?php echo ($type == "PROCEDURE" ? "<td>" . html_select("fields[$i][inout]", explode("|", $inout), $field["inout"]) : ""); ?>
<th><?php if ($display) { ?><input name="fields[<?php echo $i; ?>][field]" value="<?php echo h($field["field"]); ?>" data-maxlength="64" autocapitalize="off" aria-labelledby="label-name"><?php } ?> <th><?php if ($display) { ?><input name="fields[<?php echo $i; ?>][field]" value="<?php echo h($field["field"]); ?>" data-maxlength="64" autocapitalize="off" aria-labelledby="label-name"><?php } ?>
<input type="hidden" name="fields[<?php echo $i; ?>][orig]" value="<?php echo h($orig); ?>"><?php edit_type("fields[$i]", $field, $collations, $foreign_keys); ?> <input type="hidden" name="fields[<?php echo $i; ?>][orig]" value="<?php echo h($orig); ?>"><?php edit_type("fields[$i]", $field, $collations, $foreign_keys); ?>
<?php if ($type == "TABLE") { ?> <?php
if ($type == "TABLE") {
?>
<td><?php echo checkbox("fields[$i][null]", 1, $field["null"], "", "", "block", "label-null"); ?> <td><?php echo checkbox("fields[$i][null]", 1, $field["null"], "", "", "block", "label-null"); ?>
<td><label class="block"><input type="radio" name="auto_increment_col" value="<?php echo $i; ?>"<?php if ($field["auto_increment"]) { ?> checked<?php } ?> aria-labelledby="label-ai"></label><td<?php echo $default_class; ?>><?php <td><label class="block"><input type="radio" name="auto_increment_col" value="<?php echo $i; ?>"<?php echo ($field["auto_increment"] ? " checked" : ""); ?> aria-labelledby="label-ai"></label><td<?php echo $default_class; ?>><?php
echo checkbox("fields[$i][has_default]", 1, $field["has_default"], "", "", "", "label-default"); ?><input name="fields[<?php echo $i; ?>][default]" value="<?php echo h($field["default"]); ?>" aria-labelledby="label-default"><?php echo checkbox("fields[$i][has_default]", 1, $field["has_default"], "", "", "", "label-default"); ?><input name="fields[<?php echo $i; ?>][default]" value="<?php echo h($field["default"]); ?>" aria-labelledby="label-default"><?php
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 (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'>" : "");
} }
@@ -582,9 +584,12 @@ function tar_file($filename, $tmp_file) {
function ini_bytes($ini) { function ini_bytes($ini) {
$val = ini_get($ini); $val = ini_get($ini);
switch (strtolower(substr($val, -1))) { switch (strtolower(substr($val, -1))) {
case 'g': $val = (int)$val * 1024; // no break case 'g':
case 'm': $val = (int)$val * 1024; // no break $val = (int)$val * 1024; // no break
case 'k': $val = (int)$val * 1024; case 'm':
$val = (int)$val * 1024; // no break
case 'k':
$val = (int)$val * 1024;
} }
return $val; return $val;
} }

View File

@@ -502,17 +502,19 @@ function convert_fields($columns, $fields, $select = array()) {
/** Set cookie valid on current path /** Set cookie valid on current path
* @param string * @param string
* @param string * @param string
* @param int number of seconds, 0 for session cookie * @param int number of seconds, 0 for session cookie, 2592000 - 30 days
* @return bool * @return bool
*/ */
function cookie($name, $value, $lifetime = 2592000) { // 2592000 - 30 days function cookie($name, $value, $lifetime = 2592000) {
global $HTTPS; global $HTTPS;
return header("Set-Cookie: $name=" . urlencode($value) return header(
"Set-Cookie: $name=" . urlencode($value)
. ($lifetime ? "; expires=" . gmdate("D, d M Y H:i:s", time() + $lifetime) . " GMT" : "") . ($lifetime ? "; expires=" . gmdate("D, d M Y H:i:s", time() + $lifetime) . " GMT" : "")
. "; path=" . preg_replace('~\?.*~', '', $_SERVER["REQUEST_URI"]) . "; path=" . preg_replace('~\?.*~', '', $_SERVER["REQUEST_URI"])
. ($HTTPS ? "; secure" : "") . ($HTTPS ? "; secure" : "")
. "; HttpOnly; SameSite=lax", . "; HttpOnly; SameSite=lax",
false); false
);
} }
/** Restart stopped session /** Restart stopped session

View File

@@ -22,7 +22,6 @@ echo script("mixin(qsl('table'), {onclick: tableClick, ondblclick: partialArg(ta
// HTML valid because there is always at least one process // HTML valid because there is always at least one process
$i = -1; $i = -1;
foreach (process_list() as $i => $row) { foreach (process_list() as $i => $row) {
if (!$i) { if (!$i) {
echo "<thead><tr lang='en'>" . (support("kill") ? "<th>" : ""); echo "<thead><tr lang='en'>" . (support("kill") ? "<th>" : "");
foreach ($row as $key => $val) { foreach ($row as $key => $val) {

View File

@@ -526,9 +526,8 @@ if (!$columns && support("table")) {
echo "<fieldset>"; echo "<fieldset>";
echo "<legend>" . lang('Whole result') . "</legend>"; echo "<legend>" . lang('Whole result') . "</legend>";
$display_rows = ($exact_count ? "" : "~ ") . $found_rows; $display_rows = ($exact_count ? "" : "~ ") . $found_rows;
echo checkbox("all", 1, 0, ($found_rows !== false ? ($exact_count ? "" : "~ ") . lang('%d row(s)', $found_rows) : ""), $onclick = "var checked = formChecked(this, /check/); selectCount('selected', this.checked ? '$display_rows' : checked); selectCount('selected2', this.checked || !checked ? '$display_rows' : checked);";
"var checked = formChecked(this, /check/); selectCount('selected', this.checked ? '$display_rows' : checked); selectCount('selected2', this.checked || !checked ? '$display_rows' : checked);" echo checkbox("all", 1, 0, ($found_rows !== false ? ($exact_count ? "" : "~ ") . lang('%d row(s)', $found_rows) : ""), $onclick) . "\n";
) . "\n";
echo "</fieldset>\n"; echo "</fieldset>\n";
if ($adminer->selectCommandPrint()) { if ($adminer->selectCommandPrint()) {

View File

@@ -238,9 +238,13 @@ function editFields() {
els = qsa('[name$="[type]"]'); els = qsa('[name$="[type]"]');
for (var i = 0; i < els.length; i++) { for (var i = 0; i < els.length; i++) {
mixin(els[i], { mixin(els[i], {
onfocus: function () { lastType = selectValue(this); }, onfocus: function () {
lastType = selectValue(this);
},
onchange: editingTypeChange, onchange: editingTypeChange,
onmouseover: function (event) { helpMouseover.call(this, event, getTarget(event).value, 1) }, onmouseover: function (event) {
helpMouseover.call(this, event, getTarget(event).value, 1);
},
onmouseout: helpMouseout onmouseout: helpMouseout
}); });
} }

View File

@@ -884,7 +884,8 @@ function addEvent(el, action, handler) {
* @param HTMLElement * @param HTMLElement
*/ */
function focus(el) { function focus(el) {
setTimeout(function () { // this has to be an anonymous function because Firefox passes some arguments to setTimeout callback setTimeout(function () {
// this has to be an anonymous function because Firefox passes some arguments to setTimeout callback
el.focus(); el.focus();
}, 0); }, 0);
} }

View File

@@ -135,7 +135,7 @@ if ($_POST) {
<tr><th><?php echo lang('Server'); ?><td><input name="host" data-maxlength="60" value="<?php echo h($row["host"]); ?>" autocapitalize="off"> <tr><th><?php echo lang('Server'); ?><td><input name="host" data-maxlength="60" value="<?php echo h($row["host"]); ?>" autocapitalize="off">
<tr><th><?php echo lang('Username'); ?><td><input name="user" data-maxlength="80" value="<?php echo h($row["user"]); ?>" autocapitalize="off"> <tr><th><?php echo lang('Username'); ?><td><input name="user" data-maxlength="80" value="<?php echo h($row["user"]); ?>" autocapitalize="off">
<tr><th><?php echo lang('Password'); ?><td><input name="pass" id="pass" value="<?php echo h($row["pass"]); ?>" autocomplete="new-password"> <tr><th><?php echo lang('Password'); ?><td><input name="pass" id="pass" value="<?php echo h($row["pass"]); ?>" autocomplete="new-password">
<?php if (!$row["hashed"]) { echo script("typePassword(qs('#pass'));"); } ?> <?php echo ($row["hashed"] ? "" : script("typePassword(qs('#pass'));")); ?>
<?php echo (min_version(8) ? "" : checkbox("hashed", 1, $row["hashed"], lang('Hashed'), "typePassword(this.form['pass'], this.checked);")); ?> <?php echo (min_version(8) ? "" : checkbox("hashed", 1, $row["hashed"], lang('Hashed'), "typePassword(this.form['pass'], this.checked);")); ?>
</table> </table>

View File

@@ -277,11 +277,12 @@ function php_shrink($input) {
$output = ''; $output = '';
$in_echo = false; $in_echo = false;
$doc_comment = false; // include only first /** $doc_comment = false; // include only first /**
for (reset($tokens); list($i, $token) = each($tokens); ) { for (reset($tokens); list($i, $token) = each($tokens);) {
if (!is_array($token)) { if (!is_array($token)) {
$token = array(0, $token); $token = array(0, $token);
} }
if ($tokens[$i+2][0] === T_CLOSE_TAG && $tokens[$i+3][0] === T_INLINE_HTML && $tokens[$i+4][0] === T_OPEN_TAG if (
$tokens[$i+2][0] === T_CLOSE_TAG && $tokens[$i+3][0] === T_INLINE_HTML && $tokens[$i+4][0] === T_OPEN_TAG
&& strlen(add_apo_slashes($tokens[$i+3][1])) < strlen($tokens[$i+3][1]) + 3 && strlen(add_apo_slashes($tokens[$i+3][1])) < strlen($tokens[$i+3][1]) + 3
) { ) {
$tokens[$i+2] = array(T_ECHO, 'echo'); $tokens[$i+2] = array(T_ECHO, 'echo');

View File

@@ -39,9 +39,15 @@ if (!extension_loaded("xdebug")) {
$line = $file[$l]; $line = $file[$l];
$color = "#C0FFC0"; // tested $color = "#C0FFC0"; // tested
switch ($coverage[realpath($filename)][$l+1]) { switch ($coverage[realpath($filename)][$l+1]) {
case -1: $color = "#FFC0C0"; break; // untested case -1: // untested
case -2: $color = "Silver"; break; // dead code $color = "#FFC0C0";
case null: $color = ""; break; // not executable break;
case -2: // dead code
$color = "Silver";
break;
case null: // not executable
$color = "";
break;
} }
if ($prev_color === null) { if ($prev_color === null) {
$prev_color = $color; $prev_color = $color;

View File

@@ -13,13 +13,15 @@ if (isset($_SESSION["lang"])) {
} }
$messages_all = array(); $messages_all = array();
foreach (array_merge( foreach (
array_merge(
glob(__DIR__ . "/adminer/*.php"), glob(__DIR__ . "/adminer/*.php"),
glob(__DIR__ . "/adminer/include/*.php"), glob(__DIR__ . "/adminer/include/*.php"),
glob(__DIR__ . "/adminer/drivers/*.php"), glob(__DIR__ . "/adminer/drivers/*.php"),
glob(__DIR__ . "/editor/*.php"), glob(__DIR__ . "/editor/*.php"),
glob(__DIR__ . "/editor/include/*.php") glob(__DIR__ . "/editor/include/*.php")
) as $filename) { ) as $filename
) {
$file = file_get_contents($filename); $file = file_get_contents($filename);
if (preg_match_all("~lang\\(('(?:[^\\\\']+|\\\\.)*')([),])~", $file, $matches)) { // lang() always uses apostrophes if (preg_match_all("~lang\\(('(?:[^\\\\']+|\\\\.)*')([),])~", $file, $matches)) { // lang() always uses apostrophes
$messages_all += array_combine($matches[1], $matches[2]); $messages_all += array_combine($matches[1], $matches[2]);

50
phpcs.xml Normal file
View File

@@ -0,0 +1,50 @@
<?xml version="1.0"?>
<ruleset name="Adminer Coding Standard">
<description>The coding standard for Adminer.</description>
<arg value="s"/>
<arg name="parallel" value="8"/>
<file>.</file>
<exclude-pattern>/externals/</exclude-pattern>
<exclude-pattern>/designs/</exclude-pattern>
<rule ref="PSR12">
<exclude name="Generic.Files.LineLength"/>
<exclude name="Generic.Whitespace.DisallowTabIndent"/><!-- Replaced by: Generic.Whitespace.DisallowSpaceIndent -->
<exclude name="PSR1.Files.SideEffects.FoundWithSymbols"/>
<exclude name="PSR12.Files.FileHeader.SpacingAfterBlock"/>
<exclude name="PSR12.Operators.OperatorSpacing.NoSpaceBefore"/>
<exclude name="PSR12.Operators.OperatorSpacing.NoSpaceAfter"/>
<exclude name="PSR1.Classes.ClassDeclaration.MissingNamespace"/>
<exclude name="PSR1.Classes.ClassDeclaration.MultipleClasses"/>
<exclude name="PSR2.Classes.ClassDeclaration.OpenBraceNewLine"/><!-- Replaced by: Generic.Classes.OpeningBraceSameLine -->
<exclude name="PSR2.Classes.ClassDeclaration.CloseBraceAfterBody"/>
<exclude name="PSR2.Classes.PropertyDeclaration.Multiple"/>
<exclude name="PSR2.Classes.PropertyDeclaration.VarUsed"/>
<exclude name="PSR2.Classes.PropertyDeclaration.ScopeMissing"/>
<exclude name="PSR2.Classes.PropertyDeclaration.Underscore"/>
<exclude name="PSR12.Classes.ClassInstantiation.MissingParentheses"/>
<exclude name="PSR12.Classes.OpeningBraceSpace.Found"/>
<exclude name="Squiz.Classes.ValidClassName.NotCamelCaps"/>
<exclude name="PSR1.Methods.CamelCapsMethodName.NotCamelCaps"/>
<exclude name="PSR2.Methods.MethodDeclaration.Underscore"/>
<exclude name="PSR2.Methods.FunctionCallSignature.SpaceBeforeCloseBracket"/>
<exclude name="PSR12.ControlStructures.ControlStructureSpacing.CloseParenthesisLine"/>
<exclude name="PSR12.ControlStructures.ControlStructureSpacing.FirstExpressionLine"/>
<exclude name="PSR12.ControlStructures.ControlStructureSpacing.LineIndent"/>
<exclude name="Squiz.Functions.MultiLineFunctionDeclaration.BraceOnSameLine"/><!-- Replaced by: Generic.Functions.OpeningFunctionBraceKernighanRitchie -->
<exclude name="PSR12.Properties.ConstantVisibility.NotFound"/><!-- PHP 7.1 is not required. -->
<exclude name="Squiz.Scope.MethodScope.Missing"/>
<exclude name="Squiz.WhiteSpace.ControlStructureSpacing.SpacingBeforeClose"/>
<!-- TODO: Ignore only in <?php if () { ?><?php } ?> -->
<exclude name="Generic.WhiteSpace.ScopeIndent.Incorrect"/>
<exclude name="Generic.WhiteSpace.ScopeIndent.IncorrectExact"/>
<exclude name="Squiz.ControlStructures.ControlSignature.NewlineAfterOpenBrace"/>
<exclude name="Squiz.WhiteSpace.ScopeClosingBrace.ContentBefore"/>
</rule>
<rule ref="Generic.Classes.OpeningBraceSameLine"/>
<rule ref="Generic.Whitespace.DisallowSpaceIndent"/>
<rule ref="Generic.Functions.OpeningFunctionBraceKernighanRitchie"/>
</ruleset>

View File

@@ -8,13 +8,12 @@
* @license https://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0 * @license https://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 (one or other) * @license https://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 (one or other)
*/ */
class AdminerDotJs class AdminerDotJs {
{ const FILENAME = "adminer.js";
const FileName = "adminer.js";
function head() { function head() {
if (file_exists(self::FileName)) { if (file_exists(self::FILENAME)) {
echo script_src(self::FileName . "?v=" . crc32(file_get_contents(self::FileName))), "\n"; echo script_src(self::FILENAME . "?v=" . crc32(file_get_contents(self::FILENAME))), "\n";
} }
} }
} }

View File

@@ -365,7 +365,8 @@ if (isset($_GET["elastic"])) {
if ($name != "") { if ($name != "") {
if (isset($stats["indices"][$name])) { if (isset($stats["indices"][$name])) {
return format_index_status($name, $stats["indices"][$name]); return format_index_status($name, $stats["indices"][$name]);
} else foreach ($aliases as $index_name => $index) { } else {
foreach ($aliases as $index_name => $index) {
foreach ($index["aliases"] as $alias_name => $alias) { foreach ($index["aliases"] as $alias_name => $alias) {
if ($alias_name == $name) { if ($alias_name == $name) {
return format_alias_status($alias_name, $stats["indices"][$index_name]); return format_alias_status($alias_name, $stats["indices"][$index_name]);
@@ -373,6 +374,7 @@ if (isset($_GET["elastic"])) {
} }
} }
} }
}
ksort($stats["indices"]); ksort($stats["indices"]);
foreach ($stats["indices"] as $name => $index) { foreach ($stats["indices"] as $name => $index) {

View File

@@ -8,7 +8,7 @@ add_driver('firebird', 'Firebird (alpha)');
if (isset($_GET["firebird"])) { if (isset($_GET["firebird"])) {
define("DRIVER", "firebird"); define("DRIVER", "firebird");
if (extension_loaded("interbase") ) { if (extension_loaded("interbase")) {
class Min_DB { class Min_DB {
var var
$extension = "Firebird", $extension = "Firebird",

View File

@@ -49,7 +49,8 @@ class AdminerEditCalendar {
. ($field["type"] == "time" ? "timepicker({ $timeFormat })" . ($field["type"] == "time" ? "timepicker({ $timeFormat })"
: (preg_match("~time~", $field["type"]) ? "datetimepicker({ $dateFormat, $timeFormat })" : (preg_match("~time~", $field["type"]) ? "datetimepicker({ $dateFormat, $timeFormat })"
: "datepicker({ $dateFormat })" : "datepicker({ $dateFormat })"
)) . ";"); )) . ";"
);
} }
} }

View File

@@ -10,18 +10,19 @@ class AdminerForeignSystem {
function foreignKeys($table) { function foreignKeys($table) {
if (DRIVER == "server" && DB == "mysql") { if (DRIVER == "server" && DB == "mysql") {
switch ($table) { $return = array(
case "columns_priv": return array(array("table" => "user", "source" => array("Host", "User"), "target" => array("Host", "User"))); "columns_priv" => array(array("table" => "user", "source" => array("Host", "User"), "target" => array("Host", "User"))),
case "db": return array(array("table" => "user", "source" => array("Host", "User"), "target" => array("Host", "User"))); "db" => array(array("table" => "user", "source" => array("Host", "User"), "target" => array("Host", "User"))),
case "help_category": return array(array("table" => "help_category", "source" => array("parent_category_id"), "target" => array("help_category_id"))); "help_category" => array(array("table" => "help_category", "source" => array("parent_category_id"), "target" => array("help_category_id"))),
case "help_relation": return array(array("table" => "help_topic", "source" => array("help_topic_id"), "target" => array("help_topic_id")), array("table" => "help_keyword", "source" => array("help_keyword_id"), "target" => array("help_keyword_id"))); "help_relation" => array(array("table" => "help_topic", "source" => array("help_topic_id"), "target" => array("help_topic_id")), array("table" => "help_keyword", "source" => array("help_keyword_id"), "target" => array("help_keyword_id"))),
case "help_topic": return array(array("table" => "help_category", "source" => array("help_category_id"), "target" => array("help_category_id"))); "help_topic" => array(array("table" => "help_category", "source" => array("help_category_id"), "target" => array("help_category_id"))),
case "procs_priv": return array(array("table" => "user", "source" => array("Host", "User"), "target" => array("Host", "User")), array("table" => "proc", "source" => array("Db", "Routine_name"), "target" => array("db", "name"))); "procs_priv" => array(array("table" => "user", "source" => array("Host", "User"), "target" => array("Host", "User")), array("table" => "proc", "source" => array("Db", "Routine_name"), "target" => array("db", "name"))),
case "tables_priv": return array(array("table" => "user", "source" => array("Host", "User"), "target" => array("Host", "User"))); "tables_priv" => array(array("table" => "user", "source" => array("Host", "User"), "target" => array("Host", "User"))),
case "time_zone_name": return array(array("table" => "time_zone", "source" => array("Time_zone_id"), "target" => array("Time_zone_id"))); "time_zone_name" => array(array("table" => "time_zone", "source" => array("Time_zone_id"), "target" => array("Time_zone_id"))),
case "time_zone_transition": return array(array("table" => "time_zone", "source" => array("Time_zone_id"), "target" => array("Time_zone_id")), array("table" => "time_zone_transition_type", "source" => array("Time_zone_id", "Transition_type_id"), "target" => array("Time_zone_id", "Transition_type_id"))); "time_zone_transition" => array(array("table" => "time_zone", "source" => array("Time_zone_id"), "target" => array("Time_zone_id")), array("table" => "time_zone_transition_type", "source" => array("Time_zone_id", "Transition_type_id"), "target" => array("Time_zone_id", "Transition_type_id"))),
case "time_zone_transition_type": return array(array("table" => "time_zone", "source" => array("Time_zone_id"), "target" => array("Time_zone_id"))); "time_zone_transition_type" => array(array("table" => "time_zone", "source" => array("Time_zone_id"), "target" => array("Time_zone_id"))),
} );
return $return[$table];
} elseif (DB == "information_schema") { } elseif (DB == "information_schema") {
$schemata = array("table" => "SCHEMATA", "source" => array("TABLE_CATALOG", "TABLE_SCHEMA"), "target" => array("CATALOG_NAME", "SCHEMA_NAME")); $schemata = array("table" => "SCHEMATA", "source" => array("TABLE_CATALOG", "TABLE_SCHEMA"), "target" => array("CATALOG_NAME", "SCHEMA_NAME"));
$tables = array("table" => "TABLES", "source" => array("TABLE_CATALOG", "TABLE_SCHEMA", "TABLE_NAME"), "target" => array("TABLE_CATALOG", "TABLE_SCHEMA", "TABLE_NAME")); $tables = array("table" => "TABLES", "source" => array("TABLE_CATALOG", "TABLE_SCHEMA", "TABLE_NAME"), "target" => array("TABLE_CATALOG", "TABLE_SCHEMA", "TABLE_NAME"));
@@ -29,27 +30,28 @@ class AdminerForeignSystem {
$character_sets = array("table" => "CHARACTER_SETS", "source" => array("CHARACTER_SET_NAME"), "target" => array("CHARACTER_SET_NAME")); $character_sets = array("table" => "CHARACTER_SETS", "source" => array("CHARACTER_SET_NAME"), "target" => array("CHARACTER_SET_NAME"));
$collations = array("table" => "COLLATIONS", "source" => array("COLLATION_NAME"), "target" => array("COLLATION_NAME")); $collations = array("table" => "COLLATIONS", "source" => array("COLLATION_NAME"), "target" => array("COLLATION_NAME"));
$routine_charsets = array(array("source" => array("CHARACTER_SET_CLIENT")) + $character_sets, array("source" => array("COLLATION_CONNECTION")) + $collations, array("source" => array("DATABASE_COLLATION")) + $collations); $routine_charsets = array(array("source" => array("CHARACTER_SET_CLIENT")) + $character_sets, array("source" => array("COLLATION_CONNECTION")) + $collations, array("source" => array("DATABASE_COLLATION")) + $collations);
switch ($table) { $return = array(
case "CHARACTER_SETS": return array(array("source" => array("DEFAULT_COLLATE_NAME")) + $collations); "CHARACTER_SETS" => array(array("source" => array("DEFAULT_COLLATE_NAME")) + $collations),
case "COLLATIONS": return array($character_sets); "COLLATIONS" => array($character_sets),
case "COLLATION_CHARACTER_SET_APPLICABILITY": return array($collations, $character_sets); "COLLATION_CHARACTER_SET_APPLICABILITY" => array($collations, $character_sets),
case "COLUMNS": return array($schemata, $tables, $character_sets, $collations); "COLUMNS" => array($schemata, $tables, $character_sets, $collations),
case "COLUMN_PRIVILEGES": return array($schemata, $tables, $columns); "COLUMN_PRIVILEGES" => array($schemata, $tables, $columns),
case "TABLES": return array($schemata, array("source" => array("TABLE_COLLATION")) + $collations); "TABLES" => array($schemata, array("source" => array("TABLE_COLLATION")) + $collations),
case "SCHEMATA": return array(array("source" => array("DEFAULT_CHARACTER_SET_NAME")) + $character_sets, array("source" => array("DEFAULT_COLLATION_NAME")) + $collations); "SCHEMATA" => array(array("source" => array("DEFAULT_CHARACTER_SET_NAME")) + $character_sets, array("source" => array("DEFAULT_COLLATION_NAME")) + $collations),
case "EVENTS": return array_merge(array(array("source" => array("EVENT_CATALOG", "EVENT_SCHEMA")) + $schemata), $routine_charsets); "EVENTS" => array_merge(array(array("source" => array("EVENT_CATALOG", "EVENT_SCHEMA")) + $schemata), $routine_charsets),
case "FILES": return array($schemata, $tables); "FILES" => array($schemata, $tables),
case "KEY_COLUMN_USAGE": return array(array("source" => array("CONSTRAINT_CATALOG", "CONSTRAINT_SCHEMA")) + $schemata, $schemata, $tables, $columns, array("source" => array("TABLE_CATALOG", "REFERENCED_TABLE_SCHEMA")) + $schemata, array("source" => array("TABLE_CATALOG", "REFERENCED_TABLE_SCHEMA", "REFERENCED_TABLE_NAME")) + $tables, array("source" => array("TABLE_CATALOG", "REFERENCED_TABLE_SCHEMA", "REFERENCED_TABLE_NAME", "REFERENCED_COLUMN_NAME")) + $columns); "KEY_COLUMN_USAGE" => array(array("source" => array("CONSTRAINT_CATALOG", "CONSTRAINT_SCHEMA")) + $schemata, $schemata, $tables, $columns, array("source" => array("TABLE_CATALOG", "REFERENCED_TABLE_SCHEMA")) + $schemata, array("source" => array("TABLE_CATALOG", "REFERENCED_TABLE_SCHEMA", "REFERENCED_TABLE_NAME")) + $tables, array("source" => array("TABLE_CATALOG", "REFERENCED_TABLE_SCHEMA", "REFERENCED_TABLE_NAME", "REFERENCED_COLUMN_NAME")) + $columns),
case "PARTITIONS": return array($schemata, $tables); "PARTITIONS" => array($schemata, $tables),
case "REFERENTIAL_CONSTRAINTS": return array(array("source" => array("CONSTRAINT_CATALOG", "CONSTRAINT_SCHEMA")) + $schemata, array("source" => array("UNIQUE_CONSTRAINT_CATALOG", "UNIQUE_CONSTRAINT_SCHEMA")) + $schemata, array("source" => array("CONSTRAINT_CATALOG", "CONSTRAINT_SCHEMA", "TABLE_NAME")) + $tables, array("source" => array("CONSTRAINT_CATALOG", "CONSTRAINT_SCHEMA", "REFERENCED_TABLE_NAME")) + $tables); "REFERENTIAL_CONSTRAINTS" => array(array("source" => array("CONSTRAINT_CATALOG", "CONSTRAINT_SCHEMA")) + $schemata, array("source" => array("UNIQUE_CONSTRAINT_CATALOG", "UNIQUE_CONSTRAINT_SCHEMA")) + $schemata, array("source" => array("CONSTRAINT_CATALOG", "CONSTRAINT_SCHEMA", "TABLE_NAME")) + $tables, array("source" => array("CONSTRAINT_CATALOG", "CONSTRAINT_SCHEMA", "REFERENCED_TABLE_NAME")) + $tables),
case "ROUTINES": return array_merge(array(array("source" => array("ROUTINE_CATALOG", "ROUTINE_SCHEMA")) + $schemata), $routine_charsets); "ROUTINES" => array_merge(array(array("source" => array("ROUTINE_CATALOG", "ROUTINE_SCHEMA")) + $schemata), $routine_charsets),
case "SCHEMA_PRIVILEGES": return array($schemata); "SCHEMA_PRIVILEGES" => array($schemata),
case "STATISTICS": return array($schemata, $tables, $columns, array("source" => array("TABLE_CATALOG", "INDEX_SCHEMA")) + $schemata); "STATISTICS" => array($schemata, $tables, $columns, array("source" => array("TABLE_CATALOG", "INDEX_SCHEMA")) + $schemata),
case "TABLE_CONSTRAINTS": return array(array("source" => array("CONSTRAINT_CATALOG", "CONSTRAINT_SCHEMA")) + $schemata, array("source" => array("CONSTRAINT_CATALOG", "TABLE_SCHEMA")) + $schemata, array("source" => array("CONSTRAINT_CATALOG", "TABLE_SCHEMA", "TABLE_NAME")) + $tables); "TABLE_CONSTRAINTS" => array(array("source" => array("CONSTRAINT_CATALOG", "CONSTRAINT_SCHEMA")) + $schemata, array("source" => array("CONSTRAINT_CATALOG", "TABLE_SCHEMA")) + $schemata, array("source" => array("CONSTRAINT_CATALOG", "TABLE_SCHEMA", "TABLE_NAME")) + $tables),
case "TABLE_PRIVILEGES": return array($schemata, $tables); "TABLE_PRIVILEGES" => array($schemata, $tables),
case "TRIGGERS": return array_merge(array(array("source" => array("TRIGGER_CATALOG", "TRIGGER_SCHEMA")) + $schemata, array("source" => array("EVENT_OBJECT_CATALOG", "EVENT_OBJECT_SCHEMA")) + $schemata, array("source" => array("EVENT_OBJECT_CATALOG", "EVENT_OBJECT_SCHEMA", "EVENT_OBJECT_TABLE")) + $tables), $routine_charsets); "TRIGGERS" => array_merge(array(array("source" => array("TRIGGER_CATALOG", "TRIGGER_SCHEMA")) + $schemata, array("source" => array("EVENT_OBJECT_CATALOG", "EVENT_OBJECT_SCHEMA")) + $schemata, array("source" => array("EVENT_OBJECT_CATALOG", "EVENT_OBJECT_SCHEMA", "EVENT_OBJECT_TABLE")) + $tables), $routine_charsets),
case "VIEWS": return array($schemata); "VIEWS" => array($schemata),
} );
return $return[$table];
} }
} }

View File

@@ -10,7 +10,8 @@ class AdminerPlugin extends Adminer {
/** @access protected */ /** @access protected */
var $plugins; var $plugins;
function _findRootClass($class) { // is_subclass_of(string, string) is available since PHP 5.0.3 function _findRootClass($class) {
// is_subclass_of(string, string) is available since PHP 5.0.3
do { do {
$return = $class; $return = $class;
} while ($class = get_parent_class($class)); } while ($class = get_parent_class($class));
@@ -41,14 +42,29 @@ class AdminerPlugin extends Adminer {
foreach ($this->plugins as $plugin) { foreach ($this->plugins as $plugin) {
if (method_exists($plugin, $function)) { if (method_exists($plugin, $function)) {
switch (count($args)) { // call_user_func_array() doesn't work well with references switch (count($args)) { // call_user_func_array() doesn't work well with references
case 0: $return = $plugin->$function(); break; case 0:
case 1: $return = $plugin->$function($args[0]); break; $return = $plugin->$function();
case 2: $return = $plugin->$function($args[0], $args[1]); break; break;
case 3: $return = $plugin->$function($args[0], $args[1], $args[2]); break; case 1:
case 4: $return = $plugin->$function($args[0], $args[1], $args[2], $args[3]); break; $return = $plugin->$function($args[0]);
case 5: $return = $plugin->$function($args[0], $args[1], $args[2], $args[3], $args[4]); break; break;
case 6: $return = $plugin->$function($args[0], $args[1], $args[2], $args[3], $args[4], $args[5]); break; case 2:
default: trigger_error('Too many parameters.', E_USER_WARNING); $return = $plugin->$function($args[0], $args[1]);
break;
case 3:
$return = $plugin->$function($args[0], $args[1], $args[2]);
break;
case 4:
$return = $plugin->$function($args[0], $args[1], $args[2], $args[3]);
break;
case 5:
$return = $plugin->$function($args[0], $args[1], $args[2], $args[3], $args[4]);
break;
case 6:
$return = $plugin->$function($args[0], $args[1], $args[2], $args[3], $args[4], $args[5]);
break;
default:
trigger_error('Too many parameters.', E_USER_WARNING);
} }
if ($return !== null) { if ($return !== null) {
return $return; return $return;

View File

@@ -7,7 +7,8 @@
* @license https://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 (one or other) * @license https://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 (one or other)
*/ */
class AdminerTablesFilter { class AdminerTablesFilter {
function tablesPrint($tables) { ?> function tablesPrint($tables) {
?>
<script<?php echo nonce(); ?>> <script<?php echo nonce(); ?>>
var tablesFilterTimeout = null; var tablesFilterTimeout = null;
var tablesFilterValue = ''; var tablesFilterValue = '';