From 886ca96ad31acee6f0d057872b1ce17edc54d948 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 30 Aug 2010 18:31:59 +0000 Subject: [PATCH] Fix: UTF encoding with ajax pages --- htdocs/core/ajaxbox.php | 11 ++++++++++- htdocs/main.inc.php | 23 +++++++++++++++++------ htdocs/product/ajaxproducts.php | 5 +++-- htdocs/societe/ajaxcompanies.php | 8 +++++--- htdocs/societe/ajaxcountries.php | 9 +++++---- 5 files changed, 40 insertions(+), 16 deletions(-) diff --git a/htdocs/core/ajaxbox.php b/htdocs/core/ajaxbox.php index 84301efe238..d2eb6e84df5 100644 --- a/htdocs/core/ajaxbox.php +++ b/htdocs/core/ajaxbox.php @@ -30,7 +30,7 @@ if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); -require('./main.inc.php'); +require('../main.inc.php'); require_once(DOL_DOCUMENT_ROOT."/boxes.php"); @@ -38,6 +38,15 @@ require_once(DOL_DOCUMENT_ROOT."/boxes.php"); * View */ +// Ajout directives pour resoudre bug IE +//header('Cache-Control: Public, must-revalidate'); +//header('Pragma: public'); + +//top_htmlhead("", "", 1); // Replaced with top_httphead. An ajax page does not need html header. +top_httphead(); + +print ''."\n"; + // Registering the location of boxes if((isset($_GET['boxorder']) && !empty($_GET['boxorder'])) && (isset($_GET['userid']) && !empty($_GET['userid']))) { diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 365a6ac97ae..4f3d2cd5b3a 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -756,6 +756,21 @@ if (! function_exists("llxHeader")) } +/** + * Show HTML header + */ +function top_httphead() +{ + global $conf; + + //header("Content-type: text/html; charset=UTF-8"); + header("Content-type: text/html; charset=".$conf->file->character_set_client); + + // On the fly GZIP compression for all pages (if browser support it). Must set the bit 3 of constant to 1. + if (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_SPEED & 0x04)) { ob_start("ob_gzhandler"); } +} + + /** * \brief Show HTML header * \param head Optionnal head lines @@ -769,14 +784,10 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs { global $user, $conf, $langs, $db; + top_httphead(); + if (empty($conf->css)) $conf->css = '/theme/eldy/style.css.php'; // If not defined, eldy by default - //header("Content-type: text/html; charset=UTF-8"); - header("Content-type: text/html; charset=".$conf->file->character_set_client); - - // On the fly GZIP compression for all pages (if browser support it). Must set the bit 3 of constant to 1. - if (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_SPEED & 0x04)) { ob_start("ob_gzhandler"); } - print ''; //print ''; print "\n"; diff --git a/htdocs/product/ajaxproducts.php b/htdocs/product/ajaxproducts.php index db7697c05e2..423daf690cf 100644 --- a/htdocs/product/ajaxproducts.php +++ b/htdocs/product/ajaxproducts.php @@ -47,9 +47,10 @@ $langs->load("main"); //header('Cache-Control: Public, must-revalidate'); //header('Pragma: public'); -//print ''."\n"; +//top_htmlhead("", "", 1); // Replaced with top_httphead. An ajax page does not need html header. +top_httphead(); -//top_htmlhead("", "", 1); // Disabled. An ajax return must not include html header. +print ''."\n"; //print ''."\n"; diff --git a/htdocs/societe/ajaxcompanies.php b/htdocs/societe/ajaxcompanies.php index 1598f2701d4..ace3477b9a7 100644 --- a/htdocs/societe/ajaxcompanies.php +++ b/htdocs/societe/ajaxcompanies.php @@ -40,12 +40,14 @@ require('../main.inc.php'); */ // Ajout directives pour resoudre bug IE -header('Cache-Control: Public, must-revalidate'); -header('Pragma: public'); +//header('Cache-Control: Public, must-revalidate'); +//header('Pragma: public'); + +//top_htmlhead("", "", 1); // Replaced with top_httphead. An ajax page does not need html header. +top_httphead(); print ''."\n"; -//top_htmlhead("", "", 1, 1); // Disabled. An ajax return must not include html header. //print ''; diff --git a/htdocs/societe/ajaxcountries.php b/htdocs/societe/ajaxcountries.php index b865532db97..c01f914d497 100644 --- a/htdocs/societe/ajaxcountries.php +++ b/htdocs/societe/ajaxcountries.php @@ -38,13 +38,14 @@ require('../main.inc.php'); */ // Ajout directives pour resoudre bug IE -header('Cache-Control: Public, must-revalidate'); -header('Pragma: public'); +//header('Cache-Control: Public, must-revalidate'); +//header('Pragma: public'); + +//top_htmlhead("", "", 1); // Replaced with top_httphead. An ajax page does not need html header. +top_httphead(); print ''."\n"; -//top_htmlhead("", "", 1, 1); // Disabled. An ajax return must not include html header. - //print ''; dol_syslog(join(',',$_POST));