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.2KB

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