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:
@@ -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]
|
||||||
|
@@ -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)> )(.+)~', "\\1<code class='jush-sql'>\\3</code>",
|
preg_replace(
|
||||||
preg_replace('~(.+)\n---+\n~', "<b>\\1</b>\n",
|
'~(\n( -|mysql)> )(.+)~',
|
||||||
h($routine['comment'])
|
"\\1<code class='jush-sql'>\\3</code>",
|
||||||
)));
|
preg_replace('~(.+)\n---+\n~', "<b>\\1</b>\n", h($routine['comment']))
|
||||||
|
));
|
||||||
?>
|
?>
|
||||||
</pre>
|
</pre>
|
||||||
|
@@ -376,7 +376,6 @@ if (isset($_GET["mongo"])) {
|
|||||||
"(date)>=",
|
"(date)>=",
|
||||||
"(date)<=",
|
"(date)<=",
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function table($idf) {
|
function table($idf) {
|
||||||
|
@@ -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();
|
||||||
|
@@ -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) {
|
||||||
|
@@ -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;
|
||||||
|
@@ -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;
|
||||||
}
|
}
|
||||||
|
@@ -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
|
||||||
|
@@ -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) {
|
||||||
|
@@ -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()) {
|
||||||
|
@@ -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
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@@ -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);
|
||||||
}
|
}
|
||||||
|
@@ -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>
|
||||||
|
|
||||||
|
@@ -281,7 +281,8 @@ function php_shrink($input) {
|
|||||||
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');
|
||||||
|
12
coverage.php
12
coverage.php
@@ -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;
|
||||||
|
6
lang.php
6
lang.php
@@ -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
50
phpcs.xml
Normal 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>
|
@@ -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";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -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) {
|
||||||
|
@@ -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 })"
|
||||||
)) . ";");
|
)) . ";"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -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];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -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;
|
||||||
|
@@ -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 = '';
|
||||||
|
Reference in New Issue
Block a user