[ Index ]

PHP Cross Reference of phpBB-3.1.12-deutsch

title

Body

[close]

/phpbb/ -> filesystem.php (source)

   1  <?php
   2  /**
   3  *
   4  * This file is part of the phpBB Forum Software package.
   5  *
   6  * @copyright (c) phpBB Limited <https://www.phpbb.com>
   7  * @license GNU General Public License, version 2 (GPL-2.0)
   8  *
   9  * For full copyright and license information, please see
  10  * the docs/CREDITS.txt file.
  11  *
  12  */
  13  
  14  namespace phpbb;
  15  
  16  /**
  17  * A class with various functions that are related to paths, files and the filesystem
  18  */
  19  class filesystem
  20  {
  21      /**
  22      * Eliminates useless . and .. components from specified path.
  23      *
  24      * @param string $path Path to clean
  25      * @return string Cleaned path
  26      */
  27  	public function clean_path($path)
  28      {
  29          $exploded = explode('/', $path);
  30          $filtered = array();
  31          foreach ($exploded as $part)
  32          {
  33              if ($part === '.' && !empty($filtered))
  34              {
  35                  continue;
  36              }
  37  
  38              if ($part === '..' && !empty($filtered) && $filtered[sizeof($filtered) - 1] !== '.' && $filtered[sizeof($filtered) - 1] !== '..')
  39              {
  40                  array_pop($filtered);
  41              }
  42              else
  43              {
  44                  $filtered[] = $part;
  45              }
  46          }
  47          $path = implode('/', $filtered);
  48          return $path;
  49      }
  50  }


Generated: Thu Jan 11 00:25:41 2018 Cross-referenced by PHPXref 0.7.1