You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

remote.php 1.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. switch ($app) {
  22. case 'core':
  23. $file = OC::$SERVERROOT .'/'. $file;
  24. break;
  25. default:
  26. OC_Util::checkAppEnabled($app);
  27. OC_App::loadApp($app);
  28. $file = OC_App::getAppPath($app) .'/'. $parts[1];
  29. break;
  30. }
  31. $baseuri = OC::$WEBROOT . '/remote.php/'.$service.'/';
  32. require_once $file;
  33. } catch (Exception $ex) {
  34. OC_Response::setStatus(OC_Response::STATUS_INTERNAL_SERVER_ERROR);
  35. \OCP\Util::writeLog('remote', $ex->getMessage(), \OCP\Util::FATAL);
  36. OC_Template::printExceptionErrorPage($ex);
  37. }