' . gtext('Please check and configure the following entries: "BASTILLE_ZFS_ENABLE" and "BASTILLE_ZFS_ZPOOL".') .'
' . gtext('After configuring or skip ZFS option:') . ' ' . '' . gtext('Please click here then push "Save" button.') . ''; $prerequisites_ok = false; endif; function htmlInput($name, $title, $value="", $size=80) { $result = ""; return $result; } function htmlButton($name, $text, $value="", $title="", $confirm="", $buttonImage="") { $onClick = ($confirm == "") ? "" : "onclick='return confirm(\"{$confirm}\")'"; switch ($buttonImage) { case "save": $buttonImage = ""; break; default: $buttonImage = ""; } $result = ""; return $result; } function parseConfigFile($configFile) { global $section; $fileArray = file($configFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); // load config file content to array $configArray = array(); foreach($fileArray as $line) { // create array from config $line = trim($line); // remove leading/trailing space if ($line[0] == "#") continue; // skip if comment line if ($line[0] == "[") { // add as section $configArray[$line] = []; $section = $line; // remember section name for params } else { // process params $parameter = explode("=", $line, 2); // seperate key and value, (Split at the first occurrence only) $key = trim($parameter[0]); // set key $val = explode("#", trim($parameter[1])); // get value, remove trailing comments $value = $val[0]; // set value $configArray[$section][$key] = $value; // add param to section } } return $configArray; } function saveConfigFile($configFile, $configArray, $hashTag="", $prettyPrint=true) { //$printTab = ($prettyPrint) ? "\t" : ""; // Print leading tab. //$printSpace = ($prettyPrint) ? " " : ""; // Print spaces. $printTab = ($prettyPrint) ? "" : ""; // Do not print leading tab. $printSpace = ($prettyPrint) ? "" : ""; // Do not print spaces. $cFile = fopen($configFile, "w"); foreach($configArray as $key => $line) { // traverse array, key = section if (is_array($line)) { if ($key != '') fwrite($cFile, $key.PHP_EOL); // write section if not "['']" => NO section foreach($line as $pName => $pValue) fwrite($cFile, $printTab.$pName.$printSpace."=".$printSpace.$pValue.PHP_EOL); // "\t".$pName = add TAB for output formatting fwrite($cFile, PHP_EOL); } else fwrite($cFile, $key.$printSpace."=".$printSpace.$line.PHP_EOL); } // end foreach fclose($cFile); if (!empty($hashTag)) header("Location:#{$hashTag}"); } // load addon config - use selected config from Bastille tab or alternative if exist $configAddonArray = parseConfigFile($configAddon); // read addon config file if (empty($configAddonArray['']['ALTERNATIVE_CONFIG'])) $configFile = str_replace('"', "", $configAddonArray['']['BASTILLE_CONFIG']); // get Bastille config file path and name else $configFile = str_replace('"', "", $configAddonArray['']['ALTERNATIVE_CONFIG']); // get Bastille config file path and name // load Bastille config if (!is_file($configFile)) $input_errors[] = sprintf(gtext("%s not found!"), gettext("Configuration File")." {$configFile}"); else { $configArray = parseConfigFile($configFile); // parse Bastille config file //$savemsg = gtext("Loaded config file").": ".basename($configFile).""; } if ($_POST) { unset($input_errors); if (isset($_POST['saveParam']) && $_POST['saveParam']) { // saveParam s/n/v $buttonTag = explode("#", $_POST['saveParam']); // buttonTag[0] = section, buttonTag[1] = paramName $hashTag = str_replace(["[", "]", ".", "#"], "", $buttonTag[0]); // create destination to jump to after post $nameTag = str_replace(["[", "]", ".", "#"], "", $_POST['saveParam']); // nameTag = $configArray[$buttonTag[0]][$buttonTag[1]] = $_POST[$nameTag]; // save param to section #$savemsg .= "saveParam s/n/v: ".$_POST['saveParam']." ".$nameTag." ".$_POST[$nameTag]; } if (empty($input_errors) && !isset($_POST['loadConfig'])) saveConfigFile($configFile, $configArray, $hashTag); # Run bastille-init to update config. exec("bastille-init"); } bindtextdomain("xigmanas", $textdomain); include("fbegin.inc"); bindtextdomain("xigmanas", $textdomain_bastille); ?>
"; // loop through configuration $firstSection = true; // prevent first html_separator in loop if (is_array($configArray) && !empty($configArray)) foreach($configArray as $key => $line) { // traverse array, key = section $nameTag = str_replace(["[", "]", "."], "", $key); // create tag for post jump address and config changes if (is_array($line)) { if ($firstSection === true) $firstSection = false; else html_separator(); html_titleline(gtext("Variable Name").": ".$key, 2, $nameTag); // section title bar foreach($line as $pName => $pValue) // traverse params within section, pName = param name, pValue = param value html_text($pName, $pName, // create param entry htmlInput($nameTag.$pName, gtext("Parameter Value"), $pValue).$wSpace. htmlButton("saveParam", "", $key."#".$pName, gtext("Save"), "", "save").$wSpace. "", ); } echo ""; } echo ""; ?>
"; if (!empty($input_errors)) print_input_errors($input_errors); if (!empty($savemsg)) print_info_box($savemsg); echo "
"; echo "
"; html_remark("noteAddSection", gtext("Note"), gtext("Please be careful, as no validation will be performed on your input!")); echo "