show replacer-variables in php-config add/edit and fpm-versions add/edit; catch potential Exception thrown by Form::processForm() to display the error nicely; minor fixes in field-visibility for phpconfigs depending on php-interface and webserver; validate fcgid/fpm enable-flag correctly if not POST'ed at the same time (older behaviour)

Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann
2022-11-09 17:07:48 +01:00
parent 2b12cde77e
commit f49fd5f0f7
7 changed files with 136 additions and 19 deletions

View File

@@ -212,9 +212,10 @@ if ($page == 'overview') {
} else {
$fpmconfig_add_data = include_once dirname(__FILE__) . '/lib/formfields/admin/phpconfig/formfield.fpmconfig_add.php';
UI::view('user/form.html.twig', [
UI::view('user/form-replacers.html.twig', [
'formaction' => $linker->getLink(['section' => 'phpsettings', 'page' => 'fpmdaemons']),
'formdata' => $fpmconfig_add_data['fpmconfig_add']
'formdata' => $fpmconfig_add_data['fpmconfig_add'],
'replacers' => $fpmconfig_add_data['fpmconfig_replacers']
]);
}
} else {
@@ -282,9 +283,10 @@ if ($page == 'overview') {
} else {
$fpmconfig_edit_data = include_once dirname(__FILE__) . '/lib/formfields/admin/phpconfig/formfield.fpmconfig_edit.php';
UI::view('user/form.html.twig', [
UI::view('user/form-replacers.html.twig', [
'formaction' => $linker->getLink(['section' => 'phpsettings', 'page' => 'fpmdaemons', 'id' => $id]),
'formdata' => $fpmconfig_edit_data['fpmconfig_edit'],
'replacers' => $fpmconfig_edit_data['fpmconfig_replacers'],
'editid' => $id
]);
}

View File

@@ -79,6 +79,7 @@ if ($page == 'overview' && $userinfo['change_serversettings'] == '1') {
Response::standardError(lng('error.session_timeout'), lng('error.session_timeout_desc'));
}
try {
if (Form::processForm($settings_data, $_POST, [
'filename' => $filename,
'action' => $action,
@@ -97,6 +98,9 @@ if ($page == 'overview' && $userinfo['change_serversettings'] == '1') {
'page' => $page
]);
}
} catch (Exception $e) {
Response::dynamicError($e->getMessage(), $e->getCode());
}
} else {
$_part = isset($_GET['part']) ? $_GET['part'] : '';
if ($_part == '') {

View File

@@ -85,6 +85,12 @@ class Check
];
}
}
} elseif ((int)Settings::Get($check_array[$fieldname]['other_enabled']) == 1) {
// not in the same POST so we still need to check whether the other one's enabled
$returnvalue = [
self::FORMFIELDS_PLAUSIBILITY_CHECK_ERROR,
$check_array[$fieldname]['other_enabled_lng']
];
}
if (in_array(self::FORMFIELDS_PLAUSIBILITY_CHECK_OK, $returnvalue)) {
// be sure to deactivate the other one for the froxlor-vhost

View File

@@ -116,5 +116,57 @@ return [
]
]
]
],
'fpmconfig_replacers' => [
'replacers' => [
[
'var' => 'PEAR_DIR',
'description' => lng('admin.phpconfig.pear_dir')
],
[
'var' => 'OPEN_BASEDIR_C',
'description' => lng('admin.phpconfig.open_basedir_c')
],
[
'var' => 'OPEN_BASEDIR',
'description' => lng('admin.phpconfig.open_basedir')
],
[
'var' => 'OPEN_BASEDIR_GLOBAL',
'description' => lng('admin.phpconfig.open_basedir_global')
],
[
'var' => 'TMP_DIR',
'description' => lng('admin.phpconfig.tmp_dir')
],
[
'var' => 'CUSTOMER_EMAIL',
'description' => lng('admin.phpconfig.customer_email')
],
[
'var' => 'ADMIN_EMAIL',
'description' => lng('admin.phpconfig.admin_email')
],
[
'var' => 'DOMAIN',
'description' => lng('admin.phpconfig.domain')
],
[
'var' => 'CUSTOMER',
'description' => lng('admin.phpconfig.customer')
],
[
'var' => 'ADMIN',
'description' => lng('admin.phpconfig.admin')
],
[
'var' => 'DOCUMENT_ROOT',
'description' => lng('admin.phpconfig.docroot')
],
[
'var' => 'CUSTOMER_HOMEDIR',
'description' => lng('admin.phpconfig.homedir')
]
]
]
];

View File

@@ -119,5 +119,57 @@ return [
]
]
]
],
'fpmconfig_replacers' => [
'replacers' => [
[
'var' => 'PEAR_DIR',
'description' => lng('admin.phpconfig.pear_dir')
],
[
'var' => 'OPEN_BASEDIR_C',
'description' => lng('admin.phpconfig.open_basedir_c')
],
[
'var' => 'OPEN_BASEDIR',
'description' => lng('admin.phpconfig.open_basedir')
],
[
'var' => 'OPEN_BASEDIR_GLOBAL',
'description' => lng('admin.phpconfig.open_basedir_global')
],
[
'var' => 'TMP_DIR',
'description' => lng('admin.phpconfig.tmp_dir')
],
[
'var' => 'CUSTOMER_EMAIL',
'description' => lng('admin.phpconfig.customer_email')
],
[
'var' => 'ADMIN_EMAIL',
'description' => lng('admin.phpconfig.admin_email')
],
[
'var' => 'DOMAIN',
'description' => lng('admin.phpconfig.domain')
],
[
'var' => 'CUSTOMER',
'description' => lng('admin.phpconfig.customer')
],
[
'var' => 'ADMIN',
'description' => lng('admin.phpconfig.admin')
],
[
'var' => 'DOCUMENT_ROOT',
'description' => lng('admin.phpconfig.docroot')
],
[
'var' => 'CUSTOMER_HOMEDIR',
'description' => lng('admin.phpconfig.homedir')
]
]
]
];

View File

@@ -102,7 +102,7 @@ return [
'value' => '5s'
],
'phpfpm_pass_authorizationheader' => [
'visible' => Settings::Get('phpfpm.enabled') == 1,
'visible' => Settings::Get('phpfpm.enabled') == 1 && Settings::Get('system.webserver') == "apache2",
'label' => lng('admin.phpsettings.pass_authorizationheader'),
'type' => 'checkbox',
'value' => '1',

View File

@@ -105,13 +105,14 @@ return [
'value' => $result['fpm_reqslow']
],
'phpfpm_pass_authorizationheader' => [
'visible' => Settings::Get('phpfpm.enabled') == 1,
'visible' => Settings::Get('phpfpm.enabled') == 1 && Settings::Get('system.webserver') == "apache2",
'label' => lng('admin.phpsettings.pass_authorizationheader'),
'type' => 'checkbox',
'value' => '1',
'checked' => $result['pass_authorizationheader']
],
'override_fpmconfig' => [
'visible' => Settings::Get('phpfpm.enabled') == 1,
'label' => lng('serversettings.phpfpm_settings.override_fpmconfig'),
'type' => 'checkbox',
'value' => '1',