diff --git a/adminer/drivers/clickhouse.inc.php b/adminer/drivers/clickhouse.inc.php index 99c77ab8..ec5db517 100644 --- a/adminer/drivers/clickhouse.inc.php +++ b/adminer/drivers/clickhouse.inc.php @@ -372,21 +372,27 @@ if (isset($_GET["clickhouse"])) { return preg_match("~^(columns|sql|status|table|drop_col)$~", $feature); } - $jush = "clickhouse"; - $types = array(); - $structured_types = array(); - foreach (array( //! arrays - lang('Numbers') => array("Int8" => 3, "Int16" => 5, "Int32" => 10, "Int64" => 19, "UInt8" => 3, "UInt16" => 5, "UInt32" => 10, "UInt64" => 20, "Float32" => 7, "Float64" => 16, 'Decimal' => 38, 'Decimal32' => 9, 'Decimal64' => 18, 'Decimal128' => 38), - lang('Date and time') => array("Date" => 13, "DateTime" => 20), - lang('Strings') => array("String" => 0), - lang('Binary') => array("FixedString" => 0), - ) as $key => $val) { - $types += $val; - $structured_types[$key] = array_keys($val); + function driver_config() { + $types = array(); + $structured_types = array(); + foreach (array( //! arrays + lang('Numbers') => array("Int8" => 3, "Int16" => 5, "Int32" => 10, "Int64" => 19, "UInt8" => 3, "UInt16" => 5, "UInt32" => 10, "UInt64" => 20, "Float32" => 7, "Float64" => 16, 'Decimal' => 38, 'Decimal32' => 9, 'Decimal64' => 18, 'Decimal128' => 38), + lang('Date and time') => array("Date" => 13, "DateTime" => 20), + lang('Strings') => array("String" => 0), + lang('Binary') => array("FixedString" => 0), + ) as $key => $val) { + $types += $val; + $structured_types[$key] = array_keys($val); + } + return array( + 'jush' => "clickhouse", + 'types' => $types, + 'structured_types' => $structured_types, + 'unsigned' => array(), + 'operators' => array("=", "<", ">", "<=", ">=", "!=", "~", "!~", "LIKE", "LIKE %%", "IN", "IS NULL", "NOT LIKE", "NOT IN", "IS NOT NULL", "SQL"), + 'functions' => array(), + 'grouping' => array("avg", "count", "count distinct", "max", "min", "sum"), + 'edit_functions' => array(), + ); } - $unsigned = array(); - $operators = array("=", "<", ">", "<=", ">=", "!=", "~", "!~", "LIKE", "LIKE %%", "IN", "IS NULL", "NOT LIKE", "NOT IN", "IS NOT NULL", "SQL"); - $functions = array(); - $grouping = array("avg", "count", "count distinct", "max", "min", "sum"); - $edit_functions = array(); } diff --git a/adminer/drivers/elastic.inc.php b/adminer/drivers/elastic.inc.php index 75a19f16..799f6d0b 100644 --- a/adminer/drivers/elastic.inc.php +++ b/adminer/drivers/elastic.inc.php @@ -2,7 +2,6 @@ $drivers["elastic"] = "Elasticsearch (beta)"; if (isset($_GET["elastic"])) { - $possible_drivers = array("json + allow_url_fopen"); define("DRIVER", "elastic"); if (function_exists('json_decode') && ini_bool('allow_url_fopen')) { @@ -461,20 +460,27 @@ if (isset($_GET["elastic"])) { return $connection->last_id; } - $jush = "elastic"; - $operators = array("=", "query"); - $functions = array(); - $grouping = array(); - $edit_functions = array(array("json")); - $types = array(); ///< @var array ($type => $maximum_unsigned_length, ...) - $structured_types = array(); ///< @var array ($description => array($type, ...), ...) - foreach (array( - lang('Numbers') => array("long" => 3, "integer" => 5, "short" => 8, "byte" => 10, "double" => 20, "float" => 66, "half_float" => 12, "scaled_float" => 21), - lang('Date and time') => array("date" => 10), - lang('Strings') => array("string" => 65535, "text" => 65535), - lang('Binary') => array("binary" => 255), - ) as $key => $val) { - $types += $val; - $structured_types[$key] = array_keys($val); + function driver_config() { + $types = array(); + $structured_types = array(); + foreach (array( + lang('Numbers') => array("long" => 3, "integer" => 5, "short" => 8, "byte" => 10, "double" => 20, "float" => 66, "half_float" => 12, "scaled_float" => 21), + lang('Date and time') => array("date" => 10), + lang('Strings') => array("string" => 65535, "text" => 65535), + lang('Binary') => array("binary" => 255), + ) as $key => $val) { + $types += $val; + $structured_types[$key] = array_keys($val); + } + return array( + 'possible_drivers' => array("json + allow_url_fopen"), + 'jush' => "elastic", + 'operators' => array("=", "query"), + 'functions' => array(), + 'grouping' => array(), + 'edit_functions' => array(array("json")), + 'types' => $types, + 'structured_types' => $structured_types, + ); } } diff --git a/adminer/drivers/firebird.inc.php b/adminer/drivers/firebird.inc.php index f08b08d3..7e62930c 100644 --- a/adminer/drivers/firebird.inc.php +++ b/adminer/drivers/firebird.inc.php @@ -6,7 +6,6 @@ $drivers['firebird'] = 'Firebird (alpha)'; if (isset($_GET["firebird"])) { - $possible_drivers = array("interbase"); define("DRIVER", "firebird"); if (extension_loaded("interbase") ) { @@ -312,9 +311,14 @@ ORDER BY RDB$INDEX_SEGMENTS.RDB$FIELD_POSITION'; return preg_match("~^(columns|sql|status|table)$~", $feature); } - $jush = "firebird"; - $operators = array("="); - $functions = array(); - $grouping = array(); - $edit_functions = array(); + function driver_config() { + return array( + 'possible_drivers' => array("interbase"), + 'jush' => "firebird", + 'operators' => array("="), + 'functions' => array(), + 'grouping' => array(), + 'edit_functions' => array(), + ); + } } diff --git a/adminer/drivers/mongo.inc.php b/adminer/drivers/mongo.inc.php index 944f13f3..f2c0d7ed 100644 --- a/adminer/drivers/mongo.inc.php +++ b/adminer/drivers/mongo.inc.php @@ -2,7 +2,6 @@ $drivers["mongo"] = "MongoDB"; if (isset($_GET["mongo"])) { - $possible_drivers = array("mongo", "mongodb"); define("DRIVER", "mongo"); if (class_exists('MongoDB\Driver\Manager')) { @@ -731,8 +730,13 @@ if (isset($_GET["mongo"])) { return true; } - $jush = "mongo"; - $functions = array(); - $grouping = array(); - $edit_functions = array(array("json")); + function driver_config() { + return array( + 'possible_drivers' => array("mongo", "mongodb"), + 'jush' => "mongo", + 'functions' => array(), + 'grouping' => array(), + 'edit_functions' => array(array("json")), + ); + } } diff --git a/adminer/drivers/mssql.inc.php b/adminer/drivers/mssql.inc.php index b574079d..c8ed37c9 100644 --- a/adminer/drivers/mssql.inc.php +++ b/adminer/drivers/mssql.inc.php @@ -8,7 +8,6 @@ $drivers["mssql"] = "MS SQL (beta)"; if (isset($_GET["mssql"])) { - $possible_drivers = array("SQLSRV", "MSSQL", "PDO_DBLIB"); define("DRIVER", "mssql"); if (extension_loaded("sqlsrv")) { class Min_DB { @@ -646,28 +645,35 @@ WHERE sys1.xtype = 'TR' AND sys2.name = " . q($table) return preg_match('~^(comment|columns|database|drop_col|indexes|descidx|scheme|sql|table|trigger|view|view_trigger)$~', $feature); //! routine| } - $jush = "mssql"; - $types = array(); - $structured_types = array(); - foreach (array( //! use sys.types - lang('Numbers') => array("tinyint" => 3, "smallint" => 5, "int" => 10, "bigint" => 20, "bit" => 1, "decimal" => 0, "real" => 12, "float" => 53, "smallmoney" => 10, "money" => 20), - lang('Date and time') => array("date" => 10, "smalldatetime" => 19, "datetime" => 19, "datetime2" => 19, "time" => 8, "datetimeoffset" => 10), - lang('Strings') => array("char" => 8000, "varchar" => 8000, "text" => 2147483647, "nchar" => 4000, "nvarchar" => 4000, "ntext" => 1073741823), - lang('Binary') => array("binary" => 8000, "varbinary" => 8000, "image" => 2147483647), - ) as $key => $val) { - $types += $val; - $structured_types[$key] = array_keys($val); + function driver_config() { + $types = array(); + $structured_types = array(); + foreach (array( //! use sys.types + lang('Numbers') => array("tinyint" => 3, "smallint" => 5, "int" => 10, "bigint" => 20, "bit" => 1, "decimal" => 0, "real" => 12, "float" => 53, "smallmoney" => 10, "money" => 20), + lang('Date and time') => array("date" => 10, "smalldatetime" => 19, "datetime" => 19, "datetime2" => 19, "time" => 8, "datetimeoffset" => 10), + lang('Strings') => array("char" => 8000, "varchar" => 8000, "text" => 2147483647, "nchar" => 4000, "nvarchar" => 4000, "ntext" => 1073741823), + lang('Binary') => array("binary" => 8000, "varbinary" => 8000, "image" => 2147483647), + ) as $key => $val) { + $types += $val; + $structured_types[$key] = array_keys($val); + } + return array( + 'possible_drivers' => array("SQLSRV", "MSSQL", "PDO_DBLIB"), + 'jush' => "mssql", + 'types' => $types, + 'structured_types' => $structured_types, + 'unsigned' => array(), + 'operators' => array("=", "<", ">", "<=", ">=", "!=", "LIKE", "LIKE %%", "IN", "IS NULL", "NOT LIKE", "NOT IN", "IS NOT NULL"), + 'functions' => array("len", "lower", "round", "upper"), + 'grouping' => array("avg", "count", "count distinct", "max", "min", "sum"), + 'edit_functions' => array( + array( + "date|time" => "getdate", + ), array( + "int|decimal|real|float|money|datetime" => "+/-", + "char|text" => "+", + ) + ), + ); } - $unsigned = array(); - $operators = array("=", "<", ">", "<=", ">=", "!=", "LIKE", "LIKE %%", "IN", "IS NULL", "NOT LIKE", "NOT IN", "IS NOT NULL"); - $functions = array("len", "lower", "round", "upper"); - $grouping = array("avg", "count", "count distinct", "max", "min", "sum"); - $edit_functions = array( - array( - "date|time" => "getdate", - ), array( - "int|decimal|real|float|money|datetime" => "+/-", - "char|text" => "+", - ) - ); } diff --git a/adminer/drivers/mysql.inc.php b/adminer/drivers/mysql.inc.php index b0f596f0..8c93506b 100644 --- a/adminer/drivers/mysql.inc.php +++ b/adminer/drivers/mysql.inc.php @@ -2,7 +2,6 @@ $drivers = array("server" => "MySQL") + $drivers; if (!defined("DRIVER")) { - $possible_drivers = array("MySQLi", "MySQL", "PDO_MySQL"); define("DRIVER", "server"); // server - backwards compatibility // MySQLi supports everything, MySQL doesn't support multiple result sets, PDO_MySQL doesn't support orgtable if (extension_loaded("mysqli")) { @@ -1111,34 +1110,44 @@ if (!defined("DRIVER")) { return $connection->result("SELECT @@max_connections"); } - $jush = "sql"; ///< @var string JUSH identifier - $types = array(); ///< @var array ($type => $maximum_unsigned_length, ...) - $structured_types = array(); ///< @var array ($description => array($type, ...), ...) - foreach (array( - lang('Numbers') => array("tinyint" => 3, "smallint" => 5, "mediumint" => 8, "int" => 10, "bigint" => 20, "decimal" => 66, "float" => 12, "double" => 21), - lang('Date and time') => array("date" => 10, "datetime" => 19, "timestamp" => 19, "time" => 10, "year" => 4), - lang('Strings') => array("char" => 255, "varchar" => 65535, "tinytext" => 255, "text" => 65535, "mediumtext" => 16777215, "longtext" => 4294967295), - lang('Lists') => array("enum" => 65535, "set" => 64), - lang('Binary') => array("bit" => 20, "binary" => 255, "varbinary" => 65535, "tinyblob" => 255, "blob" => 65535, "mediumblob" => 16777215, "longblob" => 4294967295), - lang('Geometry') => array("geometry" => 0, "point" => 0, "linestring" => 0, "polygon" => 0, "multipoint" => 0, "multilinestring" => 0, "multipolygon" => 0, "geometrycollection" => 0), - ) as $key => $val) { - $types += $val; - $structured_types[$key] = array_keys($val); + /** Get driver config + * @return array array('possible_drivers' => , 'jush' => , 'types' => , 'structured_types' => , 'unsigned' => , 'operators' => , 'functions' => , 'grouping' => , 'edit_functions' => ) + */ + function driver_config() { + $types = array(); ///< @var array ($type => $maximum_unsigned_length, ...) + $structured_types = array(); ///< @var array ($description => array($type, ...), ...) + foreach (array( + lang('Numbers') => array("tinyint" => 3, "smallint" => 5, "mediumint" => 8, "int" => 10, "bigint" => 20, "decimal" => 66, "float" => 12, "double" => 21), + lang('Date and time') => array("date" => 10, "datetime" => 19, "timestamp" => 19, "time" => 10, "year" => 4), + lang('Strings') => array("char" => 255, "varchar" => 65535, "tinytext" => 255, "text" => 65535, "mediumtext" => 16777215, "longtext" => 4294967295), + lang('Lists') => array("enum" => 65535, "set" => 64), + lang('Binary') => array("bit" => 20, "binary" => 255, "varbinary" => 65535, "tinyblob" => 255, "blob" => 65535, "mediumblob" => 16777215, "longblob" => 4294967295), + lang('Geometry') => array("geometry" => 0, "point" => 0, "linestring" => 0, "polygon" => 0, "multipoint" => 0, "multilinestring" => 0, "multipolygon" => 0, "geometrycollection" => 0), + ) as $key => $val) { + $types += $val; + $structured_types[$key] = array_keys($val); + } + return array( + 'possible_drivers' => array("MySQLi", "MySQL", "PDO_MySQL"), + 'jush' => "sql", ///< @var string JUSH identifier + 'types' => $types, + 'structured_types' => $structured_types, + 'unsigned' => array("unsigned", "zerofill", "unsigned zerofill"), ///< @var array number variants + 'operators' => array("=", "<", ">", "<=", ">=", "!=", "LIKE", "LIKE %%", "REGEXP", "IN", "FIND_IN_SET", "IS NULL", "NOT LIKE", "NOT REGEXP", "NOT IN", "IS NOT NULL", "SQL"), ///< @var array operators used in select + 'functions' => array("char_length", "date", "from_unixtime", "lower", "round", "floor", "ceil", "sec_to_time", "time_to_sec", "upper"), ///< @var array functions used in select + 'grouping' => array("avg", "count", "count distinct", "group_concat", "max", "min", "sum"), ///< @var array grouping functions used in select + 'edit_functions' => array( ///< @var array of array("$type|$type2" => "$function/$function2") functions used in editing, [0] - edit and insert, [1] - edit only + array( + "char" => "md5/sha1/password/encrypt/uuid", + "binary" => "md5/sha1", + "date|time" => "now", + ), array( + number_type() => "+/-", + "date" => "+ interval/- interval", + "time" => "addtime/subtime", + "char|text" => "concat", + ) + ), + ); } - $unsigned = array("unsigned", "zerofill", "unsigned zerofill"); ///< @var array number variants - $operators = array("=", "<", ">", "<=", ">=", "!=", "LIKE", "LIKE %%", "REGEXP", "IN", "FIND_IN_SET", "IS NULL", "NOT LIKE", "NOT REGEXP", "NOT IN", "IS NOT NULL", "SQL"); ///< @var array operators used in select - $functions = array("char_length", "date", "from_unixtime", "lower", "round", "floor", "ceil", "sec_to_time", "time_to_sec", "upper"); ///< @var array functions used in select - $grouping = array("avg", "count", "count distinct", "group_concat", "max", "min", "sum"); ///< @var array grouping functions used in select - $edit_functions = array( ///< @var array of array("$type|$type2" => "$function/$function2") functions used in editing, [0] - edit and insert, [1] - edit only - array( - "char" => "md5/sha1/password/encrypt/uuid", - "binary" => "md5/sha1", - "date|time" => "now", - ), array( - number_type() => "+/-", - "date" => "+ interval/- interval", - "time" => "addtime/subtime", - "char|text" => "concat", - ) - ); } diff --git a/adminer/drivers/oracle.inc.php b/adminer/drivers/oracle.inc.php index 0395f850..688812b2 100644 --- a/adminer/drivers/oracle.inc.php +++ b/adminer/drivers/oracle.inc.php @@ -2,7 +2,6 @@ $drivers["oracle"] = "Oracle (beta)"; if (isset($_GET["oracle"])) { - $possible_drivers = array("OCI8", "PDO_OCI"); define("DRIVER", "oracle"); if (extension_loaded("oci8")) { class Min_DB { @@ -404,30 +403,37 @@ ORDER BY PROCESS return preg_match('~^(columns|database|drop_col|indexes|descidx|processlist|scheme|sql|status|table|variables|view|view_trigger)$~', $feature); //! } - $jush = "oracle"; - $types = array(); - $structured_types = array(); - foreach (array( - lang('Numbers') => array("number" => 38, "binary_float" => 12, "binary_double" => 21), - lang('Date and time') => array("date" => 10, "timestamp" => 29, "interval year" => 12, "interval day" => 28), //! year(), day() to second() - lang('Strings') => array("char" => 2000, "varchar2" => 4000, "nchar" => 2000, "nvarchar2" => 4000, "clob" => 4294967295, "nclob" => 4294967295), - lang('Binary') => array("raw" => 2000, "long raw" => 2147483648, "blob" => 4294967295, "bfile" => 4294967296), - ) as $key => $val) { - $types += $val; - $structured_types[$key] = array_keys($val); + function driver_config() { + $types = array(); + $structured_types = array(); + foreach (array( + lang('Numbers') => array("number" => 38, "binary_float" => 12, "binary_double" => 21), + lang('Date and time') => array("date" => 10, "timestamp" => 29, "interval year" => 12, "interval day" => 28), //! year(), day() to second() + lang('Strings') => array("char" => 2000, "varchar2" => 4000, "nchar" => 2000, "nvarchar2" => 4000, "clob" => 4294967295, "nclob" => 4294967295), + lang('Binary') => array("raw" => 2000, "long raw" => 2147483648, "blob" => 4294967295, "bfile" => 4294967296), + ) as $key => $val) { + $types += $val; + $structured_types[$key] = array_keys($val); + } + return array( + 'possible_drivers' => array("OCI8", "PDO_OCI"), + 'jush' => "oracle", + 'types' => $types, + 'structured_types' => $structured_types, + 'unsigned' => array(), + 'operators' => array("=", "<", ">", "<=", ">=", "!=", "LIKE", "LIKE %%", "IN", "IS NULL", "NOT LIKE", "NOT REGEXP", "NOT IN", "IS NOT NULL", "SQL"), + 'functions' => array("length", "lower", "round", "upper"), + 'grouping' => array("avg", "count", "count distinct", "max", "min", "sum"), + 'edit_functions' => array( + array( //! no parentheses + "date" => "current_date", + "timestamp" => "current_timestamp", + ), array( + "number|float|double" => "+/-", + "date|timestamp" => "+ interval/- interval", + "char|clob" => "||", + ) + ), + ); } - $unsigned = array(); - $operators = array("=", "<", ">", "<=", ">=", "!=", "LIKE", "LIKE %%", "IN", "IS NULL", "NOT LIKE", "NOT REGEXP", "NOT IN", "IS NOT NULL", "SQL"); - $functions = array("length", "lower", "round", "upper"); - $grouping = array("avg", "count", "count distinct", "max", "min", "sum"); - $edit_functions = array( - array( //! no parentheses - "date" => "current_date", - "timestamp" => "current_timestamp", - ), array( - "number|float|double" => "+/-", - "date|timestamp" => "+ interval/- interval", - "char|clob" => "||", - ) - ); } diff --git a/adminer/drivers/pgsql.inc.php b/adminer/drivers/pgsql.inc.php index d6213b4d..a07b767d 100644 --- a/adminer/drivers/pgsql.inc.php +++ b/adminer/drivers/pgsql.inc.php @@ -2,7 +2,6 @@ $drivers["pgsql"] = "PostgreSQL"; if (isset($_GET["pgsql"])) { - $possible_drivers = array("PgSQL", "PDO_PgSQL"); define("DRIVER", "pgsql"); if (extension_loaded("pgsql")) { class Min_DB { @@ -879,32 +878,39 @@ AND typelem = 0" return $connection->result("SHOW max_connections"); } - $jush = "pgsql"; - $types = array(); - $structured_types = array(); - foreach (array( //! arrays - lang('Numbers') => array("smallint" => 5, "integer" => 10, "bigint" => 19, "boolean" => 1, "numeric" => 0, "real" => 7, "double precision" => 16, "money" => 20), - lang('Date and time') => array("date" => 13, "time" => 17, "timestamp" => 20, "timestamptz" => 21, "interval" => 0), - lang('Strings') => array("character" => 0, "character varying" => 0, "text" => 0, "tsquery" => 0, "tsvector" => 0, "uuid" => 0, "xml" => 0), - lang('Binary') => array("bit" => 0, "bit varying" => 0, "bytea" => 0), - lang('Network') => array("cidr" => 43, "inet" => 43, "macaddr" => 17, "txid_snapshot" => 0), - lang('Geometry') => array("box" => 0, "circle" => 0, "line" => 0, "lseg" => 0, "path" => 0, "point" => 0, "polygon" => 0), - ) as $key => $val) { //! can be retrieved from pg_type - $types += $val; - $structured_types[$key] = array_keys($val); + function driver_config() { + $types = array(); + $structured_types = array(); + foreach (array( //! arrays + lang('Numbers') => array("smallint" => 5, "integer" => 10, "bigint" => 19, "boolean" => 1, "numeric" => 0, "real" => 7, "double precision" => 16, "money" => 20), + lang('Date and time') => array("date" => 13, "time" => 17, "timestamp" => 20, "timestamptz" => 21, "interval" => 0), + lang('Strings') => array("character" => 0, "character varying" => 0, "text" => 0, "tsquery" => 0, "tsvector" => 0, "uuid" => 0, "xml" => 0), + lang('Binary') => array("bit" => 0, "bit varying" => 0, "bytea" => 0), + lang('Network') => array("cidr" => 43, "inet" => 43, "macaddr" => 17, "txid_snapshot" => 0), + lang('Geometry') => array("box" => 0, "circle" => 0, "line" => 0, "lseg" => 0, "path" => 0, "point" => 0, "polygon" => 0), + ) as $key => $val) { //! can be retrieved from pg_type + $types += $val; + $structured_types[$key] = array_keys($val); + } + return array( + 'possible_drivers' => array("PgSQL", "PDO_PgSQL"), + 'jush' => "pgsql", + 'types' => $types, + 'structured_types' => $structured_types, + 'unsigned' => array(), + 'operators' => array("=", "<", ">", "<=", ">=", "!=", "~", "!~", "LIKE", "LIKE %%", "ILIKE", "ILIKE %%", "IN", "IS NULL", "NOT LIKE", "NOT IN", "IS NOT NULL"), // no "SQL" to avoid CSRF + 'functions' => array("char_length", "lower", "round", "to_hex", "to_timestamp", "upper"), + 'grouping' => array("avg", "count", "count distinct", "max", "min", "sum"), + 'edit_functions' => array( + array( + "char" => "md5", + "date|time" => "now", + ), array( + number_type() => "+/-", + "date|time" => "+ interval/- interval", //! escape + "char|text" => "||", + ) + ), + ); } - $unsigned = array(); - $operators = array("=", "<", ">", "<=", ">=", "!=", "~", "!~", "LIKE", "LIKE %%", "ILIKE", "ILIKE %%", "IN", "IS NULL", "NOT LIKE", "NOT IN", "IS NOT NULL"); // no "SQL" to avoid CSRF - $functions = array("char_length", "lower", "round", "to_hex", "to_timestamp", "upper"); - $grouping = array("avg", "count", "count distinct", "max", "min", "sum"); - $edit_functions = array( - array( - "char" => "md5", - "date|time" => "now", - ), array( - number_type() => "+/-", - "date|time" => "+ interval/- interval", //! escape - "char|text" => "||", - ) - ); } diff --git a/adminer/drivers/simpledb.inc.php b/adminer/drivers/simpledb.inc.php index 7bf8a780..4dce229d 100644 --- a/adminer/drivers/simpledb.inc.php +++ b/adminer/drivers/simpledb.inc.php @@ -2,7 +2,6 @@ $drivers["simpledb"] = "SimpleDB"; if (isset($_GET["simpledb"])) { - $possible_drivers = array("SimpleXML + allow_url_fopen"); define("DRIVER", "simpledb"); if (class_exists('SimpleXMLElement') && ini_bool('allow_url_fopen')) { @@ -476,9 +475,14 @@ if (isset($_GET["simpledb"])) { return $return; } - $jush = "simpledb"; - $operators = array("=", "<", ">", "<=", ">=", "!=", "LIKE", "LIKE %%", "IN", "IS NULL", "NOT LIKE", "IS NOT NULL"); - $functions = array(); - $grouping = array("count"); - $edit_functions = array(array("json")); + function driver_config() { + return array( + 'possible_drivers' => array("SimpleXML + allow_url_fopen"), + 'jush' => "simpledb", + 'operators' => array("=", "<", ">", "<=", ">=", "!=", "LIKE", "LIKE %%", "IN", "IS NULL", "NOT LIKE", "IS NOT NULL"), + 'functions' => array(), + 'grouping' => array("count"), + 'edit_functions' => array(array("json")), + ); + } } diff --git a/adminer/drivers/sqlite.inc.php b/adminer/drivers/sqlite.inc.php index b33cd9aa..265d4690 100644 --- a/adminer/drivers/sqlite.inc.php +++ b/adminer/drivers/sqlite.inc.php @@ -3,7 +3,6 @@ $drivers["sqlite"] = "SQLite 3"; $drivers["sqlite2"] = "SQLite 2"; if (isset($_GET["sqlite"]) || isset($_GET["sqlite2"])) { - $possible_drivers = array((isset($_GET["sqlite"]) ? "SQLite3" : "SQLite"), "PDO_SQLite"); define("DRIVER", (isset($_GET["sqlite"]) ? "sqlite" : "sqlite2")); if (class_exists(isset($_GET["sqlite"]) ? "SQLite3" : "SQLiteDatabase")) { if (isset($_GET["sqlite"])) { @@ -785,20 +784,25 @@ if (isset($_GET["sqlite"]) || isset($_GET["sqlite2"])) { return preg_match('~^(columns|database|drop_col|dump|indexes|descidx|move_col|sql|status|table|trigger|variables|view|view_trigger)$~', $feature); } - $jush = "sqlite"; - $types = array("integer" => 0, "real" => 0, "numeric" => 0, "text" => 0, "blob" => 0); - $structured_types = array_keys($types); - $unsigned = array(); - $operators = array("=", "<", ">", "<=", ">=", "!=", "LIKE", "LIKE %%", "IN", "IS NULL", "NOT LIKE", "NOT IN", "IS NOT NULL", "SQL"); // REGEXP can be user defined function - $functions = array("hex", "length", "lower", "round", "unixepoch", "upper"); - $grouping = array("avg", "count", "count distinct", "group_concat", "max", "min", "sum"); - $edit_functions = array( - array( - // "text" => "date('now')/time('now')/datetime('now')", - ), array( - "integer|real|numeric" => "+/-", - // "text" => "date/time/datetime", - "text" => "||", - ) - ); + function driver_config() { + return array( + 'possible_drivers' => array((isset($_GET["sqlite"]) ? "SQLite3" : "SQLite"), "PDO_SQLite"), + 'jush' => "sqlite", + 'types' => array("integer" => 0, "real" => 0, "numeric" => 0, "text" => 0, "blob" => 0), + 'structured_types' => array_keys($types), + 'unsigned' => array(), + 'operators' => array("=", "<", ">", "<=", ">=", "!=", "LIKE", "LIKE %%", "IN", "IS NULL", "NOT LIKE", "NOT IN", "IS NOT NULL", "SQL"), // REGEXP can be user defined function + 'functions' => array("hex", "length", "lower", "round", "unixepoch", "upper"), + 'grouping' => array("avg", "count", "count distinct", "group_concat", "max", "min", "sum"), + 'edit_functions' => array( + array( + // "text" => "date('now')/time('now')/datetime('now')", + ), array( + "integer|real|numeric" => "+/-", + // "text" => "date/time/datetime", + "text" => "||", + ) + ), + ); + } } diff --git a/adminer/include/bootstrap.inc.php b/adminer/include/bootstrap.inc.php index 1a6f3c4d..114b4ca4 100644 --- a/adminer/include/bootstrap.inc.php +++ b/adminer/include/bootstrap.inc.php @@ -87,6 +87,17 @@ include "../adminer/drivers/elastic.inc.php"; include "../adminer/drivers/clickhouse.inc.php"; include "../adminer/drivers/mysql.inc.php"; // must be included as last driver +$config = driver_config(); +$possible_drivers = $config['possible_drivers']; +$jush = $config['jush']; +$types = $config['types']; +$structured_types = $config['structured_types']; +$unsigned = $config['unsigned']; +$operators = $config['operators']; +$functions = $config['functions']; +$grouping = $config['grouping']; +$edit_functions = $config['edit_functions']; + define("SERVER", $_GET[DRIVER]); // read from pgsql=localhost define("DB", $_GET["db"]); // for the sake of speed and size define("ME", preg_replace('~\?.*~', '', relative_uri()) . '?' diff --git a/adminer/include/version.inc.php b/adminer/include/version.inc.php index 9833f20e..45e85577 100644 --- a/adminer/include/version.inc.php +++ b/adminer/include/version.inc.php @@ -1,2 +1,2 @@