testremote.php 637 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. /**
  3. * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
  4. * This file is licensed under the Affero General Public License version 3 or
  5. * later.
  6. * See the COPYING-README file.
  7. */
  8. OCP\JSON::checkAppEnabled('files_sharing');
  9. $remote = $_GET['remote'];
  10. function testUrl($url) {
  11. try {
  12. $result = file_get_contents($url);
  13. $data = json_decode($result);
  14. return is_object($data) and !empty($data->version);
  15. } catch (Exception $e) {
  16. return false;
  17. }
  18. }
  19. if (testUrl('https://' . $remote . '/status.php')) {
  20. echo 'https';
  21. } elseif (testUrl('http://' . $remote . '/status.php')) {
  22. echo 'http';
  23. } else {
  24. echo 'false';
  25. }