summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorBart Visscher <bartv@thisnet.nl>2012-08-10 12:27:37 +0200
committerBart Visscher <bartv@thisnet.nl>2012-08-10 12:27:37 +0200
commit82b10954e714135aac332c4e349124731841aa90 (patch)
tree84e90530d3583ff627c9366d45f7c5c09cbb1328 /lib
parent5e7086adc93c501b6fcef8650d6552e95a1b6b28 (diff)
downloadnextcloud-server-82b10954e714135aac332c4e349124731841aa90.tar.gz
nextcloud-server-82b10954e714135aac332c4e349124731841aa90.zip
Simplify loading app php script files
Diffstat (limited to 'lib')
-rw-r--r--lib/base.php44
1 files changed, 16 insertions, 28 deletions
diff --git a/lib/base.php b/lib/base.php
index b200da77ba5..c4127c73f26 100644
--- a/lib/base.php
+++ b/lib/base.php
@@ -409,10 +409,15 @@ class OC{
OC_User::logout();
header("Location: ".OC::$WEBROOT.'/');
}else{
- if(is_null(OC::$REQUESTEDFILE)) {
- self::loadapp();
- }else{
- self::loadfile();
+ $app = OC::$REQUESTEDAPP;
+ $file = OC::$REQUESTEDFILE;
+ if(is_null($file)) {
+ $file = 'index.php';
+ }
+ $file_ext = substr($file, -3);
+ if ($file_ext != 'php'
+ || !self::loadAppScriptFile($app, $file)) {
+ header('HTTP/1.0 404 Not Found');
}
}
return;
@@ -421,32 +426,15 @@ class OC{
self::handleLogin();
}
- protected static function loadapp() {
- if(file_exists(OC_App::getAppPath(OC::$REQUESTEDAPP) . '/index.php')) {
- require_once(OC_App::getAppPath(OC::$REQUESTEDAPP) . '/index.php');
- }
- else {
- trigger_error('The requested App was not found.', E_USER_ERROR);//load default app instead?
- }
- }
-
- protected static function loadfile() {
- $app = OC::$REQUESTEDAPP;
- $file = OC::$REQUESTEDFILE;
+ protected static function loadAppScriptFile($app, $file) {
$app_path = OC_App::getAppPath($app);
- if (file_exists($app_path . '/' . $file)) {
- $file_ext = substr($file, -3);
- if ($file_ext == 'php') {
- $file = $app_path . '/' . $file;
- unset($app, $app_path, $app_web_path, $file_ext);
- require_once($file);
- }
- }
- else {
- die();
- header('HTTP/1.0 404 Not Found');
- exit;
+ $file = $app_path . '/' . $file;
+ unset($app, $app_path);
+ if (file_exists($file)) {
+ require_once($file);
+ return true;
}
+ return false;
}
protected static function loadCSSFile() {