[ Index ] |
|
Code source de Dolibarr 2.0.1 |
1 <?php 2 /* Copyright (C) 2004-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> 3 * Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net> 4 * Copyright (C) 2005 Simon Tosser <simon@kornog-computing.com> 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 * or see http://www.gnu.org/ 20 * 21 * $Id: document.php,v 1.19 2005/11/11 22:36:56 eldy Exp $ 22 * $Source: /cvsroot/dolibarr/dolibarr/htdocs/document.php,v $ 23 */ 24 25 /** 26 \file htdocs/document.php 27 \brief Wrapper permettant le téléchargement de fichier de données Dolibarr 28 \remarks L'appel est document.php?file=pathrelatifdufichier&modulepart=repfichierconcerne 29 \version $Revision: 1.19 $ 30 */ 31 32 require_once ("main.inc.php"); 33 34 35 // C'est un wrapper, donc header vierge 36 function llxHeader() { } 37 38 39 $original_file = urldecode($_GET["file"]); 40 $modulepart = urldecode($_GET["modulepart"]); 41 // Défini type et attachment 42 $type = urldecode($_GET["type"]); $attachment = true; 43 if (eregi('\.html',$original_file)) { $type='text/html'; $attachment = false; } 44 if (eregi('\.pdf',$original_file)) { $type='application/pdf'; $attachment = true; } 45 46 //Suppression de la chaine de caractère ../ dans $original_file 47 $original_file = str_replace("../","/", "$original_file"); 48 49 $accessallowed=0; 50 if ($modulepart) 51 { 52 // On fait une vérification des droits et on définit le répertoire concern 53 54 // Wrapping pour les factures 55 if ($modulepart == 'facture') 56 { 57 $user->getrights('facture'); 58 if ($user->rights->facture->lire) 59 { 60 $accessallowed=1; 61 } 62 $original_file=$conf->facture->dir_output.'/'.$original_file; 63 } 64 65 // Wrapping pour les fiches intervention 66 if ($modulepart == 'ficheinter') 67 { 68 $user->getrights('ficheinter'); 69 if ($user->rights->ficheinter->lire) 70 { 71 $accessallowed=1; 72 } 73 $original_file=$conf->fichinter->dir_output.'/'.$original_file; 74 } 75 76 // Wrapping pour les prelevements 77 if ($modulepart == 'prelevement') 78 { 79 $user->getrights('prelevement'); 80 if ($user->rights->prelevement->bons->lire) 81 { 82 $accessallowed=1; 83 } 84 $original_file=$conf->prelevement->dir_output.'/'.$original_file; 85 } 86 87 // Wrapping pour les propales 88 if ($modulepart == 'propal') 89 { 90 $user->getrights('propale'); 91 if ($user->rights->propale->lire) 92 { 93 $accessallowed=1; 94 } 95 $original_file=$conf->propal->dir_output.'/'.$original_file; 96 } 97 98 // Wrapping pour les rapport de paiements 99 if ($modulepart == 'facture_paiement') 100 { 101 $user->getrights('facture'); 102 if ($user->rights->facture->lire) 103 { 104 $accessallowed=1; 105 } 106 $original_file=$conf->compta->dir_output.'/'.$original_file; 107 } 108 109 // Wrapping pour les exports de compta 110 if ($modulepart == 'export_compta') 111 { 112 $user->getrights('compta'); 113 if ($user->rights->compta->ventilation->creer) 114 { 115 $accessallowed=1; 116 } 117 $original_file=$conf->compta->dir_output.'/'.$original_file; 118 } 119 120 // Wrapping pour les societe 121 if ($modulepart == 'societe') 122 { 123 $user->getrights('societe'); 124 if ($user->rights->societe->lire) 125 { 126 $accessallowed=1; 127 } 128 $original_file=$conf->societe->dir_output.'/'.$original_file; 129 } 130 131 // Wrapping pour les expedition 132 if ($modulepart == 'expedition') 133 { 134 $user->getrights('expedition'); 135 if ($user->rights->expedition->lire) 136 { 137 $accessallowed=1; 138 } 139 $original_file=$conf->expedition->dir_output.'/'.$original_file; 140 } 141 142 // Wrapping pour la telephonie 143 if ($modulepart == 'telephonie') 144 { 145 $user->getrights('telephonie'); 146 if ($user->rights->telephonie->lire) 147 { 148 $accessallowed=1; 149 } 150 $original_file=$conf->telephonie->dir_output.'/'.$original_file; 151 } 152 153 154 // Wrapping pour la telephonie 155 if ($modulepart == 'actionscomm') 156 { 157 $user->getrights('commercial'); 158 //if ($user->rights->commercial->lire) // Ce droit n'existe pas encore 159 //{ 160 $accessallowed=1; 161 //} 162 $original_file=$conf->commercial->dir_output.'/'.$original_file; 163 } 164 165 // Wrapping pour les produits et services 166 if ($modulepart == 'produit') 167 { 168 $user->getrights('produit'); 169 //if ($user->rights->commercial->lire) // Ce droit n'existe pas encore 170 //{ 171 $accessallowed=1; 172 //} 173 $original_file=$conf->produit->dir_output.'/'.$original_file; 174 } 175 176 // Wrapping pour les factures 177 if ($modulepart == 'don') 178 { 179 $user->getrights('don'); 180 if ($user->rights->don->lire) 181 { 182 $accessallowed=1; 183 } 184 $original_file=$conf->don->dir_output.'/'.$original_file; 185 } 186 187 } 188 189 // Limite accès si droits non corrects 190 if (! $accessallowed) 191 { 192 accessforbidden(); 193 } 194 195 196 // Ouvre et renvoi fichier 197 clearstatcache(); 198 199 $filename = basename($original_file); 200 201 if (! file_exists($original_file)) 202 { 203 dolibarr_print_error(0,$langs->trans("FileDoesNotExist",$original_file)); 204 exit; 205 } 206 207 208 // Les drois sont ok et fichier trouvé, on l'envoie 209 dolibarr_syslog("document.php download $filename content-type=$type"); 210 211 if ($type) header('Content-type: '.$type); 212 if ($attachment) header('Content-Disposition: attachment; filename="'.$filename.'"'); 213 214 // Ajout directives pour résoudre bug IE 215 header('Cache-Control: Public, must-revalidate'); 216 header('Pragma: public'); 217 218 readfile($original_file); 219 220 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Mon Nov 26 12:29:37 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |