mirror of
https://github.com/vrana/adminer.git
synced 2025-08-08 15:47:00 +02:00
PHP: Use ?:
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
namespace Adminer;
|
||||
|
||||
$PROCEDURE = ($_GET["name"] ? $_GET["name"] : $_GET["call"]);
|
||||
$PROCEDURE = ($_GET["name"] ?: $_GET["call"]);
|
||||
page_header(lang('Call') . ": " . h($PROCEDURE), $error);
|
||||
|
||||
$routine = routine($_GET["call"], (isset($_GET["callf"]) ? "FUNCTION" : "PROCEDURE"));
|
||||
|
@@ -654,8 +654,8 @@ if (!defined('Adminer\DRIVER')) {
|
||||
"table" => idf_unescape($match[4] != "" ? $match[4] : $match[3]),
|
||||
"source" => array_map('Adminer\idf_unescape', $source[0]),
|
||||
"target" => array_map('Adminer\idf_unescape', $target[0]),
|
||||
"on_delete" => ($match[6] ? $match[6] : "RESTRICT"),
|
||||
"on_update" => ($match[7] ? $match[7] : "RESTRICT"),
|
||||
"on_delete" => ($match[6] ?: "RESTRICT"),
|
||||
"on_update" => ($match[7] ?: "RESTRICT"),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -258,7 +258,7 @@ ORDER BY 1"
|
||||
|
||||
function get_current_db() {
|
||||
global $connection;
|
||||
$db = $connection->_current_db ? $connection->_current_db : DB;
|
||||
$db = $connection->_current_db ?: DB;
|
||||
unset($connection->_current_db);
|
||||
return $db;
|
||||
}
|
||||
@@ -272,7 +272,7 @@ ORDER BY 1"
|
||||
|
||||
function views_table($columns) {
|
||||
$owner = where_owner('');
|
||||
return "(SELECT $columns FROM all_views WHERE " . ($owner ? $owner : "rownum < 0") . ")";
|
||||
return "(SELECT $columns FROM all_views WHERE " . ($owner ?: "rownum < 0") . ")";
|
||||
}
|
||||
|
||||
function tables_list() {
|
||||
@@ -503,7 +503,7 @@ AND c_src.TABLE_NAME = " . q($table);
|
||||
|
||||
function schemas() {
|
||||
$return = get_vals("SELECT DISTINCT owner FROM dba_segments WHERE owner IN (SELECT username FROM dba_users WHERE default_tablespace NOT IN ('SYSTEM','SYSAUX')) ORDER BY 1");
|
||||
return ($return ? $return : get_vals("SELECT DISTINCT owner FROM all_tables WHERE tablespace_name = " . q(DB) . " ORDER BY 1"));
|
||||
return ($return ?: get_vals("SELECT DISTINCT owner FROM all_tables WHERE tablespace_name = " . q(DB) . " ORDER BY 1"));
|
||||
}
|
||||
|
||||
function get_schema() {
|
||||
|
@@ -133,7 +133,7 @@ function auth_error($error) {
|
||||
$error = lang('Session support must be enabled.');
|
||||
}
|
||||
$params = session_get_cookie_params();
|
||||
cookie("adminer_key", ($_COOKIE["adminer_key"] ? $_COOKIE["adminer_key"] : rand_string()), $params["lifetime"]);
|
||||
cookie("adminer_key", ($_COOKIE["adminer_key"] ?: rand_string()), $params["lifetime"]);
|
||||
page_header(lang('Login'), $error, null);
|
||||
echo "<form action='' method='post'>\n";
|
||||
echo "<div>";
|
||||
|
@@ -75,7 +75,7 @@ var thousandsSeparator = '<?php echo js_escape(lang(',')); ?>';
|
||||
<?php
|
||||
if ($breadcrumb !== null) {
|
||||
$link = substr(preg_replace('~\b(username|db|ns)=[^&]*&~', '', ME), 0, -1);
|
||||
echo '<p id="breadcrumb"><a href="' . h($link ? $link : ".") . '">' . $drivers[DRIVER] . '</a> » ';
|
||||
echo '<p id="breadcrumb"><a href="' . h($link ?: ".") . '">' . $drivers[DRIVER] . '</a> » ';
|
||||
$link = substr(preg_replace('~\b(db|ns)=[^&]*&~', '', ME), 0, -1);
|
||||
$server = $adminer->serverName(SERVER);
|
||||
$server = ($server != "" ? $server : lang('Server'));
|
||||
|
@@ -851,7 +851,7 @@ function hidden_fields_get() {
|
||||
*/
|
||||
function table_status1($table, $fast = false) {
|
||||
$return = table_status($table, $fast);
|
||||
return ($return ? $return : array("Name" => $table));
|
||||
return ($return ?: array("Name" => $table));
|
||||
}
|
||||
|
||||
/** Find out foreign keys for each column
|
||||
@@ -1317,7 +1317,7 @@ var timeout = setTimeout(function () {
|
||||
}
|
||||
ob_flush();
|
||||
flush();
|
||||
$return = @get_key_vals(($slow_query ? $slow_query : $query), $connection2, false); // @ - may be killed
|
||||
$return = @get_key_vals(($slow_query ?: $query), $connection2, false); // @ - may be killed
|
||||
if ($connection2) {
|
||||
echo script("clearTimeout(timeout);");
|
||||
ob_flush();
|
||||
|
@@ -65,7 +65,7 @@ function get_lang() {
|
||||
*/
|
||||
function lang($idf, $number = null) {
|
||||
global $LANG, $translations;
|
||||
$translation = ($translations[$idf] ? $translations[$idf] : $idf);
|
||||
$translation = ($translations[$idf] ?: $idf);
|
||||
if (is_array($translation)) {
|
||||
$pos = ($number == 1 ? 0
|
||||
: ($LANG == 'cs' || $LANG == 'sk' ? ($number && $number < 5 ? 1 : 2) // different forms for 1, 2-4, other
|
||||
|
@@ -37,7 +37,7 @@ if ($_POST && !$error && !$_POST["add"] && !$_POST["drop_col"]) {
|
||||
$desc = $index["descs"][$key];
|
||||
$set[] = idf_escape($column) . ($length ? "(" . (+$length) . ")" : "") . ($desc ? " DESC" : "");
|
||||
$columns[] = $column;
|
||||
$lengths[] = ($length ? $length : null);
|
||||
$lengths[] = ($length ?: null);
|
||||
$descs[] = $desc;
|
||||
}
|
||||
}
|
||||
|
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
namespace Adminer;
|
||||
|
||||
$PROCEDURE = ($_GET["name"] ? $_GET["name"] : $_GET["procedure"]);
|
||||
$PROCEDURE = ($_GET["name"] ?: $_GET["procedure"]);
|
||||
$routine = (isset($_GET["function"]) ? "FUNCTION" : "PROCEDURE");
|
||||
$row = $_POST;
|
||||
$row["fields"] = (array) $row["fields"];
|
||||
|
@@ -5,7 +5,7 @@ page_header(lang('Database schema'), "", array(), h(DB . ($_GET["ns"] ? ".$_GET[
|
||||
|
||||
$table_pos = array();
|
||||
$table_pos_js = array();
|
||||
$SCHEMA = ($_GET["schema"] ? $_GET["schema"] : $_COOKIE["adminer_schema-" . str_replace(".", "_", DB)]); // $_COOKIE["adminer_schema"] was used before 3.2.0 //! ':' in table name
|
||||
$SCHEMA = ($_GET["schema"] ?: $_COOKIE["adminer_schema-" . str_replace(".", "_", DB)]); // $_COOKIE["adminer_schema"] was used before 3.2.0 //! ':' in table name
|
||||
preg_match_all('~([^:]+):([-0-9.]+)x([-0-9.]+)(_|$)~', $SCHEMA, $matches, PREG_SET_ORDER);
|
||||
foreach ($matches as $i => $match) {
|
||||
$table_pos[$match[1]] = array($match[2], $match[3]);
|
||||
@@ -28,7 +28,7 @@ foreach (table_status('', true) as $table => $table_status) {
|
||||
$field["pos"] = $pos;
|
||||
$schema[$table]["fields"][$name] = $field;
|
||||
}
|
||||
$schema[$table]["pos"] = ($table_pos[$table] ? $table_pos[$table] : array($top, 0));
|
||||
$schema[$table]["pos"] = ($table_pos[$table] ?: array($top, 0));
|
||||
foreach ($adminer->foreignKeys($table) as $val) {
|
||||
if (!$val["db"]) {
|
||||
$left = $base_left;
|
||||
|
@@ -33,7 +33,7 @@ if ($_GET["val"] && is_ajax()) {
|
||||
header("Content-Type: text/plain; charset=utf-8");
|
||||
foreach ($_GET["val"] as $unique_idf => $row) {
|
||||
$as = convert_field($fields[key($row)]);
|
||||
$select = array($as ? $as : idf_escape(key($row)));
|
||||
$select = array($as ?: idf_escape(key($row)));
|
||||
$where[] = where_check($unique_idf, $fields);
|
||||
$return = $driver->select($TABLE, $select, $where, $select);
|
||||
if ($return) {
|
||||
|
@@ -19,7 +19,7 @@ function add_quo_slashes($s) {
|
||||
function remove_lang($match) {
|
||||
global $translations;
|
||||
$idf = strtr($match[2], array("\\'" => "'", "\\\\" => "\\"));
|
||||
$s = ($translations[$idf] ? $translations[$idf] : $idf);
|
||||
$s = ($translations[$idf] ?: $idf);
|
||||
if ($match[3] == ",") { // lang() has parameters
|
||||
return $match[1] . (is_array($s) ? "lang(array('" . implode("', '", array_map('add_apo_slashes', $s)) . "')," : "sprintf('" . add_apo_slashes($s) . "',");
|
||||
}
|
||||
|
2
lang.php
2
lang.php
@@ -28,7 +28,7 @@ foreach (
|
||||
}
|
||||
}
|
||||
|
||||
foreach (glob(__DIR__ . "/adminer/lang/" . ($_SESSION["lang"] ? $_SESSION["lang"] : "*") . ".inc.php") as $filename) {
|
||||
foreach (glob(__DIR__ . "/adminer/lang/" . ($_SESSION["lang"] ?: "*") . ".inc.php") as $filename) {
|
||||
$messages = $messages_all;
|
||||
$file = file_get_contents($filename);
|
||||
$file = str_replace("\r", "", $file);
|
||||
|
@@ -57,7 +57,7 @@ if (isset($_GET["clickhouse"])) {
|
||||
|
||||
function connect($server, $username, $password) {
|
||||
preg_match('~^(https?://)?(.*)~', $server, $match);
|
||||
$this->_url = ($match[1] ? $match[1] : "http://") . urlencode($username) . ":" . urlencode($password) . "@$match[2]";
|
||||
$this->_url = ($match[1] ?: "http://") . urlencode($username) . ":" . urlencode($password) . "@$match[2]";
|
||||
$return = $this->query('SELECT 1');
|
||||
return (bool) $return;
|
||||
}
|
||||
|
@@ -78,7 +78,7 @@ if (isset($_GET["elastic"])) {
|
||||
*/
|
||||
function connect($server, $username, $password) {
|
||||
preg_match('~^(https?://)?(.*)~', $server, $match);
|
||||
$this->_url = ($match[1] ? $match[1] : "http://") . urlencode($username) . ":" . urlencode($password) . "@$match[2]";
|
||||
$this->_url = ($match[1] ?: "http://") . urlencode($username) . ":" . urlencode($password) . "@$match[2]";
|
||||
$return = $this->query('');
|
||||
if ($return) {
|
||||
$this->server_info = $return['version']['number'];
|
||||
@@ -529,7 +529,7 @@ if (isset($_GET["elastic"])) {
|
||||
$properties = array();
|
||||
foreach ($fields as $f) {
|
||||
$field_name = trim($f[1][0]);
|
||||
$field_type = trim($f[1][1] ? $f[1][1] : "text");
|
||||
$field_type = trim($f[1][1] ?: "text");
|
||||
$properties[$field_name] = array(
|
||||
'type' => $field_type
|
||||
);
|
||||
|
@@ -68,7 +68,7 @@ if (isset($_GET["elastic5"])) {
|
||||
|
||||
function connect($server, $username, $password) {
|
||||
preg_match('~^(https?://)?(.*)~', $server, $match);
|
||||
$this->_url = ($match[1] ? $match[1] : "http://") . urlencode($username) . ":" . urlencode($password) . "@$match[2]";
|
||||
$this->_url = ($match[1] ?: "http://") . urlencode($username) . ":" . urlencode($password) . "@$match[2]";
|
||||
$return = $this->query('');
|
||||
if ($return) {
|
||||
$this->server_info = $return['version']['number'];
|
||||
@@ -505,7 +505,7 @@ if (isset($_GET["elastic5"])) {
|
||||
$properties = array();
|
||||
foreach ($fields as $f) {
|
||||
$field_name = trim($f[1][0]);
|
||||
$field_type = trim($f[1][1] ? $f[1][1] : "text");
|
||||
$field_type = trim($f[1][1] ?: "text");
|
||||
$properties[$field_name] = array(
|
||||
'type' => $field_type
|
||||
);
|
||||
|
@@ -439,7 +439,7 @@ if (isset($_GET["simpledb"])) {
|
||||
}
|
||||
$connection->error = '';
|
||||
$tag = $action . "Result";
|
||||
return ($xml->$tag ? $xml->$tag : true);
|
||||
return ($xml->$tag ?: true);
|
||||
}
|
||||
|
||||
function sdb_request_all($action, $tag, $params = array(), $timeout = 0) {
|
||||
|
Reference in New Issue
Block a user