switch ($action) {
case 'add':
+ // Boolean value
foreach ($pgpoolConfigParam as $key => $value) {
if ($pgpoolConfigParam[$key]['type'] == 'B') {
if (isset($_POST[$key])) {
- $configValue[$key] = 'true';
+ $configValue[$key] = 'on';
} else {
- $configValue[$key] = 'false';
+ $configValue[$key] = 'off';
}
} else {
$configValue[$key] = trim($_POST[$key]);
}
}
+ // Backend settings
if (isset($_POST['backend_hostname'])) {
$configValue['backend_hostname'] = $_POST['backend_hostname'];
} else {
case 'cancel':
+ // Boolean value
foreach ($pgpoolConfigParam as $key => $value) {
if ($pgpoolConfigParam[$key]['type'] == 'B') {
if (isset($_POST[$key])) {
- $configValue[$key] = 'true';
+ $configValue[$key] = 'on';
} else {
- $configValue[$key] = 'false';
+ $configValue[$key] = 'off';
}
} else {
$configValue[$key] = trim($_POST[$key]);
}
}
+ // Backend settings
if (isset($_POST['backend_hostname'])) {
$configValue['backend_hostname'] = $_POST['backend_hostname'];
}
switch ($type) {
case 'B':
$result = checkBoolean($configParam[$key]);
+
+ // allow true/false and on/off as input format,
+ // but write with only on/off format.
+ if ($result) {
+ if ($configParam[$key] == 'true') {
+ $configParam[$key] = 'on';
+ } elseif ($configParam[$key] == 'false') {
+ $configParam[$key] = 'off';
+ }
+ }
+
break;
+
case 'C':
$result = checkString($configParam[$key], $value['regexp']);
break;
+
case 'F':
$result = checkFloat($configParam[$key], $value['min'], $value['max']);
break;
+
case 'N':
$result = checkInteger($configParam[$key], $value['min'], $value['max']);
break;
*/
function checkBoolean($str)
{
- if ($str == 'true' || $str == 'false') {
+ if (in_array($str, array('true', 'false', 'on', 'off'))) {
return TRUE;
} else {
return FALSE;