remote.php 1.2 KB

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