From 6d1af0e9d8e4398f71a572bb1cf2b4174ac5503b Mon Sep 17 00:00:00 2001 From: jim-p Date: Fri, 21 May 2010 13:31:33 -0400 Subject: Preserve DHCP numbered options when there is an input error. Fixes #494 --- usr/local/www/services_dhcp.php | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'usr/local/www/services_dhcp.php') diff --git a/usr/local/www/services_dhcp.php b/usr/local/www/services_dhcp.php index b72258f..0a9bb46 100755 --- a/usr/local/www/services_dhcp.php +++ b/usr/local/www/services_dhcp.php @@ -193,6 +193,18 @@ if ($_POST) { $pconfig = $_POST; + $numberoptions = array(); + for($x=0; $x<99; $x++) { + if(isset($_POST["number{$x}"]) && ctype_digit($_POST["number{$x}"])) { + $numbervalue = array(); + $numbervalue['number'] = htmlspecialchars($_POST["number{$x}"]); + $numbervalue['value'] = htmlspecialchars($_POST["value{$x}"]); + $numberoptions['item'][] = $numbervalue; + } + } + // Reload the new pconfig variable that the forum uses. + $pconfig['numberoptions'] = $numberoptions; + /* input validation */ if ($_POST['enable']) { $reqdfields = explode(" ", "range_from range_to"); @@ -313,17 +325,8 @@ if ($_POST) { // Handle the custom options rowhelper if(isset($config['dhcpd'][$if]['numberoptions']['item'])) unset($config['dhcpd'][$if]['numberoptions']['item']); - for($x=0; $x<99; $x++) { - if(isset($_POST["number{$x}"]) && ctype_digit($_POST["number{$x}"])) { - $numbervalue = array(); - $numbervalue['number'] = htmlspecialchars($_POST["number{$x}"]); - $numbervalue['value'] = htmlspecialchars($_POST["value{$x}"]); - $config['dhcpd'][$if]['numberoptions']['item'][] = $numbervalue; - } - } - - // Reload the new pconfig variable that the forum uses. - $pconfig['numberoptions'] = $config['dhcpd'][$if]['numberoptions']; + + $config['dhcpd'][$if]['numberoptions'] = $numberoptions; write_config(); -- cgit v1.1