Adminer - Extensii
Atât Adminer, cât și Editor oferă suport pentru extensii. Este posibil să suprascrieți unele funcționalități implicite ale Adminer printr-un cod personalizat. Tot ce trebuie este să definiți funcția adminer_object care returnează un obiect care extinde clasa de bază Adminer\Adminer. Apoi, trebuie doar să includeți fișierul original adminer.php sau editor.php:
<?php
function adminer_object() {
class AdminerSoftware extends Adminer\Adminer {
function name() {
// custom name in title and heading
return 'Software';
}
function permanentLogin() {
// key used for permanent login
return '10bce1554a320a7b69e768f35dc1b2a8';
}
function credentials() {
// server, username and password for connecting to database
return array('localhost', 'ODBC', '');
}
function database() {
// database name, will be escaped by Adminer
return 'software';
}
function login($login, $password) {
// validate user submitted credentials
return ($login == 'admin' && $password == '0gIOKwUl');
}
function tableName($tableStatus) {
// tables without comments would return empty string and will be ignored by Adminer
return Adminer\h($tableStatus['Comment']);
}
function fieldName($field, $order = 0) {
// only columns with comments will be displayed and only the first five in select
return ($order <= 5 && !preg_match('~_(md5|sha1)$~', $field['field']) ? Adminer\h($field['comment']) : '');
}
}
return new AdminerSoftware;
}
include './editor.php';
Pentru a crea o personalizare a Adminer Editor pentru alte drivere decât MySQL, trebuie să definiți propria metodă loginForm și să completați valoarea câmpului auth[driver] cu driverul dumneavoastră (pgsql, sqlite, ...).
De obicei, trebuie, de asemenea, să implementați metoda database.
Exemplu: editor/sqlite.php.
Adminer acceptă și plugins care sunt extensii gata de utilizare.
Referință API

