]> source.dussan.org Git - nextcloud-server.git/commitdiff
add function in filesystem to strip webroot
authorBartek Przybylski <bart.p.pl@gmail.com>
Sat, 9 Jun 2012 13:26:26 +0000 (15:26 +0200)
committerBartek Przybylski <bart.p.pl@gmail.com>
Sun, 10 Jun 2012 11:19:10 +0000 (13:19 +0200)
lib/filesystem.php
lib/image.php

index cac7e8648ef127e08a5faeaf7d5e2e966c4290a3..198f00873c5e67ec2cd2408fc328a8f54c1b11ef 100644 (file)
@@ -341,6 +341,20 @@ class OC_Filesystem{
                return self::$defaultInstance->getLocalFile($path);
        }
        
+       /**
+       * return path to file which reflects one visible in browser
+       * @param string path
+       * @return string
+       */
+       static public function getLocalPath($path) {
+               $datadir = \OCP\Config::getSystemValue('datadirectory').'/'.\OC_User::getUser().'/files';
+               $newpath = $path;
+               if (strncmp($newpath, $datadir, strlen($datadir)) == 0) {
+                       $newpath = substr($path, strlen($datadir));
+               }
+               return $newpath;
+       }
+       
        /**
         * check if the requested path is valid
         * @param string path
index 77efc56d8ccb386a0d1d8237df777cb8a5724f2e..f119c99633f20fd830e41b9802d799993a126633 100644 (file)
@@ -402,12 +402,7 @@ class OC_Image {
                        default:
                        
                                // this is mostly file created from encrypted file
-                               $datadir = \OCP\Config::getSystemValue('datadirectory').'/'.\OC_User::getUser().'/files';
-                               $newimgpath = $imagepath;
-                               if (strncmp($newimgpath, $datadir, strlen($datadir)) == 0) {
-                                       $newimgpath = substr($imagepath, strlen($datadir));
-                               }
-                               $this->resource = imagecreatefromstring(\OC_Filesystem::file_get_contents($newimgpath));
+                               $this->resource = imagecreatefromstring(\OC_Filesystem::file_get_contents(\OC_Filesystem::getLocalPath($newimgpath)));
                                $itype = IMAGETYPE_PNG;
                                OC_Log::write('core','OC_Image->loadFromFile, Default', OC_Log::DEBUG);
                                break;