2012-05-07 09:39:17 -04:00
|
|
|
<?php
|
2015-03-26 06:44:34 -04:00
|
|
|
/**
|
2016-07-21 11:07:57 -04:00
|
|
|
* @copyright Copyright (c) 2016, ownCloud, Inc.
|
|
|
|
|
*
|
2016-05-26 13:56:05 -04:00
|
|
|
* @author Björn Schießle <bjoern@schiessle.org>
|
2015-03-26 06:44:34 -04:00
|
|
|
* @author Christopher Schäpers <kondou@ts.unde.re>
|
2020-03-31 04:49:10 -04:00
|
|
|
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
|
2017-11-06 09:56:42 -05:00
|
|
|
* @author Joas Schilling <coding@schilljs.com>
|
2015-03-26 06:44:34 -04:00
|
|
|
* @author Jörn Friedrich Dreyer <jfd@butonic.de>
|
2016-05-26 13:56:05 -04:00
|
|
|
* @author Lukas Reschke <lukas@statuscode.ch>
|
2019-12-03 13:57:53 -05:00
|
|
|
* @author Maxence Lange <maxence@artificial-owl.com>
|
2016-07-21 11:07:57 -04:00
|
|
|
* @author Morris Jobke <hey@morrisjobke.de>
|
2016-07-21 12:13:36 -04:00
|
|
|
* @author Robin Appelman <robin@icewind.nl>
|
2019-12-03 13:57:53 -05:00
|
|
|
* @author Roeland Jago Douma <roeland@famdouma.nl>
|
2015-06-25 05:43:55 -04:00
|
|
|
* @author Thomas Müller <thomas.mueller@tmit.eu>
|
2020-12-16 08:54:15 -05:00
|
|
|
* @author Vincent Petry <vincent@nextcloud.com>
|
2015-03-26 06:44:34 -04:00
|
|
|
*
|
|
|
|
|
* @license AGPL-3.0
|
|
|
|
|
*
|
|
|
|
|
* This code is free software: you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU Affero General Public License, version 3,
|
|
|
|
|
* as published by the Free Software Foundation.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU Affero General Public License, version 3,
|
2019-12-03 13:57:53 -05:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
2015-03-26 06:44:34 -04:00
|
|
|
*
|
|
|
|
|
*/
|
2017-10-13 15:30:29 -04:00
|
|
|
|
|
|
|
|
require_once __DIR__ . '/lib/versioncheck.php';
|
|
|
|
|
|
2013-06-10 07:45:19 -04:00
|
|
|
try {
|
2016-10-06 06:13:02 -04:00
|
|
|
require_once __DIR__ . '/lib/base.php';
|
2014-06-30 08:48:03 -04:00
|
|
|
if (\OCP\Util::needUpgrade()) {
|
|
|
|
|
// since the behavior of apps or remotes are unpredictable during
|
|
|
|
|
// an upgrade, return a 503 directly
|
2018-06-26 06:15:09 -04:00
|
|
|
OC_Template::printErrorPage('Service unavailable', '', 503);
|
2014-06-30 08:48:03 -04:00
|
|
|
exit;
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-20 15:55:16 -05:00
|
|
|
OC::checkMaintenanceMode(\OC::$server->get(\OC\SystemConfig::class));
|
2016-07-07 06:14:45 -04:00
|
|
|
$request = \OC::$server->getRequest();
|
2015-02-10 07:02:48 -05:00
|
|
|
$pathInfo = $request->getPathInfo();
|
2015-02-23 08:07:42 -05:00
|
|
|
|
|
|
|
|
if (!$pathInfo && $request->getParam('service', '') === '') {
|
2018-06-26 04:32:50 -04:00
|
|
|
http_response_code(404);
|
2013-06-10 07:45:19 -04:00
|
|
|
exit;
|
2015-02-23 08:07:42 -05:00
|
|
|
} elseif ($request->getParam('service', '')) {
|
|
|
|
|
$service = $request->getParam('service', '');
|
2014-03-06 10:01:13 -05:00
|
|
|
} else {
|
|
|
|
|
$pathInfo = trim($pathInfo, '/');
|
2021-01-12 04:15:48 -05:00
|
|
|
[$service] = explode('/', $pathInfo);
|
2013-06-10 07:45:19 -04:00
|
|
|
}
|
2017-07-19 09:48:58 -04:00
|
|
|
$file = \OC::$server->getConfig()->getAppValue('core', 'public_' . strip_tags($service));
|
2018-09-27 10:28:47 -04:00
|
|
|
if ($file === '') {
|
2018-06-26 04:32:50 -04:00
|
|
|
http_response_code(404);
|
2013-06-10 07:45:19 -04:00
|
|
|
exit;
|
|
|
|
|
}
|
2012-05-13 18:28:22 -04:00
|
|
|
|
2014-03-06 10:01:13 -05:00
|
|
|
$parts = explode('/', $file, 2);
|
|
|
|
|
$app = $parts[0];
|
2013-06-10 07:45:19 -04:00
|
|
|
|
2014-05-10 08:00:22 -04:00
|
|
|
// Load all required applications
|
|
|
|
|
\OC::$REQUESTEDAPP = $app;
|
2020-03-26 04:30:18 -04:00
|
|
|
OC_App::loadApps(['authentication']);
|
|
|
|
|
OC_App::loadApps(['filesystem', 'logging']);
|
2014-05-10 08:00:22 -04:00
|
|
|
|
2014-09-04 09:23:55 -04:00
|
|
|
if (!\OC::$server->getAppManager()->isInstalled($app)) {
|
2019-07-15 19:03:57 -04:00
|
|
|
http_response_code(404);
|
2018-12-18 05:04:29 -05:00
|
|
|
exit;
|
2014-09-04 09:23:55 -04:00
|
|
|
}
|
2013-06-10 07:45:19 -04:00
|
|
|
OC_App::loadApp($app);
|
2013-11-22 08:00:08 -05:00
|
|
|
OC_User::setIncognitoMode(true);
|
2013-06-10 07:45:19 -04:00
|
|
|
|
2014-03-06 10:01:13 -05:00
|
|
|
$baseuri = OC::$WEBROOT . '/public.php/' . $service . '/';
|
|
|
|
|
|
|
|
|
|
require_once OC_App::getAppPath($app) . '/' . $parts[1];
|
2016-04-20 12:01:47 -04:00
|
|
|
} catch (Exception $ex) {
|
2018-06-26 06:15:09 -04:00
|
|
|
$status = 500;
|
2016-04-20 12:01:47 -04:00
|
|
|
if ($ex instanceof \OC\ServiceUnavailableException) {
|
2018-06-26 06:15:09 -04:00
|
|
|
$status = 503;
|
2016-04-20 12:01:47 -04:00
|
|
|
}
|
2014-07-24 11:18:10 -04:00
|
|
|
//show the user a detailed error page
|
2016-04-20 12:01:47 -04:00
|
|
|
\OC::$server->getLogger()->logException($ex, ['app' => 'public']);
|
2018-06-26 04:27:43 -04:00
|
|
|
OC_Template::printExceptionErrorPage($ex, $status);
|
2016-04-20 12:01:47 -04:00
|
|
|
} catch (Error $ex) {
|
2013-06-10 07:45:19 -04:00
|
|
|
//show the user a detailed error page
|
2016-04-20 12:01:47 -04:00
|
|
|
\OC::$server->getLogger()->logException($ex, ['app' => 'public']);
|
2018-06-26 06:15:09 -04:00
|
|
|
OC_Template::printExceptionErrorPage($ex, 500);
|
2013-08-18 05:02:08 -04:00
|
|
|
}
|