Blame view
sources/remote.php
1.69 KB
|
03e52840d
|
1 |
<?php |
|
03e52840d
|
2 |
|
|
31b7f2792
|
3 |
try {
|
|
31b7f2792
|
4 |
require_once 'lib/base.php'; |
|
6d9380f96
|
5 6 7 8 9 10 11 12 |
if (\OCP\Util::needUpgrade()) {
// since the behavior of apps or remotes are unpredictable during
// an upgrade, return a 503 directly
OC_Response::setStatus(OC_Response::STATUS_SERVICE_UNAVAILABLE);
OC_Template::printErrorPage('Service unavailable');
exit;
}
|
|
31b7f2792
|
13 14 15 16 17 18 19 20 21 |
$path_info = OC_Request::getPathInfo();
if ($path_info === false || $path_info === '') {
OC_Response::setStatus(OC_Response::STATUS_NOT_FOUND);
exit;
}
if (!$pos = strpos($path_info, '/', 1)) {
$pos = strlen($path_info);
}
$service=substr($path_info, 1, $pos-1);
|
|
6d9380f96
|
22 |
$file = \OC::$server->getAppConfig()->getValue('core', 'remote_' . $service);
|
|
31b7f2792
|
23 24 25 26 27 28 29 |
if(is_null($file)) {
OC_Response::setStatus(OC_Response::STATUS_NOT_FOUND);
exit;
}
$file=ltrim($file, '/');
|
|
03e52840d
|
30 |
|
|
31b7f2792
|
31 32 |
$parts=explode('/', $file, 2);
$app=$parts[0];
|
|
6d9380f96
|
33 34 35 36 37 |
// Load all required applications
\OC::$REQUESTEDAPP = $app;
OC_App::loadApps(array('authentication'));
OC_App::loadApps(array('filesystem', 'logging'));
|
|
31b7f2792
|
38 39 40 41 42 43 44 |
switch ($app) {
case 'core':
$file = OC::$SERVERROOT .'/'. $file;
break;
default:
OC_Util::checkAppEnabled($app);
OC_App::loadApp($app);
|
|
6d9380f96
|
45 |
$file = OC_App::getAppPath($app) .'/'. $parts[1]; |
|
31b7f2792
|
46 47 48 49 |
break; } $baseuri = OC::$WEBROOT . '/remote.php/'.$service.'/'; require_once $file; |
|
03e52840d
|
50 |
|
|
f7d878ff1
|
51 52 53 54 |
} catch (\OC\ServiceUnavailableException $ex) {
OC_Response::setStatus(OC_Response::STATUS_SERVICE_UNAVAILABLE);
\OCP\Util::writeLog('remote', $ex->getMessage(), \OCP\Util::FATAL);
OC_Template::printExceptionErrorPage($ex);
|
|
31b7f2792
|
55 56 57 58 |
} catch (Exception $ex) {
OC_Response::setStatus(OC_Response::STATUS_INTERNAL_SERVER_ERROR);
\OCP\Util::writeLog('remote', $ex->getMessage(), \OCP\Util::FATAL);
OC_Template::printExceptionErrorPage($ex);
|
|
03e52840d
|
59 |
} |