]> git.mxchange.org Git - friendica.git/blobdiff - boot.php
Merge pull request #3595 from annando/1707-realpath
[friendica.git] / boot.php
index b4f36eb84ebacc52ddcd1c1fd10b6c3bd6710c05..9c0ef1d08033327c421e247a906cb15f8e0edfdc 100644 (file)
--- a/boot.php
+++ b/boot.php
@@ -42,7 +42,7 @@ define ( 'FRIENDICA_PLATFORM',     'Friendica');
 define ( 'FRIENDICA_CODENAME',     'Asparagus');
 define ( 'FRIENDICA_VERSION',      '3.5.3-dev' );
 define ( 'DFRN_PROTOCOL_VERSION',  '2.23'    );
-define ( 'DB_UPDATE_VERSION',      1230      );
+define ( 'DB_UPDATE_VERSION',      1233      );
 
 /**
  * @brief Constant with a HTML line break.
@@ -1392,6 +1392,46 @@ function get_server() {
        return($server);
 }
 
+function get_temppath() {
+       $a = get_app();
+
+       $temppath = get_config("system", "temppath");
+
+       if (($temppath != "") && App::directory_usable($temppath)) {
+               // We have a temp path and it is usable
+               return App::realpath($temppath);
+       }
+
+       // We don't have a working preconfigured temp path, so we take the system path.
+       $temppath = sys_get_temp_dir();
+
+       // Check if it is usable
+       if (($temppath != "") && App::directory_usable($temppath)) {
+               // Always store the real path, not the path through symlinks
+               $temppath = App::realpath($temppath);
+
+               // To avoid any interferences with other systems we create our own directory
+               $new_temppath = $temppath . "/" . $a->get_hostname();
+               if (!is_dir($new_temppath)) {
+                       /// @TODO There is a mkdir()+chmod() upwards, maybe generalize this (+ configurable) into a function/method?
+                       mkdir($new_temppath);
+               }
+
+               if (App::directory_usable($new_temppath)) {
+                       // The new path is usable, we are happy
+                       set_config("system", "temppath", $new_temppath);
+                       return $new_temppath;
+               } else {
+                       // We can't create a subdirectory, strange.
+                       // But the directory seems to work, so we use it but don't store it.
+                       return $temppath;
+               }
+       }
+
+       // Reaching this point means that the operating system is configured badly.
+       return '';
+}
+
 function get_cachefile($file, $writemode = true) {
        $cache = get_itemcachepath();
 
@@ -1458,7 +1498,7 @@ function get_itemcachepath() {
 
        $itemcache = get_config('system', 'itemcache');
        if (($itemcache != "") && App::directory_usable($itemcache)) {
-               return $itemcache;
+               return App::realpath($itemcache);
        }
 
        $temppath = get_temppath();
@@ -1514,43 +1554,6 @@ function get_spoolpath() {
        return "";
 }
 
-function get_temppath() {
-       $a = get_app();
-
-       $temppath = get_config("system", "temppath");
-
-       if (($temppath != "") && App::directory_usable($temppath)) {
-               // We have a temp path and it is usable
-               return $temppath;
-       }
-
-       // We don't have a working preconfigured temp path, so we take the system path.
-       $temppath = sys_get_temp_dir();
-
-       // Check if it is usable
-       if (($temppath != "") && App::directory_usable($temppath)) {
-               // To avoid any interferences with other systems we create our own directory
-               $new_temppath = $temppath . "/" . $a->get_hostname();
-               if (!is_dir($new_temppath)) {
-                       /// @TODO There is a mkdir()+chmod() upwards, maybe generalize this (+ configurable) into a function/method?
-                       mkdir($new_temppath);
-               }
-
-               if (App::directory_usable($new_temppath)) {
-                       // The new path is usable, we are happy
-                       set_config("system", "temppath", $new_temppath);
-                       return $new_temppath;
-               } else {
-                       // We can't create a subdirectory, strange.
-                       // But the directory seems to work, so we use it but don't store it.
-                       return $temppath;
-               }
-       }
-
-       // Reaching this point means that the operating system is configured badly.
-       return '';
-}
-
 /// @deprecated
 function set_template_engine(App $a, $engine = 'internal') {
 /// @note This function is no longer necessary, but keep it as a wrapper to the class method