diff --git a/htdocs/compta/paiement/rapport.php b/htdocs/compta/paiement/rapport.php
index 21879d8d6ab..c71d1a7d26d 100644
--- a/htdocs/compta/paiement/rapport.php
+++ b/htdocs/compta/paiement/rapport.php
@@ -20,6 +20,13 @@
* $Source$
*
*/
+
+/** \file htdocs/compta/paiement/fiche.php
+ \ingroup facture
+ \brief Onglet paiement d'un paiement
+ \version $Revision$
+*/
+
require("./pre.inc.php");
@@ -35,8 +42,12 @@ $year = $_GET["year"];
require("../../includes/modules/rapport/pdf_paiement.class.php");
-$dir = DOL_DOCUMENT_ROOT."/document/rapport/";
+$dir = $conf->compta->dir_output;
+
+/*
+ * Action générer fichier rapport paiements
+ */
if ($_POST["action"] == 'gen')
{
$rap = new pdf_paiement($db);
@@ -49,10 +60,10 @@ llxHeader();
/*
- *
+ * Affichage liste des paiements
*
*/
-print_titre("Rapport paiements (EN COURS DE DEVELOPPEMENT)");
+print_titre("Rapport paiements");
print '
';
clearstatcache();
@@ -118,15 +129,18 @@ while (($file = readdir($handle))!==false)
if ($year)
{
$handle=opendir($dir.'/'.$year);
-
- print '';
- print '| Rapport | Taille | Date de génération |
';
+ print '
';
+ print '';
+ print '| Rapport | '.$langs->trans("Size").' | '.$langs->trans("Date").' |
';
+ $var=true;
while (($file = readdir($handle))!==false)
{
if (substr($file, 0, 8) == 'paiement')
{
+ $var=!$var;
$tfile = $dir . '/'.$year.'/'.$file;
- print '| '.$file.' | ';
+ $relativepath = $year.'/'.$file;
+ print "
".'| '.img_pdf().' '.$file.' | ';
print ''.filesize($tfile). ' bytes | ';
print ''.strftime("%d %b %Y %H:%M:%S",filemtime($tfile)).' |
';
}
diff --git a/htdocs/document.php b/htdocs/document.php
index 422a5cf356a..940b7a3a83f 100644
--- a/htdocs/document.php
+++ b/htdocs/document.php
@@ -1,5 +1,6 @@
+ * Copyright (C) 2004 Laurent Destailleur
*
* 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
@@ -21,22 +22,69 @@
*
*/
+/**
+ \file htdocs/document.php
+ \brief Wrapper permettant le téléchargement de fichier de données Dolibarr
+ L'appel ancienne méthode (non sécurisée) est document.php?file=pathcompletdufichier
+ L'appel nouvelle méthode (sécurisée) est document.php?file=pathrelatifdufichier&type=typefichier
+ \version $Revision$
+*/
+
+
+require_once("main.inc.php");
+
+
+// C'est un wrapper, donc header vierge
+function llxHeader() { }
+
+
$original_file = urldecode($_GET["file"]);
+$modulepart = urldecode($_GET["modulepart"]);
+$type = urldecode($_GET["type"]);
-$filename = basename ($original_file);
-
-if ($_GET["type"])
+$accessallowed=0;
+if ($modulepart)
{
- header('Content-type: '.$_GET["type"]);
+ // On fait une vérification des droits et on définit le répertoire concerné
+ if ($modulepart == 'facture_paiement')
+ {
+ $user->getrights('facture');
+ if ($user->rights->facture->lire)
+ {
+ $accessallowed=1;
+ }
+ $original_file=$conf->compta->dir_output.'/'.$original_file;
+ }
+}
+else
+{
+ // A terme, on ne doit rien pouvoir télécharger via document.php sans fournir type
+ // car c'est grace au type qu'on vérifie que les droits et qu'on définit le répertoire racine des fichiers
+
+ // \todo Corriger ce trou de sécurité pour ne plus permettre l'utilisation via un nom de fichier complet et sans test de droits
+
+ // Pour l'instant, autorise la passage
+ $accessallowed=1;
+}
+
+// Limite accès si droits non corrects
+if (! $accessallowed) { accessforbidden(); }
+
+$filename = basename($original_file);
+if (! file_exists($original_file)) { dolibarr_print_error(0,$langs->trans("FileDoesNotExist",$original_file)); exit; }
+
+// Les drois sont ok et fichier trouvé
+if ($type)
+{
+ header('Content-type: '.$type);
}
else
{
header('Content-type: application/pdf');
}
-
header('Content-Disposition: attachment; filename="'.$filename.'"');
-// The PDF source is in original.pdf
readfile($original_file);
+
?>
diff --git a/htdocs/master.inc.php b/htdocs/master.inc.php
index 721cd33d4dd..cbacc60afbf 100644
--- a/htdocs/master.inc.php
+++ b/htdocs/master.inc.php
@@ -196,6 +196,9 @@ if (defined("MAIN_MODULE_COMMERCIAL"))
if (defined("MAIN_MODULE_COMPTABILITE"))
{
$conf->compta->enabled=MAIN_MODULE_COMPTABILITE;
+ $conf->compta->dir_output=DOL_DATA_ROOT."/rapport";
+ $conf->compta->dir_images=DOL_DOCUMENT_ROOT."/images/rapport";
+ $conf->compta->url_images=DOL_URL_ROOT."/images/rapport";
}
if (defined("MAIN_MODULE_BANQUE"))
{