mirror of
https://github.com/friendica/friendica
synced 2024-12-24 00:40:16 +00:00
Merge pull request #3595 from annando/1707-realpath
Better use a wrapper
This commit is contained in:
commit
dd0a1cf586
3 changed files with 27 additions and 7 deletions
6
boot.php
6
boot.php
|
@ -1399,7 +1399,7 @@ function get_temppath() {
|
|||
|
||||
if (($temppath != "") && App::directory_usable($temppath)) {
|
||||
// We have a temp path and it is usable
|
||||
return realpath($temppath);
|
||||
return App::realpath($temppath);
|
||||
}
|
||||
|
||||
// We don't have a working preconfigured temp path, so we take the system path.
|
||||
|
@ -1408,7 +1408,7 @@ function get_temppath() {
|
|||
// Check if it is usable
|
||||
if (($temppath != "") && App::directory_usable($temppath)) {
|
||||
// Always store the real path, not the path through symlinks
|
||||
$temppath = realpath($temppath);
|
||||
$temppath = App::realpath($temppath);
|
||||
|
||||
// To avoid any interferences with other systems we create our own directory
|
||||
$new_temppath = $temppath . "/" . $a->get_hostname();
|
||||
|
@ -1498,7 +1498,7 @@ function get_itemcachepath() {
|
|||
|
||||
$itemcache = get_config('system', 'itemcache');
|
||||
if (($itemcache != "") && App::directory_usable($itemcache)) {
|
||||
return realpath($itemcache);
|
||||
return App::realpath($itemcache);
|
||||
}
|
||||
|
||||
$temppath = get_temppath();
|
||||
|
|
|
@ -975,7 +975,7 @@ function admin_page_site_post(App $a) {
|
|||
set_config('system', 'hide_help', $hide_help);
|
||||
|
||||
if ($itemcache != '') {
|
||||
$itemcache = realpath($itemcache);
|
||||
$itemcache = App::realpath($itemcache);
|
||||
}
|
||||
|
||||
set_config('system', 'itemcache', $itemcache);
|
||||
|
@ -983,13 +983,13 @@ function admin_page_site_post(App $a) {
|
|||
set_config('system', 'max_comments', $max_comments);
|
||||
|
||||
if ($temppath != '') {
|
||||
$temppath = realpath($temppath);
|
||||
$temppath = App::realpath($temppath);
|
||||
}
|
||||
|
||||
set_config('system', 'temppath', $temppath);
|
||||
|
||||
if ($basepath != '') {
|
||||
$basepath = realpath($basepath);
|
||||
$basepath = App::realpath($basepath);
|
||||
}
|
||||
|
||||
set_config('system', 'basepath', $basepath);
|
||||
|
|
22
src/App.php
22
src/App.php
|
@ -327,7 +327,27 @@ class App {
|
|||
$basepath = $_SERVER['PWD'];
|
||||
}
|
||||
|
||||
return $basepath;
|
||||
return self::realpath($basepath);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Returns a normalized file path
|
||||
*
|
||||
* This is a wrapper for the "realpath" function.
|
||||
* That function cannot detect the real path when some folders aren't readable.
|
||||
* Since this could happen with some hosters we need to handle this.
|
||||
*
|
||||
* @param string $path The path that is about to be normalized
|
||||
* @return string normalized path - when possible
|
||||
*/
|
||||
public static function realpath($path) {
|
||||
$normalized = realpath($path);
|
||||
|
||||
if (!is_bool($normalized)) {
|
||||
return $normalized;
|
||||
} else {
|
||||
return $path;
|
||||
}
|
||||
}
|
||||
|
||||
function get_scheme() {
|
||||
|
|
Loading…
Reference in a new issue