summaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/ajax
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2014-06-16 13:21:00 +0200
committerRobin Appelman <icewind@owncloud.com>2014-06-16 13:21:00 +0200
commit5b1b6572f7ae9ac9e300032e049e317ac7496a30 (patch)
treed9347f58482174ac208a87ca251f7d9aefd8eb80 /apps/files_sharing/ajax
parent6e06e1da0e8c283ab640d865f38414ac59c9cb18 (diff)
downloadnextcloud-server-5b1b6572f7ae9ac9e300032e049e317ac7496a30.tar.gz
nextcloud-server-5b1b6572f7ae9ac9e300032e049e317ac7496a30.zip
Make testremote more robust
Diffstat (limited to 'apps/files_sharing/ajax')
-rw-r--r--apps/files_sharing/ajax/testremote.php11
1 files changed, 8 insertions, 3 deletions
diff --git a/apps/files_sharing/ajax/testremote.php b/apps/files_sharing/ajax/testremote.php
index 5a073008832..32e2f554875 100644
--- a/apps/files_sharing/ajax/testremote.php
+++ b/apps/files_sharing/ajax/testremote.php
@@ -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';