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 '
'; print ''; @@ -100,7 +111,7 @@ for ($formyear = $syear - 2; $formyear < $syear +1 ; $formyear++) } } print "\n"; -print ''; +print ''; print '
'; clearstatcache(); @@ -118,15 +129,18 @@ while (($file = readdir($handle))!==false) if ($year) { $handle=opendir($dir.'/'.$year); - - print ''; - print ''; + print '
'; + print '
RapportTailleDate de génération
'; + print ''; + $var=true; while (($file = readdir($handle))!==false) { if (substr($file, 0, 8) == 'paiement') { + $var=!$var; $tfile = $dir . '/'.$year.'/'.$file; - print ''; + $relativepath = $year.'/'.$file; + print "".''; print ''; print ''; } 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")) {
Rapport'.$langs->trans("Size").''.$langs->trans("Date").'
'.$file.'
'.img_pdf().' '.$file.''.filesize($tfile). ' bytes'.strftime("%d %b %Y %H:%M:%S",filemtime($tfile)).'