if (isset($_GET["mssql"])) {
define('Adminer\DRIVER', "mssql");
+
if (extension_loaded("sqlsrv") && $_GET["ext"] != "pdo") {
class Db extends SqlDb {
public $extension = "sqlsrv";
if (!defined('Adminer\DRIVER')) {
define('Adminer\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") && $_GET["ext"] != "pdo") {
class Db extends \MySQLi {
if (isset($_GET["oracle"])) {
define('Adminer\DRIVER', "oracle");
+
if (extension_loaded("oci8") && $_GET["ext"] != "pdo") {
class Db extends SqlDb {
public $extension = "oci8";
if (isset($_GET["pgsql"])) {
define('Adminer\DRIVER', "pgsql");
+
if (extension_loaded("pgsql") && $_GET["ext"] != "pdo") {
class PgsqlDb extends SqlDb {
public $extension = "PgSQL";
*/
function copyFrom(string $table, array $rows): bool {
$this->error = '';
- set_error_handler(function ($errno, $error) {
+ set_error_handler(function (int $errno, string $error): bool {
$this->error = (ini_bool('html_errors') ? html_entity_decode($error) : $error);
+ return true;
});
$return = pg_copy_from($this->link, $table, $rows);
restore_error_handler();
if (isset($_GET["sqlite"])) {
define('Adminer\DRIVER', "sqlite");
- if (class_exists("SQLite3") && $_GET["ext"] != "pdo") {
+ if (class_exists("SQLite3") && $_GET["ext"] != "pdo") {
abstract class SqliteDb extends SqlDb {
public $extension = "SQLite3";
private $link;
header("Cache-Control: immutable");
}
-@ini_set("zlib.output_compression", 1); // @ - may be disabled
+@ini_set("zlib.output_compression", '1'); // @ - may be disabled
if ($_GET["file"] == "default.css") {
header("Content-Type: text/css; charset=utf-8");
*/
function allFields(): array {
$return = array();
- foreach (get_rows("SELECT TABLE_NAME AS tab, COLUMN_NAME AS field, IS_NULLABLE AS nullable, DATA_TYPE AS type, CHARACTER_MAXIMUM_LENGTH AS length" . (JUSH == 'sql' ? ", COLUMN_KEY = 'PRI' AS `primary`" : "") . "
+ foreach (
+ get_rows("SELECT TABLE_NAME AS tab, COLUMN_NAME AS field, IS_NULLABLE AS nullable, DATA_TYPE AS type, CHARACTER_MAXIMUM_LENGTH AS length" . (JUSH == 'sql' ? ", COLUMN_KEY = 'PRI' AS `primary`" : "") . "
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_SCHEMA = " . q($_GET["ns"] != "" ? $_GET["ns"] : DB) . "
-ORDER BY TABLE_NAME, ORDINAL_POSITION", $this->conn) as $row) {
+ORDER BY TABLE_NAME, ORDINAL_POSITION", $this->conn) as $row
+ ) {
$row["null"] = ($row["nullable"] == "YES");
$return[$row["tab"]][] = $row;
}
return $return;
}
-/** Compute fields() from $_POST edit data
+/** Compute fields() from $_POST edit data; used by Mongo and SimpleDB
* @return Field[] same as fields()
*/
-function fields_from_edit(): array { // used by Mongo and SimpleDB
+function fields_from_edit(): array {
$return = array();
foreach ((array) $_POST["field_keys"] as $key => $val) {
if ($val != "") {
}
function minify_js($file) {
- $file = preg_replace_callback("~'use strict';~", function ($match) { // keep only the first one
+ $file = preg_replace_callback("~'use strict';~", function ($match) {
static $count = 0;
$count++;
- return ($count == 1 ? $match[0] : '');
+ return ($count == 1 ? $match[0] : ''); // keep only the first one
}, $file);
if (function_exists('jsShrink')) {
$file = jsShrink($file);
return lzw_compress($file);
}
-function compile_file($match, $callback = '') { // $callback only to match signature
+// $callback only to match signature
+function compile_file($match, $callback = '') {
global $project;
$file = "";
list(, $filenames, $callback) = $match;
}
}
if ($project != "editor" && count(Adminer\SqlDriver::$drivers) == 1) {
- $file = str_replace('html_select("auth[driver]", SqlDriver::$drivers, DRIVER, "loginDriver(this);")', 'input_hidden("auth[driver]", "' . ($vendor == "mysql" ? "server" : $vendor) . '") . "' . reset(Adminer\SqlDriver::$drivers) . '"', $file, $count);
+ $file = str_replace(
+ 'html_select("auth[driver]", SqlDriver::$drivers, DRIVER, "loginDriver(this);")',
+ 'input_hidden("auth[driver]", "' . ($vendor == "mysql" ? "server" : $vendor) . '") . "' . reset(Adminer\SqlDriver::$drivers) . '"',
+ $file,
+ $count
+ );
if (!$count) {
echo "auth[driver] form field not found\n";
}
<rule ref="PSR1.Methods.CamelCapsMethodName.NotCamelCaps">
<exclude-pattern>adminer/drivers/</exclude-pattern>
+ <exclude-pattern>adminer/include/db.inc.php</exclude-pattern>
<exclude-pattern>adminer/include/pdo.inc.php</exclude-pattern>
+ <exclude-pattern>adminer/plugins/foreign-system.php</exclude-pattern>
<exclude-pattern>adminer/plugins/drivers/</exclude-pattern>
</rule>
#!/usr/bin/env php
<?php
-foreach (array(
- 'create' => array(1106, 412),
- 'dark' => array(816, 750),
- 'database' => array(896, 666),
- 'db' => array(1258, 752),
- 'dump' => array(784, 450),
- 'edit' => array(1006, 336),
- 'login' => array(628, 326),
- 'select' => array(924, 810),
- 'schema' => array(690, 406),
- 'sql' => array(870, 788),
- 'table' => array(816, 750),
-) as $filename => list($w, $h)) {
+foreach (
+ array(
+ 'create' => array(1106, 412),
+ 'dark' => array(816, 750),
+ 'database' => array(896, 666),
+ 'db' => array(1258, 752),
+ 'dump' => array(784, 450),
+ 'edit' => array(1006, 336),
+ 'login' => array(628, 326),
+ 'select' => array(924, 810),
+ 'schema' => array(690, 406),
+ 'sql' => array(870, 788),
+ 'table' => array(816, 750),
+ ) as $filename => list($w, $h)
+) {
$im = imagecreatefrompng("screenshots/$filename.png");
$im2 = imagecreatetruecolor($w, $h);
imagecopy($im2, $im, 0, 0, 0, 0, $w, $h);