From 93ccae3f182d6fb5fc13621c71c901528fea6c53 Mon Sep 17 00:00:00 2001 From: Alexey Berezhok Date: Fri, 31 Jan 2025 23:41:28 +0300 Subject: [PATCH] Added alternative php. Part 11 --- func_ruby/ext-modules/php_brepo_modules.mod | 52 ++++++++++++- web/extm/php_brepo_modules/edit/index.php | 60 +++++++++++++++ .../extmodules_php_brepo_modules.php | 62 +++++++++++++++ .../extmodules_php_brepo_modules_list.php | 77 +++++++++++++++++++ 4 files changed, 250 insertions(+), 1 deletion(-) create mode 100644 web/extm/php_brepo_modules/edit/index.php create mode 100644 web/templates/pages/extmodules/extmodules_php_brepo_modules.php create mode 100644 web/templates/pages/extmodules/extmodules_php_brepo_modules_list.php diff --git a/func_ruby/ext-modules/php_brepo_modules.mod b/func_ruby/ext-modules/php_brepo_modules.mod index 2841cd8..1c9e84b 100644 --- a/func_ruby/ext-modules/php_brepo_modules.mod +++ b/func_ruby/ext-modules/php_brepo_modules.mod @@ -40,7 +40,7 @@ class EmptyWorker < Kernel::ModuleCoreWorker php_list = get_list_of_installed_php if php_list.include? php_ver 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"] php_list_i = {} lst_enabled.each do |item| @@ -61,6 +61,31 @@ class EmptyWorker < Kernel::ModuleCoreWorker php_modules 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) 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] result << tmp_hash end + format = (args[2].nil? ? "shell" : args[2].strip) hestia_print_array_of_hashes(result, format, "PHPVER,MODNAME,STATE") ACTION_OK 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" puts "#{$0} php_brepo_modules COMMAND [OPTIONS] [json|csv|plain]" puts "COMMANDS:" puts " php_list - list all local php installed" 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" ACTION_OK else diff --git a/web/extm/php_brepo_modules/edit/index.php b/web/extm/php_brepo_modules/edit/index.php new file mode 100644 index 0000000..b1fa7d3 --- /dev/null +++ b/web/extm/php_brepo_modules/edit/index.php @@ -0,0 +1,60 @@ + +
+
+
+ + + +
+
+
+ + +
+ + + + + + +

+ +
+
+ +
+
+
+ + $value) { + ?> +
+
+ : + +
+
+ : + + + +
+
+ +
+ +
+ + diff --git a/web/templates/pages/extmodules/extmodules_php_brepo_modules_list.php b/web/templates/pages/extmodules/extmodules_php_brepo_modules_list.php new file mode 100644 index 0000000..bc2005c --- /dev/null +++ b/web/templates/pages/extmodules/extmodules_php_brepo_modules_list.php @@ -0,0 +1,77 @@ + +
+
+
+ + + +
+
+ +
+
+
+ + +
+ + + + + + +

+ +
+
+
+ +
+
+ + $value) { + ?> +
+
+ + + > + +
+
+ +
+
+ +
+ +