From 120997112c7acf490171d07ec32cdd6d091db9c2 Mon Sep 17 00:00:00 2001 From: Bartek Przybylski Date: Sat, 9 Jun 2012 15:22:02 +0200 Subject: [PATCH 1/4] handle encrypted images files in oc_image --- lib/image.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/image.php b/lib/image.php index 5a2e8202488..41e8c744d8c 100644 --- a/lib/image.php +++ b/lib/image.php @@ -407,11 +407,14 @@ class OC_Image { break; */ default: - error_log($imagepath); - error_log(\OC_Filesystem::getInternalPath($imagepath)); - error_log(\OC_Filesystem::getLocalFile($imagepath)); + // this is mostly file created from encrypted file - $this->resource = imagecreatefromstring(\OC_Filesystem::file_get_contents(\OC_Filesystem::getInternalPath($imagepath))); + $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)); $itype = IMAGETYPE_PNG; OC_Log::write('core','OC_Image->loadFromFile, Default', OC_Log::DEBUG); break; From 43501309e336ac0268b6e9b4b3c6f5b0f05f7056 Mon Sep 17 00:00:00 2001 From: Bartek Przybylski Date: Sat, 9 Jun 2012 15:26:26 +0200 Subject: [PATCH 2/4] add function in filesystem to strip webroot --- lib/filesystem.php | 14 ++++++++++++++ lib/image.php | 7 +------ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/lib/filesystem.php b/lib/filesystem.php index 337b0f1464b..454bb1aa81a 100644 --- a/lib/filesystem.php +++ b/lib/filesystem.php @@ -343,6 +343,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 diff --git a/lib/image.php b/lib/image.php index 41e8c744d8c..d72960101f0 100644 --- a/lib/image.php +++ b/lib/image.php @@ -409,12 +409,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; From ec55eaef5bf5f198dd9fdc46d41fa9e62105f281 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Sat, 9 Jun 2012 15:25:00 +0200 Subject: [PATCH 3/4] dont load apps when displaying the login page and only load authentication apps during login --- index.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/index.php b/index.php index d552c149df8..940bb797207 100755 --- a/index.php +++ b/index.php @@ -69,10 +69,10 @@ elseif(OC_User::isLoggedIn()) { // For all others cases, we display the guest page : } else { - OC_App::loadApps(); $error = false; // remember was checked after last login if(isset($_COOKIE["oc_remember_login"]) && isset($_COOKIE["oc_token"]) && isset($_COOKIE["oc_username"]) && $_COOKIE["oc_remember_login"]) { + OC_App::loadApps(array('authentication')); if(defined("DEBUG") && DEBUG) { OC_Log::write('core','Trying to login from cookie',OC_Log::DEBUG); } @@ -88,6 +88,7 @@ elseif(OC_User::isLoggedIn()) { // Someone wants to log in : } elseif(isset($_POST["user"]) and isset($_POST['password']) and isset($_SESSION['sectoken']) and isset($_POST['sectoken']) and ($_SESSION['sectoken']==$_POST['sectoken']) ) { + OC_App::loadApps(array('authentication')); if(OC_User::login($_POST["user"], $_POST["password"])) { if(!empty($_POST["remember_login"])){ if(defined("DEBUG") && DEBUG) { @@ -107,6 +108,7 @@ elseif(OC_User::isLoggedIn()) { // The user is already authenticated using Apaches AuthType Basic... very usable in combination with LDAP } elseif(isset($_SERVER["PHP_AUTH_USER"]) && isset($_SERVER["PHP_AUTH_PW"])){ + OC_App::loadApps(array('authentication')); if (OC_User::login($_SERVER["PHP_AUTH_USER"],$_SERVER["PHP_AUTH_PW"])) { //OC_Log::write('core',"Logged in with HTTP Authentication",OC_Log::DEBUG); OC_User::unsetMagicInCookie(); From 6e9fea341b98e4964f404fe5bc773e6f161999ec Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Sat, 9 Jun 2012 15:33:38 +0200 Subject: [PATCH 4/4] Changed preferences configvalue to clob. Fixes several bugs e.g. oc-825 and oc-743. --- db_structure.xml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/db_structure.xml b/db_structure.xml index d29dcb46f8c..94567b4d539 100644 --- a/db_structure.xml +++ b/db_structure.xml @@ -432,10 +432,8 @@ configvalue - text - + clob true - 255