]> source.dussan.org Git - nextcloud-server.git/commitdiff
basic WebDAV test in place now
authorThomas Mueller <thomas.mueller@tmit.eu>
Tue, 5 Feb 2013 22:33:44 +0000 (23:33 +0100)
committerThomas Mueller <thomas.mueller@tmit.eu>
Tue, 5 Feb 2013 22:33:44 +0000 (23:33 +0100)
lib/base.php
lib/util.php

index 90e64f13af616dbc22221d445333cb74d4304dad..6dab980dd0edec1f50a15133c8bcc9372b13f7f2 100644 (file)
@@ -546,6 +546,29 @@ class OC {
                        require_once 'core/setup.php';
                        exit();
                }
+
+               // post installation checks
+               if (!OC_Config::getValue("post-installation-checked", false)) {
+                       // setup was successful -> webdav testing now
+                       $request = OC_Request::getPathInfo();
+                       if(substr($request, -4) !== '.css' and substr($request, -3) !== '.js' and substr($request, -5) !== '.json') {
+                               if (OC_Util::isWebDAVWorking()) {
+                                       OC_Config::setValue("post-installation-checked", true);
+                               } 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();
+                               }
+                       }
+               }
+
+
                $request = OC_Request::getPathInfo();
                if(substr($request, -3) !== '.js'){// we need these files during the upgrade
                        self::checkMaintenanceMode();
index 4932be2d6cc8a08a68984d035deb62d48c941fa7..ae0900d7e843c75fbf8b9c9eac9ce22b9927f16c 100755 (executable)
@@ -514,6 +514,36 @@ 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() {
+               $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.