mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-15 22:11:36 +01:00
Correction problème de charset
Lorsque MySql est configuré par défaut en UTF-8, il était impossible d'utiliser le format ISO. Les caractères avec accents devenaient des ?
This commit is contained in:
@@ -30,7 +30,7 @@
|
||||
|
||||
define('DONOTLOADCONF',1); // To avoid loading conf by file inc..php
|
||||
|
||||
include_once("./inc.php");
|
||||
include("./inc.php");
|
||||
$setuplang=isset($_POST["selectlang"])?$_POST["selectlang"]:(isset($_GET["selectlang"])?$_GET["selectlang"]:'auto');
|
||||
$langs->setDefaultLang($setuplang);
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
\version $Revision$
|
||||
*/
|
||||
|
||||
include_once("./inc.php");
|
||||
include("./inc.php");
|
||||
if (! isset($dolibarr_main_db_prefix) || ! $dolibarr_main_db_prefix) $dolibarr_main_db_prefix='llx_';
|
||||
define('MAIN_DB_PREFIX',$dolibarr_main_db_prefix);
|
||||
require_once($dolibarr_main_document_root . "/lib/databases/".$dolibarr_main_db_type.".lib.php");
|
||||
@@ -66,13 +66,6 @@ if ($_POST["action"] == "set")
|
||||
print '<table cellspacing="0" cellpadding="4" border="0" width="100%">';
|
||||
$error=0;
|
||||
|
||||
$conf = new Conf();// on pourrait s'en passer
|
||||
$conf->db->type = $dolibarr_main_db_type;
|
||||
$conf->db->host = $dolibarr_main_db_host;
|
||||
$conf->db->name = $dolibarr_main_db_name;
|
||||
$conf->db->user = $dolibarr_main_db_user;
|
||||
$conf->db->pass = $dolibarr_main_db_pass;
|
||||
|
||||
$db = new DoliDb($conf->db->type,$conf->db->host,$conf->db->user,$conf->db->pass,$conf->db->name);
|
||||
if ($db->connected == 1)
|
||||
{
|
||||
@@ -149,7 +142,7 @@ if ($_POST["action"] == "set")
|
||||
$requestnb++;
|
||||
if ($db->query($buffer))
|
||||
{
|
||||
//print "<td>OK requete ==== $buffer</td></tr>";
|
||||
// print "<td>OK requete ==== $buffer</td></tr>";
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -385,7 +378,7 @@ if ($_POST["action"] == "set")
|
||||
while (!feof ($fp))
|
||||
{
|
||||
$buffer = fgets($fp, 4096);
|
||||
|
||||
print "<tr><td>Insertion ligne : $buffer</td><td>";
|
||||
if (strlen(trim(ereg_replace("--","",$buffer))))
|
||||
{
|
||||
if ($db->query($buffer))
|
||||
@@ -396,7 +389,7 @@ if ($_POST["action"] == "set")
|
||||
{
|
||||
if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS')
|
||||
{
|
||||
// print "<tr><td>Insertion ligne : $buffer</td><td>
|
||||
//print "<tr><td>Insertion ligne : $buffer</td><td>";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -44,7 +44,6 @@ if (file_exists($conffile))
|
||||
{
|
||||
include_once($conffile); // Fichier conf charg<72>
|
||||
|
||||
$charset=$character_set_client;
|
||||
// Remove last / or \ on directories or url value
|
||||
if (! ereg('^[\\\/]+$',$dolibarr_main_document_root)) $dolibarr_main_document_root=ereg_replace('[\\\/]+$','',$dolibarr_main_document_root);
|
||||
if (! ereg('^[\\\/]+$',$dolibarr_main_url_root)) $dolibarr_main_url_root=ereg_replace('[\\\/]+$','',$dolibarr_main_url_root);
|
||||
@@ -54,7 +53,6 @@ if (file_exists($conffile))
|
||||
{
|
||||
require_once($dolibarr_main_document_root . "/conf/conf.class.php");
|
||||
$conf=new Conf();
|
||||
$conf = new Conf();
|
||||
$conf->db->type = trim($dolibarr_main_db_type);
|
||||
$conf->db->host = trim($dolibarr_main_db_host);
|
||||
$conf->db->name = trim($dolibarr_main_db_name);
|
||||
@@ -66,6 +64,7 @@ if (file_exists($conffile))
|
||||
$conf->db->character_set=$dolibarr_main_db_charset;
|
||||
if (! isset($collation_connection) || ! $collation_connection) $collation_connection='latin1_swedish_ci';
|
||||
$conf->db->collation_connection=$collation_connection;
|
||||
|
||||
}
|
||||
if ($dolibarr_main_document_root && $dolibarr_main_db_type && ! defined('DONOTLOADCONF'))
|
||||
{
|
||||
|
||||
@@ -165,6 +165,7 @@ class DoliDb
|
||||
if (mysql_client_encoding ( $this->db ) != $this->forcecharset)
|
||||
{
|
||||
$this->query("SET NAMES '".$this->forcecharset."'", $this->db);
|
||||
$this->query("SET CHARACTER SET ". $this->forcecharset);
|
||||
}
|
||||
$this->connected = 1;
|
||||
$this->ok = 1;
|
||||
@@ -232,7 +233,8 @@ class DoliDb
|
||||
//force les enregistrement en latin1 si la base est en utf8 par d<>faut
|
||||
// Supprim<69> car plante sur mon PHP-Mysql. De plus, la base est forcement en latin1 avec
|
||||
// les nouvelles version de Dolibarr car forc<72> par l'install Dolibarr.
|
||||
//$this->query('SET NAMES '.$this->forcecharset);
|
||||
$this->query("SET NAMES '".$this->forcecharset."'", $this->db);
|
||||
$this->query("SET CHARACTER SET '".$this->forcecharset."'", $this->db);
|
||||
//print "Resultat fonction connect: ".$this->db;
|
||||
return $this->db;
|
||||
}
|
||||
|
||||
@@ -163,10 +163,11 @@ class DoliDb
|
||||
if ($this->db)
|
||||
{
|
||||
// Si client connect<63> avec charset different de celui de Dolibarr
|
||||
if (mysqli_client_encoding ( $this->db ) != $this->forcecharset)
|
||||
/*if (mysqli_client_encoding ( $this->db ) != $this->forcecharset)
|
||||
{
|
||||
$this->query("SET NAMES '".$this->forcecharset."'", $this->db);
|
||||
}
|
||||
$this->query("SET CHARACTER SET '".$this->forcecharset."'", $this->db);
|
||||
}*/
|
||||
$this->connected = 1;
|
||||
$this->ok = 1;
|
||||
}
|
||||
@@ -236,10 +237,11 @@ class DoliDb
|
||||
// les nouvelles version de Dolibarr car forc<72> par l'install Dolibarr.
|
||||
//$this->query('SET NAMES '.$this->forcecharset);
|
||||
//print "Resultat fonction connect: ".$this->db;
|
||||
$this->query("SET NAMES '".$this->forcecharset."'", $this->db);
|
||||
$this->query("SET CHARACTER SET '".$this->forcecharset."'", $this->db);
|
||||
return $this->db;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\brief Renvoie la version du serveur
|
||||
\return string Chaine version
|
||||
@@ -355,10 +357,9 @@ class DoliDb
|
||||
function query($query)
|
||||
{
|
||||
$query = trim($query);
|
||||
|
||||
if (! $this->database_name)
|
||||
{
|
||||
// Ordre SQL ne n<>cessitant pas de connexion <20> une base (exemple: CREATE DATABASE)
|
||||
// Ordre SQL ne n<>cessitant pas de connexion <20> une base (exemple: CREATE DATABASE
|
||||
$ret = mysqli_query($this->db,$query);
|
||||
}
|
||||
else
|
||||
@@ -697,7 +698,7 @@ class DoliDb
|
||||
$like = '';
|
||||
if ($table) $like = "LIKE '".$table."'";
|
||||
$sql="SHOW TABLES FROM ".$database." ".$like.";";
|
||||
//print $sql;
|
||||
// $sql;
|
||||
$result = $this->query($sql);
|
||||
while($row = $this->fetch_row($result))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user