[ Index ]
 

Code source de Dolibarr 2.0.1

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/htdocs/ -> viewimage.php (source)

   1  <?php
   2  /* Copyright (C) 2004-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
   3   * Copyright (C) 2005 Laurent Destailleur  <eldy@users.sourceforge.net>
   4   *
   5   * This program is free software; you can redistribute it and/or modify
   6   * it under the terms of the GNU General Public License as published by
   7   * the Free Software Foundation; either version 2 of the License, or
   8   * (at your option) any later version.
   9   *
  10   * This program is distributed in the hope that it will be useful,
  11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13   * GNU General Public License for more details.
  14   *
  15   * You should have received a copy of the GNU General Public License
  16   * along with this program; if not, write to the Free Software
  17   * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  18   * or see http://www.gnu.org/
  19   *
  20   * $Id: viewimage.php,v 1.14 2005/09/17 00:14:36 eldy Exp $
  21   * $Source: /cvsroot/dolibarr/dolibarr/htdocs/viewimage.php,v $
  22   *
  23   */
  24  
  25  /**     \file       htdocs/viewimage.php
  26          \brief      Wrapper permettant l'affichage de fichiers images Dolibarr
  27          \remarks    L'appel est viewimage.php?file=pathrelatifdufichier&modulepart=repfichierconcerne
  28          \version    $Revision: 1.14 $
  29  */
  30  
  31  require_once ("main.inc.php");
  32  
  33  
  34  // C'est un wrapper, donc header vierge
  35  function llxHeader() { }
  36  
  37  
  38  
  39  $original_file = urldecode($_GET["file"]);
  40  $modulepart = urldecode($_GET["modulepart"]);
  41  $type = urldecode($_GET["type"]);
  42  
  43  $filename = basename ($original_file);
  44  
  45  
  46  $accessallowed=0;
  47  if ($modulepart)
  48  {
  49      // On fait une vérification des droits et on définit le répertoire concerné
  50  
  51      // Wrapping pour les photo utilisateurs
  52      if ($modulepart == 'userphoto')
  53      {
  54          //$user->getrights('facture');
  55          //if ($user->rights->facture->lire)
  56          //{
  57              $accessallowed=1;
  58          //}
  59          $original_file=$conf->users->dir_output.'/'.$original_file;
  60      }
  61      
  62      // Wrapping pour les apercu factures
  63      if ($modulepart == 'apercufacture')
  64      {
  65          $user->getrights('facture');
  66          if ($user->rights->facture->lire)
  67          {
  68              $accessallowed=1;
  69          }
  70          $original_file=$conf->facture->dir_output.'/'.$original_file;
  71      }
  72  
  73      // Wrapping pour les apercu propal
  74      if ($modulepart == 'apercupropal')
  75      {
  76          $user->getrights('propale');
  77          if ($user->rights->propale->lire)
  78          {
  79              $accessallowed=1;
  80          }
  81          $original_file=$conf->propal->dir_output.'/'.$original_file;
  82      }
  83  
  84      // Wrapping pour les images des stats propales
  85      if ($modulepart == 'propalstats')
  86      {
  87          $user->getrights('propale');
  88          if ($user->rights->propale->lire)
  89          {
  90              $accessallowed=1;
  91          }
  92          $original_file=$conf->propal->dir_images.'/'.$original_file;
  93      }
  94  
  95      // Wrapping pour les images des stats commandes
  96      if ($modulepart == 'orderstats')
  97      {
  98          $user->getrights('commande');
  99          if ($user->rights->commande->lire)
 100          {
 101              $accessallowed=1;
 102          }
 103          $original_file=$conf->commande->dir_images.'/'.$original_file;
 104      }
 105  
 106      // Wrapping pour les images des stats commandes
 107      if ($modulepart == 'billstats')
 108      {
 109          $user->getrights('facture');
 110          if ($user->rights->facture->lire)
 111          {
 112              $accessallowed=1;
 113          }
 114          $original_file=$conf->facture->dir_images.'/'.$original_file;
 115      }
 116  
 117      // Wrapping pour les images des stats expeditions
 118      if ($modulepart == 'expeditionstats')
 119      {
 120          $user->getrights('expedition');
 121          if ($user->rights->expedition->lire)
 122          {
 123              $accessallowed=1;
 124          }
 125          $original_file=$conf->expedition->dir_images.'/'.$original_file;
 126      }
 127  
 128      // Wrapping pour les images des stats produits
 129      if ($modulepart == 'productstats')
 130      {
 131          $user->getrights('produit');
 132          if ($user->rights->produit->lire)
 133          {
 134              $accessallowed=1;
 135          }
 136          $original_file=$conf->produit->dir_images.'/'.$original_file;
 137      }
 138  
 139      // Wrapping pour les produits
 140      if ($modulepart == 'product')
 141      {
 142          $user->getrights('produit');
 143          if ($user->rights->produit->lire)
 144          {
 145              $accessallowed=1;
 146          }
 147          $original_file=$conf->produit->dir_output.'/'.$original_file;
 148      }
 149  
 150      // Wrapping pour les prelevement
 151      if ($modulepart == 'prelevement')
 152      {
 153          $user->getrights('prelevement');
 154          if ($user->rights->prelevement->bons->lire) $accessallowed=1;
 155  
 156          $original_file=$conf->prelevement->dir_output.'/bon/'.$original_file;
 157      }
 158  
 159      // Wrapping pour les graph telephonie
 160      if ($modulepart == 'telephoniegraph')
 161      {
 162          $user->getrights('telephonie');
 163          if ($user->rights->telephonie->lire)
 164          {
 165              $accessallowed=1;
 166          }
 167          $original_file=DOL_DATA_ROOT.'/graph/telephonie/'.$original_file;
 168      }
 169  
 170      // Wrapping pour les graph energie
 171      if ($modulepart == 'energie')
 172      {
 173        $accessallowed=1;
 174        $original_file=DOL_DATA_ROOT.'/energie/graph/'.$original_file;
 175      }
 176  
 177      // Wrapping pour les graph bank
 178      if ($modulepart == 'bank')
 179      {
 180        $accessallowed=1;
 181        $original_file=$conf->banque->dir_images.'/'.$original_file;
 182      }
 183  }
 184  
 185  // Limite accès si droits non corrects
 186  if (! $accessallowed) { accessforbidden(); }
 187  
 188  
 189  $filename = basename($original_file);
 190  if (! file_exists($original_file)) { dolibarr_print_error(0,$langs->trans("FileDoesNotExist",$original_file)); exit; }
 191  
 192  // Les drois sont ok et fichier trouvé
 193  if ($type)
 194  {
 195    header('Content-type: '.$type);
 196  }
 197  else
 198  {
 199    header('Content-type: image/png');
 200  }
 201  
 202  readfile($original_file);
 203  
 204  ?>


Généré le : Mon Nov 26 12:29:37 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics