diff --git a/ChangeLog b/ChangeLog
index 42404637d..f19f49635 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -87,6 +87,8 @@ $Id$
thanks to Piotr Przybylski - crackpl
- bug [password] Generate password only available if JS is enabled
(fixed for Privileges and Change password)
+- [core] RecodingEngine now accepts none as valid option.
++ [core] Dropped AllowAnywhereRecoding configuration variable.
3.3.6.0 (not yet released)
diff --git a/Documentation.html b/Documentation.html
index 7c54cff39..506260526 100644
--- a/Documentation.html
+++ b/Documentation.html
@@ -1703,18 +1703,6 @@ CREATE DATABASE,ALTER DATABASE,DROP DATABASE
expression. For example if you want only Czech and English, you should
set filter to '^(cs|en)'
.
-
$cfg['AllowAnywhereRecoding'] boolean
- Allow character set recoding of MySQL queries. You need recode or iconv
- support (compiled in or module) in PHP to allow MySQL queries recoding
- and used language file must have it enabled (by default only these
- which are in Unicode, just to avoid losing some characters).
-
- Setting this to TRUE also activates a pull-down menu
- in the Export and Import pages, to choose the character set when
- exporting a file. The default value in this menu comes from
- $cfg['Export']['charset'] and $cfg['Import']['charset'].
-
-
$cfg['RecodingEngine'] string
You can select here which functions will be used for character set
conversion. Possible values are:
@@ -1722,8 +1710,15 @@ CREATE DATABASE,ALTER DATABASE,DROP DATABASE
iconv, then recode)
iconv - use iconv or libiconv functions
recode - use recode_string function
+ none - disable encoding conversion
Default is auto.
+
+ Enabled charset conversion activates a pull-down menu
+ in the Export and Import pages, to choose the character set when
+ exporting a file. The default value in this menu comes from
+ $cfg['Export']['charset'] and $cfg['Import']['charset'].
+
Specify some parameters for iconv used in charset conversion. See
diff --git a/export.php b/export.php
index 3cb36dbf6..8572a81ab 100644
--- a/export.php
+++ b/export.php
@@ -207,7 +207,7 @@ if ($what == 'sql') {
$output_kanji_conversion = function_exists('PMA_kanji_str_conv') && $type != 'xls';
// Do we need to convert charset?
-$output_charset_conversion = $asfile && $cfg['AllowAnywhereRecoding']
+$output_charset_conversion = $asfile && $GLOBALS['PMA_recoding_engine'] != PMA_CHARSET_NONE
&& isset($charset_of_file) && $charset_of_file != $charset
&& $type != 'xls';
diff --git a/import.php b/import.php
index 4d45a59d8..85616a9aa 100644
--- a/import.php
+++ b/import.php
@@ -343,7 +343,7 @@ if ($import_file != 'none' && !$error) {
//$_SESSION['Import_message'] = $message->getDisplay();
// Convert the file's charset if necessary
-if ($cfg['AllowAnywhereRecoding'] && isset($charset_of_file)) {
+if ($GLOBALS['PMA_recoding_engine'] != PMA_CHARSET_NONE && isset($charset_of_file)) {
if ($charset_of_file != $charset) {
$charset_conversion = TRUE;
}
@@ -451,7 +451,7 @@ if (isset($my_die)) {
if (! empty($last_query_with_results)) {
// but we want to show intermediate results too
$disp_query = $sql_query;
- $disp_message = __('Your SQL query has been executed successfully');
+ $disp_message = __('Your SQL query has been executed successfully');
$sql_query = $last_query_with_results;
$go_sql = true;
}
diff --git a/libraries/charset_conversion.lib.php b/libraries/charset_conversion.lib.php
index ed44a6493..15f4a11e4 100644
--- a/libraries/charset_conversion.lib.php
+++ b/libraries/charset_conversion.lib.php
@@ -10,109 +10,44 @@ if (! defined('PHPMYADMIN')) {
exit;
}
-/**
- * Failure on loading recode/iconv extensions.
- */
-function PMA_failRecoding() {
- PMA_fatalError(__('Couldn\'t load the iconv or recode extension needed for charset conversion. Either configure PHP to enable these extensions or disable charset conversion in phpMyAdmin.'));
-}
-
-/**
- * Loads the recode or iconv extensions if any of it is not loaded yet
- */
-if (isset($cfg['AllowAnywhereRecoding'])
- && $cfg['AllowAnywhereRecoding']) {
-
- if ($cfg['RecodingEngine'] == 'recode') {
- if (!@extension_loaded('recode')) {
- PMA_failRecoding();
- }
- $PMA_recoding_engine = 'recode';
- } elseif ($cfg['RecodingEngine'] == 'iconv') {
- if (!@extension_loaded('iconv')) {
- PMA_failRecoding();
- }
- $PMA_recoding_engine = 'iconv';
- } else {
- if (@extension_loaded('iconv')) {
- $PMA_recoding_engine = 'iconv';
- } elseif (@extension_loaded('recode')) {
- $PMA_recoding_engine = 'recode';
- } else {
- PMA_failRecoding();
- }
- }
-} // end load recode/iconv extension
-
define('PMA_CHARSET_NONE', 0);
define('PMA_CHARSET_ICONV', 1);
-define('PMA_CHARSET_LIBICONV', 2);
-define('PMA_CHARSET_RECODE', 3);
-define('PMA_CHARSET_ICONV_AIX', 4);
-
-if (!isset($cfg['IconvExtraParams'])) {
- $cfg['IconvExtraParams'] = '';
-}
+define('PMA_CHARSET_RECODE', 2);
+define('PMA_CHARSET_ICONV_AIX', 3);
// Finally detect which function we will use:
-if (isset($cfg['AllowAnywhereRecoding'])
- && $cfg['AllowAnywhereRecoding']) {
-
- if (!isset($PMA_recoding_engine)) {
- $PMA_recoding_engine = $cfg['RecodingEngine'];
- }
- if ($PMA_recoding_engine == 'iconv') {
- if (@function_exists('iconv')) {
- if ((@stristr(PHP_OS, 'AIX')) && (@strcasecmp(ICONV_IMPL, 'unknown') == 0) && (@strcasecmp(ICONV_VERSION, 'unknown') == 0)) {
- $PMA_recoding_engine = PMA_CHARSET_ICONV_AIX;
- } else {
- $PMA_recoding_engine = PMA_CHARSET_ICONV;
- }
- } elseif (@function_exists('libiconv')) {
- $PMA_recoding_engine = PMA_CHARSET_LIBICONV;
+if ($cfg['RecodingEngine'] == 'iconv') {
+ if (@function_exists('iconv')) {
+ if ((@stristr(PHP_OS, 'AIX')) && (@strcasecmp(ICONV_IMPL, 'unknown') == 0) && (@strcasecmp(ICONV_VERSION, 'unknown') == 0)) {
+ $PMA_recoding_engine = PMA_CHARSET_ICONV_AIX;
} else {
- $PMA_recoding_engine = PMA_CHARSET_NONE;
-
- if (!isset($GLOBALS['is_header_sent'])) {
- include './libraries/header.inc.php';
- }
- echo __('Couldn\'t use the iconv, libiconv, or recode_string functions, although the necessary extensions appear to be loaded. Check your PHP configuration.');
- require_once './libraries/footer.inc.php';
- exit();
- }
- } elseif ($PMA_recoding_engine == 'recode') {
- if (@function_exists('recode_string')) {
- $PMA_recoding_engine = PMA_CHARSET_RECODE;
- } else {
- $PMA_recoding_engine = PMA_CHARSET_NONE;
-
- require_once './libraries/header.inc.php';
- echo __('Couldn\'t use the iconv, libiconv, or recode_string functions, although the necessary extensions appear to be loaded. Check your PHP configuration.');
- require_once './libraries/footer.inc.php';
- exit;
+ $PMA_recoding_engine = PMA_CHARSET_ICONV;
}
} else {
- if (@function_exists('iconv')) {
- if ((@stristr(PHP_OS, 'AIX')) && (@strcasecmp(ICONV_IMPL, 'unknown') == 0) && (@strcasecmp(ICONV_VERSION, 'unknown') == 0)) {
- $PMA_recoding_engine = PMA_CHARSET_ICONV_AIX;
- } else {
- $PMA_recoding_engine = PMA_CHARSET_ICONV;
- }
- } elseif (@function_exists('libiconv')) {
- $PMA_recoding_engine = PMA_CHARSET_LIBICONV;
- } elseif (@function_exists('recode_string')) {
- $PMA_recoding_engine = PMA_CHARSET_RECODE;
+ $PMA_recoding_engine = PMA_CHARSET_NONE;
+ PMA_warnMissingExtension('iconv');
+ }
+} elseif ($cfg['RecodingEngine'] == 'recode') {
+ if (@function_exists('recode_string')) {
+ $PMA_recoding_engine = PMA_CHARSET_RECODE;
+ } else {
+ $PMA_recoding_engine = PMA_CHARSET_NONE;
+ PMA_warnMissingExtension('recode');
+ }
+} elseif ($cfg['RecodingEngine'] == 'auto') {
+ if (@function_exists('iconv')) {
+ if ((@stristr(PHP_OS, 'AIX')) && (@strcasecmp(ICONV_IMPL, 'unknown') == 0) && (@strcasecmp(ICONV_VERSION, 'unknown') == 0)) {
+ $PMA_recoding_engine = PMA_CHARSET_ICONV_AIX;
} else {
- $PMA_recoding_engine = PMA_CHARSET_NONE;
-
- require_once './libraries/header.inc.php';
- echo __('Couldn\'t use the iconv, libiconv, or recode_string functions, although the necessary extensions appear to be loaded. Check your PHP configuration.');
- require_once './libraries/footer.inc.php';
- exit;
+ $PMA_recoding_engine = PMA_CHARSET_ICONV;
}
+ } elseif (@function_exists('recode_string')) {
+ $PMA_recoding_engine = PMA_CHARSET_RECODE;
+ } else {
+ $PMA_recoding_engine = PMA_CHARSET_NONE;
}
} else {
- $PMA_recoding_engine = PMA_CHARSET_NONE;
+ $PMA_recoding_engine = PMA_CHARSET_NONE;
}
/* Load AIX iconv wrapper if needed */
@@ -144,8 +79,6 @@ function PMA_convert_string($src_charset, $dest_charset, $what) {
return iconv($src_charset, $dest_charset . $GLOBALS['cfg']['IconvExtraParams'], $what);
case PMA_CHARSET_ICONV_AIX:
return PMA_aix_iconv_wrapper($src_charset, $dest_charset . $GLOBALS['cfg']['IconvExtraParams'], $what);
- case PMA_CHARSET_LIBICONV:
- return libiconv($src_charset, $dest_charset, $what);
default:
return $what;
}
@@ -170,7 +103,6 @@ function PMA_convert_file($src_charset, $dest_charset, $file) {
switch ($GLOBALS['PMA_recoding_engine']) {
case PMA_CHARSET_RECODE:
case PMA_CHARSET_ICONV:
- case PMA_CHARSET_LIBICONV:
$tmpfname = tempnam('', 'PMA_convert_file');
$fin = fopen($file, 'r');
$fout = fopen($tmpfname, 'w');
@@ -183,8 +115,6 @@ function PMA_convert_file($src_charset, $dest_charset, $file) {
$dist = iconv($src_charset, $dest_charset . $GLOBALS['cfg']['IconvExtraParams'], $line);
} elseif ($GLOBALS['PMA_recoding_engine'] == PMA_CHARSET_ICONV_AIX) {
$dist = PMA_aix_iconv_wrapper($src_charset, $dest_charset . $GLOBALS['cfg']['IconvExtraParams'], $line);
- } else {
- $dist = libiconv($src_charset, $dest_charset . $GLOBALS['cfg']['IconvExtraParams'], $line);
}
fputs($fout, $dist);
} // end while
diff --git a/libraries/config.default.php b/libraries/config.default.php
index 1ad769bad..cf4e1f3a4 100644
--- a/libraries/config.default.php
+++ b/libraries/config.default.php
@@ -2001,16 +2001,6 @@ $cfg['DefaultConnectionCollation'] = 'utf8_general_ci';
*/
$cfg['FilterLanguages'] = '';
-/**
- * Allow character set recoding of MySQL queries, must be also enabled in language
- * file to make harder using other language files than Unicode.
- * Default value is false to avoid problems on servers without the iconv
- * extension
- *
- * @global boolean $cfg['AllowAnywhereRecoding']
- */
-$cfg['AllowAnywhereRecoding'] = false;
-
/**
* You can select here which functions will be used for character set conversion.
* Possible values are:
@@ -2018,6 +2008,7 @@ $cfg['AllowAnywhereRecoding'] = false;
* recode)
* iconv - use iconv or libiconv functions
* recode - use recode_string function
+ * none - disable encoding conversion
*
* @global string $cfg['RecodingEngine']
*/
diff --git a/libraries/config.values.php b/libraries/config.values.php
index f16b62076..1e223dfa0 100644
--- a/libraries/config.values.php
+++ b/libraries/config.values.php
@@ -24,7 +24,7 @@ $cfg_db['Servers'] = array(1 => array(
'AllowDeny' => array(
'order' => array('', 'deny,allow', 'allow,deny', 'explicit')),
'only_db' => 'array'));
-$cfg_db['RecodingEngine'] = array('auto', 'iconv', 'recode');
+$cfg_db['RecodingEngine'] = array('auto', 'iconv', 'recode', 'none');
$cfg_db['OBGzip'] = array('auto', true, false);
$cfg_db['MemoryLimit'] = 'short_string';
$cfg_db['ShowTooltipAliasTB'] = array('nested', true, false);
diff --git a/libraries/core.lib.php b/libraries/core.lib.php
index 55322367a..c1413bef9 100644
--- a/libraries/core.lib.php
+++ b/libraries/core.lib.php
@@ -226,7 +226,7 @@ function PMA_fatalError($error_message, $message_args = null)
if (! isset($GLOBALS['available_languages'])) {
$GLOBALS['cfg'] = array(
'DefaultLang' => 'en',
- 'AllowAnywhereRecoding' => false);
+ );
// Loads the language file
require_once './libraries/select_lang.lib.php';
diff --git a/libraries/display_export.lib.php b/libraries/display_export.lib.php
index 5d76d7a38..c4a455ae8 100644
--- a/libraries/display_export.lib.php
+++ b/libraries/display_export.lib.php
@@ -199,7 +199,7 @@ echo PMA_pluginGetJavascript($export_list);