summaryrefslogtreecommitdiff
path: root/program
diff options
context:
space:
mode:
authorAleksander Machniak <alec@alec.pl>2014-02-07 14:43:51 +0100
committerAleksander Machniak <alec@alec.pl>2014-02-07 14:45:25 +0100
commitf130f9116e1e9ee9735d8026aa5242fc9daceecb (patch)
tree21631e61616f1f0fc8b67c02537b9d5f165c7536 /program
parent8c32f881933c19e57b9148149d1c86eb802be3ff (diff)
Fix directories check in Installer on Windows (#1489576)
Added rcube_utils::is_absolute_path() method
Diffstat (limited to 'program')
-rw-r--r--program/lib/Roundcube/rcube_config.php14
-rw-r--r--program/lib/Roundcube/rcube_utils.php12
2 files changed, 15 insertions, 11 deletions
diff --git a/program/lib/Roundcube/rcube_config.php b/program/lib/Roundcube/rcube_config.php
index 0352e4772..afe13e879 100644
--- a/program/lib/Roundcube/rcube_config.php
+++ b/program/lib/Roundcube/rcube_config.php
@@ -63,7 +63,7 @@ class rcube_config
$this->paths = explode(PATH_SEPARATOR, $paths);
// make all paths absolute
foreach ($this->paths as $i => $path) {
- if (!$this->_is_absolute($path)) {
+ if (!rcube_utils::is_absolute_path($path)) {
if ($realpath = realpath(RCUBE_INSTALL_PATH . $path)) {
$this->paths[$i] = unslashify($realpath) . '/';
}
@@ -243,8 +243,8 @@ class rcube_config
*/
public function resolve_paths($file, $use_env = true)
{
- $files = array();
- $abs_path = $this->_is_absolute($file);
+ $files = array();
+ $abs_path = rcube_utils::is_absolute_path($file);
foreach ($this->paths as $basepath) {
$realpath = $abs_path ? $file : realpath($basepath . '/' . $file);
@@ -270,14 +270,6 @@ class rcube_config
}
/**
- * Determine whether the given file path is absolute or relative
- */
- private function _is_absolute($path)
- {
- return $path[0] == DIRECTORY_SEPARATOR || preg_match('!^[a-z]:[\\\\/]!i', $path);
- }
-
- /**
* Getter for a specific config parameter
*
* @param string $name Parameter name
diff --git a/program/lib/Roundcube/rcube_utils.php b/program/lib/Roundcube/rcube_utils.php
index c48cd80e8..46d53ac91 100644
--- a/program/lib/Roundcube/rcube_utils.php
+++ b/program/lib/Roundcube/rcube_utils.php
@@ -1045,4 +1045,16 @@ class rcube_utils
return !in_array($str, array('false', '0', 'no', 'off', 'nein', ''), true);
}
+ /**
+ * OS-dependent absolute path detection
+ */
+ public static function is_absolute_path($path)
+ {
+ if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
+ return (bool) preg_match('!^[a-z]:[\\\\/]!i', $path);
+ }
+ else {
+ return $path[0] == DIRECTORY_SEPARATOR;
+ }
+ }
}