summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--api.php14
-rw-r--r--apis/init.inc.php2
2 files changed, 12 insertions, 4 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';
diff --git a/apis/init.inc.php b/apis/init.inc.php
index d24b2cca..3e948330 100644
--- a/apis/init.inc.php
+++ b/apis/init.inc.php
@@ -1,6 +1,6 @@
<?php
-if ($_SERVER['REMOTE_ADDR'] !== '127.0.0.1')
+if (!isLocalExecution())
exit(0);
Trigger::ldadp();