diff options
author | Simon Rettberg | 2016-05-17 18:14:13 +0200 |
---|---|---|
committer | Simon Rettberg | 2016-05-17 18:14:13 +0200 |
commit | 8e729913a8f6258762f4e8049caebc9dbb42a71e (patch) | |
tree | 48b1d27787847c012994248e32f5a79695221218 /api.php | |
parent | Get baseconfig ready for modularization (diff) | |
download | slx-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.php | 17 |
1 files changed, 9 insertions, 8 deletions
@@ -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); |