diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php
index fa186cde5ce..06a64fbe973 100644
--- a/htdocs/comm/propal.php
+++ b/htdocs/comm/propal.php
@@ -144,8 +144,7 @@ if ($_POST['action'] == 'send')
$propal= new Propal($db);
if ( $propal->fetch($_POST['propalid']) )
{
- $forbidden_chars=array('/','\\',':','*','?','"','<','>','|','[',']',',',';','=');
- $propalref = str_replace($forbidden_chars,'_',$propal->ref);
+ $propalref = sanitize_string($propal->ref);
$file = $conf->propal->dir_output . '/' . $propalref . '/' . $propalref . '.pdf';
if (is_readable($file))
{
@@ -811,8 +810,7 @@ if ($_GET['propalid'])
{
if ($user->rights->propale->envoyer)
{
- $forbidden_chars=array('/','\\',':','*','?','"','<','>','|','[',']',',',';','=');
- $propref = str_replace($forbidden_chars,'_',$obj->ref);
+ $propref = sanitize_string($obj->ref);
$file = $conf->propal->dir_output . '/'.$propref.'/'.$propref.'.pdf';
if (file_exists($file))
{
@@ -856,8 +854,7 @@ if ($_GET['propalid'])
print_titre($langs->trans('Documents'));
print '
';
- $forbidden_chars=array('/','\\',':','*','?','"','<','>','|','[',']',',',';','=');
- $propref = str_replace($forbidden_chars,'_',$propal->ref);
+ $propref = sanitize_string($propal->ref);
$file = $conf->propal->dir_output . '/'.$propref.'/'.$propref.'.pdf';
$relativepath = $propref.'/'.$propref.'.pdf';
diff --git a/htdocs/comm/propal/document.php b/htdocs/comm/propal/document.php
index 80eade5d01f..495b9e6e525 100644
--- a/htdocs/comm/propal/document.php
+++ b/htdocs/comm/propal/document.php
@@ -73,8 +73,7 @@ if ($propalid > 0)
if ($propal->fetch($propalid))
{
- $forbidden_chars=array('/','\\',':','*','?','"','<','>','|','[',']',',',';','=');
- $propref = str_replace($forbidden_chars, '_', $propal->ref);
+ $propref = sanitize_string($propal->ref);
$upload_dir = $conf->propal->dir_output.'/'.$propref;
if ( $error_msg )
{
diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php
index 59ed3acd46e..01484d47352 100644
--- a/htdocs/compta/facture.php
+++ b/htdocs/compta/facture.php
@@ -354,8 +354,7 @@ if ($_POST["action"] == 'send' || $_POST["action"] == 'relance')
$fac = new Facture($db,"",$_POST["facid"]);
if ( $fac->fetch($_POST["facid"]) )
{
- $forbidden_chars=array("/","\\",":","*","?","\"","<",">","|","[","]",",",";","=");
- $facref = str_replace($forbidden_chars,"_",$fac->ref);
+ $facref = sanitize_string($fac->ref);
$file = $conf->facture->dir_output . "/" . $facref . "/" . $facref . ".pdf";
if (is_readable($file))
@@ -1325,8 +1324,7 @@ else
* REFFACTURE-XXXXXX-detail.pdf ou XXXXX est une forme diverse
*/
- $forbidden_chars=array("/","\\",":","*","?","\"","<",">","|","[","]",",",";","=");
- $facref = str_replace($forbidden_chars,"_",$fac->ref);
+ $facref = sanitize_string($fac->ref);
$file = $conf->facture->dir_output . "/" . $facref . "/" . $facref . ".pdf";
$relativepath = "${facref}/${facref}.pdf";
diff --git a/htdocs/compta/facture/apercu.php b/htdocs/compta/facture/apercu.php
index 6736bb86fb9..8c9d065daf3 100644
--- a/htdocs/compta/facture/apercu.php
+++ b/htdocs/compta/facture/apercu.php
@@ -147,8 +147,7 @@ if ($_GET["facid"] > 0)
* Documents
*
*/
- $forbidden_chars=array("/","\\",":","*","?","\"","<",">","|","[","]",",",";","=");
- $facref = str_replace($forbidden_chars,"_",$fac->ref);
+ $facref = sanitize_string($fac->ref);
$file = $conf->facture->dir_output . "/" . $facref . "/" . $facref . ".pdf";
$filedetail = $conf->facture->dir_output . "/" . $facref . "/" . $facref . "-detail.pdf";
$relativepath = "${facref}/${facref}.pdf";
diff --git a/htdocs/compta/facture/facture-rec.class.php b/htdocs/compta/facture/facture-rec.class.php
index 38a94076ba5..f45af2c8a54 100644
--- a/htdocs/compta/facture/facture-rec.class.php
+++ b/htdocs/compta/facture/facture-rec.class.php
@@ -300,8 +300,7 @@ class FactureRec
/*
* Notify
*/
- $forbidden_chars=array("/","\\",":","*","?","\"","<",">","|","[","]",",",";","=");
- $facref = str_replace($forbidden_chars,"_",$this->ref);
+ $facref = sanitize_string($this->ref);
$filepdf = $conf->facture->dir_output . "/" . $facref . "/" . $facref . ".pdf";
diff --git a/htdocs/compta/propal.php b/htdocs/compta/propal.php
index 62feafbc054..a75c362287f 100644
--- a/htdocs/compta/propal.php
+++ b/htdocs/compta/propal.php
@@ -455,8 +455,7 @@ if ($_GET["propalid"])
print_titre($langs->trans('Documents'));
print '';
- $forbidden_chars=array('/','\\',':','*','?','"','<','>','|','[',']',',',';','=');
- $propref = str_replace($forbidden_chars,'_',$propal->ref);
+ $propref = sanitize_string($propal->ref);
$file = $conf->propal->dir_output . '/'.$propref.'/'.$propref.'.pdf';
$relativepath = $propref.'/'.$propref.'.pdf';
diff --git a/htdocs/facture.class.php b/htdocs/facture.class.php
index 9e8b678387e..2a9bfd53e6d 100644
--- a/htdocs/facture.class.php
+++ b/htdocs/facture.class.php
@@ -782,8 +782,7 @@ class Facture
/*
* Notify
*/
- $forbidden_chars=array("/","\\",":","*","?","\"","<",">","|","[","]",",",";","=");
- $facref = str_replace($forbidden_chars,"_",$this->ref);
+ $facref = sanitize_string($this->ref);
$filepdf = FAC_OUTPUTDIR . "/" . $facref . "/" . $facref . ".pdf";
$mesg = "La facture ".$this->ref." a été validée.\n";
diff --git a/htdocs/includes/modules/facture/modules_facture.php b/htdocs/includes/modules/facture/modules_facture.php
index 5168bcc3cdc..6c7aadb7905 100644
--- a/htdocs/includes/modules/facture/modules_facture.php
+++ b/htdocs/includes/modules/facture/modules_facture.php
@@ -155,8 +155,7 @@ function facture_meta_create($db, $facid, $message="")
if ($conf->facture->dir_output)
{
- $forbidden_chars=array("/","\\",":","*","?","\"","<",">","|","[","]",",",";","=");
- $facref = str_replace($forbidden_chars,"_",$fac->ref);
+ $facref = sanitize_string($forbidden_chars,"_",$fac->ref);
$dir = $conf->facture->dir_output . "/" . $facref ;
$file = $dir . "/" . $facref . ".meta";
diff --git a/htdocs/includes/modules/facture/pdf_adytek.modules.php b/htdocs/includes/modules/facture/pdf_adytek.modules.php
index 8d1c1ea9b1e..9a1be24d0ab 100644
--- a/htdocs/includes/modules/facture/pdf_adytek.modules.php
+++ b/htdocs/includes/modules/facture/pdf_adytek.modules.php
@@ -60,8 +60,7 @@ class pdf_adytek extends ModelePDFFactures {
$fac = new Facture($this->db,"",$facid);
$fac->fetch($facid);
- $forbidden_chars=array("/","\\",":","*","?","\"","<",">","|","[","]",",",";","=");
- $facref = str_replace($forbidden_chars,"_",$fac->ref);
+ $facref = sanitize_string($fac->ref);
$dir = $conf->facture->dir_output . "/" . $facref;
$file = $dir . "/" . $facref . ".pdf";
diff --git a/htdocs/includes/modules/facture/pdf_bernique.modules.php b/htdocs/includes/modules/facture/pdf_bernique.modules.php
index b5a97643eb1..c373e006e66 100644
--- a/htdocs/includes/modules/facture/pdf_bernique.modules.php
+++ b/htdocs/includes/modules/facture/pdf_bernique.modules.php
@@ -57,8 +57,7 @@ class pdf_bernique extends ModelePDFFactures {
if ($conf->facture->dir_output)
{
- $forbidden_chars=array("/","\\",":","*","?","\"","<",">","|","[","]",",",";","=");
- $facref = str_replace($forbidden_chars,"_",$fac->ref);
+ $facref = sanitize_string($fac->ref);
$dir = $conf->facture->dir_output . "/" . $facref . "/" ;
$file = $dir . $facref . ".pdf";
diff --git a/htdocs/includes/modules/facture/pdf_bigorneau.modules.php b/htdocs/includes/modules/facture/pdf_bigorneau.modules.php
index 549110cce8e..4eba65fe689 100644
--- a/htdocs/includes/modules/facture/pdf_bigorneau.modules.php
+++ b/htdocs/includes/modules/facture/pdf_bigorneau.modules.php
@@ -55,8 +55,7 @@ class pdf_bigorneau extends ModelePDFFactures {
if ($conf->facture->dir_output)
{
- $forbidden_chars=array("/","\\",":","*","?","\"","<",">","|","[","]",",",";","=");
- $facref = str_replace($forbidden_chars,"_",$fac->ref);
+ $facref = sanitize_string($fac->ref);
$dir = $conf->facture->dir_output . "/" . $facref . "/" ;
$file = $dir . $facref . ".pdf";
diff --git a/htdocs/includes/modules/facture/pdf_bulot.modules.php b/htdocs/includes/modules/facture/pdf_bulot.modules.php
index 5d8cc924396..05b279253bd 100644
--- a/htdocs/includes/modules/facture/pdf_bulot.modules.php
+++ b/htdocs/includes/modules/facture/pdf_bulot.modules.php
@@ -59,8 +59,7 @@ class pdf_bulot extends ModelePDFFactures {
$fac = new Facture($this->db,"",$facid);
$fac->fetch($facid);
- $forbidden_chars=array("/","\\",":","*","?","\"","<",">","|","[","]",",",";","=");
- $facref = str_replace($forbidden_chars,"_",$fac->ref);
+ $facref = sanitize_string($fac->ref);
$dir = $conf->facture->dir_output . "/" . $facref;
$file = $dir . "/" . $facref . ".pdf";
diff --git a/htdocs/includes/modules/facture/pdf_crabe.modules.php b/htdocs/includes/modules/facture/pdf_crabe.modules.php
index 20235134588..789736bed26 100644
--- a/htdocs/includes/modules/facture/pdf_crabe.modules.php
+++ b/htdocs/includes/modules/facture/pdf_crabe.modules.php
@@ -105,8 +105,7 @@ class pdf_crabe extends ModelePDFFactures
$fac = new Facture($this->db,"",$facid);
$fac->fetch($facid);
- $forbidden_chars=array("/","\\",":","*","?","\"","<",">","|","[","]",",",";","=");
- $facref = str_replace($forbidden_chars,"_",$fac->ref);
+ $facref = sanitize_string($fac->ref);
$dir = $conf->facture->dir_output . "/" . $facref;
$file = $dir . "/" . $facref . ".pdf";
diff --git a/htdocs/includes/modules/facture/pdf_oursin.modules.php b/htdocs/includes/modules/facture/pdf_oursin.modules.php
index a6d9ffcfebb..993957d514f 100644
--- a/htdocs/includes/modules/facture/pdf_oursin.modules.php
+++ b/htdocs/includes/modules/facture/pdf_oursin.modules.php
@@ -106,8 +106,7 @@ class pdf_oursin extends ModelePDFFactures
$fac = new Facture($this->db,"",$facid);
$fac->fetch($facid);
- $forbidden_chars=array("/","\\",":","*","?","\"","<",">","|","[","]",",",";","=");
- $facref = str_replace($forbidden_chars,"_",$fac->ref);
+ $facref = sanitize_string($fac->ref);
$dir = $conf->facture->dir_output . "/" . $facref;
$file = $dir . "/" . $facref . ".pdf";
diff --git a/htdocs/includes/modules/facture/pdf_tourteau.modules.php b/htdocs/includes/modules/facture/pdf_tourteau.modules.php
index 6bef02d5327..26bd2ce5786 100644
--- a/htdocs/includes/modules/facture/pdf_tourteau.modules.php
+++ b/htdocs/includes/modules/facture/pdf_tourteau.modules.php
@@ -55,8 +55,7 @@ class pdf_tourteau extends ModelePDFFactures {
if ($conf->facture->dir_output)
{
- $forbidden_chars=array("/","\\",":","*","?","\"","<",">","|","[","]",",",";","=");
- $facref = str_replace($forbidden_chars,"_",$fac->ref);
+ $facref = sanitize_string($fac->ref);
$dir = $conf->facture->dir_output . "/" . $facref . "/" ;
$file = $dir . $facref . ".pdf";
diff --git a/htdocs/includes/modules/fichinter/pdf_soleil.modules.php b/htdocs/includes/modules/fichinter/pdf_soleil.modules.php
index 3e61743a875..f6805a46ff3 100644
--- a/htdocs/includes/modules/fichinter/pdf_soleil.modules.php
+++ b/htdocs/includes/modules/fichinter/pdf_soleil.modules.php
@@ -60,8 +60,7 @@ class pdf_soleil extends ModelePDFFicheinter
$fich = new Fichinter($this->db,"",$id);
if ($fich->fetch($id))
{
- $forbidden_chars=array("/","\\",":","*","?","\"","<",">","|","[","]",",",";","=");
- $fichref = str_replace($forbidden_chars,"_",$fich->ref);
+ $fichref = sanitize_string($fich->ref);
$dir = $conf->fichinter->dir_output . "/" . $fichref;
$file = $dir . "/" . $fichref . ".pdf";
diff --git a/htdocs/includes/modules/propale/pdf_propale_adytek.modules.php b/htdocs/includes/modules/propale/pdf_propale_adytek.modules.php
index 1e76538408d..84c3b1c81d3 100644
--- a/htdocs/includes/modules/propale/pdf_propale_adytek.modules.php
+++ b/htdocs/includes/modules/propale/pdf_propale_adytek.modules.php
@@ -72,8 +72,7 @@ class pdf_propale_adytek extends ModelePDFPropales
if ($conf->propal->dir_output)
{
- $forbidden_chars=array("/","\\",":","*","?","\"","<",">","|","[","]",",",";","=");
- $propref = str_replace($forbidden_chars,"_",$propale->ref);
+ $propref = sanitize_string($propale->ref);
$dir = $conf->propal->dir_output . "/" . $propref ;
if (! file_exists($dir))
@@ -91,8 +90,7 @@ class pdf_propale_adytek extends ModelePDFPropales
return 0;
}
- $forbidden_chars=array("/","\\",":","*","?","\"","<",">","|","[","]",",",";","=");
- $propref = str_replace($forbidden_chars,"_",$propale->ref);
+ $propref = sanitize_string($propale->ref);
$file = $dir . "/" . $propref . ".pdf";
if (file_exists($dir))
diff --git a/htdocs/includes/modules/propale/pdf_propale_azur.modules.php b/htdocs/includes/modules/propale/pdf_propale_azur.modules.php
index 80475811793..d90806be208 100644
--- a/htdocs/includes/modules/propale/pdf_propale_azur.modules.php
+++ b/htdocs/includes/modules/propale/pdf_propale_azur.modules.php
@@ -116,8 +116,7 @@ class pdf_propale_azur extends ModelePDFPropales
$prop = new Propal($this->db,"",$id);
$prop->fetch($id);
- $forbidden_chars=array("/","\\",":","*","?","\"","<",">","|","[","]",",",";","=");
- $propref = str_replace($forbidden_chars,"_",$prop->ref);
+ $propref = sanitize_string($prop->ref);
$dir = $conf->propal->dir_output . "/" . $propref;
$file = $dir . "/" . $propref . ".pdf";
diff --git a/htdocs/includes/modules/propale/pdf_propale_bleu.modules.php b/htdocs/includes/modules/propale/pdf_propale_bleu.modules.php
index 2e143836ca9..fdc109cd11a 100644
--- a/htdocs/includes/modules/propale/pdf_propale_bleu.modules.php
+++ b/htdocs/includes/modules/propale/pdf_propale_bleu.modules.php
@@ -72,8 +72,7 @@ class pdf_propale_bleu extends ModelePDFPropales
if ($conf->propal->dir_output)
{
- $forbidden_chars=array("/","\\",":","*","?","\"","<",">","|","[","]",",",";","=");
- $propref = str_replace($forbidden_chars,"_",$propale->ref);
+ $propref = sanitize_string($propale->ref);
$dir = $conf->propal->dir_output . "/" . $propref ;
if (! file_exists($dir))
@@ -91,8 +90,7 @@ class pdf_propale_bleu extends ModelePDFPropales
return 0;
}
- $forbidden_chars=array("/","\\",":","*","?","\"","<",">","|","[","]",",",";","=");
- $propref = str_replace($forbidden_chars,"_",$propale->ref);
+ $propref = sanitize_string($propale->ref);
$file = $dir . "/" . $propref . ".pdf";
if (file_exists($dir))
diff --git a/htdocs/includes/modules/propale/pdf_propale_jaune.modules.php b/htdocs/includes/modules/propale/pdf_propale_jaune.modules.php
index 5cfda6d1df0..ae5d1e73250 100644
--- a/htdocs/includes/modules/propale/pdf_propale_jaune.modules.php
+++ b/htdocs/includes/modules/propale/pdf_propale_jaune.modules.php
@@ -72,8 +72,7 @@ class pdf_propale_jaune extends ModelePDFPropales
if ($conf->propal->dir_output)
{
- $forbidden_chars=array("/","\\",":","*","?","\"","<",">","|","[","]",",",";","=");
- $propref = str_replace($forbidden_chars,"_",$propale->ref);
+ $propref = sanitize_string($propale->ref);
$dir = $conf->propal->dir_output . "/" . $propref ;
if (! file_exists($dir))
{
@@ -90,8 +89,7 @@ class pdf_propale_jaune extends ModelePDFPropales
return 0;
}
- $forbidden_chars=array("/","\\",":","*","?","\"","<",">","|","[","]",",",";","=");
- $propref = str_replace($forbidden_chars,"_",$propale->ref);
+ $propref = sanitize_string($propale->ref);
$file = $dir . "/" . $propref . ".pdf";
if (file_exists($dir))
diff --git a/htdocs/includes/modules/propale/pdf_propale_rouge.modules.php b/htdocs/includes/modules/propale/pdf_propale_rouge.modules.php
index b4769d4472a..e9831dd0f0d 100644
--- a/htdocs/includes/modules/propale/pdf_propale_rouge.modules.php
+++ b/htdocs/includes/modules/propale/pdf_propale_rouge.modules.php
@@ -74,8 +74,7 @@ class pdf_propale_rouge extends ModelePDFPropales
if ($conf->propal->dir_output)
{
- $forbidden_chars=array("/","\\",":","*","?","\"","<",">","|","[","]",",",";","=");
- $propref = str_replace($forbidden_chars,"_",$propale->ref);
+ $propref = sanitize_string($propale->ref);
$dir = $conf->propal->dir_output . "/" . $propref ;
if (! file_exists($dir))
@@ -93,8 +92,7 @@ class pdf_propale_rouge extends ModelePDFPropales
return 0;
}
- $forbidden_chars=array("/","\\",":","*","?","\"","<",">","|","[","]",",",";","=");
- $propref = str_replace($forbidden_chars,"_",$propale->ref);
+ $propref = sanitize_string($propale->ref);
$file = $dir . "/" . $propref . ".pdf";
if (file_exists($dir))
diff --git a/htdocs/includes/modules/propale/pdf_propale_vert.modules.php b/htdocs/includes/modules/propale/pdf_propale_vert.modules.php
index 4b48c84a6ba..a6a190c1b85 100644
--- a/htdocs/includes/modules/propale/pdf_propale_vert.modules.php
+++ b/htdocs/includes/modules/propale/pdf_propale_vert.modules.php
@@ -72,8 +72,7 @@ class pdf_propale_vert extends ModelePDFPropales
if ($conf->propal->dir_output)
{
- $forbidden_chars=array("/","\\",":","*","?","\"","<",">","|","[","]",",",";","=");
- $propref = str_replace($forbidden_chars,"_",$propale->ref);
+ $propref = sanitize_string($propale->ref);
$dir = $conf->propal->dir_output . "/" . $propref ;
if (! file_exists($dir))
{
@@ -90,8 +89,7 @@ class pdf_propale_vert extends ModelePDFPropales
return 0;
}
- $forbidden_chars=array("/","\\",":","*","?","\"","<",">","|","[","]",",",";","=");
- $propref = str_replace($forbidden_chars,"_",$propale->ref);
+ $propref = sanitize_string($propale->ref);
$file = $dir . "/" . $propref . ".pdf";
if (file_exists($dir))