Skip to content

Commit 7260649

Browse files
authored
Fix multiple php 500 errors (hestiacp#3789)
This commit fixes multiple PHP errors which were present in /var/log/hestia/nginx-error.log due to variable declaration changes.
1 parent bbea1ad commit 7260649

File tree

19 files changed

+87
-77
lines changed

19 files changed

+87
-77
lines changed

func/main.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,8 @@ log_history() {
129129
fi
130130
touch $log
131131

132-
if [ '750' -lt "$(wc -l $log | cut -f 1 -d ' ')" ]; then
133-
tail -n 499 $log > $log.moved
132+
if [ '300' -lt "$(wc -l $log | cut -f 1 -d ' ')" ]; then
133+
tail -n 250 $log > $log.moved
134134
mv -f $log.moved $log
135135
chmod 660 $log
136136
fi

web/add/dns/index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@
397397
if (empty($v_dnssec)) {
398398
$v_dnssec = "";
399399
}
400-
400+
$accept = $_GET["accept"] ?? "";
401401
render_page($user, $TAB, "add_dns_rec");
402402
}
403403

web/add/key/index.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
use function Hestiacp\quoteshellarg\quoteshellarg;
33

44
ob_start();
5-
session_start();
65
$TAB = "USER";
76

87
// Main include

web/add/package/index.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -122,14 +122,15 @@
122122
$v_disk_quota = quoteshellarg($_POST["v_disk_quota"]);
123123
$v_bandwidth = quoteshellarg($_POST["v_bandwidth"]);
124124
$v_ratelimit = quoteshellarg($_POST["v_ratelimit"]);
125-
$v_ns1 = trim($_POST["v_ns1"], ".");
126-
$v_ns2 = trim($_POST["v_ns2"], ".");
127-
$v_ns3 = trim($_POST["v_ns3"], ".");
128-
$v_ns4 = trim($_POST["v_ns4"], ".");
129-
$v_ns5 = trim($_POST["v_ns5"], ".");
130-
$v_ns6 = trim($_POST["v_ns6"], ".");
131-
$v_ns7 = trim($_POST["v_ns7"], ".");
132-
$v_ns8 = trim($_POST["v_ns8"], ".");
125+
$v_ns1 = !empty($_POST["v_ns1"]) ? trim($_POST["v_ns1"], ".") : "";
126+
$v_ns2 = !empty($_POST["v_ns2"]) ? trim($_POST["v_ns2"], ".") : "";
127+
$v_ns3 = !empty($_POST["v_ns3"]) ? trim($_POST["v_ns3"], ".") : "";
128+
$v_ns4 = !empty($_POST["v_ns4"]) ? trim($_POST["v_ns4"], ".") : "";
129+
$v_ns5 = !empty($_POST["v_ns5"]) ? trim($_POST["v_ns5"], ".") : "";
130+
$v_ns6 = !empty($_POST["v_ns6"]) ? trim($_POST["v_ns6"], ".") : "";
131+
$v_ns7 = !empty($_POST["v_ns7"]) ? trim($_POST["v_ns7"], ".") : "";
132+
$v_ns8 = !empty($_POST["v_ns8"]) ? trim($_POST["v_ns8"], ".") : "";
133+
133134
$v_ns = $v_ns1 . "," . $v_ns2;
134135
if (!empty($v_ns3)) {
135136
$v_ns .= "," . $v_ns3;

web/edit/backup/exclusions/index.php

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
$data = json_decode(implode("", $output), true);
1818
unset($output);
1919

20+
$v_web = $v_mail = $v_db = $v_userdir = "";
2021
// Parse web
2122
$v_username = $user;
2223
foreach ($data["WEB"] as $key => $value) {
@@ -27,15 +28,6 @@
2728
}
2829
}
2930

30-
// Parse dns
31-
foreach ($data["DNS"] as $key => $value) {
32-
if (!empty($value)) {
33-
$v_dns .= $key . ":" . $value . "\n";
34-
} else {
35-
$v_dns .= $key . "\n";
36-
}
37-
}
38-
3931
// Parse mail
4032
foreach ($data["MAIL"] as $key => $value) {
4133
if (!empty($value)) {
@@ -68,32 +60,32 @@
6860
// Check token
6961
verify_csrf($_POST);
7062

71-
$v_web = $_POST["v_web"];
63+
$v_web = $_POST["v_web"] ?? "";
7264
$v_web_tmp = str_replace("\r\n", ",", $_POST["v_web"]);
7365
$v_web_tmp = rtrim($v_web_tmp, ",");
7466
$v_web_tmp = "WEB=" . quoteshellarg($v_web_tmp);
7567

76-
$v_dns = $_POST["v_dns"];
68+
$v_dns = $_POST["v_dns"] ?? "";
7769
$v_dns_tmp = str_replace("\r\n", ",", $_POST["v_dns"]);
7870
$v_dns_tmp = rtrim($v_dns_tmp, ",");
7971
$v_dns_tmp = "DNS=" . quoteshellarg($v_dns_tmp);
8072

81-
$v_mail = $_POST["v_mail"];
73+
$v_mail = $_POST["v_mail"] ?? "";
8274
$v_mail_tmp = str_replace("\r\n", ",", $_POST["v_mail"]);
8375
$v_mail_tmp = rtrim($v_mail_tmp, ",");
8476
$v_mail_tmp = "MAIL=" . quoteshellarg($v_mail_tmp);
8577

86-
$v_db = $_POST["v_db"];
78+
$v_db = $_POST["v_db"] ?? "";
8779
$v_db_tmp = str_replace("\r\n", ",", $_POST["v_db"]);
8880
$v_db_tmp = rtrim($v_db_tmp, ",");
8981
$v_db_tmp = "DB=" . quoteshellarg($v_db_tmp);
9082

91-
$v_cron = $_POST["v_cron"];
83+
$v_cron = $_POST["v_cron"] ?? "";
9284
$v_cron_tmp = str_replace("\r\n", ",", $_POST["v_cron"]);
9385
$v_cron_tmp = rtrim($v_cron_tmp, ",");
9486
$v_cron_tmp = "CRON=" . quoteshellarg($v_cron_tmp);
9587

96-
$v_userdir = $_POST["v_userdir"];
88+
$v_userdir = $_POST["v_userdir"] ?? "";
9789
$v_userdir_tmp = str_replace("\r\n", ",", $_POST["v_userdir"]);
9890
$v_userdir_tmp = rtrim($v_userdir_tmp, ",");
9991
$v_userdir_tmp = "USER=" . quoteshellarg($v_userdir_tmp);

web/edit/package/index.php

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,11 @@
224224
$v_proxy_template = quoteshellarg($_POST["v_proxy_template"]);
225225
}
226226
$v_dns_template = quoteshellarg($_POST["v_dns_template"]);
227-
$v_shell = quoteshellarg($_POST["v_shell"]);
227+
if (!empty($_POST["v_shell"])) {
228+
$v_shell = quoteshellarg($_POST["v_shell"]);
229+
} else {
230+
$v_shell = "nologin";
231+
}
228232
$v_web_domains = quoteshellarg($_POST["v_web_domains"]);
229233
$v_web_aliases = quoteshellarg($_POST["v_web_aliases"]);
230234
$v_dns_domains = quoteshellarg($_POST["v_dns_domains"]);
@@ -237,14 +241,14 @@
237241
$v_backups = quoteshellarg($_POST["v_backups"]);
238242
$v_disk_quota = quoteshellarg($_POST["v_disk_quota"]);
239243
$v_bandwidth = quoteshellarg($_POST["v_bandwidth"]);
240-
$v_ns1 = trim($_POST["v_ns1"], ".");
241-
$v_ns2 = trim($_POST["v_ns2"], ".");
242-
$v_ns3 = trim($_POST["v_ns3"], ".");
243-
$v_ns4 = trim($_POST["v_ns4"], ".");
244-
$v_ns5 = trim($_POST["v_ns5"], ".");
245-
$v_ns6 = trim($_POST["v_ns6"], ".");
246-
$v_ns7 = trim($_POST["v_ns7"], ".");
247-
$v_ns8 = trim($_POST["v_ns8"], ".");
244+
$v_ns1 = !empty($_POST["v_ns1"]) ? trim($_POST["v_ns1"], ".") : "";
245+
$v_ns2 = !empty($_POST["v_ns2"]) ? trim($_POST["v_ns2"], ".") : "";
246+
$v_ns3 = !empty($_POST["v_ns3"]) ? trim($_POST["v_ns3"], ".") : "";
247+
$v_ns4 = !empty($_POST["v_ns4"]) ? trim($_POST["v_ns4"], ".") : "";
248+
$v_ns5 = !empty($_POST["v_ns5"]) ? trim($_POST["v_ns5"], ".") : "";
249+
$v_ns6 = !empty($_POST["v_ns6"]) ? trim($_POST["v_ns6"], ".") : "";
250+
$v_ns7 = !empty($_POST["v_ns7"]) ? trim($_POST["v_ns7"], ".") : "";
251+
$v_ns8 = !empty($_POST["v_ns8"]) ? trim($_POST["v_ns8"], ".") : "";
248252
$v_ns = $v_ns1 . "," . $v_ns2;
249253
if (!empty($v_ns3)) {
250254
$v_ns .= "," . $v_ns3;

web/edit/user/index.php

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
// Prevent other users with admin privileges from editing properties of default 'admin' user
2626
if (
27-
($_SESSION["userContext"] === "admin" && isset($_SESSION["look"]) && $user == "admin") ||
27+
($_SESSION["userContext"] === "admin" && $_SESSION["look"] != "" && $user == "admin") ||
2828
($_SESSION["userContext"] === "admin" &&
2929
!isset($_SESSION["look"]) &&
3030
$user == "admin" &&
@@ -361,19 +361,25 @@
361361
}
362362
}
363363
// Change shell (admin only)
364-
if (
365-
$v_shell != $_POST["v_shell"] &&
366-
$_SESSION["userContext"] === "admin" &&
367-
empty($_SESSION["error_msg"])
368-
) {
369-
$v_shell = quoteshellarg($_POST["v_shell"]);
370-
exec(
371-
HESTIA_CMD . "v-change-user-shell " . quoteshellarg($v_username) . " " . $v_shell,
372-
$output,
373-
$return_var,
374-
);
375-
check_return_code($return_var, $output);
376-
unset($output);
364+
if (!empty($_POST["v_shell"])) {
365+
if (
366+
$v_shell != $_POST["v_shell"] &&
367+
$_SESSION["userContext"] === "admin" &&
368+
empty($_SESSION["error_msg"])
369+
) {
370+
$v_shell = quoteshellarg($_POST["v_shell"]);
371+
exec(
372+
HESTIA_CMD .
373+
"v-change-user-shell " .
374+
quoteshellarg($v_username) .
375+
" " .
376+
$v_shell,
377+
$output,
378+
$return_var,
379+
);
380+
check_return_code($return_var, $output);
381+
unset($output);
382+
}
377383
}
378384
}
379385
// Change language

web/edit/web/index.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,9 @@
343343
if (empty($_POST["v_nginx_cache_check"])) {
344344
$_POST["v_nginx_cache_check"] = "";
345345
}
346+
if (empty($v_nginx_cache_duration)) {
347+
$v_nginx_cache_duration = "";
348+
}
346349
if (
347350
($_SESSION["WEB_SYSTEM"] == "nginx" &&
348351
$v_nginx_cache_check != $_POST["v_nginx_cache_check"]) ||

web/inc/main.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,9 @@ function ipUsed() {
149149
if (empty($user_plain)) {
150150
$user_plain = "";
151151
}
152+
if (empty($_SESSION["look"])) {
153+
$_SESSION["look"] = "";
154+
}
152155

153156
require_once dirname(__FILE__) . "/i18n.php";
154157

@@ -364,11 +367,6 @@ function humanize_usage_size($usage, $round = 2) {
364367
}
365368
$display_usage = number_format($usage, $round);
366369
}
367-
if (strlen($display_usage) > 4) {
368-
if (is_float($display_usage)) {
369-
return number_format($usage, $round - 1);
370-
}
371-
}
372370
return $display_usage;
373371
}
374372

web/list/backup/exclusions/index.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
exec(HESTIA_CMD . "v-list-user-backup-exclusions $user json", $output, $return_var);
1010
$data = json_decode(implode("", $output), true);
1111
unset($output);
12-
1312
// Render page
1413
render_page($user, $TAB, "list_backup_exclusions");
1514

0 commit comments

Comments
 (0)