Blame view

sources/public.php 1.45 KB
03e52840d   Kload   Init
1
  <?php
03e52840d   Kload   Init
2

31b7f2792   Kload   Upgrade to ownclo...
3
4
5
  try {
  
  	require_once 'lib/base.php';
6d9380f96   Cédric Dupont   Update sources OC...
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   Kload   Upgrade to ownclo...
13
14
  	OC::checkMaintenanceMode();
  	OC::checkSingleUserMode();
6d9380f96   Cédric Dupont   Update sources OC...
15
16
  	$pathInfo = OC_Request::getPathInfo();
  	if (!$pathInfo && !isset($_GET['service'])) {
31b7f2792   Kload   Upgrade to ownclo...
17
18
  		header('HTTP/1.0 404 Not Found');
  		exit;
6d9380f96   Cédric Dupont   Update sources OC...
19
20
21
22
23
  	} elseif (isset($_GET['service'])) {
  		$service = $_GET['service'];
  	} else {
  		$pathInfo = trim($pathInfo, '/');
  		list($service) = explode('/', $pathInfo);
31b7f2792   Kload   Upgrade to ownclo...
24
  	}
6d9380f96   Cédric Dupont   Update sources OC...
25
26
  	$file = OCP\CONFIG::getAppValue('core', 'public_' . strip_tags($service));
  	if (is_null($file)) {
31b7f2792   Kload   Upgrade to ownclo...
27
28
29
  		header('HTTP/1.0 404 Not Found');
  		exit;
  	}
03e52840d   Kload   Init
30

6d9380f96   Cédric Dupont   Update sources OC...
31
32
33
34
35
36
37
  	$parts = explode('/', $file, 2);
  	$app = $parts[0];
  
  	// Load all required applications
  	\OC::$REQUESTEDAPP = $app;
  	OC_App::loadApps(array('authentication'));
  	OC_App::loadApps(array('filesystem', 'logging'));
03e52840d   Kload   Init
38

31b7f2792   Kload   Upgrade to ownclo...
39
40
41
  	OC_Util::checkAppEnabled($app);
  	OC_App::loadApp($app);
  	OC_User::setIncognitoMode(true);
6d9380f96   Cédric Dupont   Update sources OC...
42
43
44
  	$baseuri = OC::$WEBROOT . '/public.php/' . $service . '/';
  
  	require_once OC_App::getAppPath($app) . '/' . $parts[1];
31b7f2792   Kload   Upgrade to ownclo...
45
46
47
48
49
50
51
  
  } catch (Exception $ex) {
  	//show the user a detailed error page
  	OC_Response::setStatus(OC_Response::STATUS_INTERNAL_SERVER_ERROR);
  	\OCP\Util::writeLog('remote', $ex->getMessage(), \OCP\Util::FATAL);
  	OC_Template::printExceptionErrorPage($ex);
  }