2004-10-20 23:06:45 +02:00
|
|
|
|
<?php
|
2005-02-08 13:03:12 +01:00
|
|
|
|
/* Copyright (C) 2004-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
2004-12-28 16:02:48 +01:00
|
|
|
|
* Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.net>
|
2005-08-24 22:29:41 +02:00
|
|
|
|
* Copyright (C) 2005 Simon Tosser <simon@kornog-computing.com>
|
2004-07-12 11:46:13 +02:00
|
|
|
|
*
|
|
|
|
|
|
* 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
|
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
|
*
|
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
|
*
|
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
|
|
* or see http://www.gnu.org/
|
|
|
|
|
|
*
|
|
|
|
|
|
* $Id$
|
|
|
|
|
|
* $Source$
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
2005-02-08 13:03:12 +01:00
|
|
|
|
/**
|
|
|
|
|
|
\file htdocs/document.php
|
|
|
|
|
|
\brief Wrapper permettant le t<EFBFBD>l<EFBFBD>chargement de fichier de donn<EFBFBD>es Dolibarr
|
|
|
|
|
|
\remarks L'appel est document.php?file=pathrelatifdufichier&modulepart=repfichierconcerne
|
|
|
|
|
|
\version $Revision$
|
2004-12-28 16:02:48 +01:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
require_once("main.inc.php");
|
|
|
|
|
|
|
|
|
|
|
|
// C'est un wrapper, donc header vierge
|
|
|
|
|
|
function llxHeader() { }
|
|
|
|
|
|
|
2004-07-12 11:46:13 +02:00
|
|
|
|
$original_file = urldecode($_GET["file"]);
|
2004-12-28 16:02:48 +01:00
|
|
|
|
$modulepart = urldecode($_GET["modulepart"]);
|
|
|
|
|
|
$type = urldecode($_GET["type"]);
|
2004-07-12 11:46:13 +02:00
|
|
|
|
|
2005-08-25 12:20:13 +02:00
|
|
|
|
//Suppression de la chaine de caract<63>re ../ dans $original_file
|
|
|
|
|
|
$original_file = str_replace("../","/", "$original_file");
|
|
|
|
|
|
|
2004-12-28 16:02:48 +01:00
|
|
|
|
$accessallowed=0;
|
|
|
|
|
|
if ($modulepart)
|
|
|
|
|
|
{
|
2005-02-08 13:03:12 +01:00
|
|
|
|
// On fait une v<>rification des droits et on d<>finit le r<>pertoire concern<72>
|
|
|
|
|
|
|
|
|
|
|
|
// Wrapping pour les factures
|
|
|
|
|
|
if ($modulepart == 'facture')
|
2004-12-28 16:02:48 +01:00
|
|
|
|
{
|
2005-02-08 13:03:12 +01:00
|
|
|
|
$user->getrights('facture');
|
|
|
|
|
|
if ($user->rights->facture->lire)
|
2004-12-28 16:02:48 +01:00
|
|
|
|
{
|
2005-02-08 13:03:12 +01:00
|
|
|
|
$accessallowed=1;
|
2004-12-28 16:02:48 +01:00
|
|
|
|
}
|
2005-02-08 13:03:12 +01:00
|
|
|
|
$original_file=$conf->facture->dir_output.'/'.$original_file;
|
2004-12-28 16:02:48 +01:00
|
|
|
|
}
|
2005-02-08 13:03:12 +01:00
|
|
|
|
|
|
|
|
|
|
// Wrapping pour les fiches intervention
|
|
|
|
|
|
if ($modulepart == 'ficheinter')
|
2004-12-31 18:03:56 +01:00
|
|
|
|
{
|
2005-02-08 13:03:12 +01:00
|
|
|
|
$user->getrights('ficheinter');
|
|
|
|
|
|
if ($user->rights->ficheinter->lire)
|
2004-12-31 18:03:56 +01:00
|
|
|
|
{
|
2005-02-08 13:03:12 +01:00
|
|
|
|
$accessallowed=1;
|
2004-12-31 18:03:56 +01:00
|
|
|
|
}
|
2005-04-01 17:07:30 +02:00
|
|
|
|
$original_file=$conf->fichinter->dir_output.'/'.$original_file;
|
2004-12-31 18:03:56 +01:00
|
|
|
|
}
|
2005-02-08 13:03:12 +01:00
|
|
|
|
|
|
|
|
|
|
// Wrapping pour les prelevements
|
|
|
|
|
|
if ($modulepart == 'prelevement')
|
2004-12-31 18:03:56 +01:00
|
|
|
|
{
|
2005-02-08 13:03:12 +01:00
|
|
|
|
$user->getrights('prelevement');
|
2005-07-25 15:23:42 +02:00
|
|
|
|
if ($user->rights->prelevement->bons->lire)
|
2004-12-31 18:03:56 +01:00
|
|
|
|
{
|
2005-02-08 13:03:12 +01:00
|
|
|
|
$accessallowed=1;
|
2004-12-31 18:03:56 +01:00
|
|
|
|
}
|
2005-02-09 20:37:21 +01:00
|
|
|
|
$original_file=$conf->prelevement->dir_output.'/'.$original_file;
|
2004-12-31 18:03:56 +01:00
|
|
|
|
}
|
2005-02-08 13:03:12 +01:00
|
|
|
|
|
|
|
|
|
|
// Wrapping pour les propales
|
|
|
|
|
|
if ($modulepart == 'propal')
|
2004-12-31 18:03:56 +01:00
|
|
|
|
{
|
2005-02-08 13:03:12 +01:00
|
|
|
|
$user->getrights('propale');
|
|
|
|
|
|
if ($user->rights->propale->lire)
|
2004-12-31 18:03:56 +01:00
|
|
|
|
{
|
2005-02-08 13:03:12 +01:00
|
|
|
|
$accessallowed=1;
|
2004-12-31 18:03:56 +01:00
|
|
|
|
}
|
2005-02-08 13:03:12 +01:00
|
|
|
|
$original_file=$conf->propal->dir_output.'/'.$original_file;
|
2004-12-31 18:03:56 +01:00
|
|
|
|
}
|
2005-02-08 13:03:12 +01:00
|
|
|
|
|
|
|
|
|
|
// Wrapping pour les rapport de paiements
|
|
|
|
|
|
if ($modulepart == 'facture_paiement')
|
2004-12-28 16:49:54 +01:00
|
|
|
|
{
|
2005-02-08 13:03:12 +01:00
|
|
|
|
$user->getrights('facture');
|
|
|
|
|
|
if ($user->rights->facture->lire)
|
2004-12-28 16:49:54 +01:00
|
|
|
|
{
|
2005-02-08 13:03:12 +01:00
|
|
|
|
$accessallowed=1;
|
2004-12-28 16:49:54 +01:00
|
|
|
|
}
|
2005-02-08 13:03:12 +01:00
|
|
|
|
$original_file=$conf->compta->dir_output.'/'.$original_file;
|
2004-12-31 18:03:56 +01:00
|
|
|
|
}
|
2005-02-08 13:03:12 +01:00
|
|
|
|
|
|
|
|
|
|
// Wrapping pour les societe
|
|
|
|
|
|
if ($modulepart == 'societe')
|
2004-12-31 18:03:56 +01:00
|
|
|
|
{
|
2005-02-08 13:03:12 +01:00
|
|
|
|
$user->getrights('societe');
|
|
|
|
|
|
if ($user->rights->societe->lire)
|
2004-12-31 18:03:56 +01:00
|
|
|
|
{
|
2005-02-08 13:03:12 +01:00
|
|
|
|
$accessallowed=1;
|
2004-12-31 18:03:56 +01:00
|
|
|
|
}
|
2005-02-08 13:03:12 +01:00
|
|
|
|
$original_file=$conf->societe->dir_output.'/'.$original_file;
|
2004-12-31 18:03:56 +01:00
|
|
|
|
}
|
2005-02-08 13:03:12 +01:00
|
|
|
|
|
2005-04-17 17:41:28 +02:00
|
|
|
|
// Wrapping pour les expedition
|
|
|
|
|
|
if ($modulepart == 'expedition')
|
|
|
|
|
|
{
|
|
|
|
|
|
$user->getrights('expedition');
|
|
|
|
|
|
if ($user->rights->expedition->lire)
|
|
|
|
|
|
{
|
|
|
|
|
|
$accessallowed=1;
|
|
|
|
|
|
}
|
|
|
|
|
|
$original_file=$conf->expedition->dir_output.'/'.$original_file;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2005-02-08 13:03:12 +01:00
|
|
|
|
// Wrapping pour la telephonie
|
|
|
|
|
|
if ($modulepart == 'telephonie')
|
2004-12-31 18:03:56 +01:00
|
|
|
|
{
|
2005-02-08 13:03:12 +01:00
|
|
|
|
$user->getrights('telephonie');
|
|
|
|
|
|
if ($user->rights->telephonie->lire)
|
2004-12-31 18:03:56 +01:00
|
|
|
|
{
|
2005-02-08 13:03:12 +01:00
|
|
|
|
$accessallowed=1;
|
2004-12-31 18:03:56 +01:00
|
|
|
|
}
|
2005-02-08 13:03:12 +01:00
|
|
|
|
$original_file=$conf->telephonie->dir_output.'/'.$original_file;
|
2004-12-28 16:49:54 +01:00
|
|
|
|
}
|
2005-02-08 13:03:12 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Wrapping pour la telephonie
|
|
|
|
|
|
if ($modulepart == 'actionscomm')
|
2005-01-09 02:46:34 +01:00
|
|
|
|
{
|
2005-02-08 13:03:12 +01:00
|
|
|
|
$user->getrights('commercial');
|
|
|
|
|
|
//if ($user->rights->commercial->lire) // Ce droit n'existe pas encore
|
|
|
|
|
|
//{
|
|
|
|
|
|
$accessallowed=1;
|
|
|
|
|
|
//}
|
|
|
|
|
|
$original_file=$conf->commercial->dir_output.'/'.$original_file;
|
2005-01-09 02:46:34 +01:00
|
|
|
|
}
|
2005-08-24 22:29:41 +02:00
|
|
|
|
|
|
|
|
|
|
// Wrapping pour les produits et services
|
|
|
|
|
|
if ($modulepart == 'produit')
|
|
|
|
|
|
{
|
|
|
|
|
|
$user->getrights('produit');
|
|
|
|
|
|
//if ($user->rights->commercial->lire) // Ce droit n'existe pas encore
|
|
|
|
|
|
//{
|
|
|
|
|
|
$accessallowed=1;
|
|
|
|
|
|
//}
|
|
|
|
|
|
$original_file=$conf->produit->dir_output.'/'.$original_file;
|
|
|
|
|
|
}
|
2005-02-08 13:03:12 +01:00
|
|
|
|
|
2004-12-28 16:02:48 +01:00
|
|
|
|
}
|
2004-07-12 11:46:13 +02:00
|
|
|
|
|
2004-12-28 16:02:48 +01:00
|
|
|
|
// Limite acc<63>s si droits non corrects
|
2005-02-08 13:03:12 +01:00
|
|
|
|
if (! $accessallowed)
|
|
|
|
|
|
{
|
|
|
|
|
|
accessforbidden();
|
|
|
|
|
|
}
|
2004-12-28 16:02:48 +01:00
|
|
|
|
|
|
|
|
|
|
$filename = basename($original_file);
|
2005-02-08 13:03:12 +01:00
|
|
|
|
|
|
|
|
|
|
if (! file_exists($original_file))
|
|
|
|
|
|
{
|
|
|
|
|
|
dolibarr_print_error(0,$langs->trans("FileDoesNotExist",$original_file));
|
|
|
|
|
|
exit;
|
|
|
|
|
|
}
|
2004-12-28 16:02:48 +01:00
|
|
|
|
|
|
|
|
|
|
// Les drois sont ok et fichier trouv<75>
|
|
|
|
|
|
if ($type)
|
2004-09-22 11:03:24 +02:00
|
|
|
|
{
|
2004-12-28 16:02:48 +01:00
|
|
|
|
header('Content-type: '.$type);
|
2004-09-22 11:03:24 +02:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
header('Content-type: application/pdf');
|
|
|
|
|
|
}
|
2004-07-12 11:46:13 +02:00
|
|
|
|
header('Content-Disposition: attachment; filename="'.$filename.'"');
|
|
|
|
|
|
|
|
|
|
|
|
readfile($original_file);
|
|
|
|
|
|
|
|
|
|
|
|
?>
|