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

rel #32112 : source format

parent cd44e577
4 merge requests!1267Master,!1221Master,!1220Hotline master,!1212Hotline#32112 faille secu explorateur fichiers
......@@ -20,7 +20,7 @@
*/
class CosmoPaths {
protected
protected
$_root_dir_name,
$_filesystem;
......@@ -30,84 +30,84 @@ class CosmoPaths {
}
public function getBasePath() {
$parts = array_filter(explode('/', $this->getFilePath()));
while ((count($parts)>0) && (end($parts) !== $this->_root_dir_name))
array_pop($parts);
array_pop($parts);
return ($this->isWindowsPath() ? '' : '/') . implode('/', $parts) . '/';
}
public function getBasePath() {
$parts = array_filter(explode('/', $this->getFilePath()));
while ((count($parts)>0) && (end($parts) !== $this->_root_dir_name))
array_pop($parts);
array_pop($parts);
return ($this->isWindowsPath() ? '' : '/') . implode('/', $parts) . '/';
}
public function isWindowsPath() {
return strtoupper(substr(PHP_OS, 0, 3)) === 'WIN';
}
public function isWindowsPath() {
return strtoupper(substr(PHP_OS, 0, 3)) === 'WIN';
}
public function setFileSystem($filesystem) {
$this->_filesystem = $filesystem;
}
public function setFileSystem($filesystem) {
$this->_filesystem = $filesystem;
}
public function getFilesystem() {
require_once(realpath(dirname(__FILE__)).'/../../../library/Class/Testing/FileSystem.php');
return null == $this->_filesystem
? new Class_Testing_FileSystem()
: $this->_filesystem;
}
public function getFilesystem() {
require_once(realpath(dirname(__FILE__)).'/../../../library/Class/Testing/FileSystem.php');
return null == $this->_filesystem
? new Class_Testing_FileSystem()
: $this->_filesystem;
}
public function getConfigPath() {
return $this->getBasePath() . $this->_root_dir_name . '/config.php';
}
public function getConfigPath() {
return $this->getBasePath() . $this->_root_dir_name . '/config.php';
}
public function getBokehConfigPath() {
return $this->getBasePath() . 'config.ini';
}
public function getBokehConfigPath() {
return $this->getBasePath() . 'config.ini';
}
public function getBaseUrl() {
if (!isset($_SERVER['SCRIPT_NAME']))
return '/' . $this->getSite();
public function getBaseUrl() {
if (!isset($_SERVER['SCRIPT_NAME']))
return '/' . $this->getSite();
$parts = array_filter(explode('/', $_SERVER['SCRIPT_NAME']));
while ((count($parts)>0) && (end($parts) !== $this->_root_dir_name))
array_pop($parts);
array_pop($parts);
return $parts
? '/' . implode('/', $parts)
: '';
}
$parts = array_filter(explode('/', $_SERVER['SCRIPT_NAME']));
while ((count($parts)>0) && (end($parts) !== $this->_root_dir_name))
array_pop($parts);
array_pop($parts);
return $parts
? '/' . implode('/', $parts)
: '';
}
public function getCosmoBaseUrl() {
return $this->getBaseUrl() . '/' . $this->_root_dir_name . '/';
}
public function getCosmoBaseUrl() {
return $this->getBaseUrl() . '/' . $this->_root_dir_name . '/';
}
public function getUserfilesPath() {
return $this->getBasePath() . 'userfiles';
}
public function getUserfilesPath() {
return $this->getBasePath() . 'userfiles';
}
public function getSite() {
$parts = array_filter(explode('/', $this->getBasePath()));
return array_pop($parts);
}
public function getSite() {
$parts = array_filter(explode('/', $this->getBasePath()));
return array_pop($parts);
}
protected function getFilePath() {
if (isset($_SERVER['SCRIPT_FILENAME'])
&& false !== strpos($_SERVER['SCRIPT_FILENAME'], $this->_root_dir_name))
return $_SERVER['SCRIPT_FILENAME'];
protected function getFilePath() {
if (isset($_SERVER['SCRIPT_FILENAME'])
&& false !== strpos($_SERVER['SCRIPT_FILENAME'], $this->_root_dir_name))
return $_SERVER['SCRIPT_FILENAME'];
$current_path = $this->getFileSystem()->getcwd();
if (false !== strpos($current_path, $this->_root_dir_name))
return $current_path;
$current_path = $this->getFileSystem()->getcwd();
if (false !== strpos($current_path, $this->_root_dir_name))
return $current_path;
return realpath(dirname(__FILE__));
}
return realpath(dirname(__FILE__));
}
}
?>
\ No newline at end of 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