From 6953d0f883b6cbd676d10fe268d082d22da64fc0 Mon Sep 17 00:00:00 2001 From: Michael Kaufmann Date: Thu, 13 Oct 2022 16:53:36 +0200 Subject: [PATCH] minor fixes to fpm/php resources-forms and language-strings Signed-off-by: Michael Kaufmann --- lib/Froxlor/Api/Commands/FpmDaemons.php | 10 ++++++++++ .../admin/phpconfig/formfield.fpmconfig_add.php | 13 ++++++++----- .../admin/phpconfig/formfield.fpmconfig_edit.php | 13 ++++++++----- .../admin/phpconfig/formfield.phpconfig_add.php | 6 ++++-- .../admin/phpconfig/formfield.phpconfig_edit.php | 6 ++++-- lng/de.lng.php | 1 + lng/en.lng.php | 1 + 7 files changed, 36 insertions(+), 14 deletions(-) diff --git a/lib/Froxlor/Api/Commands/FpmDaemons.php b/lib/Froxlor/Api/Commands/FpmDaemons.php index c5aec829..32b3ff29 100644 --- a/lib/Froxlor/Api/Commands/FpmDaemons.php +++ b/lib/Froxlor/Api/Commands/FpmDaemons.php @@ -203,6 +203,11 @@ class FpmDaemons extends ApiCommand implements ResourceEntity // validation $description = Validate::validate($description, 'description', Validate::REGEX_DESC_TEXT, '', [], true); $reload_cmd = Validate::validate($reload_cmd, 'reload_cmd', '', '', [], true); + $sel_stmt = Database::prepare("SELECT `id` FROM `".TABLE_PANEL_FPMDAEMONS."` WHERE `reload_cmd` = :rc"); + $dupcheck = Database::pexecute_first($sel_stmt, ['rc' => $reload_cmd]); + if ($dupcheck && $dupcheck['id']) { + throw new Exception("PHP-FPM version with the given restart command already exists", 406); + } $config_dir = Validate::validate($config_dir, 'config_dir', Validate::REGEX_DIR, '', [], true); if (!in_array($pmanager, [ 'static', @@ -323,6 +328,11 @@ class FpmDaemons extends ApiCommand implements ResourceEntity // validation $description = Validate::validate($description, 'description', Validate::REGEX_DESC_TEXT, '', [], true); $reload_cmd = Validate::validate($reload_cmd, 'reload_cmd', '', '', [], true); + $sel_stmt = Database::prepare("SELECT `id` FROM `".TABLE_PANEL_FPMDAEMONS."` WHERE `reload_cmd` = :rc"); + $dupcheck = Database::pexecute_first($sel_stmt, ['rc' => $reload_cmd]); + if ($dupcheck && $dupcheck['id'] != $id) { + throw new Exception("PHP-FPM version with the given restart command already exists", 406); + } $config_dir = Validate::validate($config_dir, 'config_dir', Validate::REGEX_DIR, '', [], true); if (!in_array($pmanager, [ 'static', diff --git a/lib/formfields/admin/phpconfig/formfield.fpmconfig_add.php b/lib/formfields/admin/phpconfig/formfield.fpmconfig_add.php index a5efcb38..15313085 100644 --- a/lib/formfields/admin/phpconfig/formfield.fpmconfig_add.php +++ b/lib/formfields/admin/phpconfig/formfield.fpmconfig_add.php @@ -25,30 +25,33 @@ return [ 'fpmconfig_add' => [ - 'title' => lng('admin.phpsettings.addsettings'), + 'title' => lng('admin.fpmsettings.addnew'), 'image' => 'fa-solid fa-plus', 'self_overview' => ['section' => 'phpsettings', 'page' => 'fpmdaemons'], 'sections' => [ 'section_a' => [ - 'title' => lng('admin.phpsettings.addsettings'), + 'title' => lng('admin.fpmsettings.addnew'), 'image' => 'icons/phpsettings_add.png', 'fields' => [ 'description' => [ 'label' => lng('admin.phpsettings.description'), 'type' => 'text', - 'maxlength' => 50 + 'maxlength' => 50, + 'mandatory' => true ], 'reload_cmd' => [ 'label' => lng('serversettings.phpfpm_settings.reload'), 'type' => 'text', 'maxlength' => 255, - 'value' => 'service php7.4-fpm restart' + 'value' => 'service php7.4-fpm restart', + 'mandatory' => true ], 'config_dir' => [ 'label' => lng('serversettings.phpfpm_settings.configdir'), 'type' => 'text', 'maxlength' => 255, - 'value' => '/etc/php/7.4/fpm/pool.d/' + 'value' => '/etc/php/7.4/fpm/pool.d/', + 'mandatory' => true ], 'pm' => [ 'label' => lng('serversettings.phpfpm_settings.pm'), diff --git a/lib/formfields/admin/phpconfig/formfield.fpmconfig_edit.php b/lib/formfields/admin/phpconfig/formfield.fpmconfig_edit.php index 8983e1c3..224fbe87 100644 --- a/lib/formfields/admin/phpconfig/formfield.fpmconfig_edit.php +++ b/lib/formfields/admin/phpconfig/formfield.fpmconfig_edit.php @@ -25,31 +25,34 @@ return [ 'fpmconfig_edit' => [ - 'title' => lng('admin.phpsettings.editsettings'), + 'title' => lng('admin.fpmsettings.edit'), 'image' => 'fa-solid fa-pen', 'self_overview' => ['section' => 'phpsettings', 'page' => 'fpmdaemons'], 'sections' => [ 'section_a' => [ - 'title' => lng('admin.phpsettings.editsettings'), + 'title' => lng('admin.fpmsettings.edit'), 'image' => 'icons/phpsettings_edit.png', 'fields' => [ 'description' => [ 'label' => lng('admin.phpsettings.description'), 'type' => 'text', 'maxlength' => 50, - 'value' => $result['description'] + 'value' => $result['description'], + 'mandatory' => true ], 'reload_cmd' => [ 'label' => lng('serversettings.phpfpm_settings.reload'), 'type' => 'text', 'maxlength' => 255, - 'value' => $result['reload_cmd'] + 'value' => $result['reload_cmd'], + 'mandatory' => true ], 'config_dir' => [ 'label' => lng('serversettings.phpfpm_settings.configdir'), 'type' => 'text', 'maxlength' => 255, - 'value' => $result['config_dir'] + 'value' => $result['config_dir'], + 'mandatory' => true ], 'pm' => [ 'label' => lng('serversettings.phpfpm_settings.pm'), diff --git a/lib/formfields/admin/phpconfig/formfield.phpconfig_add.php b/lib/formfields/admin/phpconfig/formfield.phpconfig_add.php index 8ef947bb..4cf8b2ce 100644 --- a/lib/formfields/admin/phpconfig/formfield.phpconfig_add.php +++ b/lib/formfields/admin/phpconfig/formfield.phpconfig_add.php @@ -38,7 +38,8 @@ return [ 'description' => [ 'label' => lng('admin.phpsettings.description'), 'type' => 'text', - 'maxlength' => 50 + 'maxlength' => 50, + 'mandatory' => true ], 'binary' => [ 'visible' => Settings::Get('system.mod_fcgid') == 1, @@ -179,7 +180,8 @@ return [ 'type' => 'textarea', 'cols' => 80, 'rows' => 20, - 'value' => $result['phpsettings'] + 'value' => $result['phpsettings'], + 'mandatory' => true ], 'allow_all_customers' => [ 'label' => lng('serversettings.phpfpm_settings.allow_all_customers.title'), diff --git a/lib/formfields/admin/phpconfig/formfield.phpconfig_edit.php b/lib/formfields/admin/phpconfig/formfield.phpconfig_edit.php index 0a3512e4..18ed7e2a 100644 --- a/lib/formfields/admin/phpconfig/formfield.phpconfig_edit.php +++ b/lib/formfields/admin/phpconfig/formfield.phpconfig_edit.php @@ -39,7 +39,8 @@ return [ 'label' => lng('admin.phpsettings.description'), 'type' => 'text', 'maxlength' => 50, - 'value' => $result['description'] + 'value' => $result['description'], + 'mandatory' => true ], 'binary' => [ 'visible' => Settings::Get('system.mod_fcgid') == 1, @@ -182,7 +183,8 @@ return [ 'type' => 'textarea', 'cols' => 80, 'rows' => 20, - 'value' => $result['phpsettings'] + 'value' => $result['phpsettings'], + 'mandatory' => true ], 'allow_all_customers' => [ 'label' => lng('serversettings.phpfpm_settings.allow_all_customers.title'), diff --git a/lng/de.lng.php b/lng/de.lng.php index 8cc4bafc..1499b22f 100644 --- a/lng/de.lng.php +++ b/lng/de.lng.php @@ -301,6 +301,7 @@ return [ 'misc' => 'Sonstiges', 'fpmsettings' => [ 'addnew' => 'Neue PHP Version erstellen', + 'edit' => 'PHP version bearbeiten', ], 'phpconfig' => [ 'template_replace_vars' => 'Variablen, die in den Konfigurationen ersetzt werden', diff --git a/lng/en.lng.php b/lng/en.lng.php index fcadc540..e89c545b 100644 --- a/lng/en.lng.php +++ b/lng/en.lng.php @@ -306,6 +306,7 @@ return [ 'misc' => 'Miscellaneous', 'fpmsettings' => [ 'addnew' => 'Create new PHP version', + 'edit' => 'Change PHP version' ], 'phpconfig' => [ 'template_replace_vars' => 'Variables that will be replaced in the configs',