Skip to content

Commit f4dff67

Browse files
committed
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) <[email protected]>
1 parent 77ae3aa commit f4dff67

File tree

3 files changed

+47
-21
lines changed

3 files changed

+47
-21
lines changed

lib/functions/validate/function.checkFcgidPhpFpm.php

Lines changed: 45 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,49 @@
1414
* @package Functions
1515
*
1616
*/
17-
18-
function checkFcgidPhpFpm($fieldname, $fielddata, $newfieldvalue, $allnewfieldvalues) {
19-
20-
$returnvalue = array(FORMFIELDS_PLAUSIBILITY_CHECK_OK);
21-
22-
// check whether fcgid should be enabled but php-fpm is
23-
if($fieldname == 'system_mod_fcgid_enabled'
24-
&& (int)$newfieldvalue == 1
25-
&& (int)Settings::Get('phpfpm.enabled') == 1
26-
) {
27-
$returnvalue = array(FORMFIELDS_PLAUSIBILITY_CHECK_ERROR, 'phpfpmstillenabled');
28-
}
29-
// check whether php-fpm should be enabled but fcgid is
30-
elseif($fieldname == 'system_phpfpm_enabled'
31-
&& (int)$newfieldvalue == 1
32-
&& (int)Settings::Get('system.mod_fcgid') == 1
33-
) {
34-
$returnvalue = array(FORMFIELDS_PLAUSIBILITY_CHECK_ERROR, 'fcgidstillenabled');
35-
}
36-
37-
return $returnvalue;
17+
function checkFcgidPhpFpm($fieldname, $fielddata, $newfieldvalue, $allnewfieldvalues)
18+
{
19+
$returnvalue = array(
20+
FORMFIELDS_PLAUSIBILITY_CHECK_OK
21+
);
22+
23+
$check_array = array(
24+
'system_mod_fcgid_enabled' => array(
25+
'other_post_field' => 'system_phpfpm_enabled',
26+
'other_enabled' => 'phpfpm.enabled',
27+
'other_enabled_lng' => 'phpfpmstillenabled'
28+
),
29+
'system_phpfpm_enabled' => array(
30+
'other_post_field' => 'system_mod_fcgid_enabled',
31+
'other_enabled' => 'system.mod_fcgid',
32+
'other_enabled_lng' => 'fcgidstillenabled'
33+
)
34+
);
35+
36+
// interface is to be enabled
37+
if ((int) $newfieldvalue == 1) {
38+
// check for POST value of the other field == 1 (active)
39+
if (isset($_POST[$check_array[$fieldname]['other_post_field']]) && (int) $_POST[$check_array[$fieldname]['other_post_field']] == 1) {
40+
// the other interface is activated already and STAYS activated
41+
if ((int) Settings::Get($check_array[$fieldname]['other_enabled']) == 1) {
42+
$returnvalue = array(
43+
FORMFIELDS_PLAUSIBILITY_CHECK_ERROR,
44+
$check_array[$fieldname]['other_enabled_lng']
45+
);
46+
} else {
47+
// fcgid is being validated before fpm -> "ask" fpm about its state
48+
if ($fieldname == 'system_mod_fcgid_enabled') {
49+
$returnvalue = checkFcgidPhpFpm('system_phpfpm_enabled', null, $check_array[$fieldname]['other_post_field'], null);
50+
} else {
51+
// not, bot are nogo
52+
$returnvalue = $returnvalue = array(
53+
FORMFIELDS_PLAUSIBILITY_CHECK_ERROR,
54+
'fcgidandphpfpmnogoodtogether'
55+
);
56+
}
57+
}
58+
}
59+
}
60+
61+
return $returnvalue;
3862
}

lng/english.lng.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1838,3 +1838,4 @@
18381838
$lng['usersettings']['custom_notes']['show'] = 'Show your notes on the dashboard of the user';
18391839
$lng['serversettings']['system_send_cron_errors']['title'] = 'Send cron-errors to froxlor-admin via e-mail';
18401840
$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.';
1841+
$lng['error']['fcgidandphpfpmnogoodtogether'] = 'FCGID and PHP-FPM cannot be activated at the same time';

lng/german.lng.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1565,3 +1565,4 @@
15651565
$lng['usersettings']['custom_notes']['show'] = 'Zeige die Notizen auf dem Dashboard des Benutzers';
15661566
$lng['serversettings']['system_send_cron_errors']['title'] = 'Sende Cron-Fehler via E-Mail an den Froxlor-Admin';
15671567
$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.';
1568+
$lng['error']['fcgidandphpfpmnogoodtogether'] = 'FCGID und PHP-FPM können nicht gleichzeitig aktiviert werden.';

0 commit comments

Comments
 (0)