From d9b1a15e7296b7b4ce1435d930be3b348979c001 Mon Sep 17 00:00:00 2001 From: Julien Simonet Date: Sat, 25 Jan 2014 23:35:26 +0100 Subject: [PATCH] Suppression d'enregistrements d'une zone. --- www/lib/DNSManager.pm | 74 +++++++++++++++++++++++++++++++++++++++++++ www/views/details.tt | 7 +++- www/views/sidebar.tt | 4 +-- 3 files changed, 82 insertions(+), 3 deletions(-) diff --git a/www/lib/DNSManager.pm b/www/lib/DNSManager.pm index fef11e9..3531d44 100644 --- a/www/lib/DNSManager.pm +++ b/www/lib/DNSManager.pm @@ -353,6 +353,80 @@ prefix '/domain' => sub { }; + get '/del/:domain/:name/:type/:host/:ttl' => sub { + + unless( session( 'user' ) and defined param('domain') ) { + session errmsg => q; + redirect get_route; + } + else { + # Load :domain and search for corresponding data + my $app = initco(); + my ($auth_ok, $user, $isadmin) = $app->auth(param('login'), + param('password') ); + + my $zone = $app->get_domain(session('login') , param('domain')); + my $dump = $zone->dump; + + my $record; + my $found = false; + + given( lc param('type') ) + { + when ('a') + { + $record = $zone->a; + $found = true; + } + when ('aaaa') + { + $record = $zone->aaaa; + $found = true; + } + when ('cname') + { + $record = $zone->cname; + $found = true; + } + when ('ns') + { + $record = $zone->ns; + $found = true; + } + when ('mx') + { + $record = $zone->mx; + $found = true; + } + when ('ptr') + { + $record = $zone->ptr; + $found = true; + } + } + + if( $found ) + { + + foreach my $i ( 0 .. scalar @{$record}-1 ) + { + + if( $record->[$i]->{'name'} eq param('name') && + $record->[$i]->{'host'} eq param('host') && + $record->[$i]->{'ttl'} == param('ttl') ) + { + delete $record->[$i]; + } + + } + + } + + $app->update_domain( session('login'), $zone, param('domain') ); + } + + redirect '/domain/details/'. param('domain'); + } }; any ['get', 'post'] => '/admin' => sub { diff --git a/www/views/details.tt b/www/views/details.tt index 7545714..58caf7e 100644 --- a/www/views/details.tt +++ b/www/views/details.tt @@ -31,6 +31,7 @@ NS <% address.host %> <% address.ttl %> + <% END %> @@ -41,6 +42,7 @@ A <% address.host %> <% address.ttl %> + <% END %> @@ -51,6 +53,7 @@ AAAA <% address.host %> <% address.ttl %> + <% END %> @@ -61,6 +64,7 @@ CNAME <% address.host %> <% address.ttl %> + <% END %> @@ -71,6 +75,7 @@ PTR <% address.host %> <% address.ttl %> + <% END %> @@ -81,9 +86,9 @@ MX <% address.host %> (<% address.priority %>) <% address.ttl %> + <% END %> - diff --git a/www/views/sidebar.tt b/www/views/sidebar.tt index f529c86..42f54c5 100644 --- a/www/views/sidebar.tt +++ b/www/views/sidebar.tt @@ -37,9 +37,9 @@
- Se connecter: + Se connecter : - +