Просмотр исходного кода

Merge pull request #2863 from jaapmarcus/fix/php-warnings

Fix small php errors
Raphael 3 лет назад
Родитель
Сommit
4ac3dec283

+ 87 - 0
bin/v-list-default-php

@@ -0,0 +1,87 @@
+#!/bin/bash
+# info: list default PHP version used by default.tpl
+# options: [FORMAT]
+#
+# example: v-list-default-php
+#
+# List the default version used by de the default template
+
+#----------------------------------------------------------#
+#                Variables & Functions                     #
+#----------------------------------------------------------#
+
+# Argument definition
+format=${1-shell}
+
+# Includes
+# shellcheck source=/etc/hestiacp/hestia.conf
+source /etc/hestiacp/hestia.conf
+# shellcheck source=/usr/local/hestia/func/main.sh
+source $HESTIA/func/main.sh
+# load config file
+source_conf "$HESTIA/conf/hestia.conf"
+
+# JSON list function
+json_list() {
+    i=1
+    objects=$(echo "${versions[@]}" |wc -w)
+    echo '['
+    for version in "${versions[@]}"; do
+        if [ "$i" -lt "$objects" ]; then
+            echo -e  "\t\"$version\","
+        else
+            echo -e  "\t\"$version\""
+        fi
+        (( ++i))
+    done
+    echo "]"
+}
+
+# SHELL list function
+shell_list() {
+    echo "VERSION"
+    echo "--------"
+    for version in "${versions[@]}"; do
+        echo "$version"
+    done
+}
+
+# PLAIN list function
+plain_list() {
+    for version in "${versions[@]}"; do
+        echo "$version"
+    done
+}
+
+# CSV list function
+csv_list() {
+    echo "VERSION"
+    for version in "${versions[@]}"; do
+        echo "$version"
+    done
+}
+
+#----------------------------------------------------------#
+#                       Action                             #
+#----------------------------------------------------------#
+
+declare -a versions;
+# List through /etc/php
+for version in /etc/php/*/fpm/pool.d/www.conf; do
+    ver=$(echo "$version" | awk -F"/" '{ print $4 }');
+    versions+=("$ver")
+done
+
+# Listing data
+case $format in
+    json)   json_list ;;
+    plain)  plain_list ;;
+    csv)    csv_list ;;
+    shell)  shell_list ;;
+esac
+
+#----------------------------------------------------------#
+#                       Hestia                             #
+#----------------------------------------------------------#
+
+exit

+ 3 - 3
bin/v-update-sys-hestia-git

@@ -182,20 +182,20 @@ install_build() {
 }
 
 # Set install flags
-if [ -n "$1" ]; then
+if [ -n "$fork" ]; then
     fork_check=$(curl -s --head -w %{http_code} https://raw.githubusercontent.com/$fork/hestiacp/main/src/deb/hestia/control -o /dev/null)
     if [ "$fork_check" -ne "200" ]; then
         echo "ERROR: invalid repository name specified."
         exit 1
     else
         echo "[!] Download code from GitHub repository: $fork"
-        fork="$1"
     fi
 else
     fork="hestiacp"
 fi
 
-if [ -n "$2" ]; then
+if [ -n "$branch" ]; then
+    echo https://raw.githubusercontent.com/$fork/hestiacp/$branch/src/deb/hestia/control;
     branch_check=$(curl -s --head -w %{http_code} https://raw.githubusercontent.com/$fork/hestiacp/$branch/src/deb/hestia/control -o /dev/null)
     if [ $branch_check -ne "200" ]; then
         echo "ERROR: invalid branch name specified."

+ 2 - 2
web/edit/web/index.php

@@ -63,8 +63,8 @@ if (empty($v_letsencrypt)) {
 }
 $v_ssl_home = $data[$v_domain]['SSL_HOME'];
 $v_backend_template = $data[$v_domain]['BACKEND'];
-$v_nginx_cache = $data[$v_domain]['FASTCGI_CACHE'];
-$v_nginx_cache_duration = $data[$v_domain]['FASTCGI_DURATION'];
+$v_nginx_cache = $data[$v_domain]['FASTCGI_CACHE'] ?? '';
+$v_nginx_cache_duration = $data[$v_domain]['FASTCGI_DURATION'] ?? '';
 $v_nginx_cache_check = '';
 if (empty($v_nginx_cache_duration)) {
     $v_nginx_cache_duration = '2m';

+ 19 - 6
web/inc/prevent_csrf.php

@@ -32,9 +32,15 @@
     {
         if (!empty($_SERVER['REQUEST_METHOD'])) {
             if ($_SERVER['REQUEST_METHOD']==='POST') {
-                $hostname = explode(':', $_SERVER['HTTP_HOST']);
-                $port=$hostname[1];
-                $hostname=$hostname[0];
+                if(!empty($_SERVER["HTTP_HOST"])){
+                    list($hostname, $port) = explode(':', $_SERVER["HTTP_HOST"].":");
+                    if(empty($port)){
+                        $port = 443;
+                    }
+                }else{
+                    $hostname = gethostname();
+                    $port = 443;
+                }
                 if (isset($_SERVER['HTTP_ORIGIN'])) {
                     $origin_host = parse_url($_SERVER['HTTP_ORIGIN'], PHP_URL_HOST);
                     if (strcmp($origin_host, gethostname()) === 0 && in_array($port, array('443',$_SERVER['SERVER_PORT']))) {
@@ -55,9 +61,16 @@
     {
         if (!empty($_SERVER['REQUEST_METHOD'])) {
             if ($_SERVER['REQUEST_METHOD']==='GET') {
-                $hostname = explode(':', $_SERVER['HTTP_HOST']);
-                $port=$hostname[1];
-                $hostname=$hostname[0];
+                if(!empty($_SERVER["HTTP_HOST"])){
+                    list($hostname, $port) = explode(':', $_SERVER["HTTP_HOST"].":");
+                    if(empty($port)){
+                        $port = 443;
+                    }
+                }else{
+                    $hostname = gethostname();
+                    $port = 443;
+                }
+                
                 //list of possible entries route and these should never be blocked
                 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'))) {
                     return true;

+ 9 - 4
web/src/app/System/HestiaApp.php

@@ -28,12 +28,13 @@ class HestiaApp
         $cli_arguments = '';
         if (!empty($args) && is_array($args)) {
             foreach ($args as $arg) {
+                var_dump($arg);
                 $cli_arguments .= quoteshellarg((string)$arg) . ' ';
             }
         } else {
             $cli_arguments = quoteshellarg($args);
         }
-
+        
         exec($cli_script . ' ' . $cli_arguments . ' 2>&1', $output, $exit_code);
 
         $result['code'] = $exit_code;
@@ -194,9 +195,13 @@ class HestiaApp
     public function getCurrentBackendTemplate(string $domain){
         $status = $this->runUser('v-list-web-domain', [$domain, 'json'],$return_message);
         $version = $return_message -> json[$domain]['BACKEND'];
-        $test= preg_match('/^.*PHP-([0-9])\_([0-9])/',$version, $match);
-        return $match[1].'.'.$match[2];
-                
+        if($version != "default"){
+            $test= preg_match('/^.*PHP-([0-9])\_([0-9])/',$version, $match);
+            return $match[1].'.'.$match[2];   
+        }else{
+            $supported = $this -> run('v-list-sys-php', 'json', $result);
+            return $this -> $supported -> json[0];
+        }                
     }
     
     public function changeWebTemplate(string $domain, string $template)

+ 1 - 1
web/templates/pages/edit_server.html

@@ -841,7 +841,7 @@
 						<tr>
 							<td class="vst-text input-label step-top advanced-options">
 								<a href="javascript:elementHideShow('ssl');" class="vst-text">
-									<i class="fas fa-lock"></i><b><?=_('Hestia SSL');?><img src="/images/arrow.png"></b>
+									<i class="fas fa-lock"></i><b><?=_('SSL');?><img src="/images/arrow.png"></b>
 								</a>
 							</td>
 						</tr>