public inbox for development@lists.ipfire.org
 help / color / mirror / Atom feed
From: Matthias Fischer <matthias.fischer@ipfire.org>
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	[thread overview]
Message-ID: <20190416164124.2290-1-matthias.fischer@ipfire.org> (raw)

[-- 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


             reply	other threads:[~2019-04-16 16:41 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-16 16:41 Matthias Fischer [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190416164124.2290-1-matthias.fischer@ipfire.org \
    --to=matthias.fischer@ipfire.org \
    --cc=development@lists.ipfire.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox