Adminer - Extensions
Both Adminer and Editor offers support for extensions. It is possible to overwrite some default Adminer functionality by a custom code. All you need is to define the adminer_object function which returns an object extending the basic Adminer class. Then just include the original adminer.php or editor.php:
<?php
function adminer_object() {
class AdminerSoftware extends Adminer {
function name() {
// custom name in title and heading
return 'Software';
}
function permanentLogin() {
// key used for permanent login
return "64861f9fae9936783abbc3b731787ff4";
}
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 == '');
}
}
return new AdminerSoftware;
}
include "./editor.php";
API reference
The object can overwrite following methods:
- string name() - Name in title and navigation
- array credentials() - Connection parameters
- string permanentLogin() - Get key used for permanent login
- string database() - Identifier of selected database
- null loginForm(string $username) - Print login form
- bool login(string $login, string $password) - Authorize the user
- string tableName(array $tableStatus) - Table caption used in navigation and headings
- string fieldName(array $field, int $order) - Field caption used in select and edit
- null selectLinks(array $tableStatus, string $set) - Print links after select heading
- array backwardKeys(string $table, string $tableName) - Find backward keys for table
- null backwardKeysPrint(array $backwardKeys, array $row) - Print backward keys for row
- string selectQuery(string $query) - Query printed in select before execution
- string rowDescription(string $table) - Description of a row in a table
- array rowDescriptions(array $rows, array $foreignKeys) - Get descriptions of selected data
- string selectVal(string $val, string $link, array $field) - Value printed in select table
- string editVal(string $val, array $field) - Value conversion used in select and edit
- null selectColumnsPrint(array $select, array $columns) - Print columns box in select
- null selectSearchPrint(array $where, array $columns, array $indexes) - Print search box in select
- null selectOrderPrint(array $order, array $columns, array $indexes) - Print order box in select
- null selectLimitPrint(string $limit) - Print limit box in select
- null selectLengthPrint(string $text_length) - Print text length box in select
- null selectActionPrint() - Print action box in select
- null selectEmailPrint(array $emailFields, array $columns) - Print extra text in the end of a select form
- array selectColumnsProcess(array $columns, array $indexes) - Process columns box in select
- array selectSearchProcess(array $fields, array $indexes) - Process search box in select
- array selectOrderProcess(array $fields, array $indexes) - Process order box in select
- string selectLimitProcess() - Process limit box in select
- string selectLengthProcess() - Process length box in select
- bool selectEmailProcess(array $where, array $foreignKeys) - Process extras in select form
- string messageQuery(string $query) - Query printed after execution in the message
- array editFunctions(array $field) - Functions displayed in edit form
- string editInput(string $table, array $field, string $attrs, string $value) - Get options to display edit field
- string processInput(array $field, string $value, string $function) - Process sent input
- string dumpOutput(bool $select) - Returns export output options
- string dumpFormat(bool $select) - Returns export format options
- null navigation(string $missing) - Prints navigation after Adminer title
- null tablesPrint(array $tables) - Prints table list in menu
It is possible to use following global functions. Min_DB is subset of mysqli class.
- Min_DB connection() - Get database connection
- string idf_escape(string $idf) - Escape database identifier
- string idf_unescape(string $idf) - Unescape database identifier
- string escape_string(string $val) - Escape string to use inside ''
- string bracket_escape(string $idf, bool $back) - Escape or unescape string to use inside form []
- string h(string $string) - Escape for HTML
- string nbsp(string $string) - Escape for TD
- string checkbox(string $name, string $value, bool $checked, string $label, string $onclick) - Generate HTML checkbox
- string optionlist(array $options, mixed $selected, bool $use_keys) - Generate list of HTML options
- string html_select(string $name, array $options, string $value, string $onchange) - Generate HTML radio list
- array get_vals(string $query, mixed $column) - Get list of values from database
- string unique_idf(array $row, array $indexes) - Find unique identifier of a row
- string where(array $where) - Create SQL condition from parsed query string
- string where_check(string $val) - Create SQL condition from query string
- string where_link(int $i, string $column, string $value) - Create query string where condition from value
- bool cookie(string $name, string $value) - Set cookie valid for 1 month
- null restart_session() - Restart stopped session
- null redirect(string $location, string $message) - Send Location header and exit
- bool query_redirect(string $query, string $location, string $message, bool $redirect, bool $execute, bool $failed) - Execute query and redirect if successful
- Min_Result queries(string $query) - Execute and remember query
- queries_redirect(string $location, string $message, bool $redirect) - Redirect by remembered queries
- string remove_from_uri(string $param) - Remove parameter from query string
- string pagination(int $page) - Generate page number for pagination
- mixed get_file(string $key, bool $decompress) - Get file contents from $_FILES
- string upload_error(int $error) - Determine upload error
- string odd(string $return) - Generate class for odd rows
- bool is_utf8(string $val) - Check whether the string is in UTF-8
- string shorten_utf8(string $string, int $length, string $suffix) - Shorten UTF-8 string
- string friendly_url(string $val) - Generate friendly URL
- null hidden_fields(array $process, array $ignore) - Print hidden fields
- array column_foreign_keys(string $table) - Find out foreign keys for each column
- null input(array $field, mixed $value, string $function) - Print edit input field
- string process_input(one $field) - Process edit input field
- null search_tables() - Print results of search in all tables
- null dump_csv(array $row) - Print CSV row
- string apply_sql_function(string $function, string $column) - Apply SQL function
- bool is_email(string $email) - Check whether the string is e-mail address
- bool is_url(string $string) - Check whether the string is URL address
- null print_fieldset(string $id, string $legend, bool $visible) - Print header for hidden fieldset (close by </div></fieldset>)
- string bold(string $string, bool $bold) - Enclose $string to <b> if $bold is true
- mixed connect() - Connect to the database
- array get_databases(bool $flush) - Get cached list of databases
- array db_collation(string $db, array $collations) - Get database collation
- array tables_list() - Get tables list
- array table_status(string $name) - Get table status
- array table_status_referencable() - Get status of referencable tables
- array fields(string $table) - Get information about fields
- array indexes(string $table, string $connection2) - Get table indexes
- array foreign_keys(string $table) - Get foreign keys in table
- array view(string $name) - Get view SELECT
- array 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
- string exact_value(string $val) - Return expression for binary comparison
Min_DB
- bool connect(string $server, string $username, string $password) - Connect to server
- string quote(string $string) - Quote string to use in SQL
- bool select_db(string $database) - Select database
- mixed query(string $query, bool $unbuffered) - Send query
- bool multi_query(string $query) - Send query with more resultsets
- Min_Result store_result() - Get current resultset
- bool next_result() - Fetch next resultset
- string result(string $query, mixed $field) - Get single field from result
Min_Result