summaryrefslogtreecommitdiffstats
path: root/api.php
diff options
context:
space:
mode:
authorSimon Rettberg2014-10-06 17:46:51 +0200
committerSimon Rettberg2014-10-06 17:46:51 +0200
commit74fdd2e951c4a660d0c653e4d6c79d97da9c0955 (patch)
tree0a2d50893aa6cc684c4c1b9cec30f02e30d46e1f /api.php
parentUpdate hardcoded messagea (diff)
downloadslx-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.php14
1 files changed, 11 insertions, 3 deletions
diff --git a/api.php b/api.php
index f8e9c4d5..289a17f1 100644
--- a/api.php
+++ b/api.php
@@ -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';