From 352d6a49194d1f021f35abc4b0b20615b65a6bcb Mon Sep 17 00:00:00 2001
From: Florian Schaal <florian@schaal-24.de>
Date: Thu, 14 Dec 2017 17:10:14 +0100
Subject: [PATCH] server_ip_add not working by API (Fixes #4884)

---
 interface/lib/classes/validate_server.inc.php | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/interface/lib/classes/validate_server.inc.php b/interface/lib/classes/validate_server.inc.php
index 6361fb471c..4be0426aed 100644
--- a/interface/lib/classes/validate_server.inc.php
+++ b/interface/lib/classes/validate_server.inc.php
@@ -46,11 +46,15 @@ class validate_server {
 	 * Validator function for server-ip
 	*/
 	function check_server_ip($field_name, $field_value, $validator) {
-		if($_POST['ip_type'] == 'IPv4') {
+		global $app;
+
+		$type=(isset($app->remoting_lib->dataRecord['ip_type']))?$app->remoting_lib->dataRecord['ip_type']:$_POST['ip_type'];
+		
+		if($type == 'IPv4') {
 			if(!filter_var($field_value, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
 				return $this->get_error($validator['errmsg']);
 			}
-		} elseif ($_POST['ip_type'] == 'IPv6') {
+		} elseif ($type == 'IPv6') {
 			if(!filter_var($field_value, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
 				return $this->get_error($validator['errmsg']);
 			}
-- 
GitLab