From 163711871a183aecebf0e35c552eebc27641a583 Mon Sep 17 00:00:00 2001
From: Laurent Destailleur <eldy@users.sourceforge.net>
Date: Fri, 31 Dec 2004 18:12:29 +0000
Subject: [PATCH] =?UTF-8?q?Fix:=20Utilisation=20du=20wrapper=20s=E9curis?=
 =?UTF-8?q?=E9=20pour=20tous?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 htdocs/compta/facture/facture-rec.class.php   |  2 +-
 htdocs/compta/propal.php                      | 29 ++++++++++++-------
 htdocs/expedition/fiche.php                   | 23 ++++++++-------
 htdocs/fichinter/fiche.php                    | 16 ++++++----
 htdocs/fourn/commande/fiche.php               | 13 +++++----
 .../modules/fichinter/pdf_soleil.modules.php  | 10 ++-----
 6 files changed, 53 insertions(+), 40 deletions(-)

diff --git a/htdocs/compta/facture/facture-rec.class.php b/htdocs/compta/facture/facture-rec.class.php
index 2541dd6c7bf..3669ac47b13 100644
--- a/htdocs/compta/facture/facture-rec.class.php
+++ b/htdocs/compta/facture/facture-rec.class.php
@@ -314,7 +314,7 @@ class FactureRec
 	   */
 		$forbidden_chars=array("/","\\",":","*","?","\"","<",">","|","[","]",",",";","=");
 		$facref = str_replace($forbidden_chars,"_",$this->ref);
-		$filepdf = FAC_OUTPUTDIR . "/" . $facref . "/" . $facref . ".pdf";
+		$filepdf = $conf->facture->dir_output . "/" . $facref . "/" . $facref . ".pdf";
 
 	  
 	  $mesg = "La facture ".$this->ref." a �t� valid�e.\n";
diff --git a/htdocs/compta/propal.php b/htdocs/compta/propal.php
index f94a5981976..6ebe5bbfaac 100644
--- a/htdocs/compta/propal.php
+++ b/htdocs/compta/propal.php
@@ -21,6 +21,11 @@
  * $Source$
  *
  */
+ 
+/**
+\todo Ce fichier ne semble plus utilis�. A virer ?
+*/
+
 require("./pre.inc.php");
 
 $user->getrights('facture');
@@ -122,9 +127,9 @@ if ($_GET["propalid"])
             
       $color1 = "#e0e0e0";
 
-      print '<table class="border" cellspacing="0" cellpadding="2" width="100%">';
+      print '<table class="border" width="100%">';
 
-      print '<tr><td>Soci�t�</td><td colspan="2"><a href="fiche.php?socid='.$obj->idp.'">'.$obj->nom.'</a></td>';
+      print '<tr><td>'.$langs->trans("Company").'</td><td colspan="2"><a href="fiche.php?socid='.$obj->idp.'">'.$obj->nom.'</a></td>';
       print "<td valign=\"top\" width=\"50%\" rowspan=\"9\">Note :<br>". nl2br($obj->note)."</td></tr>";
       //
 
@@ -134,7 +139,7 @@ if ($_GET["propalid"])
 	{
 	  $projet = new Project($db);
 	  $projet->fetch($obj->fk_projet); 
-	  print '<tr><td>Projet</td><td colspan="1">';
+	  print '<tr><td>'.$langs->trans("Project").'</td><td colspan="1">';
 	  print '<a href="'.DOL_URL_ROOT.'/projet/fiche.php?id='.$projet->id.'">';
 	  print $projet->title.'</a></td></tr>';
 	}
@@ -143,7 +148,7 @@ if ($_GET["propalid"])
        *
        */
 
-      print "<tr><td bgcolor=\"$color1\">Montant HT</td><td colspan=\"2\" bgcolor=\"$color1\" align=\"right\">".price($obj->price + $obj->remise)." euros</td></tr>";
+      print "<tr><td bgcolor=\"$color1\">".$langs->trans("AmountHT")."</td><td colspan=\"2\" bgcolor=\"$color1\" align=\"right\">".price($obj->price + $obj->remise)." euros</td></tr>";
       /*
        *
        */
