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.

public.php 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. try {
  3. require_once 'lib/base.php';
  4. if (\OCP\Util::needUpgrade()) {
  5. // since the behavior of apps or remotes are unpredictable during
  6. // an upgrade, return a 503 directly
  7. OC_Response::setStatus(OC_Response::STATUS_SERVICE_UNAVAILABLE);
  8. OC_Template::printErrorPage('Service unavailable');
  9. exit;
  10. }
  11. OC::checkMaintenanceMode();
  12. OC::checkSingleUserMode();
  13. $pathInfo = OC_Request::getPathInfo();
  14. if (!$pathInfo && !isset($_GET['service'])) {
  15. header('HTTP/1.0 404 Not Found');
  16. exit;
  17. } elseif (isset($_GET['service'])) {
  18. $service = $_GET['service'];
  19. } else {
  20. $pathInfo = trim($pathInfo, '/');
  21. list($service) = explode('/', $pathInfo);
  22. }
  23. $file = OCP\CONFIG::getAppValue('core', 'public_' . strip_tags($service));
  24. if (is_null($file)) {
  25. header('HTTP/1.0 404 Not Found');
  26. exit;
  27. }
  28. $parts = explode('/', $file, 2);
  29. $app = $parts[0];
  30. // Load all required applications
  31. \OC::$REQUESTEDAPP = $app;
  32. OC_App::loadApps(array('authentication'));
  33. OC_App::loadApps(array('filesystem', 'logging'));
  34. if (!\OC::$server->getAppManager()->isInstalled($app)) {
  35. throw new Exception('App not installed: ' . $app);
  36. }
  37. OC_App::loadApp($app);
  38. OC_User::setIncognitoMode(true);
  39. $baseuri = OC::$WEBROOT . '/public.php/' . $service . '/';
  40. require_once OC_App::getAppPath($app) . '/' . $parts[1];
  41. } catch (\OC\ServiceUnavailableException $ex) {
  42. //show the user a detailed error page
  43. OC_Response::setStatus(OC_Response::STATUS_SERVICE_UNAVAILABLE);
  44. \OCP\Util::writeLog('remote', $ex->getMessage(), \OCP\Util::FATAL);
  45. OC_Template::printExceptionErrorPage($ex);
  46. } catch (Exception $ex) {
  47. //show the user a detailed error page
  48. OC_Response::setStatus(OC_Response::STATUS_INTERNAL_SERVER_ERROR);
  49. \OCP\Util::writeLog('remote', $ex->getMessage(), \OCP\Util::FATAL);
  50. OC_Template::printExceptionErrorPage($ex);
  51. }