break;
}
}
- $invalid = ($invalids ? $invalids[$adminer->bruteForceKey()] : array());
- $next_attempt = (idx($invalid, 1) > 29 ? $invalid[0] - time() : 0); // allow 30 invalid attempts
+ $invalid = idx($invalids, $adminer->bruteForceKey(), array());
+ $next_attempt = ($invalid[1] > 29 ? $invalid[0] - time() : 0); // allow 30 invalid attempts
if ($next_attempt > 0) { //! do the same with permanent login
auth_error(lang('Too many unsuccessful logins, try again in %d minute(s).', ceil($next_attempt / 60)));
}
}
/** Get a possibly missing item from a possibly missing array
+* idx($row, $key) is better than $row[$key] ?? null because it reports error for undefined $row
* @param array|null
* @param string|int
* @param mixed
foreach ((array) $where["where"] as $key => $val) {
$key = bracket_escape($key, 1); // 1 - back
$column = escape_key($key);
- $field = ($fields ? $fields[$key] : array());
+ $field = idx($fields, $key, array());
$field_type = $field["type"];
$return[] = $column
. (JUSH == "sql" && $field_type == "json" ? " = CAST(" . q($val) . " AS JSON)"
} elseif ($_GET["history"] == "all") {
$q = $history;
} elseif ($_GET["history"] != "") {
- $q = $history[$_GET["history"]][0];
+ $q = idx($history[$_GET["history"]], 0);
}
echo "<p>";
textarea("query", $q, 20);
hintOptions: {
completeSingle: false,
tables: <?php echo json_encode($tables); ?>,
- defaultTable: <?php echo json_encode($_GET["trigger"] ? $_GET["trigger"] : ($_GET["check"] ? $_GET["check"] : null)); ?>
+ defaultTable: <?php echo json_encode($_GET["trigger"] ? $_GET["trigger"] : ($_GET["check"] ?: null)); ?>
}
});
cm.setSize(width, height);
function __construct($result) {
$this->result = $result;
$this->num_rows = count($result);
- $this->fields = ($result ? array_keys(reset($result)) : array());
+ $this->fields = array_keys(idx($result, 0, array()));
}
function fetch_assoc() {