diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2013-02-09 05:13:33 -0800 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2013-02-09 05:13:33 -0800 |
commit | 279cbeb001c9d8e917838ffb6a1b10394f27cf79 (patch) | |
tree | 2a88f2ebb5b693ad74e1ec36255c63180c8a43c4 /lib | |
parent | ec829bd345045df985f623fa2fe6587d0ce68eb2 (diff) | |
parent | ea42014ba4e7ad44a290f968b1a1439f78c1117c (diff) | |
download | nextcloud-server-279cbeb001c9d8e917838ffb6a1b10394f27cf79.tar.gz nextcloud-server-279cbeb001c9d8e917838ffb6a1b10394f27cf79.zip |
Merge pull request #1481 from owncloud/fixing-1354-master
basic WebDAV test in place now
Diffstat (limited to 'lib')
-rw-r--r-- | lib/base.php | 1 | ||||
-rw-r--r-- | lib/setup.php | 20 | ||||
-rwxr-xr-x | lib/util.php | 34 |
3 files changed, 55 insertions, 0 deletions
diff --git a/lib/base.php b/lib/base.php index 5bfdb0b7c0a..84e9b0c2eeb 100644 --- a/lib/base.php +++ b/lib/base.php @@ -548,6 +548,7 @@ class OC { require_once 'core/setup.php'; exit(); } + $request = OC_Request::getPathInfo(); if(substr($request, -3) !== '.js'){// we need these files during the upgrade self::checkMaintenanceMode(); diff --git a/lib/setup.php b/lib/setup.php index 4dd190b99fb..f342142c957 100644 --- a/lib/setup.php +++ b/lib/setup.php @@ -610,4 +610,24 @@ class OC_Setup { file_put_contents(OC_Config::getValue('datadirectory', OC::$SERVERROOT.'/data').'/.htaccess', $content); file_put_contents(OC_Config::getValue('datadirectory', OC::$SERVERROOT.'/data').'/index.html', ''); } + + /** + * @brief Post installation checks + */ + public static function postSetupCheck($params) { + // setup was successful -> webdav testing now + if (OC_Util::isWebDAVWorking()) { + header("Location: ".OC::$WEBROOT.'/'); + } else { + $l=OC_L10N::get('lib'); + + $error = $l->t('Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken.'); + $hint = $l->t('Please double check the <a href=\'%s\'>installation guides</a>.', 'http://doc.owncloud.org/server/5.0/admin_manual/installation.html'); + + $tmpl = new OC_Template('', 'error', 'guest'); + $tmpl->assign('errors', array(1 => array('error' => $error, 'hint' => $hint)), false); + $tmpl->printPage(); + exit(); + } + } } diff --git a/lib/util.php b/lib/util.php index 9ce974619bc..49d914e5fbd 100755 --- a/lib/util.php +++ b/lib/util.php @@ -516,6 +516,40 @@ class OC_Util { } } + /** + * we test if webDAV is working properly + * + * The basic assumption is that if the server returns 401/Not Authenticated for an unauthenticated PROPFIND + * the web server it self is setup properly. + * + * Why not an authenticated PROFIND and other verbs? + * - We don't have the password available + * - We have no idea about other auth methods implemented (e.g. OAuth with Bearer header) + * + */ + public static function isWebDAVWorking() { + if (!function_exists('curl_init')) { + return; + } + + $settings = array( + 'baseUri' => OC_Helper::linkToRemote('webdav'), + ); + + $client = new \Sabre_DAV_Client($settings); + + $return = true; + try { + // test PROPFIND + $client->propfind('', array('{DAV:}resourcetype')); + } catch(\Sabre_DAV_Exception_NotAuthenticated $e) { + $return = true; + } catch(\Exception $e) { + $return = false; + } + + return $return; + } /** * Check if the setlocal call doesn't work. This can happen if the right local packages are not available on the server. |