do not allow to enable fcgid/fpm at the same time when both are set to 'yes' simultaneously in settings

Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann (d00p) 2015-02-01 18:02:29 +01:00
parent 77ae3aa387
commit f4dff676d6
3 changed files with 47 additions and 21 deletions

View File

@ -14,25 +14,49 @@
* @package Functions * @package Functions
* *
*/ */
function checkFcgidPhpFpm($fieldname, $fielddata, $newfieldvalue, $allnewfieldvalues)
function checkFcgidPhpFpm($fieldname, $fielddata, $newfieldvalue, $allnewfieldvalues) { {
$returnvalue = array(
$returnvalue = array(FORMFIELDS_PLAUSIBILITY_CHECK_OK); FORMFIELDS_PLAUSIBILITY_CHECK_OK
);
// check whether fcgid should be enabled but php-fpm is
if($fieldname == 'system_mod_fcgid_enabled' $check_array = array(
&& (int)$newfieldvalue == 1 'system_mod_fcgid_enabled' => array(
&& (int)Settings::Get('phpfpm.enabled') == 1 'other_post_field' => 'system_phpfpm_enabled',
) { 'other_enabled' => 'phpfpm.enabled',
$returnvalue = array(FORMFIELDS_PLAUSIBILITY_CHECK_ERROR, 'phpfpmstillenabled'); 'other_enabled_lng' => 'phpfpmstillenabled'
} ),
// check whether php-fpm should be enabled but fcgid is 'system_phpfpm_enabled' => array(
elseif($fieldname == 'system_phpfpm_enabled' 'other_post_field' => 'system_mod_fcgid_enabled',
&& (int)$newfieldvalue == 1 'other_enabled' => 'system.mod_fcgid',
&& (int)Settings::Get('system.mod_fcgid') == 1 'other_enabled_lng' => 'fcgidstillenabled'
) { )
$returnvalue = array(FORMFIELDS_PLAUSIBILITY_CHECK_ERROR, 'fcgidstillenabled'); );
}
// interface is to be enabled
return $returnvalue; if ((int) $newfieldvalue == 1) {
// check for POST value of the other field == 1 (active)
if (isset($_POST[$check_array[$fieldname]['other_post_field']]) && (int) $_POST[$check_array[$fieldname]['other_post_field']] == 1) {
// the other interface is activated already and STAYS activated
if ((int) Settings::Get($check_array[$fieldname]['other_enabled']) == 1) {
$returnvalue = array(
FORMFIELDS_PLAUSIBILITY_CHECK_ERROR,
$check_array[$fieldname]['other_enabled_lng']
);
} else {
// fcgid is being validated before fpm -> "ask" fpm about its state
if ($fieldname == 'system_mod_fcgid_enabled') {
$returnvalue = checkFcgidPhpFpm('system_phpfpm_enabled', null, $check_array[$fieldname]['other_post_field'], null);
} else {
// not, bot are nogo
$returnvalue = $returnvalue = array(
FORMFIELDS_PLAUSIBILITY_CHECK_ERROR,
'fcgidandphpfpmnogoodtogether'
);
}
}
}
}
return $returnvalue;
} }

View File

@ -1838,3 +1838,4 @@ $lng['usersettings']['custom_notes']['description'] = 'Feel free to put any note
$lng['usersettings']['custom_notes']['show'] = 'Show your notes on the dashboard of the user'; $lng['usersettings']['custom_notes']['show'] = 'Show your notes on the dashboard of the user';
$lng['serversettings']['system_send_cron_errors']['title'] = 'Send cron-errors to froxlor-admin via e-mail'; $lng['serversettings']['system_send_cron_errors']['title'] = 'Send cron-errors to froxlor-admin via e-mail';
$lng['serversettings']['system_send_cron_errors']['description'] = 'Chose whether you want to receive an e-mail on cronjob errors. Keep in mind that this can lead to an e-mail being sent every 5 minutes depending on the error and your cronjob settings.'; $lng['serversettings']['system_send_cron_errors']['description'] = 'Chose whether you want to receive an e-mail on cronjob errors. Keep in mind that this can lead to an e-mail being sent every 5 minutes depending on the error and your cronjob settings.';
$lng['error']['fcgidandphpfpmnogoodtogether'] = 'FCGID and PHP-FPM cannot be activated at the same time';

View File

@ -1565,3 +1565,4 @@ $lng['usersettings']['custom_notes']['description'] = 'Hier können Notizen je n
$lng['usersettings']['custom_notes']['show'] = 'Zeige die Notizen auf dem Dashboard des Benutzers'; $lng['usersettings']['custom_notes']['show'] = 'Zeige die Notizen auf dem Dashboard des Benutzers';
$lng['serversettings']['system_send_cron_errors']['title'] = 'Sende Cron-Fehler via E-Mail an den Froxlor-Admin'; $lng['serversettings']['system_send_cron_errors']['title'] = 'Sende Cron-Fehler via E-Mail an den Froxlor-Admin';
$lng['serversettings']['system_send_cron_errors']['description'] = 'Gib an, ob bei einem Cron-Fehler eine E-Mail versendet werden soll. Beachte das es je nach Fehler und Cronjob-Einstellungen dazu kommen kann, dass diese E-Mail alle 5 Minuten gesendet wird.'; $lng['serversettings']['system_send_cron_errors']['description'] = 'Gib an, ob bei einem Cron-Fehler eine E-Mail versendet werden soll. Beachte das es je nach Fehler und Cronjob-Einstellungen dazu kommen kann, dass diese E-Mail alle 5 Minuten gesendet wird.';
$lng['error']['fcgidandphpfpmnogoodtogether'] = 'FCGID und PHP-FPM können nicht gleichzeitig aktiviert werden.';