From b8942a6e3ac3786d82d4ab5f1c340028c29e9d62 Mon Sep 17 00:00:00 2001 From: A. Täffner <darkalex@firesplash.de> Date: Tue, 14 Jun 2016 03:21:28 -0400 Subject: [PATCH] Revert "Fixes ispconfig/ispconfig3#3943" --- interface/lib/classes/json_handler.inc.php | 23 +++++++++++++---------- 1 files changed, 13 insertions(+), 10 deletions(-) diff --git a/interface/lib/classes/json_handler.inc.php b/interface/lib/classes/json_handler.inc.php index 1df5898..de8dd5b 100644 --- a/interface/lib/classes/json_handler.inc.php +++ b/interface/lib/classes/json_handler.inc.php @@ -88,15 +88,11 @@ $keys = array_keys($_GET); $method = reset($keys); $params = array(); - - if(is_array($_POST)) { - foreach($_POST as $key => $val) { - $tmp = json_decode($val); - if(!$tmp) $params[] = $val; - else $params[] = (array)$tmp; - } - } - + + $raw = file_get_contents("php://input"); + $json = json_decode($raw, true); + if(!is_array($json)) $this->_return_json('invalid_data', 'The JSON data sent to the api is invalid'); + if(array_key_exists($method, $this->methods) == false) { $this->_return_json('invalid_method', 'Method ' . $method . ' does not exist'); } @@ -109,7 +105,14 @@ if(method_exists($this->classes[$class_name], $method) == false) { $this->_return_json('invalid_method', 'Method ' . $method . ' does not exist in the class it was expected (' . $class_name . ')'); } - + + $methObj = new ReflectionMethod($this->classes[$class_name], $method); + foreach($methObj->getParameters() as $param) { + $pname = $param->name; + if(isset($json[$pname])) $params[] = $json[$pname]; + else $params[] = null; + } + try { $this->_return_json('ok', '', call_user_func_array(array($this->classes[$class_name], $method), $params)); } catch(SoapFault $e) { -- Gitblit v1.9.1