Skip to content
Snippets Groups Projects
Commit 82b10954 authored by Bart Visscher's avatar Bart Visscher
Browse files

Simplify loading app php script files

parent 5e7086ad
Branches
No related tags found
No related merge requests found
...@@ -409,10 +409,15 @@ class OC{ ...@@ -409,10 +409,15 @@ class OC{
OC_User::logout(); OC_User::logout();
header("Location: ".OC::$WEBROOT.'/'); header("Location: ".OC::$WEBROOT.'/');
}else{ }else{
if(is_null(OC::$REQUESTEDFILE)) { $app = OC::$REQUESTEDAPP;
self::loadapp(); $file = OC::$REQUESTEDFILE;
}else{ if(is_null($file)) {
self::loadfile(); $file = 'index.php';
}
$file_ext = substr($file, -3);
if ($file_ext != 'php'
|| !self::loadAppScriptFile($app, $file)) {
header('HTTP/1.0 404 Not Found');
} }
} }
return; return;
...@@ -421,32 +426,15 @@ class OC{ ...@@ -421,32 +426,15 @@ class OC{
self::handleLogin(); self::handleLogin();
} }
protected static function loadapp() { protected static function loadAppScriptFile($app, $file) {
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;
$app_path = OC_App::getAppPath($app); $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; $file = $app_path . '/' . $file;
unset($app, $app_path, $app_web_path, $file_ext); unset($app, $app_path);
if (file_exists($file)) {
require_once($file); require_once($file);
return true;
} }
} return false;
else {
die();
header('HTTP/1.0 404 Not Found');
exit;
}
} }
protected static function loadCSSFile() { protected static function loadCSSFile() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment