remote.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. $RUNTIME_NOSETUPFS = true;
  3. $RUNTIME_NOAPPS = TRUE;
  4. require_once('lib/base.php');
  5. if (array_key_exists('PATH_INFO', $_SERVER)){
  6. $path_info = $_SERVER['PATH_INFO'];
  7. }else{
  8. $path_info = substr($_SERVER['REQUEST_URI'], strlen($_SERVER['SCRIPT_NAME']));
  9. }
  10. if ($path_info === false) {
  11. OC_Response::setStatus(OC_Response::STATUS_NOT_FOUND);
  12. exit;
  13. }
  14. if (!$pos = strpos($path_info, '/', 1)) {
  15. $pos = strlen($path_info);
  16. }
  17. $service=substr($path_info, 1, $pos-1);
  18. $file = OC_AppConfig::getValue('core', 'remote_' . $service);
  19. $file = preg_replace('/apps\//','', $file); //Todo Remove after Multiappdir migration
  20. if(is_null($file)){
  21. OC_Response::setStatus(OC_Response::STATUS_NOT_FOUND);
  22. exit;
  23. }
  24. $file = ltrim ($file, '/');
  25. $parts=explode('/', $file, 2);
  26. $app=$parts[0];
  27. switch ($app) {
  28. default:
  29. OC_Util::checkAppEnabled($app);
  30. OC_App::loadApp($app);
  31. $file = OC_App::getAppPath($app) .'/'. $parts[1];
  32. break;
  33. case 'core':
  34. $file = OC::$SERVERROOT .'/'. $file;
  35. break;
  36. }
  37. $baseuri = OC::$WEBROOT . '/remote.php/'.$service.'/';
  38. require_once($file);