Added alternative php. Part 11
This commit is contained in:
@@ -40,7 +40,7 @@ class EmptyWorker < Kernel::ModuleCoreWorker
|
|||||||
php_list = get_list_of_installed_php
|
php_list = get_list_of_installed_php
|
||||||
if php_list.include? php_ver
|
if php_list.include? php_ver
|
||||||
lst = Dir["/opt/brepo/php#{php_ver}/etc/mod-installed/*.ini"]
|
lst = Dir["/opt/brepo/php#{php_ver}/etc/mod-installed/*.ini"]
|
||||||
php_list_m = lst.map { |item| File.basename(item, ".ini") }.select { |item| item.strip != "" }
|
php_list_m = lst.map { |item| File.basename(item, ".ini") }.select { |item| item.strip != "" && !(item =~ %r{ioncube_loader_lin_}) }
|
||||||
lst_enabled = Dir["/opt/brepo/php#{php_ver}/etc/php.d/*.ini"]
|
lst_enabled = Dir["/opt/brepo/php#{php_ver}/etc/php.d/*.ini"]
|
||||||
php_list_i = {}
|
php_list_i = {}
|
||||||
lst_enabled.each do |item|
|
lst_enabled.each do |item|
|
||||||
@@ -61,6 +61,31 @@ class EmptyWorker < Kernel::ModuleCoreWorker
|
|||||||
php_modules
|
php_modules
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def disable_module(php_ver, module_name)
|
||||||
|
php_mods = get_list_of_installed_php_modules(php_ver)
|
||||||
|
return if php_mods[module_name].nil?
|
||||||
|
|
||||||
|
if File.exist? ("/opt/brepo/php#{php_ver}/etc/php.d/#{php_mods[module_name]}.ini")
|
||||||
|
File.unlink("/opt/brepo/php#{php_ver}/etc/php.d/#{php_mods[module_name]}.ini")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def enable_module(php_ver, module_name)
|
||||||
|
php_mods = get_list_of_installed_php_modules(php_ver)
|
||||||
|
return if php_mods[module_name].nil?
|
||||||
|
|
||||||
|
if php_mods[module_name] == "disabled"
|
||||||
|
case module_name
|
||||||
|
when "opcache"
|
||||||
|
File.symlink("/opt/brepo/php#{php_ver}/etc/mod-installed/#{module_name}.ini", "/opt/brepo/php#{php_ver}/etc/php.d/10-#{php_mods[module_name]}.ini")
|
||||||
|
when "mysqli", "pdo_mysql", "xmlreader", "zip"
|
||||||
|
File.symlink("/opt/brepo/php#{php_ver}/etc/mod-installed/#{module_name}.ini", "/opt/brepo/php#{php_ver}/etc/php.d/30-#{php_mods[module_name]}.ini")
|
||||||
|
else
|
||||||
|
File.symlink("/opt/brepo/php#{php_ver}/etc/mod-installed/#{module_name}.ini", "/opt/brepo/php#{php_ver}/etc/php.d/20-#{php_mods[module_name]}.ini")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def command(args)
|
def command(args)
|
||||||
return log_return("Not enough arguments. Needed command") if args.length < 1
|
return log_return("Not enough arguments. Needed command") if args.length < 1
|
||||||
|
|
||||||
@@ -87,14 +112,39 @@ class EmptyWorker < Kernel::ModuleCoreWorker
|
|||||||
tmp_hash["STATE"] = modules_list[kk]
|
tmp_hash["STATE"] = modules_list[kk]
|
||||||
result << tmp_hash
|
result << tmp_hash
|
||||||
end
|
end
|
||||||
|
format = (args[2].nil? ? "shell" : args[2].strip)
|
||||||
hestia_print_array_of_hashes(result, format, "PHPVER,MODNAME,STATE")
|
hestia_print_array_of_hashes(result, format, "PHPVER,MODNAME,STATE")
|
||||||
ACTION_OK
|
ACTION_OK
|
||||||
end
|
end
|
||||||
|
when "php_enable"
|
||||||
|
vers = args[1]
|
||||||
|
mod_n = args[2]
|
||||||
|
if vers.nil? || mod_n.nil?
|
||||||
|
log_return("Verssion and module name should be specified. #{args}")
|
||||||
|
else
|
||||||
|
vers = vers.strip
|
||||||
|
mod_n = mod_n.strip
|
||||||
|
enable_module(vers, mod_n)
|
||||||
|
ACTION_OK
|
||||||
|
end
|
||||||
|
when "php_disable"
|
||||||
|
vers = args[1]
|
||||||
|
mod_n = args[2]
|
||||||
|
if vers.nil? || mod_n.nil?
|
||||||
|
log_return("Verssion and module name should be specified. #{args}")
|
||||||
|
else
|
||||||
|
vers = vers.strip
|
||||||
|
mod_n = mod_n.strip
|
||||||
|
disable_module(vers, mod_n)
|
||||||
|
ACTION_OK
|
||||||
|
end
|
||||||
when "help"
|
when "help"
|
||||||
puts "#{$0} php_brepo_modules COMMAND [OPTIONS] [json|csv|plain]"
|
puts "#{$0} php_brepo_modules COMMAND [OPTIONS] [json|csv|plain]"
|
||||||
puts "COMMANDS:"
|
puts "COMMANDS:"
|
||||||
puts " php_list - list all local php installed"
|
puts " php_list - list all local php installed"
|
||||||
puts " php_modules [php_ver] - list available php module"
|
puts " php_modules [php_ver] - list available php module"
|
||||||
|
puts " php_enable [php_ver] [module_name] - enable php module"
|
||||||
|
puts " php_disable [php_ver] [module_name] - disable php module"
|
||||||
puts " help - help"
|
puts " help - help"
|
||||||
ACTION_OK
|
ACTION_OK
|
||||||
else
|
else
|
||||||
|
|||||||
60
web/extm/php_brepo_modules/edit/index.php
Normal file
60
web/extm/php_brepo_modules/edit/index.php
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
<?php
|
||||||
|
use function Hestiacp\quoteshellarg\quoteshellarg;
|
||||||
|
|
||||||
|
$TAB = "EXTMODULES";
|
||||||
|
|
||||||
|
// Main include
|
||||||
|
include $_SERVER["DOCUMENT_ROOT"] . "/inc/main.php";
|
||||||
|
|
||||||
|
// Check user
|
||||||
|
if ($_SESSION["userContext"] != "admin") {
|
||||||
|
header("Location: /list/user");
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
exec(HESTIA_CMD . "v-ext-modules state php_brepo_modules json", $output, $return_var);
|
||||||
|
$check_passenger_enabled = json_decode(implode("", $output), true);
|
||||||
|
if (($return_var != 0) || (empty($check_passenger_enabled)) || ($check_passenger_enabled[0]["STATE"] != "enabled")){
|
||||||
|
header("Location: /list/extmodules/");
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
unset($output);
|
||||||
|
|
||||||
|
$error_message = "";
|
||||||
|
if ((!empty($_GET["ver"])) && ($_GET["ver"] != "")) {
|
||||||
|
if (!empty($_GET["save"])){
|
||||||
|
|
||||||
|
}
|
||||||
|
$php_vers = $_GET["ver"];
|
||||||
|
$ver_quoted = quoteshellarg($_GET["ver"]);
|
||||||
|
exec(HESTIA_CMD . "v-ext-modules-run php_brepo_modules php_modules " . $ver_quoted . " json", $output, $return_var);
|
||||||
|
$phps_modules = [];
|
||||||
|
if ($return_var == 0) {
|
||||||
|
$phps_modules = json_decode(implode("", $output), true);
|
||||||
|
} else {
|
||||||
|
$error_message = $output;
|
||||||
|
}
|
||||||
|
|
||||||
|
unset($output);
|
||||||
|
|
||||||
|
// Render page
|
||||||
|
render_page($user, $TAB, "extmodules/extmodules_php_brepo_modules_list");
|
||||||
|
} else {
|
||||||
|
// Data
|
||||||
|
exec(HESTIA_CMD . "v-ext-modules-run php_brepo_modules php_list json", $output, $return_var);
|
||||||
|
$phps = [];
|
||||||
|
if ($return_var == 0) {
|
||||||
|
$phps = json_decode(implode("", $output), true);
|
||||||
|
ksort($phps);
|
||||||
|
} else {
|
||||||
|
$error_message = $output;
|
||||||
|
}
|
||||||
|
|
||||||
|
unset($output);
|
||||||
|
|
||||||
|
// Render page
|
||||||
|
render_page($user, $TAB, "extmodules/extmodules_php_brepo_modules");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Back uri
|
||||||
|
$_SESSION["back"] = $_SERVER["REQUEST_URI"];
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
<!-- Begin toolbar -->
|
||||||
|
<div class="toolbar">
|
||||||
|
<div class="toolbar-inner">
|
||||||
|
<div class="toolbar-buttons">
|
||||||
|
<a class="button button-secondary button-back js-button-back" href="/list/server/">
|
||||||
|
<i class="fas fa-arrow-left icon-blue"></i><?= _("Back") ?>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- End toolbar -->
|
||||||
|
|
||||||
|
<div class="container">
|
||||||
|
|
||||||
|
<?php
|
||||||
|
if (!empty($error_message)) {
|
||||||
|
?>
|
||||||
|
<div class="u-text-center inline-alert inline-alert-danger u-mb20" role="alert">
|
||||||
|
<i class="fas fa-circle-exclamation"></i>
|
||||||
|
<p><?= $error_message ?></p>
|
||||||
|
</div>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
|
|
||||||
|
<h1 class="u-text-center u-hide-desktop u-mt20 u-pr30 u-mb20 u-pl30"><?= _("Available PHP list") ?></h1>
|
||||||
|
|
||||||
|
<div class="units-table js-units-container">
|
||||||
|
<div class="units-table-header">
|
||||||
|
|
||||||
|
<div class="units-table-cell" style="width: 60%;"><?= _("PHP version") ?></div>
|
||||||
|
<div class="units-table-cell u-text-center"><?= _("Modules") ?></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
foreach ($phps as $key => $value) {
|
||||||
|
?>
|
||||||
|
<div class="units-table-ro js-unit">
|
||||||
|
<div class="units-table-cell u-text-center" style="width: 60%;">
|
||||||
|
<span class="u-hide-desktop"><?= _("PHP version") ?>:</span>
|
||||||
|
<?php echo "PHP ".$phps[$key]["PHPVER"]; ?>
|
||||||
|
</div>
|
||||||
|
<div class="units-table-cell u-text-center-desktop">
|
||||||
|
<span class="u-hide-desktop"><?= _("Modules") ?>:</span>
|
||||||
|
<a href="/extm/php_brepo_modules/edit/?ver=<?= urlencode($phps[$key]['PHPVER']) ?>" title="<?= $phps[$key]['PHPVER'] ?>">
|
||||||
|
<?= _("Change PHP modules list") ?>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<?php } ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<footer class="app-footer">
|
||||||
|
<div class="container app-footer-inner">
|
||||||
|
<p>
|
||||||
|
<?= _("PHP modules tunning") ?>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</footer>
|
||||||
@@ -0,0 +1,77 @@
|
|||||||
|
<!-- Begin toolbar -->
|
||||||
|
<div class="toolbar">
|
||||||
|
<div class="toolbar-inner">
|
||||||
|
<div class="toolbar-buttons">
|
||||||
|
<a class="button button-secondary button-back js-button-back" href="/list/server/">
|
||||||
|
<i class="fas fa-arrow-left icon-blue"></i><?= _("Back") ?>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="toolbar-buttons">
|
||||||
|
<button type="submit" class="button" form="main-form">
|
||||||
|
<i class="fas fa-floppy-disk icon-purple"></i><?= _("Save") ?>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- End toolbar -->
|
||||||
|
|
||||||
|
<div class="container">
|
||||||
|
|
||||||
|
<?php
|
||||||
|
if (!empty($error_message)) {
|
||||||
|
?>
|
||||||
|
<div class="u-text-center inline-alert inline-alert-danger u-mb20" role="alert">
|
||||||
|
<i class="fas fa-circle-exclamation"></i>
|
||||||
|
<p><?= $error_message ?></p>
|
||||||
|
</div>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
|
|
||||||
|
<h1 class="u-text-center u-hide-desktop u-mt20 u-pr30 u-mb20 u-pl30"><?= _("Available modules list for version PHP") ?> <?= $php_vers ?></h1>
|
||||||
|
|
||||||
|
<form id="main-form" name="v_ruby_path" method="post">
|
||||||
|
<div class="units-table js-units-container">
|
||||||
|
<div class="units-table-header">
|
||||||
|
|
||||||
|
<div class="units-table-cell u-text-center"><?= _("PHP module name") ?></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
foreach ($phps_modules as $key => $value) {
|
||||||
|
?>
|
||||||
|
<div class="units-table-ro js-unit">
|
||||||
|
<div class="form-check">
|
||||||
|
<input
|
||||||
|
class="form-check-input"
|
||||||
|
type="checkbox"
|
||||||
|
name="v_php_module_name[]"
|
||||||
|
id="v_php_module_name[]"
|
||||||
|
<?= $phps_modules[$key]["STATE"] != "disabled" ? "checked" : "" ?>
|
||||||
|
<?php
|
||||||
|
if ($phps_modules[$key]["STATE"] != "disabled") {
|
||||||
|
echo " value=\"" . $phps_modules[$key]["STATE"] . "\"";
|
||||||
|
} else {
|
||||||
|
echo " value=\"\"";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
>
|
||||||
|
<label for="v_policy_user_change_theme">
|
||||||
|
<?= $phps_modules[$key]["MODNAME"] ?>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<?php } ?>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<footer class="app-footer">
|
||||||
|
<div class="container app-footer-inner">
|
||||||
|
<p>
|
||||||
|
<?= _("PHP modules list") ?>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</footer>
|
||||||
Reference in New Issue
Block a user