Added alternative php. Part 8

This commit is contained in:
Alexey Berezhok
2025-01-22 23:10:51 +03:00
parent b29a369515
commit c25c8d8f64
17 changed files with 181 additions and 67 deletions

View File

@@ -29,32 +29,18 @@ exec(HESTIA_CMD . "v-list-web-templates-backend json", $output, $return_var);
$backend_templates = json_decode(implode("", $output), true);
unset($output);
exec(HESTIA_CMD . "v-check-rhel-utility", $output, $return_var);
$is_rhel = str_contains(implode("", $output), "+");
unset($output);
//exec(HESTIA_CMD . "v-check-rhel-utility", $output, $return_var);
//$is_rhel = str_contains(implode("", $output), "+");
//unset($output);
$v_php_versions = [
"php-5.6",
"php-7.0",
"php-7.1",
"php-7.2",
"php-7.3",
"php-7.4",
"php-8.0",
"php-8.1",
"php-8.2",
"php-74",
"php-80",
"php-81",
"php-82",
"php-83",
];
if ($is_rhel){
$v_php_versions = [
"php-74",
"php-80",
"php-81",
"php-82",
"php-83",
"php-84",
];
}
sort($v_php_versions);

View File

@@ -46,7 +46,7 @@ if (!empty($_POST["save"])) {
}
// List config
exec(HESTIA_CMD . "v-list-sys-php-config json", $output, $return_var);
exec(HESTIA_CMD . "v-list-sys-php-config default json", $output, $return_var);
$data = json_decode(implode("", $output), true);
unset($output);
$v_memory_limit = $data["CONFIG"]["memory_limit"];

View File

@@ -11,11 +11,32 @@ if ($_SESSION["userContext"] != "admin") {
exit();
}
$php_version = "default";
if (!empty($_GET["vers"])){
$php_version_tmp = trim(urldecode($_GET["vers"]));
if (preg_match('/^\d+$/', $php_version_tmp) === 1){
exec(HESTIA_CMD . "v-list-sys-php json", $output, $return_var);
$php = json_decode(implode("", $output), true);
unset($output);
foreach ($php as $version) {
if ($version == $php_version_tmp){
$php_version = $php_version_tmp;
break;
}
}
}
}
// Check POST request
if (!empty($_POST["save"])) {
// Check token
verify_csrf($_POST);
$php_save = "php";
if ($php_version != "default"){
$php_save .= $php_version;
}
// Set restart flag
$v_restart = "yes";
if (empty($_POST["v_restart"])) {
@@ -30,7 +51,7 @@ if (!empty($_POST["save"])) {
fwrite($fp, str_replace("\r\n", "\n", $_POST["v_config"]));
fclose($fp);
exec(
HESTIA_CMD . "v-change-sys-service-config " . $new_conf . " php " . $v_restart,
HESTIA_CMD . "v-change-sys-service-config " . $new_conf . " " . $php_save . " " . $v_restart,
$output,
$return_var,
);
@@ -46,7 +67,7 @@ if (!empty($_POST["save"])) {
}
// List config
exec(HESTIA_CMD . "v-list-sys-php-config json", $output, $return_var);
exec(HESTIA_CMD . "v-list-sys-php-config " . $php_version . " json", $output, $return_var);
$data = json_decode(implode("", $output), true);
unset($output);
$v_memory_limit = $data["CONFIG"]["memory_limit"];

View File

@@ -36,7 +36,7 @@ if (!empty($_POST["save"])) {
);
check_return_code($return_var, $output);
unset($output);
unlink($new_conf);
//unlink($new_conf);
}
// Set success message
@@ -46,7 +46,7 @@ if (!empty($_POST["save"])) {
}
// List config
exec(HESTIA_CMD . "v-list-sys-php-config json", $output, $return_var);
exec(HESTIA_CMD . "v-list-sys-php-config default json", $output, $return_var);
$data = json_decode(implode("", $output), true);
unset($output);
$v_memory_limit = $data["CONFIG"]["memory_limit"];

View File

@@ -126,6 +126,7 @@ $phpfpm = [];
foreach ($php as $version) {
$phpfpm[] = "php" . $version . "-fpm";
$phpfpm[] = "php" . $version . "-php-fpm";
$phpfpm[] = "brepo-php-fpm" . $version;
}
$clamav_names = [];
$clamav_names[] = "clamav-daemon";

View File

@@ -126,15 +126,16 @@
$spnd_icon_class = 'icon-green';
$state_icon = 'fa-circle-minus icon-red';
}
$vers="";
if (in_array($key, $phpfpm)){
$edit_url="php";
preg_match('/\d+/', $key, $matches);
$vers=$matches[0] ?? '82';;
} else {
$edit_url=$key;
}
if (in_array($key, $clamav_names)){
$edit_url="clamav-daemon";
} else {
$edit_url=$key;
}
$cpu = $data[$key]['CPU'] / 10;
@@ -155,7 +156,11 @@
<div class="units-table-cell units-table-heading-cell u-text-bold">
<span class="u-hide-desktop"><?= _("Service") ?>:</span>
<i class="fas <?= $state_icon ?> u-mr5"></i>
<a href="/edit/server/<? echo $edit_url ?>/" title="<?= _("Edit") ?>: <?= $key ?>">
<a href="/edit/server/<? echo $edit_url ?>/<?php
if ($vers!=""){
echo "?vers=" . urlencode($vers);
}
?>" title="<?= _("Edit") ?>: <?= $key ?>">
<?= $key ?>
</a>
</div>
@@ -164,7 +169,11 @@
<li class="units-table-row-action shortcut-enter" data-key-action="href">
<a
class="units-table-row-action-link"
href="/edit/server/<? echo $edit_url ?>/"
href="/edit/server/<? echo $edit_url ?>/<?php
if ($vers!=""){
echo "?vers=". urlencode($vers);
}
?>"
title="<?= _("Edit") ?>"
>
<i class="fas fa-pencil icon-orange"></i>