add function in filesystem to strip webroot
This commit is contained in:
parent
120997112c
commit
43501309e3
|
@ -343,6 +343,20 @@ class OC_Filesystem{
|
||||||
return self::$defaultInstance->getLocalFile($path);
|
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
|
* check if the requested path is valid
|
||||||
* @param string path
|
* @param string path
|
||||||
|
|
|
@ -409,12 +409,7 @@ class OC_Image {
|
||||||
default:
|
default:
|
||||||
|
|
||||||
// this is mostly file created from encrypted file
|
// this is mostly file created from encrypted file
|
||||||
$datadir = \OCP\Config::getSystemValue('datadirectory').'/'.\OC_User::getUser().'/files';
|
$this->resource = imagecreatefromstring(\OC_Filesystem::file_get_contents(\OC_Filesystem::getLocalPath($newimgpath)));
|
||||||
$newimgpath = $imagepath;
|
|
||||||
if (strncmp($newimgpath, $datadir, strlen($datadir)) == 0) {
|
|
||||||
$newimgpath = substr($imagepath, strlen($datadir));
|
|
||||||
}
|
|
||||||
$this->resource = imagecreatefromstring(\OC_Filesystem::file_get_contents($newimgpath));
|
|
||||||
$itype = IMAGETYPE_PNG;
|
$itype = IMAGETYPE_PNG;
|
||||||
OC_Log::write('core','OC_Image->loadFromFile, Default', OC_Log::DEBUG);
|
OC_Log::write('core','OC_Image->loadFromFile, Default', OC_Log::DEBUG);
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue