From f86ecb3bf7af9e41d5d3b041ea5ee1bf4fbeb634 Mon Sep 17 00:00:00 2001 From: Bjoern Schiessle Date: Thu, 5 Jul 2012 11:28:32 +0200 Subject: [PATCH 01/10] send ca cert path to sabredav client --- 3rdparty/Sabre/DAV/Client.php | 9 +++++++++ apps/files_external/lib/webdav.php | 3 +++ 2 files changed, 12 insertions(+) diff --git a/3rdparty/Sabre/DAV/Client.php b/3rdparty/Sabre/DAV/Client.php index 23bd7c0539..d257c86da1 100644 --- a/3rdparty/Sabre/DAV/Client.php +++ b/3rdparty/Sabre/DAV/Client.php @@ -22,6 +22,7 @@ class Sabre_DAV_Client { protected $userName; protected $password; protected $proxy; + protected $capath; /** * Constructor @@ -49,6 +50,11 @@ class Sabre_DAV_Client { 'proxy' ); + $this->capath = ''; + if (isset($settings['capath'])) { + $this->capath = $settings['capath']; + } + foreach($validSettings as $validSetting) { if (isset($settings[$validSetting])) { $this->$validSetting = $settings[$validSetting]; @@ -249,9 +255,12 @@ class Sabre_DAV_Client { // Automatically follow redirects CURLOPT_FOLLOWLOCATION => true, CURLOPT_MAXREDIRS => 5, + CURLOPT_SSL_VERIFYPEER => true, //CURLOPT_SSL_VERIFYPEER => false, ); + if ($this->capath != '') $curlSettings[CURLOPT_CAPATH] = $this->capath; + switch ($method) { case 'PUT': $curlSettings[CURLOPT_PUT] = true; diff --git a/apps/files_external/lib/webdav.php b/apps/files_external/lib/webdav.php index dda8afe9f2..097ff3c016 100644 --- a/apps/files_external/lib/webdav.php +++ b/apps/files_external/lib/webdav.php @@ -36,10 +36,13 @@ class OC_FileStorage_DAV extends OC_Filestorage_Common{ $this->root.='/'; } + $caview = \OCP\Files::getStorage('files_external'); + $capath=\OCP\Config::getSystemValue('datadirectory').$caview->getAbsolutePath(""); $settings = array( 'baseUri' => $this->createBaseUri(), 'userName' => $this->user, 'password' => $this->password, + 'capath' => $capath, ); $this->client = new Sabre_DAV_Client($settings); From aa3b575ceba3f1d3008c5051831d87f9d8e9b598 Mon Sep 17 00:00:00 2001 From: Bjoern Schiessle Date: Thu, 5 Jul 2012 11:31:30 +0200 Subject: [PATCH 02/10] disabled user upload of root certificates until sabredav client can handle them --- apps/files_external/templates/settings.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/files_external/templates/settings.php b/apps/files_external/templates/settings.php index dccc0913f2..8f8fe8d527 100644 --- a/apps/files_external/templates/settings.php +++ b/apps/files_external/templates/settings.php @@ -81,7 +81,7 @@
- + '> From 55cde0e5aa7118ed916fc76e21c72c5081cc81ae Mon Sep 17 00:00:00 2001 From: Bjoern Schiessle Date: Thu, 5 Jul 2012 11:35:08 +0200 Subject: [PATCH 03/10] moved remove and rename hook to libs/hooks.php --- apps/files_versions/appinfo/app.php | 4 +-- apps/files_versions/lib/hooks.php | 37 ++++++++++++++++++++++++++++ apps/files_versions/lib/versions.php | 37 ---------------------------- 3 files changed, 39 insertions(+), 39 deletions(-) diff --git a/apps/files_versions/appinfo/app.php b/apps/files_versions/appinfo/app.php index dba612e4b7..9ac7f6d5cd 100644 --- a/apps/files_versions/appinfo/app.php +++ b/apps/files_versions/appinfo/app.php @@ -12,5 +12,5 @@ OCP\Util::addscript('files_versions', 'versions'); // Listen to write signals OCP\Util::connectHook('OC_Filesystem', 'post_write', "OCA_Versions\Hooks", "write_hook"); // Listen to delete and rename signals -OCP\Util::connectHook('OC_Filesystem', 'delete', "OCA_Versions\Storage", "removeVersions"); -OCP\Util::connectHook('OC_Filesystem', 'rename', "OCA_Versions\Storage", "renameVersions"); \ No newline at end of file +OCP\Util::connectHook('OC_Filesystem', 'delete', "OCA_Versions\Hooks", "remove_hook"); +OCP\Util::connectHook('OC_Filesystem', 'rename', "OCA_Versions\Hooks", "rename_hook"); \ No newline at end of file diff --git a/apps/files_versions/lib/hooks.php b/apps/files_versions/lib/hooks.php index 8a74670532..b43fdb9fd3 100644 --- a/apps/files_versions/lib/hooks.php +++ b/apps/files_versions/lib/hooks.php @@ -30,6 +30,43 @@ class Hooks { } } + /** + * @brief Erase versions of deleted file + * @param array + * + * This function is connected to the delete signal of OC_Filesystem + * cleanup the versions directory if the actual file gets deleted + */ + public static function remove_hook($params) { + $rel_path = $params['path']; + $abs_path = \OCP\Config::getSystemValue('datadirectory').'/'.\OCP\User::getUser()."/versions".$rel_path.'.v'; + if(Storage::isversioned($rel_path)) { + $versions = Storage::getVersions($rel_path); + foreach ($versions as $v){ + unlink($abs_path . $v['version']); + } + } + } + + /** + * @brief rename/move versions of renamed/moved files + * @param array with oldpath and newpath + * + * This function is connected to the rename signal of OC_Filesystem and adjust the name and location + * of the stored versions along the actual file + */ + public static function rename_hook($params) { + $rel_oldpath = $params['oldpath']; + $abs_oldpath = \OCP\Config::getSystemValue('datadirectory').'/'.\OCP\User::getUser()."/versions".$rel_oldpath.'.v'; + $abs_newpath = \OCP\Config::getSystemValue('datadirectory').'/'.\OCP\User::getUser()."/versions".$params['newpath'].'.v'; + if(Storage::isversioned($rel_oldpath)) { + $versions = Storage::getVersions($rel_oldpath); + foreach ($versions as $v){ + rename($abs_oldpath.$v['version'], $abs_newpath.$v['version']); + } + } + } + } ?> diff --git a/apps/files_versions/lib/versions.php b/apps/files_versions/lib/versions.php index fb78e0a56c..412044dba7 100644 --- a/apps/files_versions/lib/versions.php +++ b/apps/files_versions/lib/versions.php @@ -323,41 +323,4 @@ class Storage { return $this->view->deleteAll( $dir, true ); } - - /** - * @brief Erase versions of deleted file - * @param array - * - * This function is connected to the delete signal of OC_Filesystem - * cleanup the versions directory if the actual file gets deleted - */ - public static function removeVersions($params) { - $rel_path = $params['path']; - $abs_path = \OCP\Config::getSystemValue('datadirectory').'/'.\OCP\User::getUser()."/versions".$rel_path.'.v'; - if(Storage::isversioned($rel_path)) { - $versions = Storage::getVersions($rel_path); - foreach ($versions as $v){ - unlink($abs_path . $v['version']); - } - } - } - - /** - * @brief rename/move versions of renamed/moved files - * @param array with oldpath and newpath - * - * This function is connected to the rename signal of OC_Filesystem and adjust the name and location - * of the stored versions along the actual file - */ - public static function renameVersions($params) { - $rel_oldpath = $params['oldpath']; - $abs_oldpath = \OCP\Config::getSystemValue('datadirectory').'/'.\OCP\User::getUser()."/versions".$rel_oldpath.'.v'; - $abs_newpath = \OCP\Config::getSystemValue('datadirectory').'/'.\OCP\User::getUser()."/versions".$params['newpath'].'.v'; - if(Storage::isversioned($rel_oldpath)) { - $versions = Storage::getVersions($rel_oldpath); - foreach ($versions as $v){ - rename($abs_oldpath.$v['version'], $abs_newpath.$v['version']); - } - } - } } From 378fa2bc86fd5df095b2d05855bd54a341dba1b0 Mon Sep 17 00:00:00 2001 From: Bjoern Schiessle Date: Thu, 5 Jul 2012 12:17:33 +0200 Subject: [PATCH 04/10] check if caview really exists --- .htaccess | 4 ++-- apps/files_external/lib/webdav.php | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.htaccess b/.htaccess index 11ee1d59f8..6d1844dbf9 100755 --- a/.htaccess +++ b/.htaccess @@ -1,8 +1,8 @@ ErrorDocument 403 /core/templates/403.php ErrorDocument 404 /core/templates/404.php -php_value upload_max_filesize 513M -php_value post_max_size 513M +php_value upload_max_filesize 2000M +php_value post_max_size 2000M php_value memory_limit 512M SetEnv htaccessWorking true diff --git a/apps/files_external/lib/webdav.php b/apps/files_external/lib/webdav.php index 097ff3c016..32dd26ae6c 100644 --- a/apps/files_external/lib/webdav.php +++ b/apps/files_external/lib/webdav.php @@ -36,8 +36,10 @@ class OC_FileStorage_DAV extends OC_Filestorage_Common{ $this->root.='/'; } - $caview = \OCP\Files::getStorage('files_external'); - $capath=\OCP\Config::getSystemValue('datadirectory').$caview->getAbsolutePath(""); + $capath = ''; + if($caview = \OCP\Files::getStorage('files_external')) { + $capath=\OCP\Config::getSystemValue('datadirectory').$caview->getAbsolutePath(""); + } $settings = array( 'baseUri' => $this->createBaseUri(), 'userName' => $this->user, From 51774cca6b34a24ccbc191184f6d36d81b879210 Mon Sep 17 00:00:00 2001 From: Bjoern Schiessle Date: Thu, 5 Jul 2012 14:20:40 +0200 Subject: [PATCH 05/10] use OC_Filesystem for rollback --- apps/files_versions/lib/versions.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/files_versions/lib/versions.php b/apps/files_versions/lib/versions.php index 412044dba7..5611e538ad 100644 --- a/apps/files_versions/lib/versions.php +++ b/apps/files_versions/lib/versions.php @@ -147,6 +147,9 @@ class Storage { public static function rollback($filename,$revision) { if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') { + $users_view = \OCP\Files::getStorage("files_versions"); + $users_view->chroot(\OCP\User::getUser().'/'); + if (\OCP\App::isEnabled('files_sharing') && $source = \OC_Share::getSource('/'.\OCP\User::getUser().'/files'.$filename)) { $pos = strpos($source, '/files', 1); $uid = substr($source, 1, $pos - 1); @@ -159,7 +162,7 @@ class Storage { $filesfoldername=\OCP\Config::getSystemValue('datadirectory').'/'. $uid .'/files'; // rollback - if ( @copy($versionsFolderName.'/'.$filename.'.v'.$revision,$filesfoldername.'/'.$filename) ) { + if( @$users_view->copy('versions'.$filename.'.v'.$revision, 'files'.$filename) ) { return true; From bd494f562f5c396de557b2887e2b4559d4dfadb9 Mon Sep 17 00:00:00 2001 From: Bjoern Schiessle Date: Thu, 5 Jul 2012 15:03:14 +0200 Subject: [PATCH 06/10] fixed faulty commit --- .htaccess | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.htaccess b/.htaccess index 6d1844dbf9..11ee1d59f8 100755 --- a/.htaccess +++ b/.htaccess @@ -1,8 +1,8 @@ ErrorDocument 403 /core/templates/403.php ErrorDocument 404 /core/templates/404.php -php_value upload_max_filesize 2000M -php_value post_max_size 2000M +php_value upload_max_filesize 513M +php_value post_max_size 513M php_value memory_limit 512M SetEnv htaccessWorking true From 5bf050b13bbac944421ac6e993993237f847068a Mon Sep 17 00:00:00 2001 From: Bjoern Schiessle Date: Thu, 5 Jul 2012 15:55:46 +0200 Subject: [PATCH 07/10] moved performance improvement from isLoggedIn() to userExists() to avoid webdav problems --- lib/user.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/user.php b/lib/user.php index 23b88aa1d0..d02c1208a8 100644 --- a/lib/user.php +++ b/lib/user.php @@ -240,17 +240,13 @@ class OC_User { * Checks if the user is logged in */ public static function isLoggedIn(){ - static $is_login_checked = null; - if (!is_null($is_login_checked)) { - return $is_login_checked; - } if( isset($_SESSION['user_id']) AND $_SESSION['user_id']) { OC_App::loadApps(array('authentication')); if (self::userExists($_SESSION['user_id']) ){ - return $is_login_checked = true; + return true; } } - return $is_login_checked = false; + return false; } /** @@ -349,13 +345,17 @@ class OC_User { * @return boolean */ public static function userExists($uid){ + static $user_exists_checked = null; + if (!is_null($user_exists_checked)) { + return $user_exists_checked; + } foreach(self::$_usedBackends as $backend){ $result=$backend->userExists($uid); if($result===true){ - return true; + return $user_exists_checked = true; } } - return false; + return $user_exists_checked = false; } /** From 5e0b80dc8d824e4b6dcea1732dae5fdfb3216183 Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Thu, 5 Jul 2012 17:12:52 +0200 Subject: [PATCH 08/10] Contacts: Fix copy&paste error --- apps/contacts/lib/addressbook.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/contacts/lib/addressbook.php b/apps/contacts/lib/addressbook.php index f33f4a204e..40675efd8b 100644 --- a/apps/contacts/lib/addressbook.php +++ b/apps/contacts/lib/addressbook.php @@ -41,7 +41,7 @@ class OC_Contacts_Addressbook{ /** * @brief Returns the list of addressbooks for a specific user. * @param string $uid - * @param boolean $active Only return calendars with this $active state, default(=false) is don't care + * @param boolean $active Only return addressbooks with this $active state, default(=false) is don't care * @return array or false. */ public static function all($uid, $active=false){ From 59b38e668dd2a31e55a7bf0bbf6e9cb57cba6f9b Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Fri, 6 Jul 2012 02:46:43 +0200 Subject: [PATCH 09/10] Missing requesttoken --- apps/contacts/js/contacts.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/contacts/js/contacts.js b/apps/contacts/js/contacts.js index 25fc122bf3..39ef14e506 100644 --- a/apps/contacts/js/contacts.js +++ b/apps/contacts/js/contacts.js @@ -327,7 +327,7 @@ Contacts={ // Make sure proper DOM is loaded. if(!$('#card')[0] && newid) { - $.getJSON(OC.filePath('contacts', 'ajax', 'loadcard.php'),{},function(jsondata){ + $.getJSON(OC.filePath('contacts', 'ajax', 'loadcard.php'),{requesttoken:requesttoken},function(jsondata){ if(jsondata.status == 'success'){ $('#rightcontent').html(jsondata.data.page).ready(function() { Contacts.UI.loadHandlers(); From a5a1d929ca2e75332f20f0cafc0711aa0f0608fb Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Fri, 6 Jul 2012 03:22:02 +0200 Subject: [PATCH 10/10] No need for being protected. --- apps/contacts/lib/app.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/contacts/lib/app.php b/apps/contacts/lib/app.php index b3a7abd28b..25461877e6 100644 --- a/apps/contacts/lib/app.php +++ b/apps/contacts/lib/app.php @@ -164,7 +164,7 @@ class OC_Contacts_App { * @brief returns the default categories of ownCloud * @return (array) $categories */ - protected static function getDefaultCategories(){ + public static function getDefaultCategories(){ return array( (string)self::$l10n->t('Birthday'), (string)self::$l10n->t('Business'),