diff options
author | apoorv <apoorvkhare007@gmail.com> | 2019-03-25 10:06:13 +0300 |
---|---|---|
committer | apoorv <apoorvkhare007@gmail.com> | 2019-04-06 15:57:11 +0300 |
commit | eca65975b3a54f36c59c6152f3a7559c83f6efe0 (patch) | |
tree | bf28bafea46a956fc3c0d3363120ec70eacd3779 | |
parent | 8282a7f1b64e75ac05451208b05dfb2f8d2a1eb3 (diff) |
Fixes #15059 Server charset hardcoded in index.php
Signed-off-by: Apoorv Khare <apoorvkhare007@gmail.com>
-rw-r--r-- | index.php | 9 | ||||
-rw-r--r-- | libraries/classes/Charsets.php | 21 |
2 files changed, 28 insertions, 2 deletions
@@ -369,12 +369,17 @@ if ($server > 0 && $GLOBALS['cfg']['ShowServerInfo']) { echo ' <li id="li_select_mysql_charset">'; echo ' ' , __('Server charset:') , ' ' . ' <span lang="en" dir="ltr">'; - $unicode = Charsets::$mysql_charset_map['utf-8']; + + $charset = Charsets::getCharset( + $GLOBALS['dbi'], + $GLOBALS['cfg']['Server']['DisableIS'] + ); $charsets = Charsets::getMySQLCharsetsDescriptions( $GLOBALS['dbi'], $GLOBALS['cfg']['Server']['DisableIS'] ); - echo ' ' , $charsets[$unicode], ' (' . $unicode, ')'; + + echo ' ' , $charsets[$charset], ' (' . $charset, ')'; echo ' </span>' . ' </li>' . ' </ul>' diff --git a/libraries/classes/Charsets.php b/libraries/classes/Charsets.php index 4f73e0eed8..d81b3f8869 100644 --- a/libraries/classes/Charsets.php +++ b/libraries/classes/Charsets.php @@ -49,6 +49,7 @@ class Charsets ); private static $_charsets = array(); + private static $_charset; private static $_charsets_descriptions = array(); private static $_collations = array(); private static $_default_collations = array(); @@ -127,6 +128,26 @@ class Charsets } } + /** + * Get current MySQL server charset. + * + * @param DatabaseInterface $dbi DatabaseInterface instance + * @param boolean $disableIs Disable use of INFORMATION_SCHEMA + * + * @return string + */ + public static function getCharset(DatabaseInterface $dbi, $disableIs) + { + $sql = 'SHOW VARIABLES LIKE \'character_set_server\';'; + $res = $dbi->query($sql); + while ($row = $dbi->fetchAssoc($res)) { + $charset = $row['Value']; + self::$_charset = $charset; + } + $dbi->freeResult($res); + return self::$_charset ; + } + /** * Get MySQL charsets * |