diff options
author | Simon Rettberg | 2018-03-28 12:37:19 +0200 |
---|---|---|
committer | Simon Rettberg | 2018-03-28 12:37:19 +0200 |
commit | bee018e41677749a6259571d7af7de77504b0736 (patch) | |
tree | 802f2f0874a88c01bd7ac7ed63a8543864130d92 /api.php | |
parent | [sysconfig] Properly disable edit button in module ist (diff) | |
download | slx-admin-bee018e41677749a6259571d7af7de77504b0736.tar.gz slx-admin-bee018e41677749a6259571d7af7de77504b0736.tar.xz slx-admin-bee018e41677749a6259571d7af7de77504b0736.zip |
api.php: Handle --arg=val aswell, populate _GET *and* _REQUEST
Diffstat (limited to 'api.php')
-rw-r--r-- | api.php | 14 |
1 files changed, 11 insertions, 3 deletions
@@ -28,11 +28,19 @@ if (!empty($_REQUEST['do'])) { $module = preg_replace('/[^a-z0-9]/', '', $_REQUEST['do']); } elseif (!empty($argv[1])) { $module = preg_replace('/[^a-z0-9]/', '', $argv[1]); - $argc = count($argv) - 1; + $argc = count($argv); for ($i = 2; $i < $argc; ++$i) { if (substr($argv[$i], 0, 2) === '--') { - $_GET[substr($argv[$i], 2)] = $argv[$i+1]; - ++$i; + // Handle --arg=value and --arg value + $key = substr($argv[$i], 2); + if (($pos = strpos($key, '=')) !== false) { + $val = substr($key, $pos + 1); + $key = substr($key, 0, $pos); + $_REQUEST[$key] = $_GET[$key] = $val; + } elseif ($i + 1 < $argc) { + $_REQUEST[$key] = $_GET[$key] = $argv[$i + 1]; + ++$i; + } } } } else { |