Code cosmetics : removed trailing tabs

This commit is contained in:
Lionel Laffineur 2023-05-21 15:03:36 +02:00
parent f21795b27d
commit e3c1f24ad6
21 changed files with 78 additions and 81 deletions

View file

@ -28,13 +28,13 @@ if (!$error && $_POST) {
}
$call[] = (isset($out[$key]) ? "@" . idf_escape($field["field"]) : $val);
}
$query = (isset($_GET["callf"]) ? "SELECT" : "CALL") . " " . table($PROCEDURE) . "(" . implode(", ", $call) . ")";
$start = microtime(true);
$result = $connection->multi_query($query);
$affected = $connection->affected_rows; // getting warnigns overwrites this
echo $adminer->selectQuery($query, $start, !$result);
if (!$result) {
echo "<p class='error'>" . error() . "\n";
} else {
@ -42,7 +42,7 @@ if (!$error && $_POST) {
if (is_object($connection2)) {
$connection2->select_db(DB);
}
do {
$result = $connection->store_result();
if (is_object($result)) {
@ -53,7 +53,7 @@ if (!$error && $_POST) {
;
}
} while ($connection->next_result());
if ($out) {
select($connection->query("SELECT " . implode(", ", $out)));
}

View file

@ -262,7 +262,7 @@ if (isset($_GET["elastic"])) {
function db_collation($db, $collations) {
}
function engines() {
return array();
}

View file

@ -24,7 +24,7 @@ if (isset($_GET["mongo"])) {
$this->error = $e->getMessage();
}
}
function query($query) {
return false;
}
@ -109,7 +109,7 @@ if (isset($_GET["mongo"])) {
class Min_Driver extends Min_SQL {
public $primary = "_id";
function select($table, $select, $where, $group, $order = array(), $limit = 1, $page = 0, $print = false) {
$select = ($select == array("*")
? array()
@ -127,7 +127,7 @@ if (isset($_GET["mongo"])) {
->skip($page * $limit)
);
}
function insert($table, $set) {
try {
$return = $this->_conn->_db->selectCollection($table)->insert($set);
@ -219,7 +219,7 @@ if (isset($_GET["mongo"])) {
$this->_link = new $class($uri, $options);
$this->executeCommand('admin', array('ping' => 1));
}
function executeCommand($db, $command) {
$class = 'MongoDB\Driver\Command';
try {
@ -229,7 +229,7 @@ if (isset($_GET["mongo"])) {
return array();
}
}
function executeBulkWrite($namespace, $bulk, $counter) {
try {
$results = $this->_link->executeBulkWrite($namespace, $bulk);
@ -575,7 +575,7 @@ if (isset($_GET["mongo"])) {
"(date)>=",
"(date)<=",
);
}
function table($idf) {

View file

@ -15,7 +15,7 @@ if ($_POST && !$error) {
: "AT " . q($row["STARTS"])
) . " ON COMPLETION" . ($row["ON_COMPLETION"] ? "" : " NOT") . " PRESERVE"
;
queries_redirect(substr(ME, 0, -1), ($EVENT != "" ? lang('Event has been altered.') : lang('Event has been created.')), queries(($EVENT != ""
? "ALTER EVENT " . idf_escape($EVENT) . $schedule
. ($EVENT != $row["EVENT_NAME"] ? "\nRENAME TO " . idf_escape($row["EVENT_NAME"]) : "")

View file

@ -6,7 +6,7 @@ $row = $_POST;
if ($_POST && !$error && !$_POST["add"] && !$_POST["change"] && !$_POST["change-js"]) {
$message = ($_POST["drop"] ? lang('Foreign key has been dropped.') : ($name != "" ? lang('Foreign key has been altered.') : lang('Foreign key has been created.')));
$location = ME . "table=" . urlencode($TABLE);
if (!$_POST["drop"]) {
$row["source"] = array_filter($row["source"], 'strlen');
ksort($row["source"]); // enforce input order
@ -16,7 +16,7 @@ if ($_POST && !$error && !$_POST["add"] && !$_POST["change"] && !$_POST["change-
}
$row["target"] = $target;
}
if ($jush == "sqlite") {
queries_redirect($location, $message, recreate_table($TABLE, $TABLE, array(), array(), array(" $name" => ($_POST["drop"] ? "" : " " . format_foreign_key($row)))));
} else {

View file

@ -39,7 +39,7 @@ class Adminer {
function bruteForceKey() {
return $_SERVER["REMOTE_ADDR"];
}
/** Get server name displayed in breadcrumbs
* @param string
* @return string HTML code or null
@ -128,7 +128,7 @@ class Adminer {
echo "<p><input type='submit' value='" . lang('Login') . "'>\n";
echo checkbox("auth[permanent]", 1, $_COOKIE["adminer_permanent"], lang('Permanent login')) . "\n";
}
/** Get login form field
* @param string
* @param string HTML
@ -480,7 +480,7 @@ class Adminer {
echo "</script>\n";
echo "</div></fieldset>\n";
}
/** Print command box in select
* @return bool whether to print default commands
*/

View file

@ -72,14 +72,14 @@ if ($auth) {
) {
redirect(auth_url($vendor, $server, $username, $db));
}
} elseif ($_POST["logout"] && (!$has_token || verify_token())) {
foreach (array("pwds", "db", "dbs", "queries") as $key) {
set_session($key, null);
}
unset_permanent();
redirect(substr(preg_replace('~\b(username|db|ns)=[^&]*&~', '', ME), 0, -1), lang('Logout successful.') . ' ' . lang('Thanks for using Adminer, consider <a href="https://www.adminer.org/en/donation/">donating</a>.'));
} elseif ($permanent && !$_SESSION["pwds"]) {
session_regenerate_id();
$private = $adminer->permanentLogin();
@ -199,7 +199,7 @@ if ($_POST) {
: lang('Invalid CSRF token. Send the form again.') . ' ' . lang('If you did not send this request from Adminer then close this page.')
);
}
} elseif ($_SERVER["REQUEST_METHOD"] == "POST") {
// posted form with no data means that post_max_size exceeded because Adminer always sends token at least
$error = lang('Too big POST data. Reduce the data or increase the %s configuration directive.', "'post_max_size'");

View file

@ -8,7 +8,7 @@ function connect_error() {
if ($_POST["db"] && !$error) {
queries_redirect(substr(ME, 0, -1), lang('Databases have been dropped.'), drop_databases($_POST["db"]));
}
page_header(lang('Select database'), $error, false);
echo "<p class='links'>\n";
foreach (array(
@ -39,9 +39,9 @@ function connect_error() {
. "<td>" . lang('Size') . " - <a href='" . h(ME) . "dbsize=1'>" . lang('Compute') . "</a>" . script("qsl('a').onclick = partial(ajaxSetHtml, '" . js_escape(ME) . "script=connect');", "")
. "</thead>\n"
;
$databases = ($_GET["dbsize"] ? count_tables($databases) : array_flip($databases));
foreach ($databases as $db => $tables) {
$root = h(ME) . "db=" . urlencode($db);
$id = h("Db-" . $db);
@ -53,7 +53,7 @@ function connect_error() {
echo "<td align='right' id='size-" . h($db) . "'>" . ($_GET["dbsize"] ? db_size($db) : "?");
echo "\n";
}
echo "</table>\n";
echo (support("database")
? "<div class='footer'><div>\n"
@ -69,7 +69,7 @@ function connect_error() {
echo script("tableCheck();");
}
}
page_footer("db");
}

View file

@ -13,14 +13,14 @@ function add_driver($id, $name) {
/*abstract*/ class Min_SQL {
var $_conn;
/** Create object for performing database operations
* @param Min_DB
*/
function __construct($connection) {
$this->_conn = $connection;
}
/** Select data from table
* @param string
* @param array result of $adminer->selectColumnsProcess()[0]
@ -52,7 +52,7 @@ function add_driver($id, $name) {
}
return $return;
}
/** Delete data from table
* @param string
* @param string " WHERE ..."
@ -63,7 +63,7 @@ function add_driver($id, $name) {
$query = "FROM " . table($table);
return queries("DELETE" . ($limit ? limit1($table, $query, $queryWhere) : " $query$queryWhere"));
}
/** Update data in table
* @param string
* @param array escaped columns in keys, quoted data in values
@ -80,7 +80,7 @@ function add_driver($id, $name) {
$query = table($table) . " SET$separator" . implode(",$separator", $values);
return queries("UPDATE" . ($limit ? limit1($table, $query, $queryWhere, $separator) : " $query$queryWhere"));
}
/** Insert data into table
* @param string
* @param array escaped columns in keys, quoted data in values
@ -92,7 +92,7 @@ function add_driver($id, $name) {
: " DEFAULT VALUES"
));
}
/** Insert or update data in table
* @param string
* @param array
@ -102,28 +102,28 @@ function add_driver($id, $name) {
/*abstract*/ function insertUpdate($table, $rows, $primary) {
return false;
}
/** Begin transaction
* @return bool
*/
function begin() {
return queries("BEGIN");
}
/** Commit transaction
* @return bool
*/
function commit() {
return queries("COMMIT");
}
/** Rollback transaction
* @return bool
*/
function rollback() {
return queries("ROLLBACK");
}
/** Return query with a timeout
* @param string
* @param int seconds
@ -131,7 +131,7 @@ function add_driver($id, $name) {
*/
function slowQuery($query, $timeout) {
}
/** Convert column to be searchable
* @param string escaped column name
* @param array array("op" => , "val" => )
@ -161,19 +161,19 @@ function add_driver($id, $name) {
function quoteBinary($s) {
return q($s);
}
/** Get warnings about the last command
* @return string HTML
*/
function warnings() {
return '';
}
/** Get help link for table
* @param string
* @return string relative URL or null
*/
function tableHelp($name) {
}
}

View file

@ -3,7 +3,7 @@
if (extension_loaded('pdo')) {
/*abstract*/ class Min_PDO {
var $_result, $server_info, $affected_rows, $errno, $error, $pdo;
function __construct() {
global $adminer;
$pos = array_search("SQL", $adminer->operators);
@ -11,7 +11,7 @@ if (extension_loaded('pdo')) {
unset($adminer->operators[$pos]);
}
}
function dsn($dsn, $username, $password, $options = array()) {
$options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_SILENT;
$options[PDO::ATTR_STATEMENT_CLASS] = array('Min_PDOStatement');
@ -22,13 +22,13 @@ if (extension_loaded('pdo')) {
}
$this->server_info = @$this->pdo->getAttribute(PDO::ATTR_SERVER_VERSION);
}
/*abstract function select_db($database);*/
function quote($string) {
return $this->pdo->quote($string);
}
function query($query, $unbuffered = false) {
$result = $this->pdo->query($query);
$this->error = "";
@ -42,11 +42,11 @@ if (extension_loaded('pdo')) {
$this->store_result($result);
return $result;
}
function multi_query($query) {
return $this->_result = $this->query($query);
}
function store_result($result = null) {
if (!$result) {
$result = $this->_result;
@ -61,7 +61,7 @@ if (extension_loaded('pdo')) {
$this->affected_rows = $result->rowCount();
return true;
}
function next_result() {
if (!$this->_result) {
return false;
@ -69,7 +69,7 @@ if (extension_loaded('pdo')) {
$this->_result->_offset = 0;
return @$this->_result->nextRowset(); // @ - PDO_PgSQL doesn't support it
}
function result($query, $field = 0) {
$result = $this->query($query);
if (!$result) {
@ -79,18 +79,18 @@ if (extension_loaded('pdo')) {
return $row[$field];
}
}
class Min_PDOStatement extends PDOStatement {
var $_offset = 0, $num_rows;
function fetch_assoc() {
return $this->fetch(PDO::FETCH_ASSOC);
}
function fetch_row() {
return $this->fetch(PDO::FETCH_NUM);
}
function fetch_field() {
$row = (object) $this->getColumnMeta($this->_offset++);
$row->orgtable = $row->table;

View file

@ -3,20 +3,20 @@
class TmpFile {
var $handler;
var $size;
function __construct() {
$this->handler = tmpfile();
}
function write($contents) {
$this->size += strlen($contents);
fwrite($this->handler, $contents);
}
function send() {
fseek($this->handler, 0);
fpassthru($this->handler);
fclose($this->handler);
}
}

View file

@ -2,15 +2,15 @@
function adminer_object() {
// required to run any plugin
include_once "../plugins/plugin.php";
// autoloader
foreach (glob("../plugins/*.php") as $filename) {
include_once $filename;
}
// enable extra drivers just by including them
//~ include "../plugins/drivers/simpledb.php";
$plugins = array(
// specify enabled plugins here
new AdminerDatabaseHide(array('information_schema')),
@ -32,13 +32,13 @@ function adminer_object() {
new AdminerTablesFilter,
new AdminerEditForeign,
);
/* It is possible to combine customization and plugins:
class AdminerCustomization extends AdminerPlugin {
}
return new AdminerCustomization($plugins);
*/
return new AdminerPlugin($plugins);
}

View file

@ -61,12 +61,12 @@ foreach ($schema as $name => $table) {
echo "<div class='table' style='top: " . $table["pos"][0] . "em; left: " . $table["pos"][1] . "em;'>";
echo '<a href="' . h(ME) . 'table=' . urlencode($name) . '"><b>' . h($name) . "</b></a>";
echo script("qsl('div').onmousedown = schemaMousedown;");
foreach ($table["fields"] as $field) {
$val = '<span' . type_class($field["type"]) . ' title="' . h($field["full_type"] . ($field["null"] ? " NULL" : '')) . '">' . h($field["field"]) . '</span>';
echo "<br>" . ($field["primary"] ? "<i>$val</i>" : $val);
}
foreach ((array) $table["references"] as $target_name => $refs) {
foreach ($refs as $left => $ref) {
$left1 = $left - $table_pos[$name][1];
@ -76,7 +76,7 @@ foreach ($schema as $name => $table) {
}
}
}
foreach ((array) $referenced[$name] as $target_name => $refs) {
foreach ($refs as $left => $columns) {
$left1 = $left - $table_pos[$name][1];
@ -86,7 +86,7 @@ foreach ($schema as $name => $table) {
}
}
}
echo "\n</div>\n";
}

View file

@ -523,7 +523,7 @@ if (!$columns && support("table")) {
}
echo "</fieldset>\n";
}
echo "<fieldset>";
echo "<legend>" . lang('Whole result') . "</legend>";
$display_rows = ($exact_count ? "" : "~ ") . $found_rows;

View file

@ -225,7 +225,7 @@ if (!isset($_GET["import"])) {
echo script(($_POST ? "" : "qs('textarea').focus();\n") . "qs('#form').onsubmit = partial(sqlSubmit, qs('#form'), '" . js_escape(remove_from_uri("sql|limit|error_stops|only_errors|history")) . "');");
echo "<p>$execute\n";
echo lang('Limit rows') . ": <input type='number' name='limit' class='size' value='" . h($_POST ? $_POST["limit"] : $_GET["limit"]) . "'>\n";
} else {
echo "<fieldset><legend>" . lang('File upload') . "</legend><div>";
$gz = (extension_loaded("zlib") ? "[.gz]" : "");

View file

@ -23,7 +23,7 @@ code { background: #eee; }
tbody tr:hover td, tbody tr:hover th { background: #eee; }
pre { margin: 1em 0 0; }
pre, textarea { font: 100%/1.25 monospace; }
input, select { vertical-align: middle; }
input { vertical-align: middle; }
input.default { box-shadow: 1px 1px 1px #777; }
input.required { box-shadow: 1px 1px 1px red; }
input.maxlength { box-shadow: 1px 1px 1px red; }

View file

@ -28,7 +28,7 @@ if (!is_view($table_status)) {
}
echo '<p class="links"><a href="' . h(ME) . 'indexes=' . urlencode($TABLE) . '">' . lang('Alter indexes') . "</a>\n";
}
if (fk_support($table_status)) {
echo "<h3 id='foreign-keys'>" . lang('Foreign keys') . "</h3>\n";
$foreign_keys = foreign_keys($TABLE);

View file

@ -196,7 +196,7 @@ function php_shrink($input) {
$short_variables = array();
$shortening = true;
$tokens = token_get_all($input);
// remove unnecessary { }
//! change also `while () { if () {;} }` to `while () if () ;` but be careful about `if () { if () { } } else { }
$shorten = 0;
@ -223,13 +223,13 @@ function php_shrink($input) {
}
}
$tokens = array_values($tokens);
foreach ($tokens as $i => $token) {
if ($token[0] === T_VARIABLE && !isset($special_variables[$token[1]])) {
$short_variables[$token[1]]++;
}
}
arsort($short_variables);
$chars = implode(range('a', 'z')) . '_' . implode(range('A', 'Z'));
// preserve variable names between versions if possible
@ -240,7 +240,7 @@ function php_shrink($input) {
foreach (array_keys($short_variables) as $number => $key) {
$short_variables[$key] = short_identifier($number, $chars); // could use also numbers and \x7f-\xff
}
$set = array_flip(preg_split('//', '!"#$%&\'()*+,-./:;<=>?@[]^`{|}'));
$space = '';
$output = '';
@ -377,9 +377,6 @@ foreach (glob(dirname(__FILE__) . "/adminer/drivers/" . ($driver ? $driver : "*"
$file = file_get_contents($filename);
foreach ($functions as $val) {
if (!strpos($file, "$val(")) {
if (!defined('STDERR')) {
define('STDERR', fopen('php://stderr', 'w'));
}
fprintf(STDERR, "Missing $val in $filename\n");
}
}

View file

@ -15,7 +15,7 @@ if ($adminer->homepage()) {
echo '<th>' . lang('Table');
echo '<td>' . lang('Rows');
echo "</thead>\n";
foreach (table_status() as $table => $row) {
$name = $adminer->tableName($row);
if (isset($row["Engine"]) && $name != "") {
@ -25,7 +25,7 @@ if ($adminer->homepage()) {
echo "<td align='right'><a href='" . h(ME . "edit=") . urlencode($table) . "'>" . ($row["Engine"] == "InnoDB" && $val ? "~ $val" : $val) . "</a>";
}
}
echo "</table>\n";
echo "</div>\n";
echo "</form>\n";

View file

@ -23,7 +23,7 @@ class Adminer {
function bruteForceKey() {
return $_SERVER["REMOTE_ADDR"];
}
function serverName($server) {
}

View file

@ -2,7 +2,7 @@
function adminer_object() {
include_once "../plugins/plugin.php";
include_once "../plugins/login-password-less.php";
class AdminerCustomization extends AdminerPlugin {
function loginFormField($name, $heading, $value) {
return parent::loginFormField($name, $heading, str_replace('value="server"', 'value="sqlite"', $value));
@ -11,7 +11,7 @@ function adminer_object() {
return "PATH_TO_YOUR_SQLITE_HERE";
}
}
return new AdminerCustomization(array(
// TODO: inline the result of password_hash() so that the password is not visible in source codes
new AdminerLoginPasswordLess(password_hash("YOUR_PASSWORD_HERE", PASSWORD_DEFAULT)),