Skip to content

Commit

Permalink
do not allow to enable fcgid/fpm at the same time when both are set t…
Browse files Browse the repository at this point in the history
…o 'yes' simultaneously in settings

Signed-off-by: Michael Kaufmann (d00p) <[email protected]>
  • Loading branch information
d00p committed Feb 1, 2015
1 parent 77ae3aa commit f4dff67
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 21 deletions.
66 changes: 45 additions & 21 deletions lib/functions/validate/function.checkFcgidPhpFpm.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
1 change: 1 addition & 0 deletions lng/english.lng.php
Original file line number Diff line number Diff line change
Expand Up @@ -1838,3 +1838,4 @@
$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';
1 change: 1 addition & 0 deletions lng/german.lng.php
Original file line number Diff line number Diff line change
Expand Up @@ -1565,3 +1565,4 @@
$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.';

0 comments on commit f4dff67

Please sign in to comment.