summaryrefslogtreecommitdiffstats
path: root/api.php
diff options
context:
space:
mode:
authorSimon Rettberg2016-05-17 18:14:13 +0200
committerSimon Rettberg2016-05-17 18:14:13 +0200
commit8e729913a8f6258762f4e8049caebc9dbb42a71e (patch)
tree48b1d27787847c012994248e32f5a79695221218 /api.php
parentGet baseconfig ready for modularization (diff)
downloadslx-admin-8e729913a8f6258762f4e8049caebc9dbb42a71e.tar.gz
slx-admin-8e729913a8f6258762f4e8049caebc9dbb42a71e.tar.xz
slx-admin-8e729913a8f6258762f4e8049caebc9dbb42a71e.zip
Modularized baseconfig fetching (api)
Diffstat (limited to 'api.php')
-rw-r--r--api.php17
1 files changed, 9 insertions, 8 deletions
diff --git a/api.php b/api.php
index e3ef94ce..15b11881 100644
--- a/api.php
+++ b/api.php
@@ -12,15 +12,12 @@ if (CONFIG_SQL_PASS === '%MYSQL_OPENSLX_PASS%')
exit(0); // Ignore API calls if not configured yet
// Autoload classes from ./inc which adhere to naming scheme <lowercasename>.inc.php
-function slxAutoloader($class)
-{
+spl_autoload_register(function ($class) {
$file = 'inc/' . preg_replace('/[^a-z0-9]/', '', mb_strtolower($class)) . '.inc.php';
if (!file_exists($file))
return;
require_once $file;
-}
-
-spl_autoload_register('slxAutoloader');
+});
function isLocalExecution()
{
@@ -36,16 +33,20 @@ if (!empty($_REQUEST['do'])) {
$module = 'main';
}
-$module = 'apis/' . $module . '.inc.php';
+Module::init();
+if (Module::isAvailable($module)) {
+ $module = 'modules/' . $module . '/api.inc.php';
+} else {
+ $module = 'apis/' . $module . '.inc.php';
+}
if (!file_exists($module)) {
- Util::traceError('Invalid module: ' . $module);
+ Util::traceError('Invalid module, or module without API: ' . $module);
}
Header('Content-Type: text/plain; charset=utf-8');
// Load module - it will execute pre-processing, or act upon request parameters
require_once($module);
-unset($module);