]> source.dussan.org Git - nextcloud-server.git/commitdiff
Make testremote more robust
authorRobin Appelman <icewind@owncloud.com>
Mon, 16 Jun 2014 11:21:00 +0000 (13:21 +0200)
committerRobin Appelman <icewind@owncloud.com>
Mon, 16 Jun 2014 11:21:00 +0000 (13:21 +0200)
apps/files_sharing/ajax/testremote.php

index 5a0730088323f4a4bc9a1b70f628d7a0c96ec19e..32e2f5548758f2bb4f0dc61192116d856203fd70 100644 (file)
@@ -8,13 +8,18 @@
 
 OCP\JSON::checkAppEnabled('files_sharing');
 OCP\JSON::checkLoggedIn();
-OCP\JSON::callCheck();
 
 $remote = $_GET['remote'];
 
-if (file_get_contents('https://' . $remote . '/status.php')) {
+function testUrl($url) {
+       $result = file_get_contents($url);
+       $data = json_decode($result);
+       return is_object($data) and !empty($data->version);
+}
+
+if (testUrl('https://' . $remote . '/status.php')) {
        echo 'https';
-} elseif (file_get_contents('http://' . $remote . '/status.php')) {
+} elseif (testUrl('http://' . $remote . '/status.php')) {
        echo 'http';
 } else {
        echo 'false';