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

rel #32112 : fix for real hosting configuration

parent 24777650
Branches
Tags
5 merge requests!1267Master,!1221Master,!1220Hotline master,!1219Stable,!1218Hotline#32112 faille secu explorateur fichiers
......@@ -22,7 +22,8 @@ function auth() {
$base_path = __DIR__ . '/../../../../'; // :)
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('USERFILESPATH', $cosmo_path->getUserfilesPath());
......
......@@ -20,19 +20,18 @@
*/
class CosmoPaths {
protected
$_root_dir_name,
$_filesystem;
protected static $_dir_name = 'cosmogramme';
protected $_filesystem;
public function __construct($root_dir_name = 'cosmogramme') {
$this->_root_dir_name = $root_dir_name;
public static function setDirName($name) {
static::$_dir_name = $name;
}
public function getBasePath() {
$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);
return ($this->isWindowsPath() ? '' : '/') . implode('/', $parts) . '/';
......@@ -58,7 +57,7 @@ class CosmoPaths {
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 {
return '/' . $this->getSite();
$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);
return $parts
......@@ -82,7 +81,7 @@ class CosmoPaths {
public function getCosmoBaseUrl() {
return $this->getBaseUrl() . '/' . $this->_root_dir_name . '/';
return $this->getBaseUrl() . '/' . static::$_dir_name . '/';
}
......@@ -99,11 +98,11 @@ class CosmoPaths {
protected function getFilePath() {
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'];
$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 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