From f4dff676d698014e7cefd10b3f8945556bf8bd7b Mon Sep 17 00:00:00 2001 From: "Michael Kaufmann (d00p)" Date: Sun, 1 Feb 2015 18:02:29 +0100 Subject: [PATCH] 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) --- .../validate/function.checkFcgidPhpFpm.php | 66 +++++++++++++------ lng/english.lng.php | 1 + lng/german.lng.php | 1 + 3 files changed, 47 insertions(+), 21 deletions(-) diff --git a/lib/functions/validate/function.checkFcgidPhpFpm.php b/lib/functions/validate/function.checkFcgidPhpFpm.php index f8178795..c0431f0d 100644 --- a/lib/functions/validate/function.checkFcgidPhpFpm.php +++ b/lib/functions/validate/function.checkFcgidPhpFpm.php @@ -14,25 +14,49 @@ * @package Functions * */ - -function checkFcgidPhpFpm($fieldname, $fielddata, $newfieldvalue, $allnewfieldvalues) { - - $returnvalue = array(FORMFIELDS_PLAUSIBILITY_CHECK_OK); - - // check whether fcgid should be enabled but php-fpm is - if($fieldname == 'system_mod_fcgid_enabled' - && (int)$newfieldvalue == 1 - && (int)Settings::Get('phpfpm.enabled') == 1 - ) { - $returnvalue = array(FORMFIELDS_PLAUSIBILITY_CHECK_ERROR, 'phpfpmstillenabled'); - } - // check whether php-fpm should be enabled but fcgid is - elseif($fieldname == 'system_phpfpm_enabled' - && (int)$newfieldvalue == 1 - && (int)Settings::Get('system.mod_fcgid') == 1 - ) { - $returnvalue = array(FORMFIELDS_PLAUSIBILITY_CHECK_ERROR, 'fcgidstillenabled'); - } - - return $returnvalue; +function checkFcgidPhpFpm($fieldname, $fielddata, $newfieldvalue, $allnewfieldvalues) +{ + $returnvalue = array( + FORMFIELDS_PLAUSIBILITY_CHECK_OK + ); + + $check_array = array( + 'system_mod_fcgid_enabled' => array( + 'other_post_field' => 'system_phpfpm_enabled', + 'other_enabled' => 'phpfpm.enabled', + 'other_enabled_lng' => 'phpfpmstillenabled' + ), + 'system_phpfpm_enabled' => array( + 'other_post_field' => 'system_mod_fcgid_enabled', + 'other_enabled' => 'system.mod_fcgid', + 'other_enabled_lng' => 'fcgidstillenabled' + ) + ); + + // interface is to be enabled + 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; } diff --git a/lng/english.lng.php b/lng/english.lng.php index cbf6c141..fef161df 100644 --- a/lng/english.lng.php +++ b/lng/english.lng.php @@ -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['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['error']['fcgidandphpfpmnogoodtogether'] = 'FCGID and PHP-FPM cannot be activated at the same time'; diff --git a/lng/german.lng.php b/lng/german.lng.php index 0da2d2bb..76ad5dd7 100644 --- a/lng/german.lng.php +++ b/lng/german.lng.php @@ -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['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['error']['fcgidandphpfpmnogoodtogether'] = 'FCGID und PHP-FPM können nicht gleichzeitig aktiviert werden.';