diff options
author | Simon Rettberg | 2014-10-06 17:46:51 +0200 |
---|---|---|
committer | Simon Rettberg | 2014-10-06 17:46:51 +0200 |
commit | 74fdd2e951c4a660d0c653e4d6c79d97da9c0955 (patch) | |
tree | 0a2d50893aa6cc684c4c1b9cec30f02e30d46e1f /api.php | |
parent | Update hardcoded messagea (diff) | |
download | slx-admin-74fdd2e951c4a660d0c653e4d6c79d97da9c0955.tar.gz slx-admin-74fdd2e951c4a660d0c653e4d6c79d97da9c0955.tar.xz slx-admin-74fdd2e951c4a660d0c653e4d6c79d97da9c0955.zip |
Support api calls via cli by using first command line option as module name
Diffstat (limited to 'api.php')
-rw-r--r-- | api.php | 14 |
1 files changed, 11 insertions, 3 deletions
@@ -12,12 +12,20 @@ function slxAutoloader($class) { } spl_autoload_register('slxAutoloader'); +function isLocalExecution() +{ + return !isset($_SERVER['REMOTE_ADDR']) || $_SERVER['REMOTE_ADDR'] === '127.0.0.1'; +} + -if (empty($_REQUEST['do'])) { +if (!empty($_REQUEST['do'])) { + $module = preg_replace('/[^a-z]/', '', $_REQUEST['do']); +} elseif (!empty($argv[1])) { + $module = preg_replace('/[^a-z]/', '', $argv[1]); +} else { // No specific module - set default $module = 'main'; -} else { - $module = preg_replace('/[^a-z]/', '', $_REQUEST['do']); + } $module = 'apis/' . $module . '.inc.php'; |