From 7f49d359306cbcd3303fcdd7feb0e6931ecffd8d Mon Sep 17 00:00:00 2001 From: Lukas Reschke Date: Fri, 25 Jan 2013 19:15:02 +0100 Subject: [PATCH 1/9] Move checkMaintenance and checkUpgrade This is needed to ensure that the routing and linkTo() function for CSP are available. --- lib/base.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/base.php b/lib/base.php index f1a60a1773..81a5a615de 100644 --- a/lib/base.php +++ b/lib/base.php @@ -422,8 +422,6 @@ class OC self::checkSSL(); self::initSession(); self::initTemplateEngine(); - self::checkMaintenanceMode(); - self::checkUpgrade(); $errors = OC_Util::checkServer(); if (count($errors) > 0) { @@ -563,10 +561,13 @@ class OC return; } + // Check if ownCloud is installed or in maintenance (update) mode if (!OC_Config::getValue('installed', false)) { require_once 'core/setup.php'; exit(); } + self::checkMaintenanceMode(); + self::checkUpgrade(); // Handle redirect URL for logged in users if (isset($_REQUEST['redirect_url']) && OC_User::isLoggedIn()) { From dbc13cf6ee775745c86f92d97d636f9ed3cf5432 Mon Sep 17 00:00:00 2001 From: Lukas Reschke Date: Fri, 25 Jan 2013 19:18:16 +0100 Subject: [PATCH 2/9] Move update inline JS --- core/js/update.js | 24 ++++++++++++++++++++++++ core/templates/update.php | 28 +--------------------------- lib/base.php | 1 + 3 files changed, 26 insertions(+), 27 deletions(-) create mode 100644 core/js/update.js diff --git a/core/js/update.js b/core/js/update.js new file mode 100644 index 0000000000..c10aa013e6 --- /dev/null +++ b/core/js/update.js @@ -0,0 +1,24 @@ +$(document).ready(function () { + OC.EventSource.requesttoken = oc_requesttoken; + var updateEventSource = new OC.EventSource(OC.webroot+'/core/ajax/update.php'); + updateEventSource.listen('success', function(message) { + $('').append(message).append('
').appendTo($('.update')); + }); + updateEventSource.listen('error', function(message) { + $('').addClass('error').append(message).append('
').appendTo($('.update')); + }); + updateEventSource.listen('failure', function(message) { + $('').addClass('error').append(message).append('
').appendTo($('.update')); + $('') + .addClass('error bold') + .append('
') + .append(t('core', 'The update was unsuccessful. Please report this issue to the ownCloud community.')) + .appendTo($('.update')); + }); + updateEventSource.listen('done', function(message) { + $('').addClass('bold').append('
').append(t('core', 'The update was successful. Redirecting you to ownCloud now.')).appendTo($('.update')); + setTimeout(function () { + window.location.href = OC.webroot; + }, 3000); + }); +}); \ No newline at end of file diff --git a/core/templates/update.php b/core/templates/update.php index c9f3144f25..d403410976 100644 --- a/core/templates/update.php +++ b/core/templates/update.php @@ -2,30 +2,4 @@
  • t('Updating ownCloud to version %s, this may take a while.', array($_['version'])); ?>

  • - - \ No newline at end of file + \ No newline at end of file diff --git a/lib/base.php b/lib/base.php index 81a5a615de..402a8af421 100644 --- a/lib/base.php +++ b/lib/base.php @@ -252,6 +252,7 @@ class OC if ($showTemplate && !OC_Config::getValue('maintenance', false)) { OC_Config::setValue('maintenance', true); OC_Log::write('core', 'starting upgrade from ' . $installedVersion . ' to ' . $currentVersion, OC_Log::DEBUG); + OC_Util::addscript('update'); $tmpl = new OC_Template('', 'update', 'guest'); $tmpl->assign('version', OC_Util::getVersionString()); $tmpl->printPage(); From 4d74738fe750cacd5c7ff40ce4652a8a4d19253c Mon Sep 17 00:00:00 2001 From: j-ed Date: Sat, 26 Jan 2013 12:04:06 +0100 Subject: [PATCH 3/9] Update config/config.sample.php added parameter mail_smtpauthtype to set SMTP authentication type. --- config/config.sample.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/config/config.sample.php b/config/config.sample.php index f26a53c155..6ac161d218 100644 --- a/config/config.sample.php +++ b/config/config.sample.php @@ -90,6 +90,10 @@ $CONFIG = array( */ "mail_smtpauth" => false, +/* authentication type needed to send mail, depends on mail_smtpmode if this is used + * Can be LOGIN (default), PLAIN or NTLM */ +"mail_smtpauthtype" => "LOGIN", + /* Username to use for sendmail mail, depends on mail_smtpauth if this is used */ "mail_smtpname" => "", From 93834b78a13814e8b799126285a70f3303d04fea Mon Sep 17 00:00:00 2001 From: j-ed Date: Sat, 26 Jan 2013 12:09:54 +0100 Subject: [PATCH 4/9] Update lib/mail.php added parameter mail_smtpauthtype to set SMTP authentication type. --- lib/mail.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/mail.php b/lib/mail.php index ffc4d01b79..1bb202ac97 100644 --- a/lib/mail.php +++ b/lib/mail.php @@ -38,6 +38,7 @@ class OC_Mail { $SMTPHOST = OC_Config::getValue( 'mail_smtphost', '127.0.0.1' ); $SMTPPORT = OC_Config::getValue( 'mail_smtpport', 25 ); $SMTPAUTH = OC_Config::getValue( 'mail_smtpauth', false ); + $SMTPAUTHTYPE = OC_Config::getValue( 'mail_smtpauthtype', 'LOGIN' ); $SMTPUSERNAME = OC_Config::getValue( 'mail_smtpname', '' ); $SMTPPASSWORD = OC_Config::getValue( 'mail_smtppassword', '' ); $SMTPDEBUG = OC_Config::getValue( 'mail_smtpdebug', false ); @@ -62,6 +63,7 @@ class OC_Mail { $mailo->SMTPAuth = $SMTPAUTH; $mailo->SMTPDebug = $SMTPDEBUG; $mailo->SMTPSecure = $SMTPSECURE; + $mailo->AuthType = $SMTPAUTHTYPE; $mailo->Username = $SMTPUSERNAME; $mailo->Password = $SMTPPASSWORD; $mailo->Timeout = $SMTPTIMEOUT; From 7f0a3018b6a965ce569b8dc3a14aeb0c00c8e06b Mon Sep 17 00:00:00 2001 From: Lukas Reschke Date: Sat, 26 Jan 2013 13:46:00 +0100 Subject: [PATCH 5/9] Fix undefined variable --- core/js/config.php | 10 +++++++--- lib/templatelayout.php | 5 ----- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/core/js/config.php b/core/js/config.php index e838fb1cd0..9069175ed6 100644 --- a/core/js/config.php +++ b/core/js/config.php @@ -17,11 +17,15 @@ header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); $l = OC_L10N::get('core'); // Get the config -$debug = (defined('DEBUG') && DEBUG) ? 'true' : 'false'; +$apps_paths = array(); +foreach(OC_App::getEnabledApps() as $app) { + $apps_paths[$app] = OC_App::getAppWebPath($app); +} + $array = array( - "oc_debug" => $debug, + "oc_debug" => (defined('DEBUG') && DEBUG) ? 'true' : 'false', "oc_webroot" => "\"".OC::$WEBROOT."\"", - "oc_appswebroots" => "\"".$_['apps_paths']. "\"", + "oc_appswebroots" => str_replace('\\/', '/', json_encode($apps_paths)), // Ugly unescape slashes waiting for better solution "oc_current_user" => "\"".OC_User::getUser(). "\"", "oc_requesttoken" => "\"".OC_Util::callRegister(). "\"", "datepickerFormatDate" => json_encode($l->l('jsdate', 'jsdate')), diff --git a/lib/templatelayout.php b/lib/templatelayout.php index 83d3619998..37ece91047 100644 --- a/lib/templatelayout.php +++ b/lib/templatelayout.php @@ -28,11 +28,6 @@ class OC_TemplateLayout extends OC_Template { break; } } - $apps_paths = array(); - foreach(OC_App::getEnabledApps() as $app) { - $apps_paths[$app] = OC_App::getAppWebPath($app); - } - $this->assign( 'apps_paths', str_replace('\\/', '/', json_encode($apps_paths)), false ); // Ugly unescape slashes waiting for better solution } else if ($renderas == 'guest') { parent::__construct('core', 'layout.guest'); } else { From 6c882d980681882134a93cfbb367fed816dfbb53 Mon Sep 17 00:00:00 2001 From: Lukas Reschke Date: Sat, 26 Jan 2013 14:03:17 +0100 Subject: [PATCH 6/9] Remove outdated comments --- apps/files/admin.php | 4 ---- apps/files/download.php | 3 --- apps/files/settings.php | 4 ---- 3 files changed, 11 deletions(-) diff --git a/apps/files/admin.php b/apps/files/admin.php index f747f8645f..02c3147dba 100644 --- a/apps/files/admin.php +++ b/apps/files/admin.php @@ -21,10 +21,6 @@ * */ - -// Init owncloud - - OCP\User::checkAdminUser(); $htaccessWorking=(getenv('htaccessWorking')=='true'); diff --git a/apps/files/download.php b/apps/files/download.php index e2149cd413..1b70b1e38f 100644 --- a/apps/files/download.php +++ b/apps/files/download.php @@ -21,9 +21,6 @@ * */ -// Init owncloud - - // Check if we are a user OCP\User::checkLoggedIn(); diff --git a/apps/files/settings.php b/apps/files/settings.php index 52ec9fd0fe..ea730a5a72 100644 --- a/apps/files/settings.php +++ b/apps/files/settings.php @@ -21,10 +21,6 @@ * */ - -// Init owncloud - - // Check if we are a user OCP\User::checkLoggedIn(); From 2e42c6f54f85c5ac5b339625d04685535ac69d40 Mon Sep 17 00:00:00 2001 From: Lukas Reschke Date: Sat, 26 Jan 2013 14:07:35 +0100 Subject: [PATCH 7/9] Use HTML5 data attribute + fix undefined variable --- apps/files/appinfo/routes.php | 5 +---- apps/files/index.php | 1 + apps/files/js/publiclistview.php | 20 -------------------- apps/files/templates/part.list.php | 2 +- apps/files_sharing/js/share.js | 2 ++ apps/files_sharing/templates/public.php | 2 -- 6 files changed, 5 insertions(+), 27 deletions(-) delete mode 100644 apps/files/js/publiclistview.php diff --git a/apps/files/appinfo/routes.php b/apps/files/appinfo/routes.php index 307a4d0320..043782a9c0 100644 --- a/apps/files/appinfo/routes.php +++ b/apps/files/appinfo/routes.php @@ -8,7 +8,4 @@ $this->create('download', 'download{file}') ->requirements(array('file' => '.*')) - ->actionInclude('files/download.php'); -// oC JS config -$this->create('publicListView', 'js/publiclistview.js') - ->actionInclude('files/js/publiclistview.php'); \ No newline at end of file + ->actionInclude('files/download.php'); \ No newline at end of file diff --git a/apps/files/index.php b/apps/files/index.php index 2c6b689b0c..378f5e02e6 100644 --- a/apps/files/index.php +++ b/apps/files/index.php @@ -76,6 +76,7 @@ $list = new OCP\Template('files', 'part.list', ''); $list->assign('files', $files, false); $list->assign('baseURL', OCP\Util::linkTo('files', 'index.php') . '?dir=', false); $list->assign('downloadURL', OCP\Util::linkTo('files', 'download.php') . '?file=', false); +$list->assign('disableSharing', false); $breadcrumbNav = new OCP\Template('files', 'part.breadcrumb', ''); $breadcrumbNav->assign('breadcrumb', $breadcrumb, false); $breadcrumbNav->assign('baseURL', OCP\Util::linkTo('files', 'index.php') . '?dir=', false); diff --git a/apps/files/js/publiclistview.php b/apps/files/js/publiclistview.php deleted file mode 100644 index f1c67aabb4..0000000000 --- a/apps/files/js/publiclistview.php +++ /dev/null @@ -1,20 +0,0 @@ - - * This file is licensed under the Affero General Public License version 3 or - * later. - * See the COPYING-README file. - */ - -// Set the content type to Javascript -header("Content-type: text/javascript"); - -// Disallow caching -header("Cache-Control: no-cache, must-revalidate"); -header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); - -if ( array_key_exists('disableSharing', $_) && $_['disableSharing'] == true ) { - echo "var disableSharing = true;"; -} else { - echo "var disableSharing = false;"; -} diff --git a/apps/files/templates/part.list.php b/apps/files/templates/part.list.php index 78f91467c7..f3f06d61d6 100644 --- a/apps/files/templates/part.list.php +++ b/apps/files/templates/part.list.php @@ -1,4 +1,4 @@ - + "> - From 10c428830e1608fb87c207ea0d6ad9a02dd6bc3e Mon Sep 17 00:00:00 2001 From: Michael Gapczynski Date: Sun, 27 Jan 2013 23:31:31 -0500 Subject: [PATCH 8/9] Add create permission, fixes #780 --- apps/files/index.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apps/files/index.php b/apps/files/index.php index 2c6b689b0c..9ee5cae6c8 100644 --- a/apps/files/index.php +++ b/apps/files/index.php @@ -83,6 +83,9 @@ $breadcrumbNav->assign('baseURL', OCP\Util::linkTo('files', 'index.php') . '?dir $maxUploadFilesize=OCP\Util::maxUploadFilesize($dir); $permissions = OCP\PERMISSION_READ; +if (OC_Filesystem::isCreatable($dir . '/')) { + $permissions |= OCP\PERMISSION_CREATE; +} if (OC_Filesystem::isUpdatable($dir . '/')) { $permissions |= OCP\PERMISSION_UPDATE; } From 06c1c35ac90f7920afa637ab0b628529b4135d40 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 28 Jan 2013 19:08:03 +0100 Subject: [PATCH 9/9] Fix phpdoc --- lib/user.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/user.php b/lib/user.php index fd0ed6ecd3..85240ce6b6 100644 --- a/lib/user.php +++ b/lib/user.php @@ -383,8 +383,8 @@ class OC_User { /** * @brief Check if the password is correct - * @param $uid The username - * @param $password The password + * @param string $uid The username + * @param string $password The password * @returns string * * returns the path to the users home directory