Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Always display all drivers (bug #3097666)

  • Loading branch information...
commit a2443670f8671abcc9c09c7c34f699da384b35fd 1 parent 753909e
Jakub Vrána authored
7 adminer/drivers/mssql.inc.php
View
@@ -5,13 +5,10 @@
* @author Jakub Vrana
*/
-$possible_drivers[] = "SQLSRV";
-$possible_drivers[] = "MSSQL";
-if (extension_loaded("sqlsrv") || extension_loaded("mssql")) {
- $drivers["mssql"] = "MS SQL";
-}
+$drivers["mssql"] = "MS SQL";
if (isset($_GET["mssql"])) {
+ $possible_drivers = array("SQLSRV", "MSSQL");
define("DRIVER", "mssql");
if (extension_loaded("sqlsrv")) {
class Min_DB {
8 adminer/drivers/mysql.inc.php
View
@@ -1,12 +1,8 @@
<?php
-$possible_drivers[] = "MySQLi";
-$possible_drivers[] = "MySQL";
-$possible_drivers[] = "PDO_MySQL";
-if (extension_loaded("mysqli") || extension_loaded("mysql") || extension_loaded("pdo_mysql")) {
- $drivers = array("server" => "MySQL") + $drivers;
-}
+$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")) {
7 adminer/drivers/oracle.inc.php
View
@@ -1,11 +1,8 @@
<?php
-$possible_drivers[] = "OCI8";
-$possible_drivers[] = "PDO_OCI";
-if (extension_loaded("oci8") || extension_loaded("pdo_oci")) {
- $drivers["oracle"] = "Oracle";
-}
+$drivers["oracle"] = "Oracle";
if (isset($_GET["oracle"])) {
+ $possible_drivers = array("OCI8", "PDO_OCI");
define("DRIVER", "oracle");
if (extension_loaded("oci8")) {
class Min_DB {
7 adminer/drivers/pgsql.inc.php
View
@@ -1,11 +1,8 @@
<?php
-$possible_drivers[] = "PgSQL";
-$possible_drivers[] = "PDO_PgSQL";
-if (extension_loaded("pgsql") || extension_loaded("pdo_pgsql")) {
- $drivers["pgsql"] = "PostgreSQL";
-}
+$drivers["pgsql"] = "PostgreSQL";
if (isset($_GET["pgsql"])) {
+ $possible_drivers = array("PgSQL", "PDO_PgSQL");
define("DRIVER", "pgsql");
if (extension_loaded("pgsql")) {
class Min_DB {
132 adminer/drivers/sqlite.inc.php
View
@@ -1,42 +1,36 @@
<?php
-$possible_drivers[] = "SQLite";
-$possible_drivers[] = "SQLite3";
-$possible_drivers[] = "PDO_SQLite";
-if (extension_loaded("sqlite3") || extension_loaded("pdo_sqlite")) {
- $drivers["sqlite"] = "SQLite 3";
-}
-if (extension_loaded("sqlite") || extension_loaded("pdo_sqlite")) {
- $drivers["sqlite2"] = "SQLite 2";
-}
+$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 (extension_loaded(isset($_GET["sqlite2"]) ? "sqlite" : "sqlite3")) {
- if (isset($_GET["sqlite2"])) {
+ if (extension_loaded(isset($_GET["sqlite"]) ? "sqlite3" : "sqlite")) {
+ if (isset($_GET["sqlite"])) {
class Min_SQLite {
- var $extension = "SQLite", $server_info, $affected_rows, $error, $_link;
+ var $extension = "SQLite3", $server_info, $affected_rows, $error, $_link;
function Min_SQLite($filename) {
- $this->server_info = sqlite_libversion();
- $this->_link = new SQLiteDatabase($filename);
+ $this->_link = new SQLite3($filename);
+ $version = $this->_link->version();
+ $this->server_info = $version["versionString"];
}
- function query($query, $unbuffered = false) {
- $method = ($unbuffered ? "unbufferedQuery" : "query");
- $result = @$this->_link->$method($query, SQLITE_BOTH, $error);
+ function query($query) {
+ $result = @$this->_link->query($query);
if (!$result) {
- $this->error = $error;
+ $this->error = $this->_link->lastErrorMsg();
return false;
- } elseif ($result === true) {
- $this->affected_rows = $this->changes();
- return true;
+ } elseif ($result->numColumns()) {
+ return new Min_Result($result);
}
- return new Min_Result($result);
+ $this->affected_rows = $this->_link->changes();
+ return true;
}
function quote($string) {
- return "'" . sqlite_escape_string($string) . "'";
+ return "'" . $this->_link->escapeString($string) . "'";
}
function store_result() {
@@ -48,7 +42,7 @@ function result($query, $field = 0) {
if (!is_object($result)) {
return false;
}
- $row = $result->_result->fetch();
+ $row = $result->_result->fetchArray();
return $row[$field];
}
}
@@ -58,68 +52,56 @@ class Min_Result {
function Min_Result($result) {
$this->_result = $result;
- if (method_exists($result, 'numRows')) { // not available in unbuffered query
- $this->num_rows = $result->numRows();
- }
}
function fetch_assoc() {
- $row = $this->_result->fetch(SQLITE_ASSOC);
- if (!$row) {
- return false;
- }
- $return = array();
- foreach ($row as $key => $val) {
- $return[($key[0] == '"' ? idf_unescape($key) : $key)] = $val;
- }
- return $return;
+ return $this->_result->fetchArray(SQLITE3_ASSOC);
}
function fetch_row() {
- return $this->_result->fetch(SQLITE_NUM);
+ return $this->_result->fetchArray(SQLITE3_NUM);
}
function fetch_field() {
- $name = $this->_result->fieldName($this->_offset++);
- $pattern = '(\\[.*]|"(?:[^"]|"")*"|(.+))';
- if (preg_match("~^($pattern\\.)?$pattern\$~", $name, $match)) {
- $table = ($match[3] != "" ? $match[3] : idf_unescape($match[2]));
- $name = ($match[5] != "" ? $match[5] : idf_unescape($match[4]));
- }
+ $column = $this->_offset++;
+ $type = $this->_result->columnType($column);
return (object) array(
- "name" => $name,
- "orgname" => $name,
- "orgtable" => $table,
+ "name" => $this->_result->columnName($column),
+ "type" => $type,
+ "charsetnr" => ($type == SQLITE3_BLOB ? 63 : 0), // 63 - binary
);
}
+ function __desctruct() {
+ return $this->_result->finalize();
+ }
}
} else {
class Min_SQLite {
- var $extension = "SQLite3", $server_info, $affected_rows, $error, $_link;
+ var $extension = "SQLite", $server_info, $affected_rows, $error, $_link;
function Min_SQLite($filename) {
- $this->_link = new SQLite3($filename);
- $version = $this->_link->version();
- $this->server_info = $version["versionString"];
+ $this->server_info = sqlite_libversion();
+ $this->_link = new SQLiteDatabase($filename);
}
- function query($query) {
- $result = @$this->_link->query($query);
+ function query($query, $unbuffered = false) {
+ $method = ($unbuffered ? "unbufferedQuery" : "query");
+ $result = @$this->_link->$method($query, SQLITE_BOTH, $error);
if (!$result) {
- $this->error = $this->_link->lastErrorMsg();
+ $this->error = $error;
return false;
- } elseif ($result->numColumns()) {
- return new Min_Result($result);
+ } elseif ($result === true) {
+ $this->affected_rows = $this->changes();
+ return true;
}
- $this->affected_rows = $this->_link->changes();
- return true;
+ return new Min_Result($result);
}
function quote($string) {
- return "'" . $this->_link->escapeString($string) . "'";
+ return "'" . sqlite_escape_string($string) . "'";
}
function store_result() {
@@ -131,7 +113,7 @@ function result($query, $field = 0) {
if (!is_object($result)) {
return false;
}
- $row = $result->_result->fetchArray();
+ $row = $result->_result->fetch();
return $row[$field];
}
}
@@ -141,29 +123,41 @@ class Min_Result {
function Min_Result($result) {
$this->_result = $result;
+ if (method_exists($result, 'numRows')) { // not available in unbuffered query
+ $this->num_rows = $result->numRows();
+ }
}
function fetch_assoc() {
- return $this->_result->fetchArray(SQLITE3_ASSOC);
+ $row = $this->_result->fetch(SQLITE_ASSOC);
+ if (!$row) {
+ return false;
+ }
+ $return = array();
+ foreach ($row as $key => $val) {
+ $return[($key[0] == '"' ? idf_unescape($key) : $key)] = $val;
+ }
+ return $return;
}
function fetch_row() {
- return $this->_result->fetchArray(SQLITE3_NUM);
+ return $this->_result->fetch(SQLITE_NUM);
}
function fetch_field() {
- $column = $this->_offset++;
- $type = $this->_result->columnType($column);
+ $name = $this->_result->fieldName($this->_offset++);
+ $pattern = '(\\[.*]|"(?:[^"]|"")*"|(.+))';
+ if (preg_match("~^($pattern\\.)?$pattern\$~", $name, $match)) {
+ $table = ($match[3] != "" ? $match[3] : idf_unescape($match[2]));
+ $name = ($match[5] != "" ? $match[5] : idf_unescape($match[4]));
+ }
return (object) array(
- "name" => $this->_result->columnName($column),
- "type" => $type,
- "charsetnr" => ($type == SQLITE3_BLOB ? 63 : 0), // 63 - binary
+ "name" => $name,
+ "orgname" => $name,
+ "orgtable" => $table,
);
}
- function __desctruct() {
- return $this->_result->finalize();
- }
}
}
13 adminer/include/auth.inc.php
View
@@ -1,12 +1,6 @@
<?php
$connection = '';
-if (!$drivers) {
- page_header(lang('No extension'), lang('None of the supported PHP extensions (%s) are available.', implode(", ", $possible_drivers)), null);
- page_footer("auth");
- exit;
-}
-
$token = $_SESSION["token"];
if (!$_SESSION["token"]) {
$_SESSION["token"] = rand(1, 1e6); // defense against cross-site request forgery
@@ -89,7 +83,12 @@ function auth_error($exception = null) {
page_footer("auth");
}
-if (isset($_GET["username"]) && class_exists("Min_DB")) { // doesn't exists with passing wrong driver
+if (isset($_GET["username"])) {
+ if (!class_exists("Min_DB")) {
+ page_header(lang('No extension'), lang('None of the supported PHP extensions (%s) are available.', implode(", ", $possible_drivers)), null);
+ page_footer("auth");
+ exit;
+ }
$connection = connect();
}
if (is_string($connection) || !$adminer->login($_GET["username"], get_session("pwds"))) {
1  adminer/include/pdo.inc.php
View
@@ -79,5 +79,4 @@ function fetch_field() {
}
}
-$possible_drivers = array();
$drivers = array();
1  changes.txt
View
@@ -7,6 +7,7 @@ Link to bookmark SQL command
Support for virtual foreign keys
Immunity against zend.ze1_compatibility_mode
Fix last page with empty result set
+Always display all drivers
Adminer 3.0.1 (released 2010-10-18):
Send the form by Ctrl+Enter in all textareas
Please sign in to comment.
Something went wrong with that request. Please try again.