Skip to content

Commit ab5a56b

Browse files
authored
Fix multiple php error (hestiacp#3743)
* Remove v_record_id from form Not used anyways * Fix array_walk function * Fix whitelabel page removed unused options * Sync up permissions with delete / add cron for auto update Role: admin could disable cron but not enable it again * Fix php errors on edit server page * Update docs link to new /docs/ endpoint Instead of https://hestiacp.com/docs/server-administration/troubleshooting.html Fix php bug in add mail
1 parent 01fe5f4 commit ab5a56b

File tree

8 files changed

+77
-97
lines changed

8 files changed

+77
-97
lines changed

web/add/cron/autoupdate/index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// Check token
66
verify_csrf($_GET);
77

8-
if ($_SESSION["user"] == "admin") {
8+
if ($_SESSION["userContext"] === "admin" && $_SESSION["POLICY_SYSTEM_HIDE_SERVICES"] == "no") {
99
exec(HESTIA_CMD . "v-add-cron-hestia-autoupdate", $output, $return_var);
1010
unset($output);
1111
}

web/add/mail/index.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,11 @@
167167
$v_domain .
168168
" " .
169169
$v_smtp_relay_host .
170-
" '" .
170+
" " .
171171
$v_smtp_relay_user .
172-
"' '" .
172+
" " .
173173
$v_smtp_relay_pass .
174-
"' " .
174+
" " .
175175
$v_smtp_relay_port,
176176
$output,
177177
$return_var,

web/delete/cron/autoupdate/index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// Check token
77
verify_csrf($_GET);
88

9-
if ($_SESSION["userContext"] === "admin") {
9+
if ($_SESSION["userContext"] === "admin" && $_SESSION["POLICY_SYSTEM_HIDE_SERVICES"] == "no") {
1010
exec(HESTIA_CMD . "v-delete-cron-hestia-autoupdate", $output, $return_var);
1111
unset($output);
1212
}

web/edit/server/index.php

Lines changed: 68 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1460,44 +1460,49 @@
14601460

14611461
// Change POLICY_SYSTEM_PROTECTED_ADMIN
14621462
if (empty($_SESSION["error_msg"])) {
1463-
if (
1464-
$_POST["v_policy_system_protected_admin"] != $_SESSION["POLICY_SYSTEM_PROTECTED_ADMIN"]
1465-
) {
1466-
exec(
1467-
HESTIA_CMD .
1468-
"v-change-sys-config-value POLICY_SYSTEM_PROTECTED_ADMIN " .
1469-
quoteshellarg($_POST["v_policy_system_protected_admin"]),
1470-
$output,
1471-
$return_var,
1472-
);
1473-
check_return_code($return_var, $output);
1474-
unset($output);
1475-
if (empty($_SESSION["error_msg"])) {
1476-
$v_policy_system_protected_admin = $_POST["v_policy_system_protected_admin"];
1463+
if (!empty($_POST["v_policy_system_protected_admin"])) {
1464+
if (
1465+
$_POST["v_policy_system_protected_admin"] !=
1466+
$_SESSION["POLICY_SYSTEM_PROTECTED_ADMIN"]
1467+
) {
1468+
exec(
1469+
HESTIA_CMD .
1470+
"v-change-sys-config-value POLICY_SYSTEM_PROTECTED_ADMIN " .
1471+
quoteshellarg($_POST["v_policy_system_protected_admin"]),
1472+
$output,
1473+
$return_var,
1474+
);
1475+
check_return_code($return_var, $output);
1476+
unset($output);
1477+
if (empty($_SESSION["error_msg"])) {
1478+
$v_policy_system_protected_admin = $_POST["v_policy_system_protected_admin"];
1479+
}
1480+
$v_security_adv = "yes";
14771481
}
1478-
$v_security_adv = "yes";
14791482
}
14801483
}
14811484

14821485
// Change POLICY_USER_VIEW_SUSPENDED
14831486
if (empty($_SESSION["error_msg"])) {
1484-
if (
1485-
$_POST["v_policy_user_view_suspended"] != $_SESSION["POLICY_USER_VIEW_SUSPENDED"] &&
1486-
!empty($_SESSION["POLICY_USER_VIEW_SUSPENDED"])
1487-
) {
1488-
exec(
1489-
HESTIA_CMD .
1490-
"v-change-sys-config-value POLICY_USER_VIEW_SUSPENDED " .
1491-
quoteshellarg($_POST["v_policy_user_view_suspended"]),
1492-
$output,
1493-
$return_var,
1494-
);
1495-
check_return_code($return_var, $output);
1496-
unset($output);
1497-
if (empty($_SESSION["error_msg"])) {
1498-
$v_policy_system_hide_admin = $_POST["v_policy_user_view_suspended"];
1487+
if (!empty($_POST["v_policy_user_view_suspended"])) {
1488+
if (
1489+
$_POST["v_policy_user_view_suspended"] != $_SESSION["POLICY_USER_VIEW_SUSPENDED"] &&
1490+
!empty($_SESSION["POLICY_USER_VIEW_SUSPENDED"])
1491+
) {
1492+
exec(
1493+
HESTIA_CMD .
1494+
"v-change-sys-config-value POLICY_USER_VIEW_SUSPENDED " .
1495+
quoteshellarg($_POST["v_policy_user_view_suspended"]),
1496+
$output,
1497+
$return_var,
1498+
);
1499+
check_return_code($return_var, $output);
1500+
unset($output);
1501+
if (empty($_SESSION["error_msg"])) {
1502+
$v_policy_user_view_suspended = $_POST["v_policy_user_view_suspended"];
1503+
}
1504+
$v_security_adv = "yes";
14991505
}
1500-
$v_security_adv = "yes";
15011506
}
15021507
}
15031508

@@ -1533,39 +1538,45 @@
15331538

15341539
// Change POLICY_SYSTEM_HIDE_ADMIN
15351540
if (empty($_SESSION["error_msg"])) {
1536-
if ($_POST["v_policy_system_hide_admin"] != $_SESSION["POLICY_SYSTEM_HIDE_ADMIN"]) {
1537-
exec(
1538-
HESTIA_CMD .
1539-
"v-change-sys-config-value POLICY_SYSTEM_HIDE_ADMIN " .
1540-
quoteshellarg($_POST["v_policy_system_hide_admin"]),
1541-
$output,
1542-
$return_var,
1543-
);
1544-
check_return_code($return_var, $output);
1545-
unset($output);
1546-
if (empty($_SESSION["error_msg"])) {
1547-
$v_policy_system_hide_admin = $_POST["v_policy_system_hide_admin"];
1541+
if (!empty($_POST["v_policy_system_hide_admin"])) {
1542+
if ($_POST["v_policy_system_hide_admin"] != $_SESSION["POLICY_SYSTEM_HIDE_ADMIN"]) {
1543+
exec(
1544+
HESTIA_CMD .
1545+
"v-change-sys-config-value POLICY_SYSTEM_HIDE_ADMIN " .
1546+
quoteshellarg($_POST["v_policy_system_hide_admin"]),
1547+
$output,
1548+
$return_var,
1549+
);
1550+
check_return_code($return_var, $output);
1551+
unset($output);
1552+
if (empty($_SESSION["error_msg"])) {
1553+
$v_policy_system_hide_admin = $_POST["v_policy_system_hide_admin"];
1554+
}
1555+
$v_security_adv = "yes";
15481556
}
1549-
$v_security_adv = "yes";
15501557
}
15511558
}
15521559

15531560
// Change POLICY_SYSTEM_HIDE_SERVICES
15541561
if (empty($_SESSION["error_msg"])) {
1555-
if ($_POST["v_policy_system_hide_services"] != $_SESSION["POLICY_SYSTEM_HIDE_SERVICES"]) {
1556-
exec(
1557-
HESTIA_CMD .
1558-
"v-change-sys-config-value POLICY_SYSTEM_HIDE_SERVICES " .
1559-
quoteshellarg($_POST["v_policy_system_hide_services"]),
1560-
$output,
1561-
$return_var,
1562-
);
1563-
check_return_code($return_var, $output);
1564-
unset($output);
1565-
if (empty($_SESSION["error_msg"])) {
1566-
$v_policy_system_hide_services = $_POST["v_policy_system_hide_services"];
1562+
if (!empty($_POST["v_policy_system_hide_services"])) {
1563+
if (
1564+
$_POST["v_policy_system_hide_services"] != $_SESSION["POLICY_SYSTEM_HIDE_SERVICES"]
1565+
) {
1566+
exec(
1567+
HESTIA_CMD .
1568+
"v-change-sys-config-value POLICY_SYSTEM_HIDE_SERVICES " .
1569+
quoteshellarg($_POST["v_policy_system_hide_services"]),
1570+
$output,
1571+
$return_var,
1572+
);
1573+
check_return_code($return_var, $output);
1574+
unset($output);
1575+
if (empty($_SESSION["error_msg"])) {
1576+
$v_policy_system_hide_services = $_POST["v_policy_system_hide_services"];
1577+
}
1578+
$v_security_adv = "yes";
15671579
}
1568-
$v_security_adv = "yes";
15691580
}
15701581
}
15711582
// Change POLICY_SYSTEM_HIDE_SERVICES

web/edit/server/whitelabel/index.php

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -78,33 +78,6 @@
7878
$return_var,
7979
);
8080
}
81-
if ($_SESSION["LOGO_LOGIN"] != $_POST["v_logo_login"]) {
82-
exec(
83-
HESTIA_CMD .
84-
"v-change-sys-config-value LOGO_LOGIN " .
85-
quoteshellarg($_POST["v_logo_login"]),
86-
$output,
87-
$return_var,
88-
);
89-
}
90-
if ($_SESSION["LOGO_HEADER"] != $_POST["v_logo_header"]) {
91-
exec(
92-
HESTIA_CMD .
93-
"v-change-sys-config-value LOGO_HEADER " .
94-
quoteshellarg($_POST["v_logo_header"]),
95-
$output,
96-
$return_var,
97-
);
98-
}
99-
if ($_SESSION["LOGO_FAVICON"] != $_POST["v_logo_favicon"]) {
100-
exec(
101-
HESTIA_CMD .
102-
"v-change-sys-config-value LOGO_FAVICON " .
103-
quoteshellarg($_POST["v_logo_favicon"]),
104-
$output,
105-
$return_var,
106-
);
107-
}
10881
}
10982

11083
// Check system configuration
@@ -123,9 +96,6 @@
12396
$v_from_name = $_SESSION["FROM_NAME"];
12497
$v_from_email = $_SESSION["FROM_EMAIL"];
12598
$v_subject_email = $_SESSION["SUBJECT_EMAIL"];
126-
$v_logo_header = $_SESSION["LOGO_HEADER"];
127-
$v_logo_login = $_SESSION["LOGO_LOGIN"];
128-
$v_logo_favicon = $_SESSION["LOGO_FAVICON"];
12999
// Render page
130100
render_page($user, $TAB, "edit_whitelabel");
131101

web/templates/includes/panel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ class="top-bar-menu-link u-hide-tablet"
210210
?>
211211
<!-- Help / Documentation -->
212212
<li class="top-bar-menu-item">
213-
<a title="<?= _("Help") ?>" class="top-bar-menu-link" href="https://hestiacp.com/docs/server-administration/troubleshooting.html" target="_blank" rel="noopener">
213+
<a title="<?= _("Help") ?>" class="top-bar-menu-link" href="https://hestiacp.com/docs/" target="_blank" rel="noopener">
214214
<i class="fas fa-circle-question"></i>
215215
<span class="top-bar-menu-link-label u-hide-desktop"><?= _("Help") ?></span>
216216
</a>

web/templates/pages/debug_panel.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class="debug-panel-toggle"
2626
if(is_string($val)){
2727
echo "<span class=\"u-text-bold\">" . $key . "= </span> " . $val . " ";
2828
}else if(is_array($val)){
29-
array_walk_recursive($lang, function (&$value) {
29+
array_walk_recursive($val, function (&$value) {
3030
$value = htmlentities($value);
3131
});
3232
echo "<span class=\"u-text-bold\">" . $key . "= </span> " .var_dump($val). " ";
@@ -39,7 +39,7 @@ class="debug-panel-toggle"
3939
if(is_string($val)){
4040
echo "<span class=\"u-text-bold\">" . $key . "= </span> " . $val . " ";
4141
}else if(is_array($val)){
42-
array_walk_recursive($lang, function (&$value) {
42+
array_walk_recursive($val, function (&$value) {
4343
$value = htmlentities($value);
4444
});
4545
echo "<span class=\"u-text-bold\">" . $key . "= </span> " .var_dump($val). " ";
@@ -52,7 +52,7 @@ class="debug-panel-toggle"
5252
if(is_string($val)){
5353
echo "<span class=\"u-text-bold\">" . $key . "= </span> " . $val . " ";
5454
}else if(is_array($val)){
55-
array_walk_recursive($lang, function (&$value) {
55+
array_walk_recursive($val, function (&$value) {
5656
$value = htmlentities($value);
5757
});
5858
echo "<span class=\"u-text-bold\">" . $key . "= </span> " .var_dump($val). " ";

web/templates/pages/edit_web.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,6 @@ class="form-link"
411411
</label>
412412
<input type="text" class="form-control js-ftp-user" <?= $ftp_user['is_new'] != 1 ? 'disabled="disabled"' : '' ?>
413413
name="v_ftp_user[<?= $i ?>][v_ftp_user]" id="v_ftp_user[<?= $i ?>][v_ftp_user]" value="<?= htmlentities(trim($v_ftp_user, "'")) ?>">
414-
<input type="hidden" name="v_record_id" value="<?= htmlentities(trim($v_record_id, "'")) ?>">
415414
<small class="hint js-ftp-user-hint"></small>
416415
</div>
417416
<div class="u-pl30 u-mb10">

0 commit comments

Comments
 (0)