]> git.joonet.de Git - adminer.git/commitdiff
Prepare for moving drivers to plugins
authorJakub Vrana <jakub@vrana.cz>
Mon, 8 Feb 2021 17:36:05 +0000 (18:36 +0100)
committerJakub Vrana <jakub@vrana.cz>
Mon, 8 Feb 2021 18:35:22 +0000 (19:35 +0100)
13 files changed:
adminer/drivers/clickhouse.inc.php
adminer/drivers/elastic.inc.php
adminer/drivers/firebird.inc.php
adminer/drivers/mongo.inc.php
adminer/drivers/mssql.inc.php
adminer/drivers/mysql.inc.php
adminer/drivers/oracle.inc.php
adminer/drivers/pgsql.inc.php
adminer/drivers/simpledb.inc.php
adminer/drivers/sqlite.inc.php
adminer/include/bootstrap.inc.php
adminer/include/version.inc.php
changes.txt

index 99c77ab8106754ebc0ac24e99863c2cf466e2b0a..ec5db517ea1ecf328c658cdfc5911de1d166d44f 100644 (file)
@@ -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);
-       }
-       $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();
+       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(),
+               );
+       }
 }
index 75a19f16e783cf22e34b36b17fded354f3d2b86f..799f6d0b311d080098c5df5d7fde43e746d9e314 100644 (file)
@@ -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,
+               );
        }
 }
index f08b08d30dda9588062a9136dbe5587dbc474788..7e62930cfacec61d62890915f83ed2db26ed19af 100644 (file)
@@ -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(),
+               );
+       }
 }
index 944f13f3d2b2c0964e64c213eb608a7d4b96b221..f2c0d7ed0018e9b8c1d8119352a6d9403c22ce24 100644 (file)
@@ -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")),
+               );
+       }
 }
index b574079d2b7d642f8bf212fae23dbfd05c5384ce..c8ed37c99b0edc6bd4f7fa6e4ed0ce7406f42f59 100644 (file)
@@ -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);
-       }
-       $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" => "+",
-               )
-       );
+       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" => "+",
+                               )
+                       ),
+               );
+       }
 }
index b0f596f0c3ebd65b8651ad32379bc2477305bc02..8c93506b39f2d0d158a4cc0f0647fb020760904f 100644 (file)
@@ -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",
-               )
-       );
 }
index 0395f850e24f9ce6f78bddb228219f79804e496c..688812b2d91ba29db2d58a95c86ee42e3fbff1bc 100644 (file)
@@ -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);
-       }
-       $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" => "||",
-               )
-       );
+       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" => "||",
+                               )
+                       ),
+               );
+       }
 }
index d6213b4d5e611b0e00d6d396e4e7f57d433a7b03..a07b767d8371f9aaaa43bc56f1bbc02b1ee6c9d0 100644 (file)
@@ -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);
-       }
-       $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" => "||",
-               )
-       );
+       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" => "||",
+                               )
+                       ),
+               );
+       }
 }
index 7bf8a780df2e59a94edf7f3b76f69221e7f53107..4dce229df58e9b01229f88e746d78077207bc884 100644 (file)
@@ -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")),
+               );
+       }
 }
index b33cd9aae50d0c1a8517b84e2f52cc9f85809b82..265d4690a952e2e83ad7f975278f89a4e2cc5620 100644 (file)
@@ -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" => "||",
+                               )
+                       ),
+               );
+       }
 }
index 1a6f3c4d8e1cbdd7fd9343e5317e9f755a29ebf3..114b4ca481b2d65825a6ae7c38d9f8b1f5ad27f3 100644 (file)
@@ -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()) . '?'
index 9833f20e204df9966513c770bfe95cf24f3843d4..45e85577e7a92cf256d5425be18ca14f172ed675 100644 (file)
@@ -1,2 +1,2 @@
 <?php
-$VERSION = "4.7.10-dev";
+$VERSION = "4.8.0-dev";
index 2ccc9e6ce953b02cc735de9670424b617a33c26f..830f7e88ff45c754ef41148ee5a614b4f5b34420 100644 (file)
@@ -1,4 +1,4 @@
-Adminer 4.7.10-dev:
+Adminer 4.8.0-dev:
 Support function default values in insert (bug #713)
 Allow SQL pseudo-function in insert
 Skip date columns for non-date values in search anywhere