From mboxrd@z Thu Jan 1 00:00:00 1970 From: Matthias Fischer To: development@lists.ipfire.org Subject: [PATCH] Fix for Bug #12050: Adding fixed leases with one 'add' click Date: Tue, 16 Apr 2019 18:41:24 +0200 Message-ID: <20190416164124.2290-1-matthias.fischer@ipfire.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============6041444502310311492==" List-Id: --===============6041444502310311492== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Signed-off-by: BeBiMa Reviewed-by: Matthias Fischer --- html/cgi-bin/dhcp.cgi | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/html/cgi-bin/dhcp.cgi b/html/cgi-bin/dhcp.cgi index 675d80012..ba5b54f84 100644 --- a/html/cgi-bin/dhcp.cgi +++ b/html/cgi-bin/dhcp.cgi @@ -412,12 +412,16 @@ if ($dhcpsettings{'ACTION'} eq $Lang::tr{'add'}.'2') { } =09 my $key =3D 0; + my $szc =3D scalar(@current2); CHECK:foreach my $line (@current2) { my @temp =3D split(/\,/,$line); if($dhcpsettings{'KEY2'} ne $key) { # same MAC is OK on different subnets. This test is not complete becau= se # if ip are not inside a known subnet, I don't warn. # Also it may be needed to put duplicate fixed lease in their right sub= net definition.. + if ((lc($dhcpsettings{'FIX_MAC'}) eq lc($temp[0])) &&(lc($dhcpsettings{= 'FIX_ADDR'}) eq lc($temp[1]))) { + last CHECK; + } foreach my $itf (@ITFs) { my $scoped =3D &General::IpInSubnet($dhcpsettings{'FIX_ADDR'}, $netsettings{"${itf}_NETADDRESS"},=20 @@ -442,11 +446,19 @@ if ($dhcpsettings{'ACTION'} eq $Lang::tr{'add'}.'2') { $dhcpsettings{'FIX_FILENAME'} =3D &Header::cleanhtml($dhcpsettings{'FIX_FIL= ENAME'}); $dhcpsettings{'FIX_ROOTPATH'} =3D &Header::cleanhtml($dhcpsettings{'FIX_ROO= TPATH'}); if ($dhcpsettings{'KEY2'} eq '') { #add or edit ? + if($key =3D=3D $szc) { #add + @current2[$key] =3D "$dhcpsettings{'FIX_MAC'},$dhcpsettings{'FIX_AD= DR'},$dhcpsettings{'FIX_ENABLED'},$dhcpsettings{'FIX_NEXTADDR'},$dhcpsettings= {'FIX_FILENAME'},$dhcpsettings{'FIX_ROOTPATH'},$dhcpsettings{'FIX_REMARK'}\n"; + # sort newly added/modified entry + &sortcurrent2; + &General::log($Lang::tr{'fixed ip lease added'}); + $dhcpsettings{'KEY2'} =3D ''; + } else { #edit unshift (@current2, "$dhcpsettings{'FIX_MAC'},$dhcpsettings{'FIX_ADDR'}= ,$dhcpsettings{'FIX_ENABLED'},$dhcpsettings{'FIX_NEXTADDR'},$dhcpsettings{'FI= X_FILENAME'},$dhcpsettings{'FIX_ROOTPATH'},$dhcpsettings{'FIX_REMARK'}\n"); &General::log($Lang::tr{'fixed ip lease added'}); =20 # Enter edit mode $dhcpsettings{'KEY2'} =3D 0; + } } else { @current2[$dhcpsettings{'KEY2'}] =3D "$dhcpsettings{'FIX_MAC'},$dhcpset= tings{'FIX_ADDR'},$dhcpsettings{'FIX_ENABLED'},$dhcpsettings{'FIX_NEXTADDR'},= $dhcpsettings{'FIX_FILENAME'},$dhcpsettings{'FIX_ROOTPATH'},$dhcpsettings{'FI= X_REMARK'}\n"; $dhcpsettings{'KEY2'} =3D ''; # End edit mode --=20 2.18.0 --===============6041444502310311492==--