Added php-selector support

This commit is contained in:
Alexey Berezhok
2024-08-27 23:35:17 +03:00
parent cce8d44f91
commit 3a964e54b1
7 changed files with 153 additions and 28 deletions

View File

@@ -108,6 +108,12 @@ $v_php_versions = array_map(function ($php_version) use ($backend_templates, $ba
return $phpinfo;
}, $v_php_versions);
if (!empty($_SESSION["PHP_SELECTOR"])) {
$v_php_selector = $_SESSION["PHP_SELECTOR"];
} else {
$v_php_selector = "";
}
// List languages
exec(HESTIA_CMD . "v-list-sys-languages json", $output, $return_var);
$language = json_decode(implode("", $output), true);
@@ -363,6 +369,23 @@ if (!empty($_POST["save"])) {
//force reload
$require_refresh = true;
}
//Check php selector
$t_v_php_selector = $_POST["v_use_php_selector"] == "on"?"yes":"no";
if ($_POST["v_use_php_selector"] != $v_php_selector){
$v_set_flag = "no";
if ($_POST["v_use_php_selector"] == "on"){
$v_set_flag = "yes";
}
exec(
HESTIA_CMD .
"v-change-selector-state " .
$v_set_flag,
$output,
$return_var,
);
check_return_code($return_var, $output);
unset($output);
}
}
}

View File

@@ -19,7 +19,14 @@ try {
define("HESTIA_DIR_BIN", "/usr/local/hestia/bin/");
define("HESTIA_CMD", "/usr/bin/sudo /usr/local/hestia/bin/");
define("DEFAULT_PHP_VERSION", "php-" . exec('php -r "echo substr(phpversion(),0,3);"'));
exec(HESTIA_CMD . "v-check-rhel-utility", $output, $return_var);
$is_rhel_detect = str_contains(implode("", $output), "+");
unset($output);
if ($is_rhel_detect) {
define("DEFAULT_PHP_VERSION", "php-" . exec('php -r "echo str_replace(\'.\', \'\', substr(phpversion(),0,3));"'));
} else {
define("DEFAULT_PHP_VERSION", "php-" . exec('php -r "echo substr(phpversion(),0,3);"'));
}
// Load Hestia Config directly
load_hestia_config();

View File

@@ -293,7 +293,7 @@
<?php } ?>
<?php } ?>
<?php if (!empty($_SESSION["WEB_BACKEND"])) { ?>
<div class="u-mt10">
<div class="u-mt20">
<label for="v_php_default_version" class="form-label">
<?= _("System PHP Version") ?>
</label>
@@ -310,6 +310,18 @@
<?php } ?>
</select>
</div>
<div class="form-check u-mb5 u-mt10">
<input
class="form-check-input"
type="checkbox"
name="v_use_php_selector"
id="v_use_php_selector"
<?= $_SESSION["PHP_SELECTOR"] == "yes" ? "checked" : "" ?>
>
<label for="v_use_php_selector">
<?= _("Use PHP cli selector") ?>
</label>
</div>
<?php } ?>
</div>
</details>