Skip to content

Commit 754a247

Browse files
authored
Add hooks to hestia-* package + Update versions (hestiacp#2440)
* Add support for pre/post install hooks hestia-nginx doesn't want to install when demo mode is enabled * Update to last versions * Update PHP version to 8.1.x * Resolve Warning Uknown "Key" Make sure keys are present or checked via empty / isset if they exsits before used * Remove deprecated "favorite" feature out of UI * Changes requiered update to php8.x.x escapeargs() can't be "NULL" Any more Same for __() and other functions Use date class for dates instead of date() function
1 parent 5148e3d commit 754a247

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+841
-341
lines changed

install/deb/filemanager/filegator/backend/Services/Auth/Adapters/HestiaAuth.php

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
*/
2121
class HestiaAuth implements Service, AuthInterface
2222
{
23-
2423
protected $permissions = [];
2524

2625
protected $private_repos = false;
@@ -32,13 +31,15 @@ public function init(array $config = [])
3231
if (isset($_SESSION['user'])) {
3332
$v_user = $_SESSION['user'];
3433
}
35-
if (isset($_SESSION['look']) && ($_SESSION['userContext'] === 'admin')){
36-
$v_user = $_SESSION['look'];
37-
}
38-
if ( $_SESSION['look'] == 'admin' && $_SESSION['POLICY_SYSTEM_PROTECTED_ADMIN'] == 'yes' ){
39-
// Go away do not login
40-
header('Location: /');
41-
exit;
34+
if (!empty($_SESSION['look'])) {
35+
if (isset($_SESSION['look']) && ($_SESSION['userContext'] === 'admin')) {
36+
$v_user = $_SESSION['look'];
37+
}
38+
if ($_SESSION['look'] == 'admin' && $_SESSION['POLICY_SYSTEM_PROTECTED_ADMIN'] == 'yes') {
39+
// Go away do not login
40+
header('Location: /');
41+
exit;
42+
}
4243
}
4344
$this->hestia_user = $v_user;
4445
$this->permissions = isset($config['permissions']) ? (array)$config['permissions'] : [];
@@ -47,16 +48,15 @@ public function init(array $config = [])
4748

4849
public function user(): ?User
4950
{
50-
5151
$cmd="/usr/bin/sudo /usr/local/hestia/bin/v-list-user";
52-
exec ($cmd." ".escapeshellarg($this->hestia_user )." json", $output, $return_var);
52+
exec($cmd." ".escapeshellarg($this->hestia_user)." json", $output, $return_var);
5353

5454
if ($return_var == 0) {
5555
$data = json_decode(implode('', $output), true);
5656
$hestia_user_info = $data[$this->hestia_user];
5757
return $this->transformUser($hestia_user_info);
5858
}
59-
59+
6060
return $this->getGuest();
6161
}
6262

@@ -126,5 +126,4 @@ public function getGuest(): User
126126

127127
return $guest;
128128
}
129-
130129
}

install/deb/filemanager/filegator/configuration.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@
1414
if (isset($_SESSION['user'])) {
1515
$v_user = $_SESSION['user'];
1616
}
17-
if (isset($_SESSION['look']) && ($_SESSION['userContext'] === 'admin')) {
18-
$v_user = $_SESSION['look'];
19-
}
20-
if ((isset($_SESSION['look']) && ($_SESSION['look'] == 'admin') && ($_SESSION['POLICY_SYSTEM_PROTECTED_ADMIN'] == 'yes'))) {
21-
header('Location: /');
17+
if (!empty($_SESSION['look'])) {
18+
if (isset($_SESSION['look']) && ($_SESSION['userContext'] === 'admin')) {
19+
$v_user = $_SESSION['look'];
20+
}
21+
if ((isset($_SESSION['look']) && ($_SESSION['look'] == 'admin') && ($_SESSION['POLICY_SYSTEM_PROTECTED_ADMIN'] == 'yes'))) {
22+
header('Location: /');
23+
}
2224
}
2325
# Create filemanager sftp key if missing and trash it after 30 min
2426
if (! file_exists('/home/'.basename($v_user).'/.ssh/hst-filemanager-key')) {
@@ -28,9 +30,9 @@
2830
if (!isset($_SESSION['SFTP_PORT'])) {
2931
exec("sudo /usr/local/hestia/bin/v-list-sys-sshd-port json", $output, $result);
3032
$port=json_decode(implode('', $output));
31-
if ( is_numeric($port[0]) && $port[0] > 0 ){
33+
if (is_numeric($port[0]) && $port[0] > 0) {
3234
$_SESSION['SFTP_PORT'] = $port[0];
33-
} else if ( preg_match('/^\s*Port\s+(\d+)$/im', file_get_contents('/etc/ssh/sshd_config'), $matches) ) {
35+
} elseif (preg_match('/^\s*Port\s+(\d+)$/im', file_get_contents('/etc/ssh/sshd_config'), $matches)) {
3436
$_SESSION['SFTP_PORT'] = $matches[1] ?? 22;
3537
} else {
3638
$_SESSION['SFTP_PORT'] = 22;

src/deb/nginx/control

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Source: hestia-nginx
22
Package: hestia-nginx
33
Priority: optional
4-
Version: 1.21.5
4+
Version: 1.21.6
55
Section: admin
66
Maintainer: HestiaCP <info@hestiacp.com>
77
Homepage: https://www.hestiacp.com

src/deb/nginx/postinst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ if [ -z "$HESTIA" ]; then
2525
export PATH
2626
fi
2727

28+
# Check if preinstall hook exists
29+
if [ -e "/etc/hestiacp/hooks/nginx/pre_install.sh" ]; then
30+
/etc/hestiacp/hooks/nginx/pre_install.sh
31+
fi
32+
2833
# Load upgrade functions and variables
2934
source /usr/local/hestia/func/main.sh
3035
source /usr/local/hestia/func/upgrade.sh
@@ -36,6 +41,10 @@ if [ ! -z "$BACKEND_PORT" ]; then
3641
/usr/local/hestia/bin/v-change-sys-port $BACKEND_PORT
3742
fi
3843

44+
if [ -e "/etc/hestiacp/hooks/nginx/post_install.sh" ]; then
45+
/etc/hestiacp/hooks/nginx/post_install.sh
46+
fi
47+
3948
# Restart hestia service
4049
if [ -f "/etc/init.d/hestia" ]; then
4150
systemctl restart hestia > /dev/null 2>&1

src/deb/php/control

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Source: hestia-php
22
Package: hestia-php
33
Priority: optional
4-
Version: 7.4.27-1
4+
Version: 8.1.4
55
Section: admin
66
Maintainer: HestaCP <info@hestiacp.com>
77
Homepage: https://www.hestiacp.com

src/deb/php/php-fpm.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,4 @@ php_admin_value[upload_max_filesize] = 256M
4141
php_admin_value[max_execution_time] = 300
4242
php_admin_value[max_input_time] = 300
4343
php_admin_value[session.save_path] = /usr/local/hestia/data/sessions
44-
php_admin_value[open_basedir] = /usr/local/hestia/:/tmp/:/dev/:/home/:/etc/ssh/:/backup/
44+
php_admin_value[open_basedir] = /usr/local/hestia/:/tmp/:/dev/:/home/:/etc/ssh/:/backup/:/var/tmp/

src/deb/php/postinst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ if [ ! -e "/usr/local/hestia/data/users/admin" ]; then
1111
exit
1212
fi
1313

14+
# Check if preinstall hook exists
15+
if [ -e "/etc/hestiacp/hooks/php/pre_install.sh" ]; then
16+
/etc/hestiacp/hooks/php/pre_install.sh
17+
fi
18+
1419
###############################################################
1520
# Initialize functions/variables #
1621
###############################################################
@@ -30,4 +35,9 @@ source /usr/local/hestia/install/upgrade/upgrade.conf
3035
# Restart hestia service
3136
if [ -f "/etc/init.d/hestia" ]; then
3237
systemctl restart hestia > /dev/null 2>&1
38+
fi
39+
40+
# Check if preinstall hook exists
41+
if [ -e "/etc/hestiacp/hooks/php/post_install.sh" ]; then
42+
/etc/hestiacp/hooks/php/post_install.sh
3343
fi

web/add/cron/index.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
ob_start();
34
$TAB = 'CRON';
45

@@ -69,6 +70,24 @@
6970
}
7071
}
7172

73+
if (empty($v_cmd)) {
74+
$v_cmd = '';
75+
}
76+
if (empty($v_month)) {
77+
$v_month = '';
78+
}
79+
if (empty($v_day)) {
80+
$v_day = '';
81+
}
82+
if (empty($v_wday)) {
83+
$v_wday = '';
84+
}
85+
if (empty($v_hour)) {
86+
$v_hour = '';
87+
}
88+
if (empty($v_min)) {
89+
$v_min = '';
90+
}
7291
// Render
7392
render_page($user, $TAB, 'add_cron');
7493

web/add/db/index.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
ob_start();
34
$TAB = 'DB';
45

@@ -132,7 +133,13 @@
132133
}
133134

134135
// Get user email
135-
$v_db_email = $panel[$user]['CONTACT'];
136+
$v_db_email = '';
137+
if (empty($v_database)) {
138+
$v_database = '';
139+
}
140+
if (empty($v_dbuser)) {
141+
$v_dbuser = '';
142+
}
136143

137144
// List avaiable database types
138145
$db_types = explode(',', $_SESSION['DB_SYSTEM']);

web/add/dns/index.php

Lines changed: 71 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
ob_start();
34
$TAB = 'DNS';
45

@@ -39,6 +40,31 @@
3940
$v_domain = escapeshellarg($v_domain);
4041
$v_domain = strtolower($v_domain);
4142
$v_ip = $_POST['v_ip'];
43+
// Change NameServers
44+
if (empty($_POST['v_ns1'])) {
45+
$_POST['v_ns1'] = '';
46+
}
47+
if (empty($_POST['v_ns2'])) {
48+
$_POST['v_ns2'] = '';
49+
}
50+
if (empty($_POST['v_ns3'])) {
51+
$_POST['v_ns3'] = '';
52+
}
53+
if (empty($_POST['v_ns4'])) {
54+
$_POST['v_ns4'] = '';
55+
}
56+
if (empty($_POST['v_ns5'])) {
57+
$_POST['v_ns5'] = '';
58+
}
59+
if (empty($_POST['v_ns6'])) {
60+
$_POST['v_ns6'] = '';
61+
}
62+
if (empty($_POST['v_ns7'])) {
63+
$_POST['v_ns7'] = '';
64+
}
65+
if (empty($_POST['v_ns8'])) {
66+
$_POST['v_ns8'] = '';
67+
}
4268
$v_ns1 = escapeshellarg($_POST['v_ns1']);
4369
$v_ns2 = escapeshellarg($_POST['v_ns2']);
4470
$v_ns3 = escapeshellarg($_POST['v_ns3']);
@@ -54,8 +80,11 @@
5480
check_return_code($return_var, $output);
5581
unset($output);
5682
}
83+
exec(HESTIA_CMD."v-list-user ".$user." json", $output, $return_var);
84+
$user_config = json_decode(implode('', $output), true);
85+
unset($output);
86+
$v_template = $user_config[$user_plain]['DNS_TEMPLATE'];
5787

58-
// Change domain template
5988
if (($v_template != $_POST['v_template']) && (empty($_SESSION['error_msg']))) {
6089
$v_template = escapeshellarg($_POST['v_template']);
6190
exec(HESTIA_CMD."v-change-dns-domain-tpl ".$user." ".$v_domain." ".$v_template." 'no'", $output, $return_var);
@@ -156,6 +185,30 @@
156185
}
157186
}
158187

188+
if (empty($v_ns1)) {
189+
$v_ns1 = '';
190+
}
191+
if (empty($v_ns2)) {
192+
$v_ns2 = '';
193+
}
194+
if (empty($v_ns3)) {
195+
$v_ns3 = '';
196+
}
197+
if (empty($v_ns4)) {
198+
$v_ns4 = '';
199+
}
200+
if (empty($v_ns5)) {
201+
$v_ns5 = '';
202+
}
203+
if (empty($v_ns6)) {
204+
$v_ns6 = '';
205+
}
206+
if (empty($v_ns7)) {
207+
$v_ns7 = '';
208+
}
209+
if (empty($v_ns8)) {
210+
$v_ns8 = '';
211+
}
159212

160213
$v_ns1 = str_replace("'", "", $v_ns1);
161214
$v_ns2 = str_replace("'", "", $v_ns2);
@@ -193,6 +246,11 @@
193246
if (empty($v_ns1)) {
194247
exec(HESTIA_CMD."v-list-user-ns ".$user." json", $output, $return_var);
195248
$nameservers = json_decode(implode('', $output), true);
249+
for ($i = 0; $i < 8; $i++) {
250+
if (empty($nameservers[$i])) {
251+
$nameservers[$i] = '';
252+
}
253+
}
196254
$v_ns1 = str_replace("'", "", $nameservers[0]);
197255
$v_ns2 = str_replace("'", "", $nameservers[1]);
198256
$v_ns3 = str_replace("'", "", $nameservers[2]);
@@ -211,6 +269,18 @@
211269
if (empty($v_rec)) {
212270
$v_rec = '@';
213271
}
272+
if (empty($v_type)) {
273+
$v_type = '';
274+
}
275+
if (empty($v_val)) {
276+
$v_val = '';
277+
}
278+
if (empty($v_priority)) {
279+
$v_priority = '';
280+
}
281+
if (empty($v_ttl)) {
282+
$v_ttl = '';
283+
}
214284
render_page($user, $TAB, 'add_dns_rec');
215285
}
216286

0 commit comments

Comments
 (0)