diff --git a/admin_ipsandports.php b/admin_ipsandports.php index 6b64ae8f..84006fb0 100644 --- a/admin_ipsandports.php +++ b/admin_ipsandports.php @@ -160,5 +160,14 @@ if ($page == 'ipsandports' || $page == 'overview') { eval("echo \"" . \Froxlor\UI\Template::getTemplate("ipsandports/ipsandports_edit") . "\";"); } } + } elseif ($action == 'jqCheckIP') { + $ip = $_POST['ip'] ?? ""; + if ((filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) || filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) && filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE | FILTER_FLAG_NO_PRIV_RANGE) == false) { + // returns notice if private network detected so we can display it + echo json_encode($lng['admin']['ipsandports']['ipnote']); + } else { + echo 0; + } + exit(); } } diff --git a/lib/Froxlor/Api/Commands/IpsAndPorts.php b/lib/Froxlor/Api/Commands/IpsAndPorts.php index 2e690833..9b349080 100644 --- a/lib/Froxlor/Api/Commands/IpsAndPorts.php +++ b/lib/Froxlor/Api/Commands/IpsAndPorts.php @@ -170,7 +170,7 @@ class IpsAndPorts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resour { if ($this->isAdmin() && $this->getUserDetail('change_serversettings')) { - $ip = \Froxlor\Validate\Validate::validate_ip2($this->getParam('ip'), false, 'invalidip', false, false, false, false, true); + $ip = \Froxlor\Validate\Validate::validate_ip2($this->getParam('ip'), false, 'invalidip', false, true, false, false, true); $port = \Froxlor\Validate\Validate::validate($this->getParam('port', true, 80), 'port', '/^(([1-9])|([1-9][0-9])|([1-9][0-9][0-9])|([1-9][0-9][0-9][0-9])|([1-5][0-9][0-9][0-9][0-9])|(6[0-4][0-9][0-9][0-9])|(65[0-4][0-9][0-9])|(655[0-2][0-9])|(6553[0-5]))$/Di', array( 'stringisempty', 'myport' @@ -367,7 +367,7 @@ class IpsAndPorts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resour 'id' => $id )); - $ip = \Froxlor\Validate\Validate::validate_ip2($this->getParam('ip', true, $result['ip']), false, 'invalidip', false, false, false, false, true); + $ip = \Froxlor\Validate\Validate::validate_ip2($this->getParam('ip', true, $result['ip']), false, 'invalidip', false, true, false, false, true); $port = \Froxlor\Validate\Validate::validate($this->getParam('port', true, $result['port']), 'port', '/^(([1-9])|([1-9][0-9])|([1-9][0-9][0-9])|([1-9][0-9][0-9][0-9])|([1-5][0-9][0-9][0-9][0-9])|(6[0-4][0-9][0-9][0-9])|(65[0-4][0-9][0-9])|(655[0-2][0-9])|(6553[0-5]))$/Di', array( 'stringisempty', 'myport' diff --git a/lng/english.lng.php b/lng/english.lng.php index 5a1868a9..db12fe4d 100644 --- a/lng/english.lng.php +++ b/lng/english.lng.php @@ -409,6 +409,7 @@ $lng['admin']['ipsandports']['add'] = 'Add IP/Port'; $lng['admin']['ipsandports']['edit'] = 'Edit IP/Port'; $lng['admin']['ipsandports']['ipandport'] = 'IP/Port'; $lng['admin']['ipsandports']['ip'] = 'IP'; +$lng['admin']['ipsandports']['ipnote'] = '
Note: Although private ip addresses are allowed, some features like DNS might not behave correctly.
Only use private ip addresses if you are sure.
'; $lng['admin']['ipsandports']['port'] = 'Port'; // ADDED IN 1.2.13-rc3 diff --git a/lng/german.lng.php b/lng/german.lng.php index 9208d0e4..74dc5acb 100644 --- a/lng/german.lng.php +++ b/lng/german.lng.php @@ -404,6 +404,7 @@ $lng['admin']['ipsandports']['add'] = 'IP-Adresse/Port hinzufügen'; $lng['admin']['ipsandports']['edit'] = 'IP-Adresse/Port bearbeiten'; $lng['admin']['ipsandports']['ipandport'] = 'IP-Adresse/Port'; $lng['admin']['ipsandports']['ip'] = 'IP-Adresse'; +$lng['admin']['ipsandports']['ipnote'] = '
Hinweis: Obwohl private IP Adressen erlaubt sind, kann es bei manchen Features wie DNS zu ungewolltem Verhalten kommen.
Verwende private Adressen nur wenn du sicher bist.
'; $lng['admin']['ipsandports']['port'] = 'Port'; // ADDED IN 1.2.13-rc3 diff --git a/templates/Sparkle/admin/ipsandports/ipsandports_add.tpl b/templates/Sparkle/admin/ipsandports/ipsandports_add.tpl index 806617ee..20326cd3 100644 --- a/templates/Sparkle/admin/ipsandports/ipsandports_add.tpl +++ b/templates/Sparkle/admin/ipsandports/ipsandports_add.tpl @@ -6,6 +6,7 @@ $header {$title} +
diff --git a/templates/Sparkle/admin/ipsandports/ipsandports_edit.tpl b/templates/Sparkle/admin/ipsandports/ipsandports_edit.tpl index 4d12e2ac..4f61b938 100644 --- a/templates/Sparkle/admin/ipsandports/ipsandports_edit.tpl +++ b/templates/Sparkle/admin/ipsandports/ipsandports_edit.tpl @@ -6,6 +6,7 @@ $header {$title} +
diff --git a/templates/Sparkle/assets/js/ipsandports.js b/templates/Sparkle/assets/js/ipsandports.js new file mode 100644 index 00000000..87091afa --- /dev/null +++ b/templates/Sparkle/assets/js/ipsandports.js @@ -0,0 +1,46 @@ +$(document).ready(function() { + + var getUrlParameter = function getUrlParameter(sParam) { + var sPageURL = decodeURIComponent(window.location.search.substring(1)), + sURLVariables = sPageURL.split('&'), + sParameterName, + i; + + for (i = 0; i < sURLVariables.length; i++) { + sParameterName = sURLVariables[i].split('='); + + if (sParameterName[0] === sParam) { + return sParameterName[1] === undefined ? true : sParameterName[1]; + } + } + }; + + /** + * check for internal ip and output a notice if private-range ip is given + */ + $('#ip').change(function() { + var ipval = $(this).val(); + if (ipval.length > 0) { + var sid = getUrlParameter('s'); + $.ajax({ + url: "admin_ipsandports.php?s="+sid+"&page=overview&action=jqCheckIP", + type: "POST", + data: { + ip: ipval + }, + dataType: "json", + success: function(json) { + if (json != 0) { + $('#ip').parent().append(json); + } else { + $('#ipnote').remove(); + } + }, + error: function(a, b) { + console.log(a, b); + } + }); + } + }); + +});