mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-09 02:58:23 +01:00
Fix: Data in memory must always be encoded in utf8. PHP files functions need ISO, so we convert data just before and after using them.
This commit is contained in:
@@ -907,7 +907,7 @@ $companystatic=new Societe($db);
|
|||||||
|
|
||||||
$now=gmmktime();
|
$now=gmmktime();
|
||||||
|
|
||||||
$id = $_GET['propalid'];
|
$id = $_GET['propalid']?$_GET['propalid']:$_GET['id'];
|
||||||
$ref= $_GET['ref'];
|
$ref= $_GET['ref'];
|
||||||
if ($id > 0 || ! empty($ref))
|
if ($id > 0 || ! empty($ref))
|
||||||
{
|
{
|
||||||
@@ -920,7 +920,7 @@ if ($id > 0 || ! empty($ref))
|
|||||||
$product_static=new Product($db);
|
$product_static=new Product($db);
|
||||||
|
|
||||||
$propal = new Propal($db);
|
$propal = new Propal($db);
|
||||||
$propal->fetch($_GET['propalid'],$_GET['ref']);
|
$propal->fetch($id,$ref);
|
||||||
|
|
||||||
$societe = new Societe($db);
|
$societe = new Societe($db);
|
||||||
$societe->fetch($propal->socid);
|
$societe->fetch($propal->socid);
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ llxHeader();
|
|||||||
|
|
||||||
$html = new Form($db);
|
$html = new Form($db);
|
||||||
|
|
||||||
$id = $_GET['propalid'];
|
$id = $_GET['propalid']?$_GET['propalid']:$_GET['id'];
|
||||||
$ref= $_GET['ref'];
|
$ref= $_GET['ref'];
|
||||||
if ($id > 0 || ! empty($ref))
|
if ($id > 0 || ! empty($ref))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ llxHeader();
|
|||||||
|
|
||||||
$html = new Form($db);
|
$html = new Form($db);
|
||||||
|
|
||||||
$id = $_GET['facid'];
|
$id = $_GET['facid']?$_GET['facid']:$_GET['id'];
|
||||||
$ref= $_GET['ref'];
|
$ref= $_GET['ref'];
|
||||||
if ($id > 0 || ! empty($ref))
|
if ($id > 0 || ! empty($ref))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -256,7 +256,7 @@ if (empty($action) || $action == 'file_manager' || eregi('refresh',$action) || $
|
|||||||
print '<tr class="liste_titre">';
|
print '<tr class="liste_titre">';
|
||||||
print '<td class="liste_titre" align="left">'.$langs->trans("ECMSections").'</td>';
|
print '<td class="liste_titre" align="left">'.$langs->trans("ECMSections").'</td>';
|
||||||
print '<td class="liste_titre" colspan="5" align="right">';
|
print '<td class="liste_titre" colspan="5" align="right">';
|
||||||
print '<a href="'.$_SERVER["PHP_SELF"].'?action=refreshmanual'.($section?'&section='.$section:'').'">'.img_picto($langs->trans("Refresh"),'refresh').'</a> ';
|
print '<a href="'.$_SERVER["PHP_SELF"].'?action=refreshmanual'.($section?'&section='.$section:'').'">'.img_picto($langs->trans("Refresh"),'refresh').'</a>';
|
||||||
print '</td>';
|
print '</td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ if ($_GET["facid"])
|
|||||||
print '<table class="border" width="100%">';
|
print '<table class="border" width="100%">';
|
||||||
|
|
||||||
// Ref
|
// Ref
|
||||||
print '<tr><td width="30%" nowrap="nowrap">'.$langs->trans("Ref").'</td><td colspan="3">';
|
print '<tr><td width="20%" nowrap="nowrap">'.$langs->trans("Ref").'</td><td colspan="3">';
|
||||||
print $html->showrefnav($fac,'facid','',1,'rowid','ref',$morehtmlref);
|
print $html->showrefnav($fac,'facid','',1,'rowid','ref',$morehtmlref);
|
||||||
print '</td>';
|
print '</td>';
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
|
|||||||
@@ -431,7 +431,7 @@ class FormFile
|
|||||||
if (empty($useinecm)) print_titre($langs->trans("AttachedFiles"));
|
if (empty($useinecm)) print_titre($langs->trans("AttachedFiles"));
|
||||||
else { $bc[true]=''; $bc[false]=''; };
|
else { $bc[true]=''; $bc[false]=''; };
|
||||||
$url=$_SERVER["PHP_SELF"];
|
$url=$_SERVER["PHP_SELF"];
|
||||||
print '<table width="100%" class="noborder">';
|
print '<table width="100%" class="nobordernopadding">';
|
||||||
print '<tr class="liste_titre">';
|
print '<tr class="liste_titre">';
|
||||||
print_liste_field_titre($langs->trans("Documents2"),$_SERVER["PHP_SELF"],"name","",$param,'align="left"',$sortfield,$sortorder);
|
print_liste_field_titre($langs->trans("Documents2"),$_SERVER["PHP_SELF"],"name","",$param,'align="left"',$sortfield,$sortorder);
|
||||||
print_liste_field_titre($langs->trans("Size"),$_SERVER["PHP_SELF"],"size","",$param,'align="right"',$sortfield,$sortorder);
|
print_liste_field_titre($langs->trans("Size"),$_SERVER["PHP_SELF"],"size","",$param,'align="right"',$sortfield,$sortorder);
|
||||||
@@ -457,14 +457,15 @@ class FormFile
|
|||||||
|
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
print "<tr $bc[$var]><td>";
|
print "<tr $bc[$var]><td>";
|
||||||
|
//print "XX".$file['name']; //$file['name'] must be utf8
|
||||||
print '<a href="'.DOL_URL_ROOT.'/document.php?modulepart='.$modulepart;
|
print '<a href="'.DOL_URL_ROOT.'/document.php?modulepart='.$modulepart;
|
||||||
if ($forcedownload) print '&type=application/binary';
|
if ($forcedownload) print '&type=application/binary';
|
||||||
print '&file='.urlencode($relativepath.$file['name']).'">';
|
print '&file='.urlencode($relativepath.$file['name']).'">';
|
||||||
print img_mime($file['name']).' ';
|
print img_mime($file['name'],$file['name'].' ('.dol_print_size($file['size'],0,0).')').' ';
|
||||||
print htmlentities(dol_trunc($file['name'],$maxlength,'middle'));
|
print dol_trunc($file['name'],$maxlength,'middle');
|
||||||
print '</a>';
|
print '</a>';
|
||||||
print "</td>\n";
|
print "</td>\n";
|
||||||
print '<td align="right">'.dol_print_size($file['size']).'</td>';
|
print '<td align="right">'.dol_print_size($file['size'],1,1).'</td>';
|
||||||
print '<td align="center">'.dol_print_date($file['date'],"dayhour").'</td>';
|
print '<td align="center">'.dol_print_date($file['date'],"dayhour").'</td>';
|
||||||
print '<td align="right">';
|
print '<td align="right">';
|
||||||
//print ' ';
|
//print ' ';
|
||||||
|
|||||||
@@ -231,6 +231,13 @@ MonthOfDay=Month of the day
|
|||||||
HourShort=H
|
HourShort=H
|
||||||
Rate=Rate
|
Rate=Rate
|
||||||
Bytes=Bytes
|
Bytes=Bytes
|
||||||
|
KiloBytes=Kilobytes
|
||||||
|
MegaBytes=Megabytes
|
||||||
|
GigaBytes=Gigabytes
|
||||||
|
b=b.
|
||||||
|
Kb=Kb
|
||||||
|
Mb=Mb
|
||||||
|
Gb=Gb
|
||||||
Cut=Cut
|
Cut=Cut
|
||||||
Copy=Copy
|
Copy=Copy
|
||||||
Paste=Paste
|
Paste=Paste
|
||||||
|
|||||||
@@ -230,6 +230,13 @@ MonthOfDay=Mois du jour
|
|||||||
HourShort=H
|
HourShort=H
|
||||||
Rate=Taux
|
Rate=Taux
|
||||||
Bytes=Octets
|
Bytes=Octets
|
||||||
|
KiloBytes=Kilooctets
|
||||||
|
MegaBytes=Megaoctets
|
||||||
|
GigaBytes=Gigaoctets
|
||||||
|
b=o.
|
||||||
|
Kb=Ko
|
||||||
|
Mb=Mo
|
||||||
|
Gb=Go
|
||||||
Cut=Couper
|
Cut=Couper
|
||||||
Copy=Copier
|
Copy=Copier
|
||||||
Paste=Coller
|
Paste=Coller
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ Notify_NOTIFY_VAL_FAC=Validation facture
|
|||||||
Notify_NOTIFY_APP_ORDER_SUPPLIER=Approbation commande fournisseur
|
Notify_NOTIFY_APP_ORDER_SUPPLIER=Approbation commande fournisseur
|
||||||
Notify_NOTIFY_REF_ORDER_SUPPLIER=Refus commande fournisseur
|
Notify_NOTIFY_REF_ORDER_SUPPLIER=Refus commande fournisseur
|
||||||
NbOfAttachedFiles=Nombre de fichiers/documents liés
|
NbOfAttachedFiles=Nombre de fichiers/documents liés
|
||||||
TotalSizeOfAttachedFiles=Taille total des fichiers/documents liés
|
TotalSizeOfAttachedFiles=Taille total fichiers/documents liés
|
||||||
MaxSize=Taille maximum
|
MaxSize=Taille maximum
|
||||||
AttachANewFile=Ajouter un nouveau fichier/document
|
AttachANewFile=Ajouter un nouveau fichier/document
|
||||||
LinkedObject=Objet lié
|
LinkedObject=Objet lié
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2008 Laurent Destailleur <eldy@users.sourceforge.net>
|
/* Copyright (C) 2008-2009 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Scan a directory and return a list of files/directories
|
* \brief Scan a directory and return a list of files/directories. Content for string is UTF8.
|
||||||
* \param $path Starting path from which to search
|
* \param $path Starting path from which to search
|
||||||
* \param $types Can be "directories", "files", or "all"
|
* \param $types Can be "directories", "files", or "all"
|
||||||
* \param $recursive Determines whether subdirectories are searched
|
* \param $recursive Determines whether subdirectories are searched
|
||||||
@@ -43,7 +43,7 @@ function dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefil
|
|||||||
$loadsize=$mode?true:false;
|
$loadsize=$mode?true:false;
|
||||||
|
|
||||||
// Clean parameters
|
// Clean parameters
|
||||||
$path=eregi_replace('[\\/]+$','',$path);
|
$path=eregi_replace('[\\/]+$','',utf8_check($path)?utf8_decode($path):$path);
|
||||||
|
|
||||||
if (! is_dir($path)) return array();
|
if (! is_dir($path)) return array();
|
||||||
|
|
||||||
@@ -52,6 +52,9 @@ function dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefil
|
|||||||
$file_list = array();
|
$file_list = array();
|
||||||
while (false !== ($file = readdir($dir)))
|
while (false !== ($file = readdir($dir)))
|
||||||
{
|
{
|
||||||
|
// readdir return value in ISO and we want UTF8 in memory
|
||||||
|
if (! utf8_check($file)) $file=utf8_encode($file);
|
||||||
|
|
||||||
$qualified=1;
|
$qualified=1;
|
||||||
|
|
||||||
// Check if file is qualified
|
// Check if file is qualified
|
||||||
@@ -64,8 +67,8 @@ function dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefil
|
|||||||
if (is_dir($path."/".$file) && (($types=="directories") || ($types=="all")))
|
if (is_dir($path."/".$file) && (($types=="directories") || ($types=="all")))
|
||||||
{
|
{
|
||||||
// Add entry into file_list array
|
// Add entry into file_list array
|
||||||
if ($loaddate || $sortcriteria == 'date') $filedate=filemtime($path."/".$file);
|
if ($loaddate || $sortcriteria == 'date') $filedate=filemtime(utf8_check($path."/".$file)?utf8_decode($path."/".$file):$path."/".$file);
|
||||||
if ($loadsize || $sortcriteria == 'size') $filesize=filesize($path."/".$file);
|
if ($loadsize || $sortcriteria == 'size') $filesize=filesize(utf8_check($path."/".$file)?utf8_decode($path."/".$file):$path."/".$file);
|
||||||
|
|
||||||
if (! $filter || eregi($filter,$path.'/'.$file))
|
if (! $filter || eregi($filter,$path.'/'.$file))
|
||||||
{
|
{
|
||||||
@@ -87,8 +90,8 @@ function dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefil
|
|||||||
else if (! is_dir($path."/".$file) && (($types == "files") || ($types == "all")))
|
else if (! is_dir($path."/".$file) && (($types == "files") || ($types == "all")))
|
||||||
{
|
{
|
||||||
// Add file into file_list array
|
// Add file into file_list array
|
||||||
if ($loaddate || $sortcriteria == 'date') $filedate=filemtime($path."/".$file);
|
if ($loaddate || $sortcriteria == 'date') $filedate=filemtime(utf8_check($path."/".$file)?utf8_decode($path."/".$file):$path."/".$file);
|
||||||
if ($loadsize || $sortcriteria == 'size') $filesize=filesize($path."/".$file);
|
if ($loadsize || $sortcriteria == 'size') $filesize=filesize(utf8_check($path."/".$file)?utf8_decode($path."/".$file):$path."/".$file);
|
||||||
if (! $filter || eregi($filter,$path.'/'.$file))
|
if (! $filter || eregi($filter,$path.'/'.$file))
|
||||||
{
|
{
|
||||||
$file_list[] = array(
|
$file_list[] = array(
|
||||||
@@ -193,19 +196,18 @@ function dol_mimetype($file)
|
|||||||
*/
|
*/
|
||||||
function dol_dir_is_emtpy($folder)
|
function dol_dir_is_emtpy($folder)
|
||||||
{
|
{
|
||||||
if (is_dir($folder))
|
$newfolder=utf8_check($folder)?utf8_decode($folder):$folder; // The opendir need ISO strings
|
||||||
|
if (is_dir($newfolder))
|
||||||
{
|
{
|
||||||
$handle = opendir($folder);
|
$handle = opendir($newfolder);
|
||||||
while( (gettype( $name = readdir($handle)) != "boolean")){
|
while ((gettype( $name = readdir($handle)) != "boolean"))
|
||||||
|
{
|
||||||
$name_array[] = $name;
|
$name_array[] = $name;
|
||||||
}
|
}
|
||||||
foreach($name_array as $temp)
|
foreach($name_array as $temp) $folder_content .= $temp;
|
||||||
$folder_content .= $temp;
|
|
||||||
|
|
||||||
if($folder_content == "...")
|
if ($folder_content == "...") return true;
|
||||||
return true;
|
else return false;
|
||||||
else
|
|
||||||
return false;
|
|
||||||
|
|
||||||
closedir($handle);
|
closedir($handle);
|
||||||
}
|
}
|
||||||
@@ -221,16 +223,18 @@ function dol_dir_is_emtpy($folder)
|
|||||||
function dol_count_nb_of_line($file)
|
function dol_count_nb_of_line($file)
|
||||||
{
|
{
|
||||||
$nb=0;
|
$nb=0;
|
||||||
|
|
||||||
|
$newfile=utf8_check($file)?utf8_decode($file):$file; // The fopen need ISO strings
|
||||||
//print 'x'.$file;
|
//print 'x'.$file;
|
||||||
$fp=fopen($file,'r');
|
$fp=fopen($newfile,'r');
|
||||||
if ($fp)
|
if ($fp)
|
||||||
{
|
{
|
||||||
while (!feof($fp))
|
while (!feof($fp))
|
||||||
{
|
{
|
||||||
$line=fgets($fp);
|
$line=fgets($fp);
|
||||||
$nb++;
|
$nb++;
|
||||||
}
|
}
|
||||||
fclose($fp);
|
fclose($fp);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -698,13 +698,33 @@ function dol_date($fmt, $timestamp, $gm=0)
|
|||||||
/**
|
/**
|
||||||
* \brief Return string with formated size
|
* \brief Return string with formated size
|
||||||
* \param size Size to print
|
* \param size Size to print
|
||||||
|
* \param shortvalue Tell if we want long value to use another unit (Ex: 1.5Kb instead of 1500b)
|
||||||
|
* \param shortunit Use short value of size unit
|
||||||
* \return string Link
|
* \return string Link
|
||||||
*/
|
*/
|
||||||
function dol_print_size($size)
|
function dol_print_size($size,$shortvalue=0,$shortunit=0)
|
||||||
{
|
{
|
||||||
global $langs;
|
global $langs;
|
||||||
|
$level=1024;
|
||||||
|
|
||||||
return $size.' '.$langs->trans("Bytes");
|
// Set value text
|
||||||
|
if (empty($shortvalue) || $size < ($level*10))
|
||||||
|
{
|
||||||
|
$ret=$size;
|
||||||
|
$textunitshort=$langs->trans("b");
|
||||||
|
$textunitlong=$langs->trans("Bytes");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$ret=round($size/$level,0);
|
||||||
|
$textunitshort=$langs->trans("Kb");
|
||||||
|
$textunitlong=$langs->trans("KiloBytes");
|
||||||
|
}
|
||||||
|
// Use long or short text unit
|
||||||
|
if (empty($shortunit)) { $ret.=' '.$textunitlong; }
|
||||||
|
else { $ret.=' '.$textunitshort; }
|
||||||
|
|
||||||
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -2111,11 +2131,12 @@ function print_fleche_navigation($page,$file,$options='',$nextpage,$betweenarrow
|
|||||||
function dol_delete_file($file)
|
function dol_delete_file($file)
|
||||||
{
|
{
|
||||||
$ok=true;
|
$ok=true;
|
||||||
foreach (glob($file) as $filename)
|
$newfile=utf8_check($file)?utf8_decode($file):$file; // glob function accepts only ISO string
|
||||||
|
foreach (glob($newfile) as $filename)
|
||||||
{
|
{
|
||||||
$ok=unlink($filename);
|
$ok=unlink($filename);
|
||||||
if ($ok) dol_syslog("Removed file $filename",LOG_DEBUG);
|
if ($ok) dol_syslog("Removed file ".$filename,LOG_DEBUG);
|
||||||
else dol_syslog("Failed to remove file $filename",LOG_ERR);
|
else dol_syslog("Failed to remove file ".$filename,LOG_ERR);
|
||||||
}
|
}
|
||||||
return $ok;
|
return $ok;
|
||||||
}
|
}
|
||||||
@@ -2128,7 +2149,8 @@ function dol_delete_file($file)
|
|||||||
*/
|
*/
|
||||||
function dol_delete_dir($dir)
|
function dol_delete_dir($dir)
|
||||||
{
|
{
|
||||||
return rmdir($dir);
|
$newdir=utf8_check($dir)?utf8_decode($dir):$dir;
|
||||||
|
return rmdir($newdir);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -2140,7 +2162,8 @@ function dol_delete_dir($dir)
|
|||||||
function dol_delete_dir_recursive($dir,$count=0)
|
function dol_delete_dir_recursive($dir,$count=0)
|
||||||
{
|
{
|
||||||
//dol_syslog("functions.lib:dol_delete_dir_recursive ".$dir,LOG_DEBUG);
|
//dol_syslog("functions.lib:dol_delete_dir_recursive ".$dir,LOG_DEBUG);
|
||||||
if ($handle = opendir("$dir"))
|
$newdir=utf8_check($dir)?utf8_decode($dir):$dir;
|
||||||
|
if ($handle = opendir("$newdir"))
|
||||||
{
|
{
|
||||||
while (false !== ($item = readdir($handle)))
|
while (false !== ($item = readdir($handle)))
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user