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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. OC_Util::checkAppEnabled($app);
  35. OC_App::loadApp($app);
  36. OC_User::setIncognitoMode(true);
  37. $baseuri = OC::$WEBROOT . '/public.php/' . $service . '/';
  38. require_once OC_App::getAppPath($app) . '/' . $parts[1];
  39. } catch (\OC\ServiceUnavailableException $ex) {
  40. //show the user a detailed error page
  41. OC_Response::setStatus(OC_Response::STATUS_SERVICE_UNAVAILABLE);
  42. \OCP\Util::writeLog('remote', $ex->getMessage(), \OCP\Util::FATAL);
  43. OC_Template::printExceptionErrorPage($ex);
  44. } catch (Exception $ex) {
  45. //show the user a detailed error page
  46. OC_Response::setStatus(OC_Response::STATUS_INTERNAL_SERVER_ERROR);
  47. \OCP\Util::writeLog('remote', $ex->getMessage(), \OCP\Util::FATAL);
  48. OC_Template::printExceptionErrorPage($ex);
  49. }