PageRenderTime 44ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/remote.php

https://github.com/sezuan/core
PHP | 49 lines | 42 code | 7 blank | 0 comment | 6 complexity | c936fffff80abbf41c20655c9d2cc916 MD5 | raw file
Possible License(s): AGPL-3.0, AGPL-1.0, MPL-2.0-no-copyleft-exception
  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. }