keyfield = "name"; if ($_POST) { $pconfig = $_POST; if ($_POST['apply']) { $result = haproxy_check_and_run($savemsg, true); if ($result) unlink_if_exists($d_haproxyconfdirty_path); } else { $a_files = $fileslist->haproxy_htmllist_get_values($fields_files); $filedupcheck = array(); foreach($a_files as $key => $file) { $name = $file['name']; if (!preg_match("/^[a-zA-Z][a-zA-Z0-9\.\-_]*$/", $file['name'])) $input_errors[] = "The field 'Name' (".htmlspecialchars($file['name']).") contains invalid characters. Use only: a-zA-Z0-9.-_ and start with a letter"; if (isset($filedupcheck[$name])) $input_errors[] = "Duplicate names are not allowed: " . htmlspecialchars($name); $filedupcheck[$name] = true; } // replace references in backends to renamed 'files' foreach($a_pools as &$backend) { if (is_arrayset($backend,'errorfiles','item')) foreach($backend['errorfiles']['item'] as &$errorfile) { $found = false; foreach($a_files as $key => $file) { if ($errorfile['errorfile'] == $key) { $errorfile['errorfile'] = $file['name']; $found = true; } } if (!$found) $input_errors[] = "Errorfile marked for deletion: " . $errorfile['errorfile'] . " which is used in backend " . $backend['name']; } } if (!$input_errors) { // save config when no errors found touch($d_haproxyconfdirty_path); write_config($changedesc); header("Location: haproxy_files.php"); exit; } } } $pf_version=substr(trim(file_get_contents("/etc/version")),0,3); $pgtitle = "Services: HAProxy: Files"; include("head.inc"); ?>