Skip to content

Commit 3f36e9b

Browse files
author
Kristan Kenney
authored
Fixes for /edit/server/ (hestiacp#2300)
* hestiacp#2296 - Fix API allowed IPs being reset on save * Fix missing option for debug mode on release builds/flag reset on saving * Hide DNS, Mail, and Database sections if not installed
1 parent c8755fe commit 3f36e9b

File tree

2 files changed

+315
-311
lines changed

2 files changed

+315
-311
lines changed

web/edit/server/index.php

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1113,11 +1113,29 @@
11131113
}
11141114
}
11151115

1116+
// Change API access
1117+
if (empty($_SESSION['error_msg'])) {
1118+
if ($_POST['v_api'] != $_SESSION['API']) {
1119+
$api_status = 'disable';
1120+
if ($_POST['v_api'] == 'yes') {
1121+
$api_status = 'enable';
1122+
}
1123+
exec(HESTIA_CMD."v-change-sys-api ".escapeshellarg($api_status), $output, $return_var);
1124+
check_return_code($return_var, $output);
1125+
unset($output);
1126+
if (empty($_SESSION['error_msg'])) {
1127+
$v_api = $_POST['v_api'];
1128+
}
1129+
$v_security_adv = 'yes';
1130+
}
1131+
}
1132+
1133+
// Change API allowed IPs
11161134
if (empty($_SESSION['error_msg'])) {
11171135
if ($_POST['v_api_allowed_ip'] != $_SESSION['API_ALLOWED_IP']) {
11181136
$ips = array();
11191137
foreach (explode("\n", $_POST['v_api_allowed_ip']) as $ip) {
1120-
if ($ip != "allow-all") {
1138+
if (trim($ip) != "allow-all") {
11211139
if (filter_var(trim($ip), FILTER_VALIDATE_IP)) {
11221140
$ips[] = trim($ip);
11231141
}
@@ -1130,29 +1148,13 @@
11301148
check_return_code($return_var, $output);
11311149
unset($output);
11321150
if (empty($_SESSION['error_msg'])) {
1133-
$v_login_style = $_POST['v_api_allowed_ip'];
1151+
$v_api_allowed_ip = $_POST['v_api_allowed_ip'];
11341152
}
11351153
$v_security_adv = 'yes';
11361154
}
11371155
}
11381156
}
11391157

1140-
if (empty($_SESSION['error_msg'])) {
1141-
if ($_POST['v_api'] != $_SESSION['API']) {
1142-
$api_status = 'disable';
1143-
if ($_POST['v_api'] == 'yes') {
1144-
$api_status = 'enable';
1145-
}
1146-
exec(HESTIA_CMD."v-change-sys-api ".escapeshellarg($api_status), $output, $return_var);
1147-
check_return_code($return_var, $output);
1148-
unset($output);
1149-
if (empty($_SESSION['error_msg'])) {
1150-
$v_login_style = $_POST['v_api'];
1151-
}
1152-
$v_security_adv = 'yes';
1153-
}
1154-
}
1155-
11561158
// Update SSL certificate
11571159
if ((!empty($_POST['v_ssl_crt'])) && (empty($_SESSION['error_msg']))) {
11581160
if (($v_ssl_crt != str_replace("\r\n", "\n", $_POST['v_ssl_crt'])) || ($v_ssl_key != str_replace("\r\n", "\n", $_POST['v_ssl_key']))) {

0 commit comments

Comments
 (0)