Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion adminer/drivers/mysql.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ function attach(string $server, string $username, string $password): string {
}
list($host, $port) = host_port($server);
return $this->dsn(
"mysql:charset=utf8;host=$host" . ($port ? (is_numeric($port) ? ";port=" : ";unix_socket=") . $port : ""),
"mysql:charset=utf8".(!empty($host) ? ";host=$host" : '') . ($port ? (is_numeric($port) ? ";port=" : ";unix_socket=") . $port : ""),
$username,
$password,
$options
Expand Down
72 changes: 36 additions & 36 deletions adminer/include/design.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function page_header(string $title, string $error = "", $breadcrumb = array(), s

$css = adminer()->css();
if (is_int(key($css))) { // legacy return value
$css = array_fill_keys($css, 'light');
$css = array_fill_keys($css, 'light');
}
$has_light = in_array('light', $css) || in_array('', $css);
$has_dark = in_array('dark', $css) || in_array('', $css);
Expand All @@ -40,31 +40,31 @@ function page_header(string $title, string $error = "", $breadcrumb = array(), s
);
$media = " media='(prefers-color-scheme: dark)'";
if ($dark !== false) {
echo "<link rel='stylesheet'" . ($dark ? "" : $media) . " href='../adminer/static/dark.css'>\n";
echo "<link rel='stylesheet'" . ($dark ? "" : $media) . " href='../adminer/static/dark.css'>\n";
}
echo "<meta name='color-scheme' content='" . ($dark === null ? "light dark" : ($dark ? "dark" : "light")) . "'>\n";

// this is matched by compile.php
echo script_src("../adminer/static/functions.js");
echo script_src("static/editing.js");
if (adminer()->head($dark)) {
echo "<link rel='icon' href='data:image/gif;base64,R0lGODlhEAAQAJEAAAQCBPz+/PwCBAROZCH5BAEAAAAALAAAAAAQABAAAAI2hI+pGO1rmghihiUdvUBnZ3XBQA7f05mOak1RWXrNq5nQWHMKvuoJ37BhVEEfYxQzHjWQ5qIAADs='>\n";
echo "<link rel='apple-touch-icon' href='../adminer/static/logo.png'>\n";
echo "<link rel='icon' href='data:image/gif;base64,R0lGODlhEAAQAJEAAAQCBPz+/PwCBAROZCH5BAEAAAAALAAAAAAQABAAAAI2hI+pGO1rmghihiUdvUBnZ3XBQA7f05mOak1RWXrNq5nQWHMKvuoJ37BhVEEfYxQzHjWQ5qIAADs='>\n";
echo "<link rel='apple-touch-icon' href='../adminer/static/logo.png'>\n";
}
foreach ($css as $url => $mode) {
$attrs = ($mode == 'dark' && !$dark
? $media
: ($mode == 'light' && $has_dark ? " media='(prefers-color-scheme: light)'" : "")
);
echo "<link rel='stylesheet'$attrs href='" . h($url) . "'>\n";
$attrs = ($mode == 'dark' && !$dark
? $media
: ($mode == 'light' && $has_dark ? " media='(prefers-color-scheme: light)'" : "")
);
echo "<link rel='stylesheet'$attrs href='" . h($url) . "'>\n";
}
echo "\n<body class='" . lang('ltr') . " nojs";
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-----
$version = unserialize(file_get_contents($filename));
$public = "-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwqWOVuF5uw7/+Z70djoK
RlHIZFZPO0uYRezq90+7Amk+FDNd7KkL5eDve+vHRJBLAszF/7XKXe11xwliIsFs
DFWQlsABVZB3oisKCBEuI71J4kPH8dKGEWR9jDHFw3cWmoH3PmqImX6FISWbG3B8
Expand All @@ -74,9 +74,9 @@ function page_header(string $title, string $error = "", $breadcrumb = array(), s
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
}
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() . "')")
Expand All @@ -90,39 +90,39 @@ function page_header(string $title, string $error = "", $breadcrumb = array(), s
echo "<div id='content'>\n";
echo "<span id='menuopen' class='jsonly'>" . icon("move", "", "menu", "") . "</span>" . script("qs('#menuopen').onclick = event => { qs('#foot').classList.toggle('foot'); event.stopPropagation(); }");
if ($breadcrumb !== null) {
$link = substr(preg_replace('~\b(username|db|ns)=[^&]*&~', '', ME), 0, -1);
echo '<p id="breadcrumb"><a href="' . h($link ?: ".") . '">' . get_driver(DRIVER) . '</a> » ';
$link = substr(preg_replace('~\b(db|ns)=[^&]*&~', '', ME), 0, -1);
$server = adminer()->serverName(SERVER);
$server = ($server != "" ? $server : lang('Server'));
if ($breadcrumb === false) {
echo "$server\n";
} else {
echo "<a href='" . h($link) . "' accesskey='1' title='Alt+Shift+1'>$server</a> » ";
if ($_GET["ns"] != "" || (DB != "" && is_array($breadcrumb))) {
echo '<a href="' . h($link . "&db=" . urlencode(DB) . (support("scheme") ? "&ns=" : "")) . '">' . h(DB) . '</a> » ';
$link = substr(preg_replace('~\b(username|db|ns)=[^&]*&~', '', ME), 0, -1);
echo '<p id="breadcrumb"><a href="' . h($link ?: ".") . '">' . get_driver(DRIVER) . '</a> » ';
$link = substr(preg_replace('~\b(db|ns)=[^&]*&~', '', ME), 0, -1);
$server = adminer()->serverName(SERVER);
$server = ($server != "" ? $server : lang('Server'));
if ($breadcrumb === false) {
echo "$server\n";
} else {
echo "<a href='" . h($link) . "' accesskey='1' title='Alt+Shift+1'>$server</a> » ";
if ($_GET["ns"] != "" || (DB != "" && is_array($breadcrumb))) {
echo '<a href="' . h($link . "&db=" . urlencode(DB) . (support("scheme") ? "&ns=" : "")) . '">' . h(DB) . '</a> » ';
}
if (is_array($breadcrumb)) {
if ($_GET["ns"] != "") {
echo '<a href="' . h(substr(ME, 0, -1)) . '">' . h($_GET["ns"]) . '</a> » ';
}
if (is_array($breadcrumb)) {
if ($_GET["ns"] != "") {
echo '<a href="' . h(substr(ME, 0, -1)) . '">' . h($_GET["ns"]) . '</a> » ';
}
foreach ($breadcrumb as $key => $val) {
$desc = (is_array($val) ? $val[1] : h($val));
if ($desc != "") {
echo "<a href='" . h(ME . "$key=") . urlencode(is_array($val) ? $val[0] : $val) . "'>$desc</a> » ";
}
foreach ($breadcrumb as $key => $val) {
$desc = (is_array($val) ? $val[1] : h($val));
if ($desc != "") {
echo "<a href='" . h(ME . "$key=") . urlencode(is_array($val) ? $val[0] : $val) . "'>$desc</a> » ";
}
}
echo "$title\n";
}
echo "$title\n";
}
}
echo "<h2>$title_all</h2>\n";
echo "<div id='ajaxstatus' class='jsonly hidden'></div>\n";
restart_session();
page_messages($error);
$databases = &get_session("dbs");
if (DB != "" && $databases && !in_array(DB, $databases, true)) {
$databases = null;
$databases = null;
}
stop_session();
define('Adminer\PAGE_HEADER', 1);
Expand Down
2 changes: 1 addition & 1 deletion adminer/include/editing.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ function edit_fields(array $fields, array $collations, $type = "TABLE", array $f
}

/** Move fields up and down or add field
* @param Field[] $fields
* @param array<array{field?: string, full_type: string, type: string, length: numeric-string|null, unsigned: string, default?: string, null: bool, auto_increment: bool, ...}> $fields
*/
function process_fields(array &$fields): bool {
$offset = 0;
Expand Down
2 changes: 1 addition & 1 deletion adminer/include/functions.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,7 @@ function is_shortable(array $field): bool {
function host_port(string $server) {
return (preg_match('~^(\[(.+)]|([^:]+)):([^:]+)$~', $server, $match) // [a:b] - IPv6
? array($match[2] . $match[3], $match[4])
: array($server, '')
: explode(':', $server, 2)
);
}

Expand Down
1 change: 1 addition & 0 deletions adminer/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* @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)
*/

// this is matched by compile.php

namespace Adminer;
Expand Down
2 changes: 1 addition & 1 deletion adminer/static/default.css
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ input.wayoff { left: -1000px; position: absolute; }
.icon-plus { background-image: url(data:image/gif;base64,R0lGODlhEgASAIEAMe7u7gAAgJmZmQAAACH5BAEAAAEALAAAAAASABIAAQIhhI+py+0PTQjxzCopvm/6rykgCHGVGaFliLXuI8TyTMsFADs=); }
.icon-cross { background-image: url(data:image/gif;base64,R0lGODlhEgASAIEAMe7u7gAAgJmZmQAAACH5BAEAAAEALAAAAAASABIAAQIjhI+py+0PIwph1kZvfnnDLoFfd2GU4THnsUruC0fCTNc2XQAAOw==); }
.icon-move { background-image: url(data:image/gif;base64,R0lGODlhEgASAJEAAO7u7gAAAJmZmQAAACH5BAEAAAEALAAAAAASABIAAAIfhI+py+3vgpyU0Rug3gnX5U3cqIWSZZLqigjuC8dvAQA7); }
#schema .arrow { height: 1.25em; background: url(data:image/gif;base64,R0lGODlhCAAKAIAAAICAgP///yH5BAEAAAEALAAAAAAIAAoAAAIPBIJplrGLnpQRqtOy3rsAADs=) no-repeat right center; }
#schema .arrow { height: 1.25em; background: url(data:image/gif;base64,R0lGODlhCAAKAIAAAICAgP//yH5BAEAAAEALAAAAAAIAAoAAAIPBIJplrGLnpQRqtOy3rsAADs=) no-repeat right center; }

.rtl h2 { margin: 0 -18px 20px 0; }
.rtl p, .rtl table, .rtl .error, .rtl .message { margin: 1em 0 0 20px; }
Expand Down
6 changes: 5 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,16 @@
"require": {
"php": ">=7.4"
},
"require-dev": {
"phpstan/phpstan": "^2.1.30"
},
"scripts": {
"check": [
"phpcs",
"phpstan analyse -c phpstan.neon"
],
"compile": "@php compile.php",
"clean": "rm -f adminer*.php editor*.php"
}
},
"prefer-stable" : true
}
23 changes: 5 additions & 18 deletions phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<exclude-pattern>/externals/</exclude-pattern>
<exclude-pattern>/designs/</exclude-pattern>
<exclude-pattern>/(adminer|editor)[-.]</exclude-pattern>
<exclude-pattern>vendor/*</exclude-pattern>

<rule ref="PSR12">
<exclude name="Generic.WhiteSpace.DisallowTabIndent"/><!-- Replaced by: Generic.WhiteSpace.DisallowSpaceIndent -->
Expand All @@ -20,6 +21,7 @@
<exclude name="PSR12.Properties.ConstantVisibility.NotFound"/><!-- PHP 7.1 is not required. -->

<!-- More readable. -->
<exclude name="PSR12.Files.FileHeader.SpacingAfterTagBlock"/>
<exclude name="PSR12.Files.FileHeader.SpacingAfterBlock"/>
<exclude name="PSR12.Classes.OpeningBraceSpace.Found"/>
<exclude name="PSR12.Operators.OperatorSpacing.NoSpaceBefore"/>
Expand All @@ -46,11 +48,9 @@
</rule>

<rule ref="PSR1.Methods.CamelCapsMethodName.NotCamelCaps">
<exclude-pattern>adminer/drivers/</exclude-pattern>
<exclude-pattern>adminer/include/db.inc.php</exclude-pattern>
<exclude-pattern>adminer/include/pdo.inc.php</exclude-pattern>
<exclude-pattern>adminer/plugins/foreign-system.php</exclude-pattern>
<exclude-pattern>adminer/plugins/drivers/</exclude-pattern>
<exclude-pattern>include/*</exclude-pattern>
<exclude-pattern>drivers/*</exclude-pattern>
<exclude-pattern>plugins/foreign-system.php</exclude-pattern>
</rule>

<rule ref="Generic.Files.LineLength">
Expand Down Expand Up @@ -79,7 +79,6 @@
<rule ref="Generic.Files.EndFileNewline"/>
<rule ref="Generic.Files.LowercasedFilename"/>
<rule ref="Generic.Formatting.SpaceAfterCast"/>
<rule ref="Generic.Functions.CallTimePassByReference"/>
<rule ref="Generic.Functions.OpeningFunctionBraceKernighanRitchie"/>
<rule ref="Generic.NamingConventions.ConstructorName"/>
<rule ref="Generic.PHP.BacktickOperator"/>
Expand All @@ -93,19 +92,7 @@
<rule ref="Squiz.Arrays.ArrayBracketSpacing"/>
<rule ref="Squiz.Classes.LowercaseClassKeywords"/>
<rule ref="Squiz.Classes.SelfMemberReference"/>
<rule ref="Squiz.CSS.ClassDefinitionNameSpacing"/>
<rule ref="Squiz.CSS.ColonSpacing"/>
<rule ref="Squiz.CSS.DuplicateClassDefinition"/>
<rule ref="Squiz.CSS.DuplicateStyleDefinition"/>
<rule ref="Squiz.CSS.EmptyClassDefinition"/>
<rule ref="Squiz.CSS.EmptyStyleDefinition"/>
<rule ref="Squiz.CSS.ForbiddenStyles"/>
<rule ref="Squiz.CSS.Indentation"/>
<rule ref="Squiz.CSS.MissingColon"/>
<rule ref="Squiz.CSS.Opacity"/>
<rule ref="Squiz.CSS.SemicolonSpacing"/>
<rule ref="Squiz.Functions.FunctionDuplicateArgument"/>
<rule ref="Squiz.Objects.ObjectMemberComma"/>
<rule ref="Squiz.Operators.IncrementDecrementUsage"/>
<rule ref="Squiz.Operators.ValidLogicalOperators"/>
<rule ref="Squiz.PHP.DiscouragedFunctions"/>
Expand Down
10 changes: 8 additions & 2 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ parameters:
- "~Adminer\\\\Result.*mysqli_result~" # mysqli_result
- "~Function Adminer\\\\queries\\(\\) never returns Adminer\\\\Result~" # mysqli_result

# must check if needs fix
- message: "~Function Adminer\\\\get_driver\\(\\) never returns null~"
- message: "~Offset 'generated' does not exist~"
- message: "~Parameter &\\$fields by-ref type of function Adminer\\\\process_fields~"
- message: "~Offset 'orig' does not exist~"
- message: "~Parameter #2 \\$row of function Adminer\\\\create_routine expects array\\{name\\?: string, fields: list<array\\{field: string, type: string, length: numeric-string, unsigned: string, null: bool, full_type: string, collation: string, inout\\?: string\\}>, comment: string, returns\\?: array\\{type: string, length: numeric-string, unsigned: string, collation: string\\}, definition: string, language\\?: string\\}, non-empty-array given~"
- message: "~Parameter #2 \\$row of function Adminer\\\\routine_id expects array\\{name\\?: string, fields: list<array\\{field: string, type: string, length: numeric-string, unsigned: string, null: bool, full_type: string, collation: string, inout\\?: string\\}>, comment: string, returns\\?: array\\{type: string, length: numeric-string, unsigned: string, collation: string\\}, definition: string, language\\?: string\\}, non-empty-array given~"

# not real problems
- identifier: include.fileNotFound # includes in include/ relative from index.php
- identifier: includeOnce.fileNotFound # ./adminer-plugins.php
Expand Down Expand Up @@ -45,8 +53,6 @@ parameters:
- identifier: if.alwaysTrue
- identifier: isset.offset
- identifier: deadCode.unreachable
- "~Function Adminer\\\\get_driver\\(\\) never returns null~"
- "~on array\\{}~"

paths:
- adminer/drivers/mysql.inc.php # other drivers inherit the annotations so we take them from here
Expand Down
16 changes: 8 additions & 8 deletions plugins/highlight-codemirror.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@ function syntaxHighlighting($tableStatuses) {
echo Adminer\script_src("$this->root/mode/javascript/javascript$this->minified.js", true);
$tables = array_fill_keys(array_keys($tableStatuses), array());
if (Adminer\support("sql")) {
echo Adminer\script_src("$this->root/mode/sql/sql$this->minified.js", true);
echo Adminer\script_src("$this->root/addon/hint/sql-hint$this->minified.js", true);
if (isset($_GET["sql"]) || isset($_GET["trigger"]) || isset($_GET["check"])) {
foreach (Adminer\driver()->allFields() as $table => $fields) {
foreach ($fields as $field) {
$tables[$table][] = $field["field"];
}
}
echo Adminer\script_src("$this->root/mode/sql/sql$this->minified.js", true);
echo Adminer\script_src("$this->root/addon/hint/sql-hint$this->minified.js", true);
if (isset($_GET["sql"]) || isset($_GET["trigger"]) || isset($_GET["check"])) {
foreach (Adminer\driver()->allFields() as $table => $fields) {
foreach ($fields as $field) {
$tables[$table][] = $field["field"];
}
}
}
}
?>
<script <?php echo Adminer\nonce(); ?>>
addEventListener('DOMContentLoaded', () => {
Expand Down