Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

remote.php 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. try {
  3. require_once 'lib/base.php';
  4. if (\OCP\Util::needUpgrade()) {
  5. // since the behavior of apps or remotes are unpredictable during
  6. // an upgrade, return a 503 directly
  7. OC_Response::setStatus(OC_Response::STATUS_SERVICE_UNAVAILABLE);
  8. OC_Template::printErrorPage('Service unavailable');
  9. exit;
  10. }
  11. $path_info = OC_Request::getPathInfo();
  12. if ($path_info === false || $path_info === '') {
  13. OC_Response::setStatus(OC_Response::STATUS_NOT_FOUND);
  14. exit;
  15. }
  16. if (!$pos = strpos($path_info, '/', 1)) {
  17. $pos = strlen($path_info);
  18. }
  19. $service=substr($path_info, 1, $pos-1);
  20. $file = \OC::$server->getAppConfig()->getValue('core', 'remote_' . $service);
  21. if(is_null($file)) {
  22. OC_Response::setStatus(OC_Response::STATUS_NOT_FOUND);
  23. exit;
  24. }
  25. $file=ltrim($file, '/');
  26. $parts=explode('/', $file, 2);
  27. $app=$parts[0];
  28. // Load all required applications
  29. \OC::$REQUESTEDAPP = $app;
  30. OC_App::loadApps(array('authentication'));
  31. OC_App::loadApps(array('filesystem', 'logging'));
  32. switch ($app) {
  33. case 'core':
  34. $file = OC::$SERVERROOT .'/'. $file;
  35. break;
  36. default:
  37. OC_Util::checkAppEnabled($app);
  38. OC_App::loadApp($app);
  39. $file = OC_App::getAppPath($app) .'/'. $parts[1];
  40. break;
  41. }
  42. $baseuri = OC::$WEBROOT . '/remote.php/'.$service.'/';
  43. require_once $file;
  44. } catch (Exception $ex) {
  45. OC_Response::setStatus(OC_Response::STATUS_INTERNAL_SERVER_ERROR);
  46. \OCP\Util::writeLog('remote', $ex->getMessage(), \OCP\Util::FATAL);
  47. OC_Template::printExceptionErrorPage($ex);
  48. }