@@ -156,7 +161,7 @@ if ($_GET["propalid"])
 
       $totalht = $propal->price ;
 
-      print "<tr><td bgcolor=\"$color1\">Total HT</td><td colspan=\"2\" bgcolor=\"$color1\" align=\"right\"><b>".price($totalht)."</b> euros</td></tr>";
+      print "<tr><td bgcolor=\"$color1\">".$langs->trans("TotalHT")."</td><td colspan=\"2\" bgcolor=\"$color1\" align=\"right\"><b>".price($totalht)."</b> euros</td></tr>";
       /*
        *
        */
@@ -167,10 +172,12 @@ if ($_GET["propalid"])
       /*
        *
        */
-      print "<tr><td>PDF</a></td>";
-      $file = PROPALE_OUTPUTDIR. "/$obj->ref/$obj->ref.pdf";
+      print "<tr><td>".$langs->trans("Propal")." PDF</a></td>";
+      $file = $conf->propal->dir_output. "/$obj->ref/$obj->ref.pdf";
+      $relativepath = "$obj->ref/$obj->ref.pdf";
+
       if (file_exists($file)) {
-	print '<td colspan="2"><a href="'.PROPALE_OUTPUT_URL.'/'.$obj->ref.'/'.$obj->ref.'.pdf">'.$obj->ref.'.pdf</a></td></tr>';
+	    print '<td colspan="2"><a href="'.DOL_URL_ROOT.'/document.php?type=propal&file='.urlencode($relativepath).'">'.$obj->ref.'.pdf</a></td></tr>';
       }
       print '</tr>';
       /*
@@ -223,7 +230,7 @@ if ($_GET["propalid"])
 	    {
 	      print_titre("Facture associ�e");
 	    }
-	  print '<table class="border" width="100%" cellspacing="0" cellpadding="3">';
+	  print '<table class="border" width="100%">';
 	  print "<tr>";
 	  print '<td>'.$langs->trans("Ref").'</td>';
 	  print '<td>'.$langs->trans("Date").'</td>';
@@ -305,7 +312,7 @@ if ($_GET["propalid"])
        */
       if ($obj->statut <> 4 && $user->societe_id == 0)
 	{  
-	  print '<p><table id="actions" width="100%" cellspacing="4" cellpadding="4"><tr>';
+	  print '<br><table id="actions" width="100%"><tr>';
 	  
 	  if ($obj->statut == 2 && $user->rights->facture->creer)
 	    {
@@ -345,7 +352,7 @@ if ($_GET["propalid"])
      */
     print_titre("Produits");
     
-    print '<table class="noborder" width="100%" cellspacing="0" cellpadding="3">';
+    print '<table class="noborder" width="100%">';
     print "<tr class=\"liste_titre\">";
     print "<td>".$langs->trans("Ref")."</td><td>Produit</td>";
     print '<td align="right">'.$langs->trans("Price").'</td><td align="center">Remise</td><td align="center">Qt�.</td></tr>';
diff --git a/htdocs/expedition/fiche.php b/htdocs/expedition/fiche.php
index 3521e4183c0..8322e739662 100644
--- a/htdocs/expedition/fiche.php
+++ b/htdocs/expedition/fiche.php
@@ -484,16 +484,19 @@ else
 	 * Documents g�n�r�s
 	 *
 	 */
-	$file = FAC_OUTPUTDIR . "/" . $commande->ref . "/" . $commande->ref . ".pdf";
-	
+	$file = $conf->commande->dir_output . "/" . $commande->ref . "/" . $commande->ref . ".pdf";
+	$relativepath = $commande->ref . "/" . $commande->ref . ".pdf";
+
+    $var=true;
+    	
 	if (file_exists($file))
 	  {
 	    print "<table width=\"100%\" cellspacing=2><tr><td width=\"50%\" valign=\"top\">";
 	    print_titre("Documents");
-	    print '<table width="100%" cellspacing="0" class="border" cellpadding="3">';
+	    print '<table width="100%" class="border">';
 	    
-	    print "<tr $bc[0]><td>Commande PDF</td>";
-	    print '<td><a href="'.FAC_OUTPUT_URL."/".$commande->ref."/".$commande->ref.'.pdf">'.$commande->ref.'.pdf</a></td>';
+	    print "<tr $bc[$true]><td>".$langs->trans("Order")." PDF</td>";
+	    print '<td><a href="'.DOL_URL_ROOT.'/document.php?modulepart=commande&file='.urlencode($relativepath).'">'.$commande->ref.'.pdf</a></td>';
 	    print '<td align="right">'.filesize($file). ' bytes</td>';
 	    print '<td align="right">'.strftime("%d %b %Y %H:%M:%S",filemtime($file)).'</td>';
 	    print '</tr>';
@@ -515,8 +518,8 @@ else
 		if ($num)
 		  {
 		    $i = 0; $total = 0;
-		    print '<table border="1" cellspacing="0" cellpadding="4" width="100%">';
-		    print "<tr $bc[$var]><td>Date</td><td>Action</td></tr>\n";
+		    print '<table class="border" width="100%">';
+		    print "<tr $bc[$var]><td>".$langs->trans("Date")."</td><td>".$langs->trans("Action")."</td></tr>\n";
 		    
 		    $var=True;
 		    while ($i < $num)
@@ -524,8 +527,8 @@ else
 			$objp = $db->fetch_object($result);
 			$var=!$var;
 			print "<tr $bc[$var]>";
-			print "<td>".strftime("%d %B %Y",$objp->da)."</TD>\n";
-			print '<td>'.stripslashes($objp->note).'</TD>';
+			print "<td>".strftime("%d %B %Y",$objp->da)."</td>\n";
+			print '<td>'.stripslashes($objp->note).'</td>';
 			print "</tr>";
 			$i++;
 		      }
@@ -534,7 +537,7 @@ else
 	      }
 	    else
 	      {
-		print $db->error();
+		dolibarr_print_error($db);
 	      }
 	    
 	    /*
diff --git a/htdocs/fichinter/fiche.php b/htdocs/fichinter/fiche.php
index 25d59efd99b..08b2f41f3ea 100644
--- a/htdocs/fichinter/fiche.php
+++ b/htdocs/fichinter/fiche.php
@@ -157,7 +157,7 @@ if ($_GET["action"] == 'create')
       
       $smonth = 1;
       $syear = date("Y", time());
-      print '<table class="border" cellpadding="3" cellspacing="0" width="100%">';
+      print '<table class="border" width="100%">';
       
       print '<input type="hidden" name="socidp" value='.$_GET["socidp"].'>';
       print "<tr><td>Soci�t�</td><td><b>".$objsoc->nom."</td></tr>";
@@ -169,7 +169,7 @@ if ($_GET["action"] == 'create')
 	{
 	  if ($day == $cday)
 	    {
-	      print "<option value=\"$day\" SELECTED>$day";
+	      print "<option value=\"$day\" selected>$day";
 	    }
 	  else
 	    {
@@ -371,7 +371,7 @@ if ($_GET["id"])
 	      print '<a class="tabAction" href="fiche.php?id='.$_GET["id"].'&action=edit">'.$langs->trans("Edit").'</a>';
 	    }
 	  	  
-	  $file = FICHEINTER_OUTPUTDIR . "/$fichinter->ref/$fichinter->ref.pdf";
+	  $file = $conf->ficheinter->dir_output . "/$fichinter->ref/$fichinter->ref.pdf";
 	  if ($fichinter->statut == 0 or !file_exists($file))
 	    {
 	      print '<a class="tabAction" href="fiche.php?id='.$_GET["id"].'&action=generate">'.$langs->trans("BuildPDF").'</a>';
@@ -389,13 +389,17 @@ if ($_GET["id"])
   
       print '<table width="50%" cellspacing="2"><tr><td width="50%" valign="top">';
       print_titre("Documents g�n�r�s");
-      print '<table width="100%" cellspacing="0" class="border" cellpadding="3">';
+      print '<table width="100%" class="border">';
+      
+      $file = $conf->ficheinter->dir_output . "/$fichinter->ref/$fichinter->ref.pdf";
+      $relativepath="$fichinter->ref/$fichinter->ref.pdf";
       
-      $file = FICHEINTER_OUTPUTDIR . "/$fichinter->ref/$fichinter->ref.pdf";
+      $var=true;
+
       if (file_exists($file))
 	{
 	  print "<tr $bc[0]><td>Ficheinter PDF</a></td>";
-	  print '<td><a href="'.FICHEINTER_OUTPUT_URL.'/'.$fichinter->ref.'/'.$fichinter->ref.'.pdf">'.$fichinter->ref.'.pdf</a></td>';
+	  print '<td><a href="'.DOL_URL_ROOT.'/document.php?modulepart=ficheinter&file='.urlencode($relativepath).'">'.$fichinter->ref.'.pdf</a></td>';
 	  print '<td align="right">'.filesize($file). ' bytes</td>';
 	  print '<td align="right">'.strftime("%d %b %Y %H:%M:%S",filemtime($file)).'</td></tr>';
 	}  
diff --git a/htdocs/fourn/commande/fiche.php b/htdocs/fourn/commande/fiche.php
index ea998d49ad6..c4f5f1d4504 100644
--- a/htdocs/fourn/commande/fiche.php
+++ b/htdocs/fourn/commande/fiche.php
@@ -616,7 +616,7 @@ if ($id > 0)
 	}
       else
 	{
-	  print $db->error();
+	  dolibarr_print_error($db);
 	}
       print "&nbsp;</td></tr></table>";
 
@@ -624,15 +624,18 @@ if ($id > 0)
        * Documents g�n�r�s
        *
        */
-      $file = FAC_OUTPUTDIR . "/" . $commande->ref . "/" . $commande->ref . ".pdf";
-	
+      $file = $conf->commande->dir_output . "/" . $commande->ref . "/" . $commande->ref . ".pdf";
+	  $relativepath=$commande->ref . "/" . $commande->ref . ".pdf";
+	  
+	  $var=true;
+	  
       if (file_exists($file))
 	{
 	  print_titre("Documents");
 	  print '<table width="100%" class="border">';
 	    
-	  print "<tr $bc[0]><td>Commande PDF</td>";
-	  print '<td><a href="'.FAC_OUTPUT_URL."/".$commande->ref."/".$commande->ref.'.pdf">'.$commande->ref.'.pdf</a></td>';
+	  print "<tr $bc[$var]><td>".$langs->trans("Order")." PDF</td>";
+	  print '<td><a href="'.DOL_URL_ROOT.'/document.php?modulepart=commande&file='.urlencode($relativepath).'">'.$commande->ref.'.pdf</a></td>';
 	  print '<td align="right">'.filesize($file). ' bytes</td>';
 	  print '<td align="right">'.strftime("%d %b %Y %H:%M:%S",filemtime($file)).'</td>';
 	  print '</tr>';
diff --git a/htdocs/includes/modules/fichinter/pdf_soleil.modules.php b/htdocs/includes/modules/fichinter/pdf_soleil.modules.php
index 5e9d2dee98a..f68e525fed5 100644
--- a/htdocs/includes/modules/fichinter/pdf_soleil.modules.php
+++ b/htdocs/includes/modules/fichinter/pdf_soleil.modules.php
@@ -54,18 +54,14 @@ class pdf_soleil extends ModelePDFFicheinter
       $fich = new Fichinter($this->db,"",$id);
       if ($fich->fetch($id))
 	{
-	  if (defined("FICHEINTER_OUTPUTDIR"))
-	    {
-
-	      $dir = FICHEINTER_OUTPUTDIR . "/" . $fich->ref . "/" ;
-	      $file = $dir . $fich->ref . ".pdf";
+      $dir = $conf->ficheinter->dir_output . "/" . $fich->ref . "/" ;
+      $file = $dir . $fich->ref . ".pdf";
 	      
-	      if (! file_exists($dir))
+	  if (! file_exists($dir))
 		{
 		  umask(0);
 		  mkdir($dir, 0755);
 		}
-	    }
 	  
 	  if (file_exists($dir))
 	    {
-- 
GitLab