Skip to content
Snippets Groups Projects
Commit 4ce80eeb authored by Patrick Barroca's avatar Patrick Barroca :grin:
Browse files

Merge branch 'hotline#32112_faille_secu_explorateur_fichiers' into 'stable'

Hotline#32112 faille secu explorateur fichiers

See merge request !1218
parents 24777650 e7182bb0
Branches
Tags
4 merge requests!1267Master,!1221Master,!1220Hotline master,!1219Stable
...@@ -22,7 +22,8 @@ function auth() { ...@@ -22,7 +22,8 @@ function auth() {
$base_path = __DIR__ . '/../../../../'; // :) $base_path = __DIR__ . '/../../../../'; // :)
require_once($base_path . 'cosmogramme/php/classes/classe_cosmopaths.php'); require_once($base_path . 'cosmogramme/php/classes/classe_cosmopaths.php');
$cosmo_path = new CosmoPaths('ckeditor'); CosmoPaths::setDirName('ckeditor');
$cosmo_path = new CosmoPaths();
define('BASE_URL', $cosmo_path->getBaseUrl()); define('BASE_URL', $cosmo_path->getBaseUrl());
define('USERFILESPATH', $cosmo_path->getUserfilesPath()); define('USERFILESPATH', $cosmo_path->getUserfilesPath());
......
...@@ -20,19 +20,18 @@ ...@@ -20,19 +20,18 @@
*/ */
class CosmoPaths { class CosmoPaths {
protected protected static $_dir_name = 'cosmogramme';
$_root_dir_name, protected $_filesystem;
$_filesystem;
public function __construct($root_dir_name = 'cosmogramme') { public static function setDirName($name) {
$this->_root_dir_name = $root_dir_name; static::$_dir_name = $name;
} }
public function getBasePath() { public function getBasePath() {
$parts = array_filter(explode('/', $this->getFilePath())); $parts = array_filter(explode('/', $this->getFilePath()));
while ((count($parts)>0) && (end($parts) !== $this->_root_dir_name)) while ((count($parts)>0) && (end($parts) !== static::$_dir_name))
array_pop($parts); array_pop($parts);
array_pop($parts); array_pop($parts);
return ($this->isWindowsPath() ? '' : '/') . implode('/', $parts) . '/'; return ($this->isWindowsPath() ? '' : '/') . implode('/', $parts) . '/';
...@@ -58,7 +57,7 @@ class CosmoPaths { ...@@ -58,7 +57,7 @@ class CosmoPaths {
public function getConfigPath() { public function getConfigPath() {
return $this->getBasePath() . $this->_root_dir_name . '/config.php'; return $this->getBasePath() . static::$_dir_name . '/config.php';
} }
...@@ -72,7 +71,7 @@ class CosmoPaths { ...@@ -72,7 +71,7 @@ class CosmoPaths {
return '/' . $this->getSite(); return '/' . $this->getSite();
$parts = array_filter(explode('/', $_SERVER['SCRIPT_NAME'])); $parts = array_filter(explode('/', $_SERVER['SCRIPT_NAME']));
while ((count($parts)>0) && (end($parts) !== $this->_root_dir_name)) while ((count($parts)>0) && (end($parts) !== static::$_dir_name))
array_pop($parts); array_pop($parts);
array_pop($parts); array_pop($parts);
return $parts return $parts
...@@ -82,7 +81,7 @@ class CosmoPaths { ...@@ -82,7 +81,7 @@ class CosmoPaths {
public function getCosmoBaseUrl() { public function getCosmoBaseUrl() {
return $this->getBaseUrl() . '/' . $this->_root_dir_name . '/'; return $this->getBaseUrl() . '/' . static::$_dir_name . '/';
} }
...@@ -99,11 +98,11 @@ class CosmoPaths { ...@@ -99,11 +98,11 @@ class CosmoPaths {
protected function getFilePath() { protected function getFilePath() {
if (isset($_SERVER['SCRIPT_FILENAME']) if (isset($_SERVER['SCRIPT_FILENAME'])
&& false !== strpos($_SERVER['SCRIPT_FILENAME'], $this->_root_dir_name)) && false !== strpos($_SERVER['SCRIPT_FILENAME'], static::$_dir_name))
return $_SERVER['SCRIPT_FILENAME']; return $_SERVER['SCRIPT_FILENAME'];
$current_path = $this->getFileSystem()->getcwd(); $current_path = $this->getFileSystem()->getcwd();
if (false !== strpos($current_path, $this->_root_dir_name)) if (false !== strpos($current_path, static::$_dir_name))
return $current_path; return $current_path;
return realpath(dirname(__FILE__)); return realpath(dirname(__FILE__));
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment