From 068f7c5b05a5c89c8f87581feceb77dc9840f910 Mon Sep 17 00:00:00 2001 From: Knah Tsaeb Date: Tue, 6 Aug 2013 17:13:53 +0200 Subject: [PATCH] [fix] bad encode charset with php <5.4 --- index.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/index.php b/index.php index c39ddf4..ad7ac41 100644 --- a/index.php +++ b/index.php @@ -49,7 +49,17 @@ if (get_magic_quotes_gpc()) { $_COOKIE = array_map('stripslashes_deep', $_COOKIE); } -$ci = array_map('htmlentities', array_merge($_POST, $_GET)); +/* PHP < 5.4 use htmlentities with ISO-8859-1 charset by default + * PHP > 5.4 use htmlentities with UTF-8 charset by default + * see http://php.net/manual/fr/function.htmlentities.php + * + */ +function myHtmlentities($var) { + return htmlentities($var, ENT_QUOTES, 'UTF-8'); +} + +$ci = array_merge($_POST, $_GET, $_COOKIE); +$ci = array_map('myHtmlentities', $ci); $_SESSION['bc'] = $ci['bc']; if (!file_exists($GLOBALS['config']['CONFIG_FILE']) || strlen(file_get_contents($GLOBALS['config']['CONFIG_FILE'])) == 0) { @@ -186,9 +196,9 @@ function n_print($data, $name = '') {
'; echo ' - ', basename($aBackTrace[0]['file']), ' ligne => ', $aBackTrace[0]['line'], ' + ', basename($aBackTrace[0]['file']), ' ligne => ', $aBackTrace[0]['line'], ' '; - echo '
',       htmlentities(print_r($data, 1)), '
'; + echo '
', htmlentities(print_r($data, 1)), '
'; echo '

';