public inbox for development@lists.ipfire.org
 help / color / mirror / Atom feed
* [PATCH] Fix for Bug #12050: Adding fixed leases with one 'add' click
@ 2019-04-16 16:41 Matthias Fischer
  2019-04-17  9:31 ` Michael Tremer
  0 siblings, 1 reply; 23+ messages in thread
From: Matthias Fischer @ 2019-04-16 16:41 UTC (permalink / raw)
  To: development

[-- Attachment #1: Type: text/plain, Size: 2595 bytes --]

Signed-off-by: BeBiMa <bbitsch(a)ipfire.org>
Reviewed-by: Matthias Fischer <matthias.fischer(a)ipfire.org>
---
 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') {
     }
 	
     my $key = 0;
+    my $szc =  scalar(@current2);
     CHECK:foreach my $line (@current2) {
         my @temp = split(/\,/,$line);
         if($dhcpsettings{'KEY2'} ne $key) {
  	    # same MAC is OK on different subnets. This test is not complete because
 	    # 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 subnet 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 = &General::IpInSubnet($dhcpsettings{'FIX_ADDR'},
 						  $netsettings{"${itf}_NETADDRESS"}, 
@@ -442,11 +446,19 @@ if ($dhcpsettings{'ACTION'} eq $Lang::tr{'add'}.'2') {
 	$dhcpsettings{'FIX_FILENAME'} = &Header::cleanhtml($dhcpsettings{'FIX_FILENAME'});
 	$dhcpsettings{'FIX_ROOTPATH'} = &Header::cleanhtml($dhcpsettings{'FIX_ROOTPATH'});
 	if ($dhcpsettings{'KEY2'} eq '') { #add or edit ?
+	    if($key == $szc) { #add
+	        @current2[$key] = "$dhcpsettings{'FIX_MAC'},$dhcpsettings{'FIX_ADDR'},$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'} = '';
+        } else { #edit
 	    unshift (@current2, "$dhcpsettings{'FIX_MAC'},$dhcpsettings{'FIX_ADDR'},$dhcpsettings{'FIX_ENABLED'},$dhcpsettings{'FIX_NEXTADDR'},$dhcpsettings{'FIX_FILENAME'},$dhcpsettings{'FIX_ROOTPATH'},$dhcpsettings{'FIX_REMARK'}\n");
 	    &General::log($Lang::tr{'fixed ip lease added'});
 
 	    # Enter edit mode
 	    $dhcpsettings{'KEY2'} = 0;
+	    }
 	} else {
 	    @current2[$dhcpsettings{'KEY2'}] = "$dhcpsettings{'FIX_MAC'},$dhcpsettings{'FIX_ADDR'},$dhcpsettings{'FIX_ENABLED'},$dhcpsettings{'FIX_NEXTADDR'},$dhcpsettings{'FIX_FILENAME'},$dhcpsettings{'FIX_ROOTPATH'},$dhcpsettings{'FIX_REMARK'}\n";
 	    $dhcpsettings{'KEY2'} = '';       # End edit mode
-- 
2.18.0


^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2019-05-20 20:27 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-16 16:41 [PATCH] Fix for Bug #12050: Adding fixed leases with one 'add' click Matthias Fischer
2019-04-17  9:31 ` Michael Tremer
2019-04-17 21:49   ` Aw: " Bernhard Bitsch
2019-04-18  9:50     ` Michael Tremer
2019-04-18 11:23       ` Aw: " Bernhard Bitsch
2019-04-18 11:42         ` Michael Tremer
2019-04-18 12:54           ` Aw: " Bernhard Bitsch
2019-04-18 12:59             ` Bernhard Bitsch
2019-04-18 14:47             ` [PATCH] " Michael Tremer
2019-04-18 20:37               ` Aw: " Bernhard Bitsch
2019-04-20 16:35                 ` Michael Tremer
2019-05-17 10:58                   ` Aw: " Bernhard Bitsch
2019-05-17 19:18                     ` Michael Tremer
2019-05-17 22:21                       ` Aw: " Bernhard Bitsch
2019-05-17 22:27                         ` Michael Tremer
2019-05-18 18:28                           ` Aw: " Bernhard Bitsch
2019-05-20  9:37                             ` Michael Tremer
2019-05-20 14:21                               ` Aw: " Bernhard Bitsch
2019-05-20 16:03                                 ` Tom Rymes
2019-05-20 16:42                                   ` Aw: Re: Re: [PATCH] Fix for Bug #12050: Adding fixed leases with one 'add' click / Bug #10629 Bernhard Bitsch
2019-05-20 16:49                                     ` Tom Rymes
2019-05-20 19:13                                       ` Aw: " Bernhard Bitsch
2019-05-20 20:27                                 ` Aw: Re: [PATCH] Fix for Bug #12050: Adding fixed leases with one 'add' click Bernhard Bitsch

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox