mirror of
https://github.com/vrana/adminer.git
synced 2025-08-09 16:17:48 +02:00
Use utf8mb4 on more places
This commit is contained in:
@@ -292,9 +292,7 @@ if (!defined("DRIVER")) {
|
|||||||
$connection = new Min_DB;
|
$connection = new Min_DB;
|
||||||
$credentials = $adminer->credentials();
|
$credentials = $adminer->credentials();
|
||||||
if ($connection->connect($credentials[0], $credentials[1], $credentials[2])) {
|
if ($connection->connect($credentials[0], $credentials[1], $credentials[2])) {
|
||||||
$connection->set_charset( // available in MySQLi since PHP 5.0.5
|
$connection->set_charset(charset($connection)); // available in MySQLi since PHP 5.0.5
|
||||||
version_compare($connection->server_info, "5.5.3") > 0 ? "utf8mb4" : "utf8" // SHOW CHARSET would require an extra query
|
|
||||||
);
|
|
||||||
$connection->query("SET sql_quote_show_create = 1, autocommit = 1");
|
$connection->query("SET sql_quote_show_create = 1, autocommit = 1");
|
||||||
return $connection;
|
return $connection;
|
||||||
}
|
}
|
||||||
|
@@ -16,7 +16,7 @@ if ($_POST && !$error) {
|
|||||||
if ($is_sql) {
|
if ($is_sql) {
|
||||||
echo "-- Adminer $VERSION " . $drivers[DRIVER] . " dump\n\n";
|
echo "-- Adminer $VERSION " . $drivers[DRIVER] . " dump\n\n";
|
||||||
if ($jush == "sql") {
|
if ($jush == "sql") {
|
||||||
echo "SET NAMES utf8;
|
echo "SET NAMES " . charset($connection) . ";
|
||||||
SET time_zone = '+00:00';
|
SET time_zone = '+00:00';
|
||||||
" . ($_POST["data_style"] ? "SET foreign_key_checks = 0;
|
" . ($_POST["data_style"] ? "SET foreign_key_checks = 0;
|
||||||
SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO';
|
SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO';
|
||||||
|
@@ -412,7 +412,7 @@ username.form['auth[driver]'].onchange();
|
|||||||
* @return array expressions to join by AND
|
* @return array expressions to join by AND
|
||||||
*/
|
*/
|
||||||
function selectSearchProcess($fields, $indexes) {
|
function selectSearchProcess($fields, $indexes) {
|
||||||
global $jush;
|
global $connection, $jush;
|
||||||
$return = array();
|
$return = array();
|
||||||
foreach ($indexes as $i => $index) {
|
foreach ($indexes as $i => $index) {
|
||||||
if ($index["type"] == "FULLTEXT" && $_GET["fulltext"][$i] != "") {
|
if ($index["type"] == "FULLTEXT" && $_GET["fulltext"][$i] != "") {
|
||||||
@@ -443,7 +443,8 @@ username.form['auth[driver]'].onchange();
|
|||||||
&& (!preg_match("~[\x80-\xFF]~", $val["val"]) || $is_text)
|
&& (!preg_match("~[\x80-\xFF]~", $val["val"]) || $is_text)
|
||||||
) {
|
) {
|
||||||
$name = idf_escape($name);
|
$name = idf_escape($name);
|
||||||
$cols[] = ($jush == "sql" && $is_text && !preg_match('~^utf8~', $field["collation"]) ? "CONVERT($name USING utf8)" : $name);
|
$charset = charset($connection);
|
||||||
|
$cols[] = ($jush == "sql" && $is_text && !preg_match("~^$charset" . "_~", $field["collation"]) ? "CONVERT($name USING $charset)" : $name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$return[] = ($cols ? "(" . implode("$cond OR ", $cols) . "$cond)" : "0");
|
$return[] = ($cols ? "(" . implode("$cond OR ", $cols) . "$cond)" : "0");
|
||||||
|
@@ -65,6 +65,14 @@ function bracket_escape($idf, $back = false) {
|
|||||||
return strtr($idf, ($back ? array_flip($trans) : $trans));
|
return strtr($idf, ($back ? array_flip($trans) : $trans));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Get connection charset
|
||||||
|
* @param Min_DB
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function charset($connection) {
|
||||||
|
return (version_compare($connection->server_info, "5.5.3") > 0 ? "utf8mb4" : "utf8"); // SHOW CHARSET would require an extra query
|
||||||
|
}
|
||||||
|
|
||||||
/** Escape for HTML
|
/** Escape for HTML
|
||||||
* @param string
|
* @param string
|
||||||
* @return string
|
* @return string
|
||||||
@@ -373,7 +381,7 @@ function unique_array($row, $indexes) {
|
|||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function where($where, $fields = array()) {
|
function where($where, $fields = array()) {
|
||||||
global $jush;
|
global $connection, $jush;
|
||||||
$return = array();
|
$return = array();
|
||||||
$function_pattern = '(^[\w\(]+(' . str_replace("_", ".*", preg_quote(idf_escape("_"))) . ')?\)+$)'; //! columns looking like functions
|
$function_pattern = '(^[\w\(]+(' . str_replace("_", ".*", preg_quote(idf_escape("_"))) . ')?\)+$)'; //! columns looking like functions
|
||||||
foreach ((array) $where["where"] as $key => $val) {
|
foreach ((array) $where["where"] as $key => $val) {
|
||||||
@@ -386,7 +394,7 @@ function where($where, $fields = array()) {
|
|||||||
) // LIKE because of floats but slow with ints, in MS SQL because of text
|
) // LIKE because of floats but slow with ints, in MS SQL because of text
|
||||||
; //! enum and set
|
; //! enum and set
|
||||||
if ($jush == "sql" && preg_match('~char|text~', $fields[$key]["type"]) && preg_match("~[^ -@]~", $val)) { // not just [a-z] to catch non-ASCII characters
|
if ($jush == "sql" && preg_match('~char|text~', $fields[$key]["type"]) && preg_match("~[^ -@]~", $val)) { // not just [a-z] to catch non-ASCII characters
|
||||||
$return[] = "$column = " . q($val) . " COLLATE utf8_bin";
|
$return[] = "$column = " . q($val) . " COLLATE " . charset($connection) . "_bin";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreach ((array) $where["null"] as $key) {
|
foreach ((array) $where["null"] as $key) {
|
||||||
|
Reference in New Issue
Block a user