[ Index ]
 

Code source de Dotclear 2.0-beta6

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/inc/ -> load_plugin_file.php (source)

   1  <?php
   2  # ***** BEGIN LICENSE BLOCK *****
   3  # This file is part of DotClear.
   4  # Copyright (c) 2005 Olivier Meunier and contributors. All rights
   5  # reserved.
   6  #
   7  # DotClear is free software; you can redistribute it and/or modify
   8  # it under the terms of the GNU General Public License as published by
   9  # the Free Software Foundation; either version 2 of the License, or
  10  # (at your option) any later version.
  11  # 
  12  # DotClear is distributed in the hope that it will be useful,
  13  # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15  # GNU General Public License for more details.
  16  # 
  17  # You should have received a copy of the GNU General Public License
  18  # along with DotClear; if not, write to the Free Software
  19  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  20  #
  21  # ***** END LICENSE BLOCK *****
  22  
  23  if (isset($_SERVER['DC_RC_PATH'])) {
  24      define('DC_RC_PATH',$_SERVER['DC_RC_PATH']);
  25  } elseif (isset($_SERVER['REDIRECT_DC_RC_PATH'])) {
  26      define('DC_RC_PATH',$_SERVER['REDIRECT_DC_RC_PATH']);
  27  } else {
  28      define('DC_RC_PATH',dirname(__FILE__).'/config.php');
  29  }
  30  
  31  if (!is_file(DC_RC_PATH)) {
  32      trigger_error('Unable to open config file',E_USER_ERROR);
  33      exit;
  34  }
  35  
  36  require DC_RC_PATH;
  37  
  38  #  ClearBricks and DotClear classes auto-loader
  39  if (@is_dir('/usr/lib/clearbricks')) {
  40      define('CLEARBRICKS_PATH','/usr/lib/clearbricks');
  41  } elseif (is_dir(dirname(__FILE__).'/clearbricks')) {
  42      define('CLEARBRICKS_PATH',dirname(__FILE__).'/clearbricks');
  43  } elseif (isset($_SERVER['CLEARBRICKS_PATH']) && is_dir($_SERVER['CLEARBRICKS_PATH'])) {
  44      define('CLEARBRICKS_PATH',$_SERVER['CLEARBRICKS_PATH']);
  45  }
  46  
  47  if (!defined('CLEARBRICKS_PATH') || !is_dir(CLEARBRICKS_PATH)) {
  48      exit('No clearbricks path defined');
  49  }
  50  
  51  require CLEARBRICKS_PATH.'/_common.php';
  52  
  53  if (empty($_GET['pf'])) {
  54      header('Content-Type: text/plain');
  55      http::head(404,'Not Found');
  56      exit;
  57  }
  58  
  59  $allow_types = array('png','jpg','jpeg','gif','css','js');
  60  
  61  $pf = path::clean($_GET['pf']);
  62  
  63  foreach (array_reverse(explode(PATH_SEPARATOR,DC_PLUGINS_ROOT)) as $m)
  64  {
  65      $PF = path::real($m.'/'.$pf);
  66      
  67      if ($PF !== false) {
  68          break;
  69      }
  70  }
  71  
  72  if ($PF === false || !is_file($PF) || !is_readable($PF)) {
  73      header('Content-Type: text/plain');
  74      http::head(404,'Not Found');
  75      exit;
  76  }
  77  
  78  if (!in_array(files::getExtension($PF),$allow_types)) {
  79      header('Content-Type: text/plain');
  80      http::head(404,'Not Found');
  81      exit;
  82  }
  83  
  84  http::cache(array_merge(array($PF),get_included_files()));
  85  
  86  header('Content-Type: '.files::getMimeType($PF));
  87  readfile($PF);
  88  exit;
  89  ?>


Généré le : Fri Feb 23 22:16:06 2007 par Balluche grâce à PHPXref 0.7