From 4434016a8bcb815b3cc61e5f0f8157e60db6e710 Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Tue, 29 May 2012 17:02:32 +0200 Subject: [PATCH 01/39] Whitespace fixes --- lib/files.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/files.php b/lib/files.php index 072de33004..79d214665d 100644 --- a/lib/files.php +++ b/lib/files.php @@ -32,11 +32,11 @@ class OC_Files { * get the content of a directory * @param dir $directory */ - public static function getDirectoryContent($directory, $mimetype_filter = ''){ + public static function getDirectoryContent($directory, $mimetype_filter = ''){ if(strpos($directory,OC::$CONFIG_DATADIRECTORY)===0){ $directory=substr($directory,strlen(OC::$CONFIG_DATADIRECTORY)); } - $files=OC_FileCache::getFolderContent($directory, '', $mimetype_filter); + $files=OC_FileCache::getFolderContent($directory, '', $mimetype_filter); foreach($files as &$file){ $file['directory']=$directory; $file['type']=($file['mimetype']=='httpd/unix-directory')?'dir':'file'; From 0934a975b2bfb7582fd32d9f067ee1bf2cd5bf81 Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Wed, 30 May 2012 17:47:31 +0200 Subject: [PATCH 02/39] Remove unused L10N variable --- apps/tasks/index.php | 1 - 1 file changed, 1 deletion(-) diff --git a/apps/tasks/index.php b/apps/tasks/index.php index 5e17ca454e..4ff304a560 100644 --- a/apps/tasks/index.php +++ b/apps/tasks/index.php @@ -26,7 +26,6 @@ OCP\Util::addScript('','oc-vcategories'); OCP\App::setActiveNavigationEntry('tasks_index'); $categories = OC_Calendar_App::getCategoryOptions(); -$l10n = new OC_L10N('tasks'); $priority_options = OC_Task_App::getPriorityOptions(); $output = new OCP\Template('tasks', 'tasks', 'user'); $output->assign('priority_options', $priority_options); From 2ae58ee6c01f2ba3a97f6d2741c46ea5dda68792 Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Wed, 30 May 2012 18:23:23 +0200 Subject: [PATCH 03/39] Calendar: small cleanup of import progress writing --- apps/calendar/ajax/import/import.php | 39 +++++++++++----------------- 1 file changed, 15 insertions(+), 24 deletions(-) diff --git a/apps/calendar/ajax/import/import.php b/apps/calendar/ajax/import/import.php index 202af1eb46..904c07c52e 100644 --- a/apps/calendar/ajax/import/import.php +++ b/apps/calendar/ajax/import/import.php @@ -7,16 +7,23 @@ */ //check for calendar rights or create new one ob_start(); + OCP\JSON::checkLoggedIn(); OCP\App::checkAppEnabled('calendar'); + $nl="\r\n"; $comps = array('VEVENT'=>true, 'VTODO'=>true, 'VJOURNAL'=>true); + $progressfile = 'import_tmp/' . md5(session_id()) . '.txt'; -if(is_writable('import_tmp/')){ - $progressfopen = fopen($progressfile, 'w'); - fwrite($progressfopen, '10'); - fclose($progressfopen); + +function writeProgress($pct) { + if(is_writable('import_tmp/')){ + $progressfopen = fopen($progressfile, 'w'); + fwrite($progressfopen, $pct); + fclose($progressfopen); + } } +writeProgress('10'); $file = OC_Filesystem::file_get_contents($_POST['path'] . '/' . $_POST['file']); if($_POST['method'] == 'new'){ $id = OC_Calendar_Calendar::addCalendar(OCP\USER::getUser(), $_POST['calname']); @@ -29,20 +36,12 @@ if($_POST['method'] == 'new'){ } $id = $_POST['id']; } -if(is_writable('import_tmp/')){ - $progressfopen = fopen($progressfile, 'w'); - fwrite($progressfopen, '20'); - fclose($progressfopen); -} +writeProgress('20'); // normalize the newlines $file = str_replace(array("\r","\n\n"), array("\n","\n"), $file); $lines = explode("\n", $file); unset($file); -if(is_writable('import_tmp/')){ - $progressfopen = fopen($progressfile, 'w'); - fwrite($progressfopen, '30'); - fclose($progressfopen); -} +writeProgress('30'); // analyze the file, group components by uid, and keep refs to originating calendar object // $cals is array calendar objects, keys are 1st line# $cal, ie array( $cal => $caldata ) // $caldata is array( 'first' => 1st component line#, 'last' => last comp line#, 'end' => end line# ) @@ -86,11 +85,7 @@ foreach($lines as $line) { $i++; } // import the calendar -if(is_writable('import_tmp/')){ - $progressfopen = fopen($progressfile, 'w'); - fwrite($progressfopen, '60'); - fclose($progressfopen); -} +writeProgress('60'); foreach($uids as $uid) { $prefix=$suffix=$content=array(); @@ -117,11 +112,7 @@ foreach($uids as $uid) { } } // finished import -if(is_writable('import_tmp/')){ - $progressfopen = fopen($progressfile, 'w'); - fwrite($progressfopen, '100'); - fclose($progressfopen); -} +writeProgress('100'); sleep(3); if(is_writable('import_tmp/')){ unlink($progressfile); From a33f580db10483f6daa6142923633a3b1d808794 Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Thu, 31 May 2012 13:00:58 +0200 Subject: [PATCH 04/39] Remove OC_App::register function The data supplied is never used in OwnCloud. Removed the call from all the apps, and made the public API function empty. --- apps/admin_dependencies_chk/appinfo/app.php | 5 --- apps/bookmarks/appinfo/app.php | 2 -- apps/calendar/appinfo/app.php | 4 --- apps/contacts/appinfo/app.php | 5 --- apps/external/appinfo/app.php | 2 -- apps/files/appinfo/app.php | 1 - apps/files_versions/appinfo/app.php | 8 +---- apps/gallery/appinfo/app.php | 5 --- apps/media/appinfo/app.php | 2 -- apps/remoteStorage/appinfo/app.php | 4 --- apps/tasks/appinfo/app.php | 5 --- apps/user_webfinger/appinfo/app.php | 4 --- lib/app.php | 40 +-------------------- lib/public/app.php | 1 - search/appinfo/app.php | 5 --- settings/appinfo/app.php | 7 ---- 16 files changed, 2 insertions(+), 98 deletions(-) delete mode 100644 search/appinfo/app.php delete mode 100644 settings/appinfo/app.php diff --git a/apps/admin_dependencies_chk/appinfo/app.php b/apps/admin_dependencies_chk/appinfo/app.php index 72d368a085..62b26342d2 100644 --- a/apps/admin_dependencies_chk/appinfo/app.php +++ b/apps/admin_dependencies_chk/appinfo/app.php @@ -1,9 +1,4 @@ 14, - 'id' => 'admin_dependencies_chk', - 'name' => 'Owncloud Install Info' )); - OCP\App::registerAdmin('admin_dependencies_chk','settings'); diff --git a/apps/bookmarks/appinfo/app.php b/apps/bookmarks/appinfo/app.php index 8a8f443891..f4bca9df70 100644 --- a/apps/bookmarks/appinfo/app.php +++ b/apps/bookmarks/appinfo/app.php @@ -10,8 +10,6 @@ OC::$CLASSPATH['OC_Bookmarks_Bookmarks'] = 'apps/bookmarks/lib/bookmarks.php'; OC::$CLASSPATH['OC_Search_Provider_Bookmarks'] = 'apps/bookmarks/lib/search.php'; -OCP\App::register( array( 'order' => 70, 'id' => 'bookmark', 'name' => 'Bookmarks' )); - $l = new OC_l10n('bookmarks'); OCP\App::addNavigationEntry( array( 'id' => 'bookmarks_index', 'order' => 70, 'href' => OCP\Util::linkTo( 'bookmarks', 'index.php' ), 'icon' => OCP\Util::imagePath( 'bookmarks', 'bookmarks.png' ), 'name' => $l->t('Bookmarks'))); diff --git a/apps/calendar/appinfo/app.php b/apps/calendar/appinfo/app.php index b02fc602c6..886c218f7c 100644 --- a/apps/calendar/appinfo/app.php +++ b/apps/calendar/appinfo/app.php @@ -11,10 +11,6 @@ OCP\Util::connectHook('OC_User', 'post_deleteUser', 'OC_Calendar_Hooks', 'delete OCP\Util::addscript('calendar','loader'); OCP\Util::addscript("3rdparty", "chosen/chosen.jquery.min"); OCP\Util::addStyle("3rdparty", "chosen/chosen"); -OCP\App::register( array( - 'order' => 10, - 'id' => 'calendar', - 'name' => 'Calendar' )); OCP\App::addNavigationEntry( array( 'id' => 'calendar_index', 'order' => 10, diff --git a/apps/contacts/appinfo/app.php b/apps/contacts/appinfo/app.php index 20d97697bf..7a04ec7ff5 100644 --- a/apps/contacts/appinfo/app.php +++ b/apps/contacts/appinfo/app.php @@ -9,11 +9,6 @@ OCP\Util::connectHook('OC_User', 'post_deleteUser', 'OC_Contacts_Hooks', 'delete OCP\Util::connectHook('OC_Calendar', 'getEvents', 'OC_Contacts_Hooks', 'getBirthdayEvents'); OCP\Util::connectHook('OC_Calendar', 'getSources', 'OC_Contacts_Hooks', 'getCalenderSources'); -OCP\App::register( array( - 'order' => 10, - 'id' => 'contacts', - 'name' => 'Contacts' )); - OCP\App::addNavigationEntry( array( 'id' => 'contacts_index', 'order' => 10, diff --git a/apps/external/appinfo/app.php b/apps/external/appinfo/app.php index ee5437782c..1a02f3a1be 100644 --- a/apps/external/appinfo/app.php +++ b/apps/external/appinfo/app.php @@ -26,8 +26,6 @@ OCP\Util::addStyle( 'external', 'style'); OCP\App::registerAdmin('external', 'settings'); -OCP\App::register(array('order' => 70, 'id' => 'external', 'name' => 'External')); - $sites = OC_External::getSites(); for ($i = 0; $i < sizeof($sites); $i++) { OCP\App::addNavigationEntry( diff --git a/apps/files/appinfo/app.php b/apps/files/appinfo/app.php index 5c0d3c8db8..db3b213ab8 100644 --- a/apps/files/appinfo/app.php +++ b/apps/files/appinfo/app.php @@ -1,7 +1,6 @@ 2, "id" => "files", "name" => "Files" )); OCP\App::registerAdmin('files','admin'); OCP\App::addNavigationEntry( array( "id" => "files_index", "order" => 0, "href" => OCP\Util::linkTo( "files", "index.php" ), "icon" => OCP\Util::imagePath( "core", "places/home.svg" ), "name" => $l->t("Files") )); diff --git a/apps/files_versions/appinfo/app.php b/apps/files_versions/appinfo/app.php index 457c512535..49f1573f7c 100644 --- a/apps/files_versions/appinfo/app.php +++ b/apps/files_versions/appinfo/app.php @@ -2,14 +2,8 @@ require_once('apps/files_versions/versions.php'); -// Add an entry in the app list -OCP\App::register( array( - 'order' => 10, - 'id' => 'files_versions', - 'name' => 'Versioning' )); - OCP\App::registerAdmin('files_versions', 'settings'); OCP\Util::addscript('files_versions', 'versions'); // Listen to write signals -OCP\Util::connectHook(OC_Filesystem::CLASSNAME, OC_Filesystem::signal_post_write, "OCA_Versions\Storage", "write_hook"); \ No newline at end of file +OCP\Util::connectHook(OC_Filesystem::CLASSNAME, OC_Filesystem::signal_post_write, "OCA_Versions\Storage", "write_hook"); diff --git a/apps/gallery/appinfo/app.php b/apps/gallery/appinfo/app.php index 878da48698..e1db33eb31 100644 --- a/apps/gallery/appinfo/app.php +++ b/apps/gallery/appinfo/app.php @@ -29,11 +29,6 @@ OC::$CLASSPATH['OC_Gallery_Hooks_Handlers'] = 'apps/gallery/lib/hooks_handlers.p $l = OC_L10N::get('gallery'); -OCP\App::register(array( - 'order' => 20, - 'id' => 'gallery', - 'name' => 'Pictures')); - OCP\App::addNavigationEntry( array( 'id' => 'gallery_index', 'order' => 20, diff --git a/apps/media/appinfo/app.php b/apps/media/appinfo/app.php index d6a09c4805..869bc34402 100644 --- a/apps/media/appinfo/app.php +++ b/apps/media/appinfo/app.php @@ -29,8 +29,6 @@ require_once('apps/media/lib_scanner.php'); OCP\Util::addscript('media','loader'); OCP\App::registerPersonal('media','settings'); -OCP\App::register( array( 'order' => 3, 'id' => 'media', 'name' => 'Media' )); - OCP\App::addNavigationEntry(array('id' => 'media_index', 'order' => 2, 'href' => OCP\Util::linkTo('media', 'index.php'), 'icon' => OCP\Util::imagePath('core', 'places/music.svg'), 'name' => $l->t('Music'))); OC_Search::registerProvider('OC_MediaSearchProvider'); diff --git a/apps/remoteStorage/appinfo/app.php b/apps/remoteStorage/appinfo/app.php index 14b8a3d11d..c278fd7305 100644 --- a/apps/remoteStorage/appinfo/app.php +++ b/apps/remoteStorage/appinfo/app.php @@ -1,6 +1,2 @@ 10, - 'id' => 'remoteStorage', - 'name' => 'remoteStorage compatibility' )); OCP\App::registerPersonal('remoteStorage','settings'); diff --git a/apps/tasks/appinfo/app.php b/apps/tasks/appinfo/app.php index f346e2aa4c..e7c82d6f24 100644 --- a/apps/tasks/appinfo/app.php +++ b/apps/tasks/appinfo/app.php @@ -3,11 +3,6 @@ $l=new OC_L10N('tasks'); OC::$CLASSPATH['OC_Calendar_Calendar'] = 'apps/calendar/lib/calendar.php'; OC::$CLASSPATH['OC_Task_App'] = 'apps/tasks/lib/app.php'; -OCP\App::register( array( - 'order' => 11, - 'id' => 'tasks', - 'name' => 'Tasks' )); - OCP\App::addNavigationEntry( array( 'id' => 'tasks_index', 'order' => 11, diff --git a/apps/user_webfinger/appinfo/app.php b/apps/user_webfinger/appinfo/app.php index a45efd96a4..3336af6682 100644 --- a/apps/user_webfinger/appinfo/app.php +++ b/apps/user_webfinger/appinfo/app.php @@ -1,7 +1,3 @@ 11, - 'id' => 'user_webfinger', - 'name' => 'Webfinger' )); OCP\CONFIG::setAppValue('core', 'public_host-meta', '/apps/user_webfinger/host-meta.php'); OCP\CONFIG::setAppValue('core', 'public_webfinger', '/apps/user_webfinger/webfinger.php'); diff --git a/lib/app.php b/lib/app.php index 78de0fa21b..124b76cdc3 100755 --- a/lib/app.php +++ b/lib/app.php @@ -28,7 +28,6 @@ */ class OC_App{ static private $init = false; - static private $apps = array(); static private $activeapp = ''; static private $navigation = array(); static private $settingsForms = array(); @@ -54,14 +53,7 @@ class OC_App{ return true; } - // Our very own core apps are hardcoded - foreach( array( 'settings') as $app ){ - if(is_null($types)){ - require( $app.'/appinfo/app.php' ); - } - } - - // The rest comes here + // Load the enabled apps here $apps = self::getEnabledApps(); // prevent app.php from printing output ob_start(); @@ -216,36 +208,6 @@ class OC_App{ OC_Appconfig::setValue( $app, 'enabled', 'no' ); } - /** - * @brief makes owncloud aware of this app - * @param $data array with all information - * @returns true/false - * - * This function registers the application. $data is an associative array. - * The following keys are required: - * - id: id of the application, has to be unique ('addressbook') - * - name: Human readable name ('Addressbook') - * - version: array with Version (major, minor, bugfix) ( array(1, 0, 2)) - * - * The following keys are optional: - * - order: integer, that influences the position of your application in - * a list of applications. Lower values come first. - * - */ - public static function register( $data ){ - OC_App::$apps[] = $data; - } - - /** - * @brief returns information of all apps - * @return array with all information - * - * This function returns all data it got via register(). - */ - public static function get(){ - return OC_App::$apps; - } - /** * @brief adds an entry to the navigation * @param $data array containing the data diff --git a/lib/public/app.php b/lib/public/app.php index 3960db6d89..1f84087f07 100644 --- a/lib/public/app.php +++ b/lib/public/app.php @@ -52,7 +52,6 @@ class App { * */ public static function register( $data ){ - return \OC_App::register( $data ); } diff --git a/search/appinfo/app.php b/search/appinfo/app.php deleted file mode 100644 index b91341643f..0000000000 --- a/search/appinfo/app.php +++ /dev/null @@ -1,5 +0,0 @@ - 2, "id" => 'search', 'name' => 'Search' )); - -?> diff --git a/settings/appinfo/app.php b/settings/appinfo/app.php deleted file mode 100644 index d18bcdbff0..0000000000 --- a/settings/appinfo/app.php +++ /dev/null @@ -1,7 +0,0 @@ - "settings", "name" => "Settings" )); -OC_App::register( array( "order" => 1, "id" => "admin", "name" => "Administration" )); -OC_App::register( array( "order" => 1, "id" => "help", "name" => "Help" )); - -?> From 3b36a9b704339b409c1065e843d33e3b8c8dc213 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Thu, 31 May 2012 13:06:27 +0200 Subject: [PATCH 05/39] LDAP: make queries compatible also with PostgreSQL --- apps/user_ldap/lib_ldap.php | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/apps/user_ldap/lib_ldap.php b/apps/user_ldap/lib_ldap.php index 5cd7e0241b..b900a67ec3 100644 --- a/apps/user_ldap/lib_ldap.php +++ b/apps/user_ldap/lib_ldap.php @@ -366,19 +366,24 @@ class OC_LDAP { $table = self::getMapTable($isUser); $dn = self::sanitizeDN($dn); - $sqliteAdjustment = ''; + $sqlAdjustment = ''; $dbtype = OCP\Config::getSystemValue('dbtype'); - if(($dbtype == 'sqlite') || ($dbtype == 'sqlite3')) { - $sqliteAdjustment = 'OR'; + if($dbtype == 'mysql') { + $sqlAdjustment = 'FROM dual'; } $insert = OCP\DB::prepare(' - INSERT '.$sqliteAdjustment.' IGNORE INTO '.$table.' - (ldap_dn, owncloud_name) - VALUES (?,?) + INSERT INTO '.$table.' (ldap_dn, owncloud_name) + SELECT ?,? + '.$sqlAdjustment.' + WHERE NOT EXISTS ( + SELECT 1 + FROM '.$table.' + WHERE ldap_dn = ? + AND owncloud_name = ? ) '); - $res = $insert->execute(array($dn, $ocname)); + $res = $insert->execute(array($dn, $ocname, $dn, $ocname)); return !OCP\DB::isError($res); } From e93bb5135d0d12d3811f8c1eeaf162a613a3d98d Mon Sep 17 00:00:00 2001 From: Sam Tuke Date: Thu, 31 May 2012 12:25:07 +0100 Subject: [PATCH 06/39] Applied fix from kalassico for "Chiper text must be a string" bug (http://forum.owncloud.org/viewtopic.php?f=3&t=2586&p=5094) --- apps/files_encryption/lib/crypt.php | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/apps/files_encryption/lib/crypt.php b/apps/files_encryption/lib/crypt.php index ec27900cbc..d2b8ad145a 100644 --- a/apps/files_encryption/lib/crypt.php +++ b/apps/files_encryption/lib/crypt.php @@ -43,16 +43,23 @@ class OC_Crypt { self::init($params['uid'],$params['password']); } - public static function init($login,$password) { - $view=new OC_FilesystemView('/'.$login); - OC_FileProxy::$enabled=false; - if(!$view->file_exists('/encryption.key')){// does key exist? - OC_Crypt::createkey($login,$password); - } - $key=$view->file_get_contents('/encryption.key'); - OC_FileProxy::$enabled=true; - $_SESSION['enckey']=OC_Crypt::decrypt($key, $password); - } + public static function init($login,$password) { + $view1=new OC_FilesystemView('/'); + if(!$view1->file_exists('/'.$login)){ + $view1->mkdir('/'.$login); + } + + $view=new OC_FilesystemView('/'.$login); + + OC_FileProxy::$enabled=false; + if(!$view->file_exists('/encryption.key')){// does key exist? + OC_Crypt::createkey($login,$password); + } + $key=$view->file_get_contents('/encryption.key'); + OC_FileProxy::$enabled=true; + $_SESSION['enckey']=OC_Crypt::decrypt($key, $password); + } + /** * get the blowfish encryption handeler for a key From 43fcae0409d558cbbbd7571fa731391e20c4b5d9 Mon Sep 17 00:00:00 2001 From: Sam Tuke Date: Thu, 31 May 2012 14:50:41 +0100 Subject: [PATCH 07/39] clarified comment --- lib/filesystemview.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/filesystemview.php b/lib/filesystemview.php index d893bd4d3d..105ffb80af 100644 --- a/lib/filesystemview.php +++ b/lib/filesystemview.php @@ -103,7 +103,7 @@ class OC_FilesystemView { } /** - * following functions are equivilent to their php buildin equivilents for arguments/return values. + * the following functions operate with arguments and return values identical to those of their PHP built-in equivalents */ public function mkdir($path){ return $this->basicOperation('mkdir',$path,array('create','write')); From fc400e06c339f41b25ac5fe158c37c473634f39e Mon Sep 17 00:00:00 2001 From: Sam Tuke Date: Thu, 31 May 2012 14:53:52 +0100 Subject: [PATCH 08/39] fixed typos in var names --- lib/filesystemview.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/filesystemview.php b/lib/filesystemview.php index 105ffb80af..a55a3a70de 100644 --- a/lib/filesystemview.php +++ b/lib/filesystemview.php @@ -345,7 +345,7 @@ class OC_FilesystemView { */ private function basicOperation($operation,$path,$hooks=array(),$extraParam=null){ if(OC_FileProxy::runPreProxies($operation,$path, $extraParam) and OC_Filesystem::isValidPath($path)){ - $interalPath=$this->getInternalPath($path); + $internalPath=$this->getInternalPath($path); $run=true; if(OC_Filesystem::$loaded and $this->fakeRoot==OC_Filesystem::getRoot()){ foreach($hooks as $hook){ @@ -358,9 +358,9 @@ class OC_FilesystemView { } if($run and $storage=$this->getStorage($path)){ if(!is_null($extraParam)){ - $result=$storage->$operation($interalPath,$extraParam); + $result=$storage->$operation($internalPath,$extraParam); }else{ - $result=$storage->$operation($interalPath); + $result=$storage->$operation($internalPath); } $result=OC_FileProxy::runPostProxies($operation,$path,$result); if(OC_Filesystem::$loaded and $this->fakeRoot==OC_Filesystem::getRoot()){ From 8744b09959de4bfff523555f77c76a0a2153e338 Mon Sep 17 00:00:00 2001 From: Sam Tuke Date: Thu, 31 May 2012 17:02:35 +0100 Subject: [PATCH 09/39] added extensive class comment based on icewind's January list email --- lib/filesystemview.php | 52 +++++++++++++++++++++++++++--------------- 1 file changed, 33 insertions(+), 19 deletions(-) diff --git a/lib/filesystemview.php b/lib/filesystemview.php index a55a3a70de..dcbdd1ae12 100644 --- a/lib/filesystemview.php +++ b/lib/filesystemview.php @@ -1,25 +1,39 @@ . -* -*/ + * ownCloud + * + * @author Frank Karlitschek + * @copyright 2012 Frank Karlitschek frank@owncloud.org + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE + * License as published by the Free Software Foundation; either + * version 3 of the License, or any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU Affero General Public + * License along with this library. If not, see . + */ + + +/** + * Class to provide app access to files outside of the currently logged in user's data + * folder. Functions are provided to create a "view" into ownCloud's virtual file + * system, and an API similar to the oc_filesystem class is available for manipulating + * those files (including the ability to read, write, and delete files). + * + * Every view can have it's own chroot, giving it access to a part of the + * filesystem and will provide the same functionality as oc_filesystem. + + * For instance an app can create a new filesystem view on a data folder belonging + * to a user other than the one logged in, so that it may change the files there + * (use case: enabling sharing of files). + */ class OC_FilesystemView { private $fakeRoot=''; From 6b3df8ae9c61ce6badc653d293eac7d61820f144 Mon Sep 17 00:00:00 2001 From: Sam Tuke Date: Thu, 31 May 2012 17:32:34 +0100 Subject: [PATCH 10/39] Improved class comment block --- lib/filesystemview.php | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/lib/filesystemview.php b/lib/filesystemview.php index dcbdd1ae12..c62c48d528 100644 --- a/lib/filesystemview.php +++ b/lib/filesystemview.php @@ -22,17 +22,18 @@ /** - * Class to provide app access to files outside of the currently logged in user's data - * folder. Functions are provided to create a "view" into ownCloud's virtual file - * system, and an API similar to the oc_filesystem class is available for manipulating - * those files (including the ability to read, write, and delete files). + * Class to provide access to ownCloud filesystem via a "view", and methods for + * working with files within that view (e.g. read, write, delete, etc.). Each + * view is restricted to a set of directories via a virtual root. The default view + * uses the currently logged in user's data directory as root (parts of + * OC_Filesystem are merely a wrapper for OC_FilesystemView). + * + * Apps that need to access files outside of the user data folders (to modify files + * belonging to a user other than the one currently logged in, for example) should + * use this class directly rather than using OC_Filesystem, or making use of PHP's + * built-in file manipulation functions. This will ensure all hooks and proxies + * are triggered correctly. * - * Every view can have it's own chroot, giving it access to a part of the - * filesystem and will provide the same functionality as oc_filesystem. - - * For instance an app can create a new filesystem view on a data folder belonging - * to a user other than the one logged in, so that it may change the files there - * (use case: enabling sharing of files). */ class OC_FilesystemView { From ef60dcc23e0c751dbcc9f6dfc4f1277cf30db82b Mon Sep 17 00:00:00 2001 From: Sam Tuke Date: Thu, 31 May 2012 17:38:35 +0100 Subject: [PATCH 11/39] fixed typo --- lib/filestorage.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/filestorage.php b/lib/filestorage.php index d05acd3674..1d7e004af3 100644 --- a/lib/filestorage.php +++ b/lib/filestorage.php @@ -21,7 +21,7 @@ */ /** - * Privde a common interface to all different storage options + * Provde a common interface to all different storage options */ abstract class OC_Filestorage{ public function __construct($parameters){} From ec0c0f3907d08c886f392eb99da19d5a39bf48cf Mon Sep 17 00:00:00 2001 From: Sam Tuke Date: Thu, 31 May 2012 17:57:34 +0100 Subject: [PATCH 12/39] Added & improved documentation --- lib/filesystemview.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/filesystemview.php b/lib/filesystemview.php index c62c48d528..c8df59cf82 100644 --- a/lib/filesystemview.php +++ b/lib/filesystemview.php @@ -33,7 +33,9 @@ * use this class directly rather than using OC_Filesystem, or making use of PHP's * built-in file manipulation functions. This will ensure all hooks and proxies * are triggered correctly. - * + * + * Filesystem functions are not called directly; they are passed to the correct + * OC_Filestorage object */ class OC_FilesystemView { @@ -118,7 +120,9 @@ class OC_FilesystemView { } /** - * the following functions operate with arguments and return values identical to those of their PHP built-in equivalents + * the following functions operate with arguments and return values identical + * to those of their PHP built-in equivalents. Mostly they are merely wrappers + * for OC_Filestorage via basicOperation(). */ public function mkdir($path){ return $this->basicOperation('mkdir',$path,array('create','write')); @@ -351,12 +355,16 @@ class OC_FilesystemView { } /** - * abstraction for running most basic operations + * @brief abstraction layer for basic filesystem functions: wrapper for OC_Filestorage * @param string $operation * @param string #path * @param array (optional) hooks * @param mixed (optional) $extraParam * @return mixed + * + * This method takes requests for basic filesystem functions (e.g. reading & writing + * files), processes hooks and proxies, sanitises paths, and finally passes them on to + * OC_Filestorage for delegation to a storage backend for execution */ private function basicOperation($operation,$path,$hooks=array(),$extraParam=null){ if(OC_FileProxy::runPreProxies($operation,$path, $extraParam) and OC_Filesystem::isValidPath($path)){ From 3db28d7616ffcc09aa23e4ab50bf6b5224c98a7c Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Thu, 31 May 2012 19:46:32 +0200 Subject: [PATCH 13/39] linkTo instead of hard links in Files and Files_Archive. Hope that makes sense. --- apps/files/js/fileactions.js | 2 +- apps/files/js/filelist.js | 4 ++-- apps/files_archive/js/archive.js | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/files/js/fileactions.js b/apps/files/js/fileactions.js index 68268a7d3a..19978b61a7 100644 --- a/apps/files/js/fileactions.js +++ b/apps/files/js/fileactions.js @@ -161,7 +161,7 @@ FileActions.register('all','Rename',function(){return OC.imagePath('core','actio }); FileActions.register('dir','Open','',function(filename){ - window.location='index.php?dir='+encodeURIComponent($('#dir').val()).replace(/%2F/g, '/')+'/'+encodeURIComponent(filename); + window.location=OC.linkTo('files', 'index.php') + '&dir='+encodeURIComponent($('#dir').val()).replace(/%2F/g, '/')+'/'+encodeURIComponent(filename); }); FileActions.setDefault('dir','Open'); diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index 31fb5f892e..e6a9a6883a 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -41,7 +41,7 @@ FileList={ html = $('').attr({ "data-type": "dir", "data-size": size, "data-file": name}); td = $('').attr({"class": "filename", "style": 'background-image:url('+OC.imagePath('core', 'filetypes/folder.png')+')' }); td.append(''); - var link_elem = $('').attr({ "class": "name", "href": "index.php?dir="+ encodeURIComponent($('#dir').val()+'/'+name).replace(/%2F/g, '/') }); + var link_elem = $('').attr({ "class": "name", "href": OC.linkTo('files', 'index.php')+"&dir="+ encodeURIComponent($('#dir').val()+'/'+name).replace(/%2F/g, '/') }); link_elem.append($('').addClass('nametext').text(name)); link_elem.append($('').attr({'class': 'uploadtext', 'currentUploads': 0})); td.append(link_elem); @@ -56,7 +56,7 @@ FileList={ modifiedColor=Math.round((Math.round((new Date()).getTime() / 1000)-lastModifiedTime)/60/60/24*5); td = $('').attr({ "class": "filesize", "title": humanFileSize(size), "style": 'color:rgb('+sizeColor+','+sizeColor+','+sizeColor+')'}).text(simpleSize); html.append(td); - + td = $('').attr({ "class": "date" }); td.append($('').attr({ "class": "modified", "title": formatDate(lastModified), "style": 'color:rgb('+modifiedColor+','+modifiedColor+','+modifiedColor+')' }).text( relative_modified_date(lastModified.getTime() / 1000) )); html.append(td); diff --git a/apps/files_archive/js/archive.js b/apps/files_archive/js/archive.js index 531eb61c01..9fb9853e29 100644 --- a/apps/files_archive/js/archive.js +++ b/apps/files_archive/js/archive.js @@ -8,11 +8,11 @@ $(document).ready(function() { if(typeof FileActions!=='undefined'){ FileActions.register('application/zip','Open','',function(filename){ - window.location='index.php?dir='+encodeURIComponent($('#dir').val()).replace(/%2F/g, '/')+'/'+encodeURIComponent(filename); + window.location=OC.linkTo('files', 'index.php')+'&dir='+encodeURIComponent($('#dir').val()).replace(/%2F/g, '/')+'/'+encodeURIComponent(filename); }); FileActions.setDefault('application/zip','Open'); FileActions.register('application/x-gzip','Open','',function(filename){ - window.location='index.php?dir='+encodeURIComponent($('#dir').val()).replace(/%2F/g, '/')+'/'+encodeURIComponent(filename); + window.location=OC.linkTo('files', 'index.php')+'&dir='+encodeURIComponent($('#dir').val()).replace(/%2F/g, '/')+'/'+encodeURIComponent(filename); }); FileActions.setDefault('application/x-gzip','Open'); } From f0bd57186686689d0f65c356cd7f226c045dd6e3 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Thu, 31 May 2012 20:00:46 +0200 Subject: [PATCH 14/39] fix potential XSS --- apps/calendar/templates/part.choosecalendar.rowfields.php | 2 +- .../calendar/templates/part.choosecalendar.rowfields.shared.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/calendar/templates/part.choosecalendar.rowfields.php b/apps/calendar/templates/part.choosecalendar.rowfields.php index 965523f847..bad268897b 100644 --- a/apps/calendar/templates/part.choosecalendar.rowfields.php +++ b/apps/calendar/templates/part.choosecalendar.rowfields.php @@ -1,6 +1,6 @@ '; -echo ''; +echo ''; echo ''; echo ''; echo ''; diff --git a/apps/calendar/templates/part.choosecalendar.rowfields.shared.php b/apps/calendar/templates/part.choosecalendar.rowfields.shared.php index a23266da0c..6a212858a2 100644 --- a/apps/calendar/templates/part.choosecalendar.rowfields.shared.php +++ b/apps/calendar/templates/part.choosecalendar.rowfields.shared.php @@ -1,4 +1,4 @@ '; -echo ''; +echo ''; echo '' . $l->t('shared with you by') . ' ' . $_['share']['owner'] . ''; \ No newline at end of file From d4ea853fcf3b3f82e2e489c81280b27bfbd62bf3 Mon Sep 17 00:00:00 2001 From: Frank Karlitschek Date: Thu, 31 May 2012 20:26:09 +0200 Subject: [PATCH 15/39] use our own serverHost call so that ownCloud works with reverse proxy servers --- apps/files_sharing/ajax/email.php | 4 ++-- apps/user_openid/phpmyid.php | 2 +- apps/user_openid/user_openid.php | 4 ++-- core/lostpassword/index.php | 2 +- lib/ocs.php | 4 ++-- ocs/providers.php | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/apps/files_sharing/ajax/email.php b/apps/files_sharing/ajax/email.php index 163683cd0e..523c3d2078 100644 --- a/apps/files_sharing/ajax/email.php +++ b/apps/files_sharing/ajax/email.php @@ -7,7 +7,7 @@ $type = (strpos($_POST['file'], '.') === false) ? 'folder' : 'file'; $subject = $user.' shared a '.$type.' with you'; $link = $_POST['link']; $text = $user.' shared the '.$type.' '.$_POST['file'].' with you. It is available for download here: '.$link; -$fromaddress = OCP\Config::getUserValue($user, 'settings', 'email', 'sharing-noreply@'.$_SERVER['HTTP_HOST']); +$fromaddress = OCP\Config::getUserValue($user, 'settings', 'email', 'sharing-noreply@'.OCP\Util::getServerHost()); OC_Mail::send($_POST['toaddress'], $_POST['toaddress'], $subject, $text, $fromaddress, $user); -?> \ No newline at end of file +?> diff --git a/apps/user_openid/phpmyid.php b/apps/user_openid/phpmyid.php index 137daa485a..5aaab64285 100644 --- a/apps/user_openid/phpmyid.php +++ b/apps/user_openid/phpmyid.php @@ -1624,7 +1624,7 @@ if (! array_key_exists('idp_url', $profile)) //Determine the requested URL - DO NOT OVERRIDE $profile['req_url'] = sprintf("%s://%s%s", $proto, - $_SERVER['HTTP_HOST'], + OCP\Util::getServerHost(), // $port,//host already includes the path $_SERVER["REQUEST_URI"]); diff --git a/apps/user_openid/user_openid.php b/apps/user_openid/user_openid.php index 8deb42f68c..3267db3fa0 100644 --- a/apps/user_openid/user_openid.php +++ b/apps/user_openid/user_openid.php @@ -39,9 +39,9 @@ class OC_USER_OPENID extends OC_User_Backend { // Get identity from user and redirect browser to OpenID Server $openid = new SimpleOpenID; $openid->SetIdentity($uid); - $openid->SetTrustRoot('http://' . $_SERVER["HTTP_HOST"]); + $openid->SetTrustRoot('http://' . OCP\Util::getServerHost()); if ($openid->GetOpenIDServer()){ - $openid->SetApprovedURL('http://' . $_SERVER["HTTP_HOST"] . OC::$WEBROOT); // Send Response from OpenID server to this script + $openid->SetApprovedURL('http://' . OCP\Util::getServerHost() . OC::$WEBROOT); // Send Response from OpenID server to this script $openid->Redirect(); // This will redirect user to OpenID Server exit; }else{ diff --git a/core/lostpassword/index.php b/core/lostpassword/index.php index 6a4748588f..f1d90eaeff 100644 --- a/core/lostpassword/index.php +++ b/core/lostpassword/index.php @@ -22,7 +22,7 @@ if (isset($_POST['user'])) { $tmpl->assign('link', $link); $msg = $tmpl->fetchPage(); $l = OC_L10N::get('core'); - $from = 'lostpassword-noreply@' . $_SERVER['HTTP_HOST']; + $from = 'lostpassword-noreply@' . OCP\Util::getServerHost(); $r=mail($email, $l->t('Owncloud password reset'), $msg, 'From:' . $from); OC_MAIL::send($email,$_POST['user'],$l->t('ownCloud password reset'),$msg,$from,'ownCloud'); echo('sent'); diff --git a/lib/ocs.php b/lib/ocs.php index e28eb61987..1be41202d7 100644 --- a/lib/ocs.php +++ b/lib/ocs.php @@ -357,11 +357,11 @@ class OC_OCS { */ private static function apiConfig($format) { $user=OC_OCS::checkpassword(false); - $url=substr($_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME'],0,-11).''; + $url=substr(OCP\Util::getServerHost().$_SERVER['SCRIPT_NAME'],0,-11).''; $xml['version']='1.5'; $xml['website']='ownCloud'; - $xml['host']=$_SERVER['HTTP_HOST']; + $xml['host']=OCP\Util::getServerHost(); $xml['contact']=''; $xml['ssl']='false'; echo(OC_OCS::generatexml($format,'ok',100,'',$xml,'config','',1)); diff --git a/ocs/providers.php b/ocs/providers.php index 397d2f06f5..adaa28db6c 100644 --- a/ocs/providers.php +++ b/ocs/providers.php @@ -23,7 +23,7 @@ require_once('../lib/base.php'); -$url='http://'.substr($_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'],0,-17).'ocs/v1.php/'; +$url='http://'.substr(OCP\Util::getServerHost().$_SERVER['REQUEST_URI'],0,-17).'ocs/v1.php/'; echo(' From 57a56299d8a216cad170e0510167d0d7777f1f8a Mon Sep 17 00:00:00 2001 From: Frank Karlitschek Date: Thu, 31 May 2012 21:10:03 +0200 Subject: [PATCH 16/39] =?UTF-8?q?more=20fixes=20i=20don=C2=B4t=20understan?= =?UTF-8?q?d=20why=20this=20worked=20before.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/files_versions/versions.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/apps/files_versions/versions.php b/apps/files_versions/versions.php index 8a88808f54..ed4fd97e51 100644 --- a/apps/files_versions/versions.php +++ b/apps/files_versions/versions.php @@ -96,14 +96,14 @@ class Storage { } // check filesize - if(filesize($filesfoldername.$filename)>\OCP\Config::getSystemValue('files_versionsmaxfilesize', Storage::DEFAULTMAXFILESIZE)){ + if(filesize($filesfoldername.'/'.$filename)>\OCP\Config::getSystemValue('files_versionsmaxfilesize', Storage::DEFAULTMAXFILESIZE)){ return false; } // check mininterval if the file is being modified by the owner (all shared files should be versioned despite mininterval) if ($uid == \OCP\User::getUser()) { - $matches=glob($versionsfoldername.$filename.'.v*'); + $matches=glob($versionsfoldername.'/'.$filename.'.v*'); sort($matches); $parts=explode('.v',end($matches)); if((end($parts)+Storage::DEFAULTMININTERVAL)>time()){ @@ -114,10 +114,10 @@ class Storage { // create all parent folders $info=pathinfo($filename); - @mkdir($versionsfoldername.$info['dirname'],0700,true); + if(!file_exists($versionsfoldername.'/'.$info['dirname'])) mkdir($versionsfoldername.'/'.$info['dirname'],0700,true); // store a new version of a file - copy($filesfoldername.$filename,$versionsfoldername.$filename.'.v'.time()); + copy($filesfoldername.'/'.$filename,$versionsfoldername.'/'.$filename.'.v'.time()); // expire old revisions Storage::expire($filename); @@ -143,7 +143,7 @@ class Storage { $filesfoldername=\OCP\Config::getSystemValue('datadirectory').'/'. $uid .'/files'; // rollback - if ( @copy($versionsfoldername.$filename.'.v'.$revision,$filesfoldername.$filename) ) { + if ( @copy($versionsfoldername.'/'.$filename.'.v'.$revision,$filesfoldername.$filename) ) { return true; @@ -172,7 +172,7 @@ class Storage { $versionsfoldername=\OCP\Config::getSystemValue('datadirectory').'/'. $uid .'/'.\OCP\Config::getSystemValue('files_versionsfolder', Storage::DEFAULTFOLDER); // check for old versions - $matches=glob($versionsfoldername.$filename.'.v*'); + $matches=glob($versionsfoldername.'/'.$filename.'.v*'); if(count($matches)>1){ return true; }else{ @@ -201,7 +201,7 @@ class Storage { $versions=array(); // fetch for old versions - $matches=glob($versionsfoldername.$filename.'.v*'); + $matches=glob($versionsfoldername.'/'.$filename.'.v*'); sort($matches); foreach($matches as $ma) { $parts=explode('.v',$ma); @@ -238,14 +238,14 @@ class Storage { $versionsfoldername=\OCP\Config::getSystemValue('datadirectory').'/'. $uid .'/'.\OCP\Config::getSystemValue('files_versionsfolder', Storage::DEFAULTFOLDER); // check for old versions - $matches=glob($versionsfoldername.$filename.'.v*'); + $matches=glob($versionsfoldername.'/'.$filename.'.v*'); if(count($matches)>\OCP\Config::getSystemValue('files_versionmaxversions', Storage::DEFAULTMAXVERSIONS)){ $numbertodelete=count($matches-\OCP\Config::getSystemValue('files_versionmaxversions', Storage::DEFAULTMAXVERSIONS)); // delete old versions of a file $deleteitems=array_slice($matches,0,$numbertodelete); foreach($deleteitems as $de){ - unlink($versionsfoldername.$filename.'.v'.$de); + unlink($versionsfoldername.'/'.$filename.'.v'.$de); } } } From 5f4132d6badc660267d41098e673e30f62f8028e Mon Sep 17 00:00:00 2001 From: Frank Karlitschek Date: Thu, 31 May 2012 21:16:36 +0200 Subject: [PATCH 17/39] more fixes --- apps/files_versions/versions.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/files_versions/versions.php b/apps/files_versions/versions.php index ed4fd97e51..f39b5a7f4e 100644 --- a/apps/files_versions/versions.php +++ b/apps/files_versions/versions.php @@ -81,7 +81,7 @@ class Storage { Storage::init(); // check if filename is a directory - if(is_dir($filesfoldername.$filename)){ + if(is_dir($filesfoldername.'/'.$filename)){ return false; } @@ -143,7 +143,7 @@ class Storage { $filesfoldername=\OCP\Config::getSystemValue('datadirectory').'/'. $uid .'/files'; // rollback - if ( @copy($versionsfoldername.'/'.$filename.'.v'.$revision,$filesfoldername.$filename) ) { + if ( @copy($versionsfoldername.'/'.$filename.'.v'.$revision,$filesfoldername.'/'.$filename) ) { return true; From a72e6cc113656aa343c2bc738fba9e617a262d80 Mon Sep 17 00:00:00 2001 From: Frank Karlitschek Date: Thu, 31 May 2012 21:28:58 +0200 Subject: [PATCH 18/39] fix oc-780 --- config/config.sample.php | 2 +- lib/mail.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config/config.sample.php b/config/config.sample.php index e46c3cacd7..e86dc05cb0 100644 --- a/config/config.sample.php +++ b/config/config.sample.php @@ -22,7 +22,7 @@ $CONFIG = array( "appstoreurl" => "", "mail_smtpmode" => "sendmail", "mail_smtphost" => "127.0.0.1", -"mail_smtpauth" => "false", +"mail_smtpauth" => false, "mail_smtpname" => "", "mail_smtppassword" => "", "appcodechecker" => "", diff --git a/lib/mail.php b/lib/mail.php index 0045f8de6d..b46f73bd94 100644 --- a/lib/mail.php +++ b/lib/mail.php @@ -31,7 +31,7 @@ class OC_Mail { $SMTPMODE = OC_Config::getValue( 'mail_smtpmode', 'sendmail' ); $SMTPHOST = OC_Config::getValue( 'mail_smtphost', '127.0.0.1' ); - $SMTPAUTH = OC_Config::getValue( 'mail_smtpauth', 'false' ); + $SMTPAUTH = OC_Config::getValue( 'mail_smtpauth', false ); $SMTPUSERNAME = OC_Config::getValue( 'mail_smtpname', '' ); $SMTPPASSWORD = OC_Config::getValue( 'mail_smtppassword', '' ); From baae4c741ded1c702369c1a513b08324a63985f5 Mon Sep 17 00:00:00 2001 From: Frank Karlitschek Date: Thu, 31 May 2012 21:44:05 +0200 Subject: [PATCH 19/39] fix the breadcrumb --- apps/files/index.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/files/index.php b/apps/files/index.php index a2fae12d94..60a3836cb5 100644 --- a/apps/files/index.php +++ b/apps/files/index.php @@ -74,11 +74,11 @@ foreach( explode( '/', $dir ) as $i ){ // make breadcrumb und filelist markup $list = new OCP\Template( 'files', 'part.list', '' ); $list->assign( 'files', $files ); -$list->assign( 'baseURL', OCP\Util::linkTo('files', 'index.php').'?dir='); +$list->assign( 'baseURL', OCP\Util::linkTo('files', 'index.php').'&dir='); $list->assign( 'downloadURL', OCP\Util::linkTo('files', 'download.php').'?file='); $breadcrumbNav = new OCP\Template( 'files', 'part.breadcrumb', '' ); $breadcrumbNav->assign( 'breadcrumb', $breadcrumb ); -$breadcrumbNav->assign( 'baseURL', OCP\Util::linkTo('files', 'index.php').'?dir='); +$breadcrumbNav->assign( 'baseURL', OCP\Util::linkTo('files', 'index.php').'&dir='); $upload_max_filesize = OCP\Util::computerFileSize(ini_get('upload_max_filesize')); $post_max_size = OCP\Util::computerFileSize(ini_get('post_max_size')); From 24d14783d7b4706a3ad374a2229271f8f422e9cd Mon Sep 17 00:00:00 2001 From: Frank Karlitschek Date: Fri, 1 Jun 2012 10:38:44 +0200 Subject: [PATCH 20/39] added a serverProtocol function that correctly returns the used protocol even if the ssl connection is terminated at a reverse_proxy or at a load balancer --- lib/base.php | 10 +++++----- lib/helper.php | 25 ++++++++++++++++++++++--- lib/public/util.php | 10 ++++++++++ 3 files changed, 37 insertions(+), 8 deletions(-) diff --git a/lib/base.php b/lib/base.php index fdb682bf50..cb98a6c9e0 100644 --- a/lib/base.php +++ b/lib/base.php @@ -214,8 +214,8 @@ class OC{ // redirect to https site if configured if( OC_Config::getValue( "forcessl", false )){ ini_set("session.cookie_secure", "on"); - if(!isset($_SERVER['HTTPS']) or $_SERVER['HTTPS'] != 'on') { - $url = "https://". $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; + if(OC_Helper::serverProtocol()<>'https') { + $url = "https://". OC_Helper::serverHost() . $_SERVER['REQUEST_URI']; header("Location: $url"); exit(); } @@ -376,11 +376,11 @@ class OC{ // CSRF protection if(isset($_SERVER['HTTP_REFERER'])) $referer=$_SERVER['HTTP_REFERER']; else $referer=''; - if(isset($_SERVER['HTTPS']) and $_SERVER['HTTPS']<>'') $protocol='https://'; else $protocol='http://'; + $protocol=OC_Helper::serverProtocol().'://'; if(!self::$CLI){ - $server=$protocol.$_SERVER['SERVER_NAME']; + $server=$protocol.OC_Helper::serverHost(); if(($_SERVER['REQUEST_METHOD']=='POST') and (substr($referer,0,strlen($server))<>$server)) { - $url = $protocol.$_SERVER['SERVER_NAME'].OC::$WEBROOT.'/index.php'; + $url = $protocol.OC_Helper::serverProtocol().OC::$WEBROOT.'/index.php'; header("Location: $url"); exit(); } diff --git a/lib/helper.php b/lib/helper.php index 537465b15a..f8f84b91ae 100644 --- a/lib/helper.php +++ b/lib/helper.php @@ -89,6 +89,27 @@ class OC_Helper { return $host; } + + /** + * @brief Returns the server protocol + * @returns the server protocol + * + * Returns the server protocol. It respects reverse proxy servers and load balancers + */ + public static function serverProtocol() { + if (isset($_SERVER['HTTP_X_FORWARDED_PROTO'])) { + $proto = strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']); + }else{ + if(isset($_SERVER['HTTPS']) and !empty($_SERVER['HTTPS']) and ($_SERVER['HTTPS']!='off')) { + $proto = 'https'; + }else{ + $proto = 'http'; + } + } + return($proto); + } + + /** * @brief Creates an absolute url * @param $app app @@ -99,9 +120,7 @@ class OC_Helper { */ public static function linkToAbsolute( $app, $file ) { $urlLinkTo = self::linkTo( $app, $file ); - // Checking if the request was made through HTTPS. The last in line is for IIS - $protocol = isset($_SERVER['HTTPS']) && !empty($_SERVER['HTTPS']) && ($_SERVER['HTTPS']!='off'); - $urlLinkTo = ($protocol?'https':'http') . '://' . self::serverHost() . $urlLinkTo; + $urlLinkTo = OC_Helper::serverProtocol(). '://' . self::serverHost() . $urlLinkTo; return $urlLinkTo; } diff --git a/lib/public/util.php b/lib/public/util.php index 39a185d02a..9b499574da 100644 --- a/lib/public/util.php +++ b/lib/public/util.php @@ -168,6 +168,16 @@ class Util { return(\OC_Helper::serverHost()); } + /** + * @brief Returns the server protocol + * @returns the server protocol + * + * Returns the server protocol. It respects reverse proxy servers and load balancers + */ + public static function getServerProtocol() { + return(\OC_Helper::serverProtocol()); + } + /** * @brief Creates path to an image * @param $app app From 83c6714c723a1e224f2477192ca88bd6144b76e7 Mon Sep 17 00:00:00 2001 From: Frank Karlitschek Date: Fri, 1 Jun 2012 11:12:50 +0200 Subject: [PATCH 21/39] =?UTF-8?q?don=C2=B4t=20start=20a=20session=20here.?= =?UTF-8?q?=20I=20don=C2=B4t=20think=20it=C2=B4s=20needed.=20Let=C2=B4s=20?= =?UTF-8?q?see=20if=20it=20breaks=20something?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/files/ajax/timezone.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/files/ajax/timezone.php b/apps/files/ajax/timezone.php index 8e1d2aa1ec..cafb5074ec 100644 --- a/apps/files/ajax/timezone.php +++ b/apps/files/ajax/timezone.php @@ -1,6 +1,6 @@ From a2b41a140ea7e29c27261b264dd39c21170f3fa7 Mon Sep 17 00:00:00 2001 From: Frank Karlitschek Date: Fri, 1 Jun 2012 11:46:18 +0200 Subject: [PATCH 22/39] correctly detect https --- apps/user_openid/templates/settings.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/user_openid/templates/settings.php b/apps/user_openid/templates/settings.php index 731a2c57e9..b2bbe5a46a 100644 --- a/apps/user_openid/templates/settings.php +++ b/apps/user_openid/templates/settings.php @@ -1,7 +1,7 @@
OpenID -
t('you can authenticate to other sites with this address');?>
+
t('you can authenticate to other sites with this address');?>
From 93295994dc951e02405930dfbe8eca18bb4d9b07 Mon Sep 17 00:00:00 2001 From: Frank Karlitschek Date: Fri, 1 Jun 2012 12:15:03 +0200 Subject: [PATCH 23/39] fix oc-769 --- lib/vcategories.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/vcategories.php b/lib/vcategories.php index d6351e2858..ddcec1b6a4 100644 --- a/lib/vcategories.php +++ b/lib/vcategories.php @@ -136,7 +136,7 @@ class OC_VCategories { if(!is_null($vobject)) { $this->loadFromVObject($vobject, $sync); } else { - OC_Log::write('core','OC_VCategories::rescan, unable to parse. ID: '.$value[0].', '.substr($value[1], 0, 50).'(...)', OC_Log::DEBUG); + OC_Log::write('core','OC_VCategories::rescan, unable to parse. ID: '.', '.substr($object, 0, 100).'(...)', OC_Log::DEBUG); } } $this->save(); From 75d56f24f23efbafb9cc5c8f779ba020e0bb3c51 Mon Sep 17 00:00:00 2001 From: Frank Karlitschek Date: Fri, 1 Jun 2012 12:41:38 +0200 Subject: [PATCH 24/39] =?UTF-8?q?try=20to=20switch=20magic=20quotes=20off.?= =?UTF-8?q?=20it=C2=B4s=20evil=20and=20deprecated?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/base.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/base.php b/lib/base.php index cb98a6c9e0..e6fcb9ec4d 100644 --- a/lib/base.php +++ b/lib/base.php @@ -329,6 +329,11 @@ class OC{ date_default_timezone_set('UTC'); ini_set('arg_separator.output','&'); + // try to switch magic quotes off. + if(function_exists('set_magic_quotes_runtime')) { + @set_magic_quotes_runtime(false); + } + //try to configure php to enable big file uploads. //this doesn´t work always depending on the webserver and php configuration. //Let´s try to overwrite some defaults anyways From a4f177d75d28649af21bc33975259e6d19cae634 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Fri, 1 Jun 2012 13:49:11 +0200 Subject: [PATCH 25/39] LDAP group backend: If a group filter is not configured, do not do anything. Fixes oc-867 --- apps/user_ldap/group_ldap.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/apps/user_ldap/group_ldap.php b/apps/user_ldap/group_ldap.php index b3ff6c5388..2c16bf312f 100644 --- a/apps/user_ldap/group_ldap.php +++ b/apps/user_ldap/group_ldap.php @@ -25,10 +25,15 @@ class OC_GROUP_LDAP extends OC_Group_Backend { // //group specific settings protected $ldapGroupFilter; protected $ldapGroupMemberAssocAttr; + protected $configured = false; public function __construct() { $this->ldapGroupFilter = OCP\Config::getAppValue('user_ldap', 'ldap_group_filter', '(objectClass=posixGroup)'); $this->ldapGroupMemberAssocAttr = OCP\Config::getAppValue('user_ldap', 'ldap_group_member_assoc_attribute', 'uniqueMember'); + + if(empty($this->ldapGroupFilter) || empty($this->ldapGroupMemberAssocAttr)) { + $this->configured = false; + } } /** @@ -40,6 +45,9 @@ class OC_GROUP_LDAP extends OC_Group_Backend { * Checks whether the user is member of a group or not. */ public function inGroup($uid, $gid) { + if(!$this->configured) { + return false; + } $dn_user = OC_LDAP::username2dn($uid); $dn_group = OC_LDAP::groupname2dn($gid); // just in case @@ -79,6 +87,9 @@ class OC_GROUP_LDAP extends OC_Group_Backend { * if the user exists at all. */ public function getUserGroups($uid) { + if(!$this->configured) { + return array(); + } $userDN = OC_LDAP::username2dn($uid); if(!$userDN) { return array(); @@ -111,6 +122,10 @@ class OC_GROUP_LDAP extends OC_Group_Backend { * @returns array with user ids */ public function usersInGroup($gid) { + if(!$this->configured) { + return array(); + } + $groupDN = OC_LDAP::groupname2dn($gid); if(!$groupDN) { return array(); @@ -149,6 +164,10 @@ class OC_GROUP_LDAP extends OC_Group_Backend { * Returns a list with all groups */ public function getGroups() { + if(!$this->configured) { + return array(); + } + $ldap_groups = OC_LDAP::fetchListOfGroups($this->ldapGroupFilter, array(OC_LDAP::conf('ldapGroupDisplayName'), 'dn')); $groups = OC_LDAP::ownCloudGroupNames($ldap_groups); return $groups; From ad6562d14fabb0822e197e2ed70e4a3f8c02e23f Mon Sep 17 00:00:00 2001 From: Frank Karlitschek Date: Fri, 1 Jun 2012 14:18:14 +0200 Subject: [PATCH 26/39] sort users and groups. fixes oc-779 --- lib/group.php | 2 ++ lib/user.php | 1 + 2 files changed, 3 insertions(+) diff --git a/lib/group.php b/lib/group.php index a78eb51fff..7967e1a581 100644 --- a/lib/group.php +++ b/lib/group.php @@ -233,6 +233,7 @@ class OC_Group { $groups=array_merge($backend->getUserGroups($uid),$groups); } + asort($groups); return $groups; } @@ -250,6 +251,7 @@ class OC_Group { $groups=array_merge($backend->getGroups(),$groups); } + asort($groups); return $groups; } diff --git a/lib/user.php b/lib/user.php index ee2a80b159..d7e9bf1a64 100644 --- a/lib/user.php +++ b/lib/user.php @@ -336,6 +336,7 @@ class OC_User { } } } + asort($users); return $users; } From e58efd78777d3f1955aabcc4ff35c44595f3489d Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Fri, 1 Jun 2012 16:02:04 +0200 Subject: [PATCH 27/39] LDAP group backend: Set configured true when it is... fixe oc-887 --- apps/user_ldap/group_ldap.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/user_ldap/group_ldap.php b/apps/user_ldap/group_ldap.php index 2c16bf312f..baca1d32ba 100644 --- a/apps/user_ldap/group_ldap.php +++ b/apps/user_ldap/group_ldap.php @@ -31,8 +31,8 @@ class OC_GROUP_LDAP extends OC_Group_Backend { $this->ldapGroupFilter = OCP\Config::getAppValue('user_ldap', 'ldap_group_filter', '(objectClass=posixGroup)'); $this->ldapGroupMemberAssocAttr = OCP\Config::getAppValue('user_ldap', 'ldap_group_member_assoc_attribute', 'uniqueMember'); - if(empty($this->ldapGroupFilter) || empty($this->ldapGroupMemberAssocAttr)) { - $this->configured = false; + if(!empty($this->ldapGroupFilter) && !empty($this->ldapGroupMemberAssocAttr)) { + $this->configured = true; } } From dcb06393a86eee01e64df4c9092efcf3b0af2d8d Mon Sep 17 00:00:00 2001 From: Frank Karlitschek Date: Fri, 1 Jun 2012 16:30:47 +0200 Subject: [PATCH 28/39] fix propper error reporting --- lib/setup.php | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/setup.php b/lib/setup.php index 8c2d523121..a096fdbb4c 100644 --- a/lib/setup.php +++ b/lib/setup.php @@ -94,6 +94,7 @@ class OC_Setup { 'error' => 'MySQL username and/or password not valid', 'hint' => 'You need to enter either an existing account or the administrator.' ); + return($error); } else { $oldUser=OC_Config::getValue('dbuser', false); From e6b0eb3423ff0346fce64aadc1b33d481be7761f Mon Sep 17 00:00:00 2001 From: Frank Karlitschek Date: Fri, 1 Jun 2012 16:48:42 +0200 Subject: [PATCH 29/39] prevend a division by zero problem --- settings/personal.php | 1 + 1 file changed, 1 insertion(+) diff --git a/settings/personal.php b/settings/personal.php index 41499657ac..64e08be89e 100644 --- a/settings/personal.php +++ b/settings/personal.php @@ -20,6 +20,7 @@ $rootInfo=OC_FileCache::get(''); $used=$rootInfo['size']; $free=OC_Filesystem::free_space(); $total=$free+$used; +if($total==0) $total=1; // prevent division by zero $relative=round(($used/$total)*10000)/100; $email=OC_Preferences::getValue(OC_User::getUser(), 'settings','email',''); From 7203f6951efbb56fcd300900e541c198cd994667 Mon Sep 17 00:00:00 2001 From: Sam Tuke Date: Fri, 1 Jun 2012 16:34:09 +0100 Subject: [PATCH 30/39] Extended class comment --- lib/user.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/user.php b/lib/user.php index d7e9bf1a64..be349aeb05 100644 --- a/lib/user.php +++ b/lib/user.php @@ -21,7 +21,9 @@ */ /** - * This class provides all methods for user management. + * This class provides wrapper methods for user management. Multiple backends are + * supported. User management operations are delegated to the configured backend for + * execution. * * Hooks provided: * pre_createUser(&run, uid, password) From 4b4d13165a1698a19ad6726d634b8880e1405fea Mon Sep 17 00:00:00 2001 From: Sam Tuke Date: Fri, 1 Jun 2012 16:46:18 +0100 Subject: [PATCH 31/39] Minor change to comment --- lib/user/backend.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/user/backend.php b/lib/user/backend.php index 3df907226c..c31d4b5785 100644 --- a/lib/user/backend.php +++ b/lib/user/backend.php @@ -40,8 +40,10 @@ define('OC_USER_BACKEND_USER_EXISTS', 0x100000); /** - * abstract base class for user management - * subclass this for your own backends and see OC_User_Example for descriptions + * Abstract base class for user management. Provides methods for querying backend + * capabilities. + * + * Subclass this for your own backends, and see OC_User_Example for descriptions */ abstract class OC_User_Backend { From 07e1e3a9454df55d27e3c52e6345a6a3aee1344a Mon Sep 17 00:00:00 2001 From: Frank Karlitschek Date: Fri, 1 Jun 2012 19:54:07 +0200 Subject: [PATCH 32/39] check if apps folder is writable --- lib/util.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/util.php b/lib/util.php index be7fc00da8..628c23f4cb 100644 --- a/lib/util.php +++ b/lib/util.php @@ -28,6 +28,14 @@ class OC_Util { exit; } + // Check if apps folder is writable. + if(!is_writable(OC::$SERVERROOT."/apps/")) { + $tmpl = new OC_Template( '', 'error', 'guest' ); + $tmpl->assign('errors',array(1=>array('error'=>"Can't write into apps directory 'apps'",'hint'=>"You can usually fix this by giving the webserver user write access to the config directory in owncloud"))); + $tmpl->printPage(); + exit; + } + // Create root dir. if(!is_dir($CONFIG_DATADIRECTORY_ROOT)){ $success=@mkdir($CONFIG_DATADIRECTORY_ROOT); From 410b556a8651695dd15e742e0501d4da341ef594 Mon Sep 17 00:00:00 2001 From: Sam Tuke Date: Fri, 1 Jun 2012 18:59:57 +0100 Subject: [PATCH 33/39] Added class comment block --- tests/lib/user/backend.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/lib/user/backend.php b/tests/lib/user/backend.php index 5dab5afb18..984249e84e 100644 --- a/tests/lib/user/backend.php +++ b/tests/lib/user/backend.php @@ -20,6 +20,16 @@ * */ +/** + * Abstract class to provide the basis of backend-specific unit test classes. + * + * All subclasses MUST assign a backend property in setUp() which implements + * user operations (add, remove, etc.). Test methods in this class will then be + * run on each separate subclass and backend therein. + * + * For an example see /tests/lib/user/dummy.php + */ + abstract class Test_User_Backend extends UnitTestCase { /** * @var OC_User_Backend $backend From 4aa96de53784e2765943df9fb6d7a2b87c87036f Mon Sep 17 00:00:00 2001 From: Frank Karlitschek Date: Fri, 1 Jun 2012 20:00:33 +0200 Subject: [PATCH 34/39] add a check for pdo --- lib/util.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/util.php b/lib/util.php index 628c23f4cb..fda60587b8 100644 --- a/lib/util.php +++ b/lib/util.php @@ -264,6 +264,9 @@ class OC_Util { if(floatval(phpversion())<5.3){ $errors[]=array('error'=>'PHP 5.3 is required.
','hint'=>'Please ask your server administrator to update PHP to version 5.3 or higher. PHP 5.2 is no longer supported by ownCloud and the PHP community.'); } + if(!defined('PDO::ATTR_DRIVER_NAME')){ + $errors[]=array('error'=>'PHP PDO module is not installed.
','hint'=>'Please ask your server administrator to install the module.'); + } return $errors; } From 66f1957e3b82400a04bbd20c5b5ce3ae9d4334c8 Mon Sep 17 00:00:00 2001 From: Michael Gapczynski Date: Fri, 1 Jun 2012 14:38:25 -0400 Subject: [PATCH 35/39] Improve efficiency of retrieving log file entries --- lib/log/owncloud.php | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/lib/log/owncloud.php b/lib/log/owncloud.php index 0b7a231d30..5913d8b5b8 100644 --- a/lib/log/owncloud.php +++ b/lib/log/owncloud.php @@ -62,23 +62,26 @@ class OC_Log_Owncloud { public static function getEntries($limit=50, $offset=0){ self::init(); $minLevel=OC_Config::getValue( "loglevel", OC_Log::WARN ); - $entries=array(); - if(!file_exists(self::$logFile)) { - return array(); - } - $contents=file(self::$logFile); - if(!$contents) {//error while reading log - return array(); - } - $end=max(count($contents)-$offset-1, 0); - $start=max($end-$limit,0); - $i=$end; - while($i>$start){ - $entry=json_decode($contents[$i]); - if($entry->level>=$minLevel){ - $entries[]=$entry; + $entries = array(); + $handle = fopen(self::$logFile, 'r'); + if ($handle) { + // Just a guess to set the file pointer to the right spot + $maxLineLength = 150; + fseek($handle, -($limit * $maxLineLength + $offset * $maxLineLength), SEEK_END); + // Skip first line, because it is most likely a partial line + fgets($handle); + while (!feof($handle)) { + $line = fgets($handle); + if (!empty($line)) { + $entry = json_decode($line); + if ($entry->level >= $minLevel) { + $entries[] = $entry; + } + } } - $i--; + fclose($handle); + // Extract the needed entries and reverse the order + $entries = array_reverse(array_slice($entries, -($limit + $offset), $limit)); } return $entries; } From cc84bd2993b4f5049076dc4d12d6dada9d1a4f85 Mon Sep 17 00:00:00 2001 From: Michael Gapczynski Date: Fri, 1 Jun 2012 15:15:05 -0400 Subject: [PATCH 36/39] Fix typo in log message --- lib/filecache.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/filecache.php b/lib/filecache.php index a94349e19c..a29e29928a 100644 --- a/lib/filecache.php +++ b/lib/filecache.php @@ -419,7 +419,7 @@ class OC_FileCache{ } return $result; }else{ - OC_Log::write('files','getChached(): file not found in cache ('.$path.')',OC_Log::DEBUG); + OC_Log::write('files','getCached(): file not found in cache ('.$path.')',OC_Log::DEBUG); if(isset(self::$savedData[$path])){ return self::$savedData[$path]; }else{ From 993ebc4c902965e4612207fef9e5b04fe0838a59 Mon Sep 17 00:00:00 2001 From: Michael Gapczynski Date: Sat, 2 Jun 2012 20:06:52 -0400 Subject: [PATCH 37/39] Verify user exists when checking if logged in, fix for bug oc-863 --- lib/user.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/user.php b/lib/user.php index be349aeb05..17c11322b8 100644 --- a/lib/user.php +++ b/lib/user.php @@ -242,7 +242,7 @@ class OC_User { * Checks if the user is logged in */ public static function isLoggedIn(){ - if( isset($_SESSION['user_id']) AND $_SESSION['user_id'] ){ + if( isset($_SESSION['user_id']) AND $_SESSION['user_id'] AND self::userExists($_SESSION['user_id']) ){ return true; } else{ From e90cbcaf5b5f2f1d39947d16dc3927550874f4d9 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Sun, 3 Jun 2012 02:50:34 +0200 Subject: [PATCH 38/39] http user backend --- lib/user/http.php | 93 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 lib/user/http.php diff --git a/lib/user/http.php b/lib/user/http.php new file mode 100644 index 0000000000..009aa30c6f --- /dev/null +++ b/lib/user/http.php @@ -0,0 +1,93 @@ +. +* +*/ + +/** + * user backend using http auth requests + */ +class OC_User_HTTP extends OC_User_Backend { + /** + * split http://user@host/path into a user and url part + * @param string path + * @return array + */ + private function parseUrl($url){ + $parts=parse_url($url); + $url=$parts['scheme'].'://'.$parts['host']; + if(isset($parts['port'])){ + $url.=':'.$parts['port']; + } + $url.=$parts['path']; + if(isset($parts['query'])){ + $url.='?'.$parts['query']; + } + return array($parts['user'],$url); + + } + + /** + * check if an url is a valid login + * @param string url + * @return boolean + */ + private function matchUrl($url){ + return ! is_null(parse_url($url,PHP_URL_USER)); + } + + /** + * @brief Check if the password is correct + * @param $uid The username + * @param $password The password + * @returns string + * + * Check if the password is correct without logging in the user + * returns the user id or false + */ + public function checkPassword($uid, $password){ + if(!$this->matchUrl($uid)){ + return false; + } + list($user,$url)=$this->parseUrl($uid); + + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, $url); + curl_setopt($ch, CURLOPT_USERPWD, $user.':'.$password); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + + curl_exec($ch); + + $status = curl_getinfo($ch, CURLINFO_HTTP_CODE); + + curl_close($ch); + + return $status==200; + } + + /** + * @brief check if a user exists + * @param string $uid the username + * @return boolean + */ + public function userExists($uid){ + return $this->matchUrl($uid); + } +} \ No newline at end of file From f3c1d1eded96e948b2ddc608de48778b62232231 Mon Sep 17 00:00:00 2001 From: Frank Karlitschek Date: Sun, 3 Jun 2012 23:48:59 +0200 Subject: [PATCH 39/39] link to apps.owncloud.com thanks to guillaume for the patch --- settings/js/apps.js | 6 +++++- settings/templates/apps.php | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/settings/js/apps.js b/settings/js/apps.js index f6e08b608b..5ac7d80b94 100644 --- a/settings/js/apps.js +++ b/settings/js/apps.js @@ -17,7 +17,7 @@ $(document).ready(function(){ }); $('#leftcontent li').click(function(){ var app=$(this).data('app'); - $('#rightcontent p').show(); + $('#rightcontent p.license').show(); $('#rightcontent span.name').text(app.name); $('#rightcontent small.externalapp').text(app.internallabel); $('#rightcontent span.version').text(app.version); @@ -31,6 +31,10 @@ $(document).ready(function(){ $('#rightcontent input.enable').val((app.active)?t('settings','Disable'):t('settings','Enable')); $('#rightcontent input.enable').data('appid',app.id); $('#rightcontent input.enable').data('active',app.active); + if ( app.internal == false ) { + $('#rightcontent p.appslink').show(); + $('#rightcontent a').attr('href','http://apps.owncloud.com/content/show.php?content='+app.id); + } return false; }); $('#rightcontent input.enable').click(function(){ diff --git a/settings/templates/apps.php b/settings/templates/apps.php index 7642ab7fb8..c620f796e0 100644 --- a/settings/templates/apps.php +++ b/settings/templates/apps.php @@ -22,6 +22,7 @@

t('Select an App');?>

- + +