Dotclear


Ignore:
Timestamp:
03/08/18 17:58:39 (8 years ago)
Author:
franck <carnet.franck.paul@…>
Branch:
default
Message:

Code formatting (PSR-2)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • inc/load_plugin_file.php

    r3143 r3730  
    1313#  ClearBricks and DotClear classes auto-loader 
    1414if (@is_dir('/usr/lib/clearbricks')) { 
    15      define('CLEARBRICKS_PATH','/usr/lib/clearbricks'); 
    16 } elseif (is_dir(dirname(__FILE__).'/libs/clearbricks')) { 
    17      define('CLEARBRICKS_PATH',dirname(__FILE__).'/libs/clearbricks'); 
     15    define('CLEARBRICKS_PATH', '/usr/lib/clearbricks'); 
     16} elseif (is_dir(dirname(__FILE__) . '/libs/clearbricks')) { 
     17    define('CLEARBRICKS_PATH', dirname(__FILE__) . '/libs/clearbricks'); 
    1818} elseif (isset($_SERVER['CLEARBRICKS_PATH']) && is_dir($_SERVER['CLEARBRICKS_PATH'])) { 
    19      define('CLEARBRICKS_PATH',$_SERVER['CLEARBRICKS_PATH']); 
     19    define('CLEARBRICKS_PATH', $_SERVER['CLEARBRICKS_PATH']); 
    2020} 
    2121 
    2222if (!defined('CLEARBRICKS_PATH') || !is_dir(CLEARBRICKS_PATH)) { 
    23      exit('No clearbricks path defined'); 
     23    exit('No clearbricks path defined'); 
    2424} 
    2525 
    26 require CLEARBRICKS_PATH.'/_common.php'; 
     26require CLEARBRICKS_PATH . '/_common.php'; 
    2727 
    2828if (isset($_SERVER['DC_RC_PATH'])) { 
    29      define('DC_RC_PATH',$_SERVER['DC_RC_PATH']); 
     29    define('DC_RC_PATH', $_SERVER['DC_RC_PATH']); 
    3030} elseif (isset($_SERVER['REDIRECT_DC_RC_PATH'])) { 
    31      define('DC_RC_PATH',$_SERVER['REDIRECT_DC_RC_PATH']); 
     31    define('DC_RC_PATH', $_SERVER['REDIRECT_DC_RC_PATH']); 
    3232} else { 
    33      define('DC_RC_PATH',dirname(__FILE__).'/config.php'); 
     33    define('DC_RC_PATH', dirname(__FILE__) . '/config.php'); 
    3434} 
    3535 
    3636if (!is_file(DC_RC_PATH)) { 
    37      trigger_error('Unable to open config file',E_USER_ERROR); 
    38      exit; 
     37    trigger_error('Unable to open config file', E_USER_ERROR); 
     38    exit; 
    3939} 
    4040 
     
    4242 
    4343if (empty($_GET['pf'])) { 
    44      header('Content-Type: text/plain'); 
    45      http::head(404,'Not Found'); 
    46      exit; 
     44    header('Content-Type: text/plain'); 
     45    http::head(404, 'Not Found'); 
     46    exit; 
    4747} 
    4848 
    4949// $_GET['v'] : version in url to bypass cache in case of dotclear upgrade or in dev mode 
    5050// but don't care of value 
    51 if (isset($_GET['v'])) 
    52 { 
     51if (isset($_GET['v'])) { 
    5352    unset($_GET['v']); 
    5453} 
    5554 
    5655// Only $_GET['pf'] is allowed in URL 
    57 if (count($_GET) > 1) 
    58 { 
     56if (count($_GET) > 1) { 
    5957    header('Content-Type: text/plain'); 
    60     http::head(403,'Forbidden'); 
     58    http::head(403, 'Forbidden'); 
    6159    exit; 
    6260} 
    6361 
    64 $allow_types = array('png','jpg','jpeg','gif','css','js','swf','svg'); 
     62$allow_types = array('png', 'jpg', 'jpeg', 'gif', 'css', 'js', 'swf', 'svg'); 
    6563 
    6664$pf = path::clean($_GET['pf']); 
    6765 
    68 $paths = array_reverse(explode(PATH_SEPARATOR,DC_PLUGINS_ROOT)); 
     66$paths = array_reverse(explode(PATH_SEPARATOR, DC_PLUGINS_ROOT)); 
    6967 
    7068# Adding some folders here to load some stuff 
    71 $paths[] = dirname(__FILE__).'/swf'; 
    72 $paths[] = dirname(__FILE__).'/js'; 
    73 $paths[] = dirname(__FILE__).'/css'; 
     69$paths[] = dirname(__FILE__) . '/swf'; 
     70$paths[] = dirname(__FILE__) . '/js'; 
     71$paths[] = dirname(__FILE__) . '/css'; 
    7472 
    75 foreach ($paths as $m) 
    76 { 
    77      $PF = path::real($m.'/'.$pf); 
     73foreach ($paths as $m) { 
     74    $PF = path::real($m . '/' . $pf); 
    7875 
    79      if ($PF !== false) { 
    80           break; 
    81      } 
     76    if ($PF !== false) { 
     77        break; 
     78    } 
    8279} 
    8380unset($paths); 
    8481 
    8582if ($PF === false || !is_file($PF) || !is_readable($PF)) { 
    86      header('Content-Type: text/plain'); 
    87      http::head(404,'Not Found'); 
    88      exit; 
     83    header('Content-Type: text/plain'); 
     84    http::head(404, 'Not Found'); 
     85    exit; 
    8986} 
    9087 
    91 if (!in_array(files::getExtension($PF),$allow_types)) { 
    92      header('Content-Type: text/plain'); 
    93      http::head(404,'Not Found'); 
    94      exit; 
     88if (!in_array(files::getExtension($PF), $allow_types)) { 
     89    header('Content-Type: text/plain'); 
     90    http::head(404, 'Not Found'); 
     91    exit; 
    9592} 
    9693 
    97 http::$cache_max_age = 7 * 24 * 60 * 60;     // One week cache for plugin's files served by ?pf=… is better than old 2 hours 
    98 http::cache(array_merge(array($PF),get_included_files())); 
     94http::$cache_max_age = 7 * 24 * 60 * 60; // One week cache for plugin's files served by ?pf=… is better than old 2 hours 
     95http::cache(array_merge(array($PF), get_included_files())); 
    9996 
    100 header('Content-Type: '.files::getMimeType($PF)); 
     97header('Content-Type: ' . files::getMimeType($PF)); 
    10198// Content-length is not mandatory and must be the exact size of content transfered AFTER possible compression (gzip, deflate, …) 
    10299//header('Content-Length: '.filesize($PF)); 
Note: See TracChangeset for help on using the changeset viewer.

Sites map