*/ public $operators; // operators used in select, null for all operators
/** @var string @visibility protected(set) */ public $error = ''; // HTML
/** Name in title and navigation
* @return string HTML code
*/
function name() {
return "Adminer";
}
/** Connection parameters
* @return array{string, string, string}
*/
function credentials() {
return array(SERVER, $_GET["username"], get_password());
}
/** Get SSL connection options
* @return string[]|void
*/
function connectSsl() {
}
/** Get key used for permanent login
* @param bool
* @return string cryptic string which gets combined with password or false in case of an error
*/
function permanentLogin($create = false) {
return password_file($create);
}
/** Return key used to group brute force attacks; behind a reverse proxy, you want to return the last part of X-Forwarded-For
* @return string
*/
function bruteForceKey() {
return $_SERVER["REMOTE_ADDR"];
}
/** Get server name displayed in breadcrumbs
* @param string
* @return string HTML code or null
*/
function serverName($server) {
return h($server);
}
/** Identifier of selected database
* @return string
*/
function database() {
// should be used everywhere instead of DB
return DB;
}
/** Get cached list of databases
* @param bool
* @return list
*/
function databases($flush = true) {
return get_databases($flush);
}
/** Get list of schemas
* @return list
*/
function schemas() {
return schemas();
}
/** Specify limit for waiting on some slow queries like DB list
* @return float number of seconds
*/
function queryTimeout() {
return 2;
}
/** Headers to send before HTML output
* @return void
*/
function headers() {
}
/** Get Content Security Policy headers
* @return list of arrays with directive name in key, allowed sources in value
*/
function csp() {
return csp();
}
/** Print HTML code inside
* @param bool dark CSS: false to disable, true to force, null to base on user preferences
* @return bool true to link favicon.ico
*/
function head($dark = null) {
// this is matched by compile.php
echo "\n";
echo ($dark !== false ? "\n" : "");
return true;
}
/** Get URLs of the CSS files
* @return list
*/
function css() {
$return = array();
foreach (array("", "-dark") as $mode) {
$filename = "adminer$mode.css";
if (file_exists($filename)) {
$return[] = "$filename?v=" . crc32(file_get_contents($filename));
}
}
return $return;
}
/** Print login form
* @return void
*/
function loginForm() {
global $drivers;
echo "
\n";
// this is matched by compile.php
echo $this->loginFormField('driver', '
\n";
echo checkbox("auth[permanent]", 1, $_COOKIE["adminer_permanent"], lang('Permanent login')) . "\n";
}
/** Get login form field
* @param string
* @param string HTML
* @param string HTML
* @return string
*/
function loginFormField($name, $heading, $value) {
return $heading . $value . "\n";
}
/** Authorize the user
* @param string
* @param string
* @return mixed true for success, string for error message, false for unknown error
*/
function login($login, $password) {
if ($password == "") {
return lang('Adminer does not support accessing a database without a password, more information.', target_blank());
}
return true;
}
/** Table caption used in navigation and headings
* @param TableStatus result of table_status1()
* @return string HTML code, "" to ignore table
*/
function tableName($tableStatus) {
return h($tableStatus["Name"]);
}
/** Field caption used in select and edit
* @param Field single field returned from fields()
* @param int order of column in select
* @return string HTML code, "" to ignore field
*/
function fieldName($field, $order = 0) {
$type = $field["full_type"];
$comment = $field["comment"];
return '' . h($field["field"]) . '';
}
/** Print links after select heading
* @param TableStatus result of table_status1()
* @param string new item options, NULL for no new item
* @return void
*/
function selectLinks($tableStatus, $set = "") {
global $driver;
echo '
';
$links = array("select" => lang('Select data'));
if (support("table") || support("indexes")) {
$links["table"] = lang('Show structure');
}
$is_view = false;
if (support("table")) {
$is_view = is_view($tableStatus);
if ($is_view) {
$links["view"] = lang('Alter view');
} else {
$links["create"] = lang('Alter table');
}
}
if ($set !== null) {
$links["edit"] = lang('New item');
}
$name = $tableStatus["Name"];
foreach ($links as $key => $val) {
echo " $val";
}
echo doc_link(array(JUSH => $driver->tableHelp($name, $is_view)), "?");
echo "\n";
}
/** Get foreign keys for table
* @param string
* @return ForeignKey[] same format as foreign_keys()
*/
function foreignKeys($table) {
return foreign_keys($table);
}
/** Find backward keys for table
* @param string
* @param string
* @return BackwardKey[]
*/
function backwardKeys($table, $tableName) {
return array();
}
/** Print backward keys for row
* @param BackwardKey[] result of $this->backwardKeys()
* @param string[]
* @return void
*/
function backwardKeysPrint($backwardKeys, $row) {
}
/** Query printed in select before execution
* @param string query to be executed
* @param float start time of the query
* @param bool
* @return string
*/
function selectQuery($query, $start, $failed = false) {
global $driver;
$return = "
" . h(str_replace("\n", " ", $query)) . "(" . format_time($start) . ")"
. (support("sql") ? " " . lang('Edit') . "" : "")
. $return
;
}
/** Query printed in SQL command before execution
* @param string query to be executed
* @return string escaped query to be printed
*/
function sqlCommandQuery($query) {
return shorten_utf8(trim($query), 1000);
}
/** Print HTML code just before the Execute button in SQL command
* @return void
*/
function sqlPrintAfter() {
}
/** Description of a row in a table
* @param string
* @return string SQL expression, empty string for no description
*/
function rowDescription($table) {
return "";
}
/** Get descriptions of selected data
* @param list all data to print
* @param ForeignKey[]
* @return list
*/
function rowDescriptions($rows, $foreignKeys) {
return $rows;
}
/** Get a link to use in select table
* @param string raw value of the field
* @param Field single field returned from fields()
* @return string|void null to create the default link
*/
function selectLink($val, $field) {
}
/** Value printed in select table
* @param string HTML-escaped value to print
* @param string link to foreign key
* @param Field single field returned from fields()
* @param string original value before applying editVal() and escaping
* @return string
*/
function selectVal($val, $link, $field, $original) {
$return = ($val === null ? "NULL"
: (preg_match("~char|binary|boolean~", $field["type"]) && !preg_match("~var~", $field["type"]) ? "$val"
: (preg_match('~json~', $field["type"]) ? "$val"
: $val)
));
if (preg_match('~blob|bytea|raw|file~', $field["type"]) && !is_utf8($val)) {
$return = "" . lang('%d byte(s)', strlen($original)) . "";
}
return ($link ? "$return" : $return);
}
/** Value conversion used in select and edit
* @param string
* @param Field single field returned from fields()
* @return string
*/
function editVal($val, $field) {
return $val;
}
/** Print table structure in tabular format
* @param Field[] data about individual fields
* @param TableStatus
* @return void
*/
function tableStructurePrint($fields, $tableStatus = null) {
global $driver;
echo "
\n";
}
/** Print list of indexes on table in tabular format
* @param Index[] data about all indexes on a table
* @return void
*/
function tableIndexesPrint($indexes) {
echo "