Totul se află în namespace-ul Adminer. Type aliases
Obiectul poate suprascrie următoarele metode:
- string Adminer::name() - Name in title and navigation
- array{string, string, string} Adminer::credentials() - Connection parameters
- string[]|void Adminer::connectSsl() - Get SSL connection options
- string Adminer::bruteForceKey() - Return key used to group brute force attacks; behind a reverse proxy, you want to return the last part of X-Forwarded-For
- string Adminer::serverName(?string $server) - Get server name displayed in breadcrumbs
- ?string Adminer::database() - Identifier of selected database
- list<string> Adminer::pluginsLinks() - Print links after list of plugins
- list<string> Adminer::operators() - Operators used in select
- list<string> Adminer::schemas() - Get list of schemas
- float Adminer::queryTimeout() - Specify limit for waiting on some slow queries like DB list
- void Adminer::afterConnect() - Called after connecting and selecting a database
- void Adminer::headers() - Headers to send before HTML output
- list<string[]> $dark) - Print HTML code inside <head>
- void Adminer::bodyClass() - Print extra classes in <body class>; must start with a space
- string[] Adminer::css() - Get URLs of the CSS files
- void Adminer::loginForm() - Print login form
- string Adminer::login(string $login, string $password) - Authorize the user
- string Adminer::tableName(TableStatus $tableStatus) - Table caption used in navigation and headings
- string $set) - Print links after select heading
- ForeignKey[] Adminer::foreignKeys(string $table) - Get foreign keys for table
- BackwardKey[] Adminer::backwardKeys(string $table, string $tableName) - Find backward keys for table
- void Adminer::backwardKeysPrint(BackwardKey[] $backwardKeys, string[] $row) - Print backward keys for row
- string $query) - Query printed in SQL command before execution
- void Adminer::sqlPrintAfter() - Print HTML code just before the Execute button in SQL command
- string Adminer::rowDescription(string $table) - Description of a row in a table
- list<string[]> $val, array{type: string} $field) - Get a link to use in select table
- string Adminer::editVal(?string $val, array{type: string} $field) - Value conversion used in select and edit
- string[] Adminer::config() - Get configuration options for AdminerConfig
- void Adminer::tableIndexesPrint(Index[] $indexes, TableStatus $tableStatus) - Print list of indexes on table in tabular format
- void $where, string[] $columns, Index[] $indexes) - Print search box in select
- void Adminer::selectLimitPrint(int $limit) - Print limit box in select
- void Adminer::selectActionPrint(Index[] $indexes) - Print action box in select
- bool Adminer::selectCommandPrint() - Print command box in select
- bool Adminer::selectImportPrint() - Print import box in select
- void $columns, Index[] $indexes) - Process columns box in select
- list<string> Adminer::selectSearchProcess(Field[] $fields, Index[] $indexes) - Process search box in select
- list<string> Adminer::selectOrderProcess(Field[] $fields, Index[] $indexes) - Process order box in select
- int Adminer::selectLimitProcess() - Process limit box in select
- numeric-string Adminer::selectLengthProcess() - Process length box in select
- bool $select, list<string> $where, list<string> $group, list<string> $order, int $limit, int $page) - Build SQL query used in select
- string Adminer::editRowPrint(string $table, Field[] $fields, mixed $row, ?bool $update) - Print before edit form
- string[] Adminer::editFunctions(Field|array{null:bool} $field) - Functions displayed in edit form
- string $table, Field $field, ?string $value) - Get hint for edit field
- string Adminer::dumpOutput() - Return export output options
- string[] Adminer::dumpFormat() - Return export format options
- void Adminer::dumpDatabase(string $db) - Export database structure
- void Adminer::dumpData(string $table, string $style, string $query) - Export table data
- string Adminer::dumpFilename(string $identifier) - Set export filename
- string Adminer::dumpFooter() - Print text after export
- string Adminer::importServerPath() - Set the path of the file for webserver load
- bool Adminer::homepage() - Print homepage
- void Adminer::syntaxHighlighting(TableStatus[] $tables) - Set up syntax highlight for code and <textarea>
- void Adminer::databasesPrint(string $missing) - Print databases list in menu
- string[] Adminer::menuActions(string[] $actions, string $missing) - Print table list in menu
- void Adminer::tablesPrint(TableStatus[] $tables) - Print table list in menu
- list<string[]> Adminer::showVariables() - Get server variables
- list<string[]> Adminer::showStatus() - Get status variables
- list<string[]> Adminer::processList() - Get process list
- Result|bool Adminer::killProcess(numeric-string $id) - Kill a process
Este posibil să se utilizeze următoarele funcții în spațiul de nume Adminer.
- Db adminer() - Get Adminer object
- Driver driver() - Get Driver object
- ?Db connect() - Connect to the database
- string q(string $string) - Shortcut for connection()->quote($string)
- mixed number(string $val) - Remove non-digits from a string; used instead of intval() to not corrupt big numbers
- string number_type() - Get regular expression to match numeric types
- mixed[] $back) - Escape or unescape string to use inside form []
- bool charset(Db $connection) - Get connection charset
- bool ini_bool(string $ini) - Get INI boolean value
- int ini_bytes(string $ini) - Get INI bytes value
- bool sid() - Check if SID is necessary
- void set_password(string $vendor, ?string $server, string $username, ?string $password) - Set password to session
- string|false|null get_password() - Get password from session
- string|false $column) - Get list of values from database
- string[] $connection2, string $error) - Get all rows of result
- string[]|void unique_array(string[] $row, Index[] $indexes) - Find unique identifier of a row
- string escape_key(string $key) - Escape column key used in where()
- string $fields) - Create SQL condition from query string
- string $columns, Field[] $fields, list<string> $select) - Get select clause for convertible fields
- string cookie_path() - Get path for a cookie
- void get_url(string $url, resource $context) - Get contents from URL
- mixed[] get_settings(string $cookie) - Get settings stored in a cookie
- mixed $cookie) - Store settings to a cookie
- void restart_session() - Restart stopped session
- void &(string $key) - Get session variable for current server
- mixed set_session(string $key, mixed $val) - Set session variable for current server
- string is_ajax() - Find whether it is an AJAX request
- void $redirect, bool $execute, bool $failed, string $time) - Execute query and redirect if successful
- Result|bool $escape) - Apply command to all array items
- bool queries_redirect(?string $location, string $message, bool $redirect) - Redirect by remembered queries
- string relative_uri() - Get relative REQUEST_URI
- string $decompress, string $delimiter) - Get file contents from $_FILES
- string upload_error(int $error) - Determine upload error
- string repeat_pattern(string $pattern, int $length) - Create repeat pattern for preg
- bool is_utf8(?string $val) - Check whether the string is in UTF-8
- string format_number(float|numeric-string $val) - Format decimal number
- string friendly_url(string $val) - Generate friendly URL
- TableStatus column_foreign_keys(string $table) - Find out foreign keys for each column
- Field[] fields_from_edit() - Compute fields() from $_POST edit data; used by Mongo and SimpleDB
- string dump_csv(string[] $row) - Print CSV row
- string get_temp_dir() - Get path of the temporary directory
- resource|void file_open_lock(string $filename) - Open and exclusively lock a file
- void file_write_unlock(resource $fp, string $data) - Write and unlock a file
- void file_unlock(resource $fp) - Unlock and close a file
- mixed first(mixed[] $array) - Get first element of an array
- string password_file(bool $create) - Read password from file adminer.key in temporary directory or create one
- string rand_string() - Get a random string
- string select_value(string|string[]|list<string[]> $val, string $link, array{type: string, full_type?: string} $field, ?numeric-string $text_length) - Format value to use in select
- bool is_blob(array{type: string} $field) - Check whether the field type is blob or equivalent
- bool is_mail(?string $email) - Check whether the string is e-mail address
- bool is_url(?string $string) - Check whether the string is URL address
- bool is_shortable(array{type: string} $field) - Check if field should be shortened
- array{0: string, 1: string} host_port(string $server) - Split server into host and (port or socket)
- string count_rows(string $table, list<string> $where, bool $is_group, list<string> $group) - Get query to compute number of found rows
- string[] slow_query(string $query) - Run query which can be killed by AJAX call after timing out
- string get_token() - Generate BREACH resistant CSRF token
- bool verify_token() - Verify if supplied CSRF token is valid
HTML helpers:
Funcții specifice limbii:
Funcții specifice driverului:
- bool Db::set_charset(string $charset) - Set the client character set
- Result::__construct( $result) - @param resource $result
- array<?string>|false Result::fetch_assoc() - Fetch next row as associative array
- list<?string>|false Result::fetch_row() - Fetch next row as numbered array
- \stdClass Result::fetch_field() - Fetch next field
- string idf_escape(string $idf) - Escape database identifier
- string table(string $idf) - Get escaped table name
- list<string> get_databases(bool $flush) - Get cached list of databases
- string $query, string $where, string $separator) - Formulate SQL modification query with limit 1
- ?string logged_user() - Get logged user
- string[] tables_list() - Get tables list
- int[] count_tables(list<string> $databases) - Count tables in all databases
- array<string, TableStatus> is_view(TableStatus $table_status) - Find out whether the identifier is view
- bool fk_support(TableStatus $table_status) - Check if table supports foreign keys
- Field[] fields(string $table) - Get information about fields
- Index[] foreign_keys(string $table) - Get foreign keys in table
- array{select:string} view(string $name) - Get view SELECT
- string[][] collations() - Get sorted grouped list of collations
- bool information_schema(?string $db) - Find out if database is information_schema
- string error() - Get escaped error message
- Result create_database(string $db, string $collation) - Create database
- bool drop_databases(list<string> $databases) - Drop databases
- bool auto_increment() - Generate modifier for auto increment column
- Result|bool $table, string $alter) - Run commands to alter indexes
- bool truncate_tables(list<string> $tables) - Run commands to truncate tables
- Result|bool drop_views(list<string> $views) - Drop views
- Result|bool drop_tables(list<string> $tables) - Drop tables
- bool move_tables(list<string> $tables, list<string> $views, string $target) - Move tables to other schema
- bool copy_tables(list<string> $tables, list<string> $views, string $target) - Copy tables to other schema
- Trigger triggers(string $table) - Get defined triggers
- array{Timing: list<string>, Event: list<string>, Type: list<string>} trigger_options() - Get trigger options
- Routine routine(string $name, 'FUNCTION'|'PROCEDURE' $type) - Get information about stored routine
- list<string[]> routines() - Get list of routines
- list<string> routine_languages() - Get list of available routine languages
- string routine_id(string $name, Routine $row) - Get routine signature
- string last_id(Result|bool $result) - Get last auto increment ID
- Result explain(Db $connection, string $query) - Explain select
- numeric-string|null found_rows(TableStatus $table_status, list<string> $where) - Get approximate number of rows
- string create_sql(string $table, ?bool $auto_increment, string $style) - Get SQL command to create table
- string truncate_sql(string $table) - Get SQL command to truncate table
- string trigger_sql(string $table) - Get SQL commands to create triggers
- list<string[]> show_variables() - Get server variables
- list<string[]> show_status() - Get status variables
- list<string[]> process_list() - Get process list
- string|void convert_field(Field $field) - Convert field in select and edit
- string $feature) - Check whether a feature is supported
- Result|bool kill_process(numeric-string $id) - Kill a process
- string connection_id() - Return query to get connection ID
- numeric-string max_connections() - Get maximum number of connections
- string[] types() - Get user defined types
- string type_values(int $id) - Get values of user defined type
- list<string> schemas() - Get existing schemas
- string get_schema() - Get current schema
- bool Driver:
- void add_driver(string $id, string $name) - Add or overwrite a driver
- ?string get_driver(string $id) - Get driver name
- Driver::__construct(Db $connection) - Create object for performing database operations
- int[] Driver::types() - Get all types
- list<string>[]|list<string> Driver::structuredTypes() - Get structured types
- string|void Driver::enumLength(Field $field) - Get enum values
- string|void Driver::unconvertFunction(Field $field) - Function used to convert the value inputted by user
- Result|false $queryWhere, int $limit) - Delete data from table
- Result|bool $set) - Insert data into table
- string Driver::insertReturning(string $table) - Get RETURNING clause for INSERT queries (PostgreSQL specific)
- Result|bool Driver::begin() - Begin transaction
- Result|bool Driver::commit() - Commit transaction
- Result|bool Driver::rollback() - Rollback transaction
- string|void $idf, array{op:string, val:string} $val, Field $field) - Convert column to be searchable
- ?string Driver::value(?string $val, array{type: string} $field) - Convert value returned by database to actual value
- string Driver::quoteBinary(string $s) - Quote binary string
- string|void Driver::warnings() - Get warnings about the last command
- string|void Driver::inheritsFrom(string $table) - Get tables this table inherits from
- list<array{table: string, ns: string}> Driver::inheritedTables(string $table) - Get inherited tables
- Partitions Driver::partitionsInfo(string $table) - Get partitions info
- bool Driver::hasCStyleEscapes() - Check if C-style escapes are supported
- list<string> Driver::engines() - Get supported engines
- bool Driver::supportsIndex(TableStatus $table_status) - Check whether table supports indexes
- list<string> Driver::indexAlgorithms(TableStatus $tableStatus) - Return list of supported index algorithms, first one is default
- string[] Driver::checkConstraints(string $table) - Get defined check constraints
- array<list<array{field:string, null:bool, type:string, length:?numeric-string}>> Driver::allFields() - Get all fields in the current schema
Db:
Funcții specifice administratorului:
- string[] referencable_primary(string $self) - Get referencable tables with single column primary key except self
- void $value, string $onchange, string $placeholder) - Generate HTML <select> or <input> if $options are empty
- void $foreign_keys, list<string> $extra_types) - Print table columns for type edit
- string process_length(?string $length) - Filter length value including enums
- string $field, Field $type_field) - Create SQL string from field
- string default_value(Field $field) - Get default value clause
- string|void type_class(string $type) - Get type class to use in CSS
- void process_fields(Field[] $fields) - Add or remove field
- string normalize_enum(list<string> $match) - Callback used in routine()
- Result|bool grant('GRANT'|'REVOKE' $grant, list<string> $privileges, ?string $columns, string $on) - Issue grant or revoke commands
- void create_trigger(string $on, Trigger $row) - Generate SQL query for creating trigger
- string create_routine('PROCEDURE'|'FUNCTION' $routine, Routine $row) - Generate SQL query for creating routine
- string remove_definer(string $query) - Remove current user definer from SQL command
- string format_foreign_key(ForeignKey $foreign_key) - Format foreign key to use in SQL query
- void tar_file(string $filename, TmpFile $tmp_file) - Add a file to TAR
- string db_size(string $db) - Compute size of database
- void set_utf8mb4(string $create) - Print SET NAMES if utf8mb4 might be needed
Funcții specifice editorului: