Skip to content

Commit 4ac3dec

Browse files
authored
Merge pull request hestiacp#2863 from jaapmarcus/fix/php-warnings
Fix small php errors
2 parents e61cb38 + a073989 commit 4ac3dec

File tree

6 files changed

+121
-16
lines changed

6 files changed

+121
-16
lines changed

bin/v-list-default-php

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
#!/bin/bash
2+
# info: list default PHP version used by default.tpl
3+
# options: [FORMAT]
4+
#
5+
# example: v-list-default-php
6+
#
7+
# List the default version used by de the default template
8+
9+
#----------------------------------------------------------#
10+
# Variables & Functions #
11+
#----------------------------------------------------------#
12+
13+
# Argument definition
14+
format=${1-shell}
15+
16+
# Includes
17+
# shellcheck source=/etc/hestiacp/hestia.conf
18+
source /etc/hestiacp/hestia.conf
19+
# shellcheck source=/usr/local/hestia/func/main.sh
20+
source $HESTIA/func/main.sh
21+
# load config file
22+
source_conf "$HESTIA/conf/hestia.conf"
23+
24+
# JSON list function
25+
json_list() {
26+
i=1
27+
objects=$(echo "${versions[@]}" |wc -w)
28+
echo '['
29+
for version in "${versions[@]}"; do
30+
if [ "$i" -lt "$objects" ]; then
31+
echo -e "\t\"$version\","
32+
else
33+
echo -e "\t\"$version\""
34+
fi
35+
(( ++i))
36+
done
37+
echo "]"
38+
}
39+
40+
# SHELL list function
41+
shell_list() {
42+
echo "VERSION"
43+
echo "--------"
44+
for version in "${versions[@]}"; do
45+
echo "$version"
46+
done
47+
}
48+
49+
# PLAIN list function
50+
plain_list() {
51+
for version in "${versions[@]}"; do
52+
echo "$version"
53+
done
54+
}
55+
56+
# CSV list function
57+
csv_list() {
58+
echo "VERSION"
59+
for version in "${versions[@]}"; do
60+
echo "$version"
61+
done
62+
}
63+
64+
#----------------------------------------------------------#
65+
# Action #
66+
#----------------------------------------------------------#
67+
68+
declare -a versions;
69+
# List through /etc/php
70+
for version in /etc/php/*/fpm/pool.d/www.conf; do
71+
ver=$(echo "$version" | awk -F"/" '{ print $4 }');
72+
versions+=("$ver")
73+
done
74+
75+
# Listing data
76+
case $format in
77+
json) json_list ;;
78+
plain) plain_list ;;
79+
csv) csv_list ;;
80+
shell) shell_list ;;
81+
esac
82+
83+
#----------------------------------------------------------#
84+
# Hestia #
85+
#----------------------------------------------------------#
86+
87+
exit

bin/v-update-sys-hestia-git

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,20 +182,20 @@ install_build() {
182182
}
183183

184184
# Set install flags
185-
if [ -n "$1" ]; then
185+
if [ -n "$fork" ]; then
186186
fork_check=$(curl -s --head -w %{http_code} https://raw.githubusercontent.com/$fork/hestiacp/main/src/deb/hestia/control -o /dev/null)
187187
if [ "$fork_check" -ne "200" ]; then
188188
echo "ERROR: invalid repository name specified."
189189
exit 1
190190
else
191191
echo "[!] Download code from GitHub repository: $fork"
192-
fork="$1"
193192
fi
194193
else
195194
fork="hestiacp"
196195
fi
197196

198-
if [ -n "$2" ]; then
197+
if [ -n "$branch" ]; then
198+
echo https://raw.githubusercontent.com/$fork/hestiacp/$branch/src/deb/hestia/control;
199199
branch_check=$(curl -s --head -w %{http_code} https://raw.githubusercontent.com/$fork/hestiacp/$branch/src/deb/hestia/control -o /dev/null)
200200
if [ $branch_check -ne "200" ]; then
201201
echo "ERROR: invalid branch name specified."

web/edit/web/index.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@
6363
}
6464
$v_ssl_home = $data[$v_domain]['SSL_HOME'];
6565
$v_backend_template = $data[$v_domain]['BACKEND'];
66-
$v_nginx_cache = $data[$v_domain]['FASTCGI_CACHE'];
67-
$v_nginx_cache_duration = $data[$v_domain]['FASTCGI_DURATION'];
66+
$v_nginx_cache = $data[$v_domain]['FASTCGI_CACHE'] ?? '';
67+
$v_nginx_cache_duration = $data[$v_domain]['FASTCGI_DURATION'] ?? '';
6868
$v_nginx_cache_check = '';
6969
if (empty($v_nginx_cache_duration)) {
7070
$v_nginx_cache_duration = '2m';

web/inc/prevent_csrf.php

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,15 @@ function prevent_post_csrf()
3232
{
3333
if (!empty($_SERVER['REQUEST_METHOD'])) {
3434
if ($_SERVER['REQUEST_METHOD']==='POST') {
35-
$hostname = explode(':', $_SERVER['HTTP_HOST']);
36-
$port=$hostname[1];
37-
$hostname=$hostname[0];
35+
if(!empty($_SERVER["HTTP_HOST"])){
36+
list($hostname, $port) = explode(':', $_SERVER["HTTP_HOST"].":");
37+
if(empty($port)){
38+
$port = 443;
39+
}
40+
}else{
41+
$hostname = gethostname();
42+
$port = 443;
43+
}
3844
if (isset($_SERVER['HTTP_ORIGIN'])) {
3945
$origin_host = parse_url($_SERVER['HTTP_ORIGIN'], PHP_URL_HOST);
4046
if (strcmp($origin_host, gethostname()) === 0 && in_array($port, array('443',$_SERVER['SERVER_PORT']))) {
@@ -55,9 +61,16 @@ function prevent_get_csrf()
5561
{
5662
if (!empty($_SERVER['REQUEST_METHOD'])) {
5763
if ($_SERVER['REQUEST_METHOD']==='GET') {
58-
$hostname = explode(':', $_SERVER['HTTP_HOST']);
59-
$port=$hostname[1];
60-
$hostname=$hostname[0];
64+
if(!empty($_SERVER["HTTP_HOST"])){
65+
list($hostname, $port) = explode(':', $_SERVER["HTTP_HOST"].":");
66+
if(empty($port)){
67+
$port = 443;
68+
}
69+
}else{
70+
$hostname = gethostname();
71+
$port = 443;
72+
}
73+
6174
//list of possible entries route and these should never be blocked
6275
if (in_array($_SERVER['DOCUMENT_URI'], array('/list/user/index.php', '/login/index.php','/list/web/index.php','/list/dns/index.php','/list/mail/index.php','/list/db/index.php','/list/cron/index.php','/list/backup/index.php','/reset/index.php'))) {
6376
return true;

web/src/app/System/HestiaApp.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,13 @@ public function run(string $cmd, $args, &$cmd_result=null): bool
2828
$cli_arguments = '';
2929
if (!empty($args) && is_array($args)) {
3030
foreach ($args as $arg) {
31+
var_dump($arg);
3132
$cli_arguments .= quoteshellarg((string)$arg) . ' ';
3233
}
3334
} else {
3435
$cli_arguments = quoteshellarg($args);
3536
}
36-
37+
3738
exec($cli_script . ' ' . $cli_arguments . ' 2>&1', $output, $exit_code);
3839

3940
$result['code'] = $exit_code;
@@ -194,9 +195,13 @@ public function databaseAdd(string $dbname, string $dbuser, string $dbpass, stri
194195
public function getCurrentBackendTemplate(string $domain){
195196
$status = $this->runUser('v-list-web-domain', [$domain, 'json'],$return_message);
196197
$version = $return_message -> json[$domain]['BACKEND'];
197-
$test= preg_match('/^.*PHP-([0-9])\_([0-9])/',$version, $match);
198-
return $match[1].'.'.$match[2];
199-
198+
if($version != "default"){
199+
$test= preg_match('/^.*PHP-([0-9])\_([0-9])/',$version, $match);
200+
return $match[1].'.'.$match[2];
201+
}else{
202+
$supported = $this -> run('v-list-sys-php', 'json', $result);
203+
return $this -> $supported -> json[0];
204+
}
200205
}
201206

202207
public function changeWebTemplate(string $domain, string $template)

web/templates/pages/edit_server.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -841,7 +841,7 @@
841841
<tr>
842842
<td class="vst-text input-label step-top advanced-options">
843843
<a href="javascript:elementHideShow('ssl');" class="vst-text">
844-
<i class="fas fa-lock"></i><b><?=_('Hestia SSL');?><img src="/images/arrow.png"></b>
844+
<i class="fas fa-lock"></i><b><?=_('SSL');?><img src="/images/arrow.png"></b>
845845
</a>
846846
</td>
847847
</tr>

0 commit comments

Comments
 (0)