diff --git a/lib/base.php b/lib/base.php
index 89ebefb0deae0d7014d25c215173bc86fcb02aed..0c9fe329b8fe36aa67d55af8121bab74a359ec07 100644
--- a/lib/base.php
+++ b/lib/base.php
@@ -669,12 +669,15 @@ class OC {
 		$app = $param['app'];
 		$file = $param['file'];
 		$app_path = OC_App::getAppPath($app);
-		$file = $app_path . '/' . $file;
-		unset($app, $app_path);
-		if (file_exists($file)) {
-			require_once $file;
-			return true;
+		if (OC_App::isEnabled($app) && $app_path !== false) {
+			$file = $app_path . '/' . $file;
+			unset($app, $app_path);
+			if (file_exists($file)) {
+				require_once $file;
+				return true;
+			}
 		}
+		header('HTTP/1.0 404 Not Found');
 		return false;
 	}