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

Code style: Fix

This commit is contained in:
Jakub Vrana
2025-04-08 21:16:09 +02:00
parent 8bce359fae
commit 88099b7dd7
11 changed files with 41 additions and 24 deletions

View File

@@ -11,6 +11,7 @@ add_driver("mssql", "MS SQL");
if (isset($_GET["mssql"])) {
define('Adminer\DRIVER', "mssql");
if (extension_loaded("sqlsrv") && $_GET["ext"] != "pdo") {
class Db extends SqlDb {
public $extension = "sqlsrv";

View File

@@ -5,6 +5,7 @@ SqlDriver::$drivers = array("server" => "MySQL / MariaDB") + SqlDriver::$drivers
if (!defined('Adminer\DRIVER')) {
define('Adminer\DRIVER', "server"); // server - backwards compatibility
// MySQLi supports everything, MySQL doesn't support multiple result sets, PDO_MySQL doesn't support orgtable
if (extension_loaded("mysqli") && $_GET["ext"] != "pdo") {
class Db extends \MySQLi {

View File

@@ -5,6 +5,7 @@ add_driver("oracle", "Oracle (beta)");
if (isset($_GET["oracle"])) {
define('Adminer\DRIVER', "oracle");
if (extension_loaded("oci8") && $_GET["ext"] != "pdo") {
class Db extends SqlDb {
public $extension = "oci8";

View File

@@ -5,6 +5,7 @@ add_driver("pgsql", "PostgreSQL");
if (isset($_GET["pgsql"])) {
define('Adminer\DRIVER', "pgsql");
if (extension_loaded("pgsql") && $_GET["ext"] != "pdo") {
class PgsqlDb extends SqlDb {
public $extension = "PgSQL";
@@ -94,8 +95,9 @@ if (isset($_GET["pgsql"])) {
*/
function copyFrom(string $table, array $rows): bool {
$this->error = '';
set_error_handler(function ($errno, $error) {
set_error_handler(function (int $errno, string $error): bool {
$this->error = (ini_bool('html_errors') ? html_entity_decode($error) : $error);
return true;
});
$return = pg_copy_from($this->link, $table, $rows);
restore_error_handler();

View File

@@ -5,8 +5,8 @@ add_driver("sqlite", "SQLite");
if (isset($_GET["sqlite"])) {
define('Adminer\DRIVER', "sqlite");
if (class_exists("SQLite3") && $_GET["ext"] != "pdo") {
if (class_exists("SQLite3") && $_GET["ext"] != "pdo") {
abstract class SqliteDb extends SqlDb {
public $extension = "SQLite3";
private $link;

View File

@@ -11,7 +11,7 @@ if (substr(VERSION, -4) != '-dev') {
header("Cache-Control: immutable");
}
@ini_set("zlib.output_compression", 1); // @ - may be disabled
@ini_set("zlib.output_compression", '1'); // @ - may be disabled
if ($_GET["file"] == "default.css") {
header("Content-Type: text/css; charset=utf-8");

View File

@@ -257,10 +257,12 @@ AND CHECK_CLAUSE NOT LIKE '% IS NOT NULL'", $this->conn); // ignore default IS N
*/
function allFields(): array {
$return = array();
foreach (get_rows("SELECT TABLE_NAME AS tab, COLUMN_NAME AS field, IS_NULLABLE AS nullable, DATA_TYPE AS type, CHARACTER_MAXIMUM_LENGTH AS length" . (JUSH == 'sql' ? ", COLUMN_KEY = 'PRI' AS `primary`" : "") . "
foreach (
get_rows("SELECT TABLE_NAME AS tab, COLUMN_NAME AS field, IS_NULLABLE AS nullable, DATA_TYPE AS type, CHARACTER_MAXIMUM_LENGTH AS length" . (JUSH == 'sql' ? ", COLUMN_KEY = 'PRI' AS `primary`" : "") . "
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_SCHEMA = " . q($_GET["ns"] != "" ? $_GET["ns"] : DB) . "
ORDER BY TABLE_NAME, ORDINAL_POSITION", $this->conn) as $row) {
ORDER BY TABLE_NAME, ORDINAL_POSITION", $this->conn) as $row
) {
$row["null"] = ($row["nullable"] == "YES");
$return[$row["tab"]][] = $row;
}

View File

@@ -595,10 +595,10 @@ function column_foreign_keys(string $table): array {
return $return;
}
/** Compute fields() from $_POST edit data
/** Compute fields() from $_POST edit data; used by Mongo and SimpleDB
* @return Field[] same as fields()
*/
function fields_from_edit(): array { // used by Mongo and SimpleDB
function fields_from_edit(): array {
$return = array();
foreach ((array) $_POST["field_keys"] as $key => $val) {
if ($val != "") {

View File

@@ -199,10 +199,10 @@ function minify_css($file) {
}
function minify_js($file) {
$file = preg_replace_callback("~'use strict';~", function ($match) { // keep only the first one
$file = preg_replace_callback("~'use strict';~", function ($match) {
static $count = 0;
$count++;
return ($count == 1 ? $match[0] : '');
return ($count == 1 ? $match[0] : ''); // keep only the first one
}, $file);
if (function_exists('jsShrink')) {
$file = jsShrink($file);
@@ -210,7 +210,8 @@ function minify_js($file) {
return lzw_compress($file);
}
function compile_file($match, $callback = '') { // $callback only to match signature
// $callback only to match signature
function compile_file($match, $callback = '') {
global $project;
$file = "";
list(, $filenames, $callback) = $match;
@@ -303,7 +304,12 @@ if ($vendor) {
}
}
if ($project != "editor" && count(Adminer\SqlDriver::$drivers) == 1) {
$file = str_replace('html_select("auth[driver]", SqlDriver::$drivers, DRIVER, "loginDriver(this);")', 'input_hidden("auth[driver]", "' . ($vendor == "mysql" ? "server" : $vendor) . '") . "' . reset(Adminer\SqlDriver::$drivers) . '"', $file, $count);
$file = str_replace(
'html_select("auth[driver]", SqlDriver::$drivers, DRIVER, "loginDriver(this);")',
'input_hidden("auth[driver]", "' . ($vendor == "mysql" ? "server" : $vendor) . '") . "' . reset(Adminer\SqlDriver::$drivers) . '"',
$file,
$count
);
if (!$count) {
echo "auth[driver] form field not found\n";
}

View File

@@ -47,7 +47,9 @@
<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>
</rule>

View File

@@ -1,18 +1,20 @@
#!/usr/bin/env php
<?php
foreach (array(
'create' => array(1106, 412),
'dark' => array(816, 750),
'database' => array(896, 666),
'db' => array(1258, 752),
'dump' => array(784, 450),
'edit' => array(1006, 336),
'login' => array(628, 326),
'select' => array(924, 810),
'schema' => array(690, 406),
'sql' => array(870, 788),
'table' => array(816, 750),
) as $filename => list($w, $h)) {
foreach (
array(
'create' => array(1106, 412),
'dark' => array(816, 750),
'database' => array(896, 666),
'db' => array(1258, 752),
'dump' => array(784, 450),
'edit' => array(1006, 336),
'login' => array(628, 326),
'select' => array(924, 810),
'schema' => array(690, 406),
'sql' => array(870, 788),
'table' => array(816, 750),
) as $filename => list($w, $h)
) {
$im = imagecreatefrompng("screenshots/$filename.png");
$im2 = imagecreatetruecolor($w, $h);
imagecopy($im2, $im, 0, 0, 0, 0, $w, $h);