diff --git a/app/app.pm b/app/app.pm index 7f74754..3ce50e2 100644 --- a/app/app.pm +++ b/app/app.pm @@ -92,6 +92,12 @@ sub delete_domain { $ze->del(); } +sub update_domain_raw { + my ($self, $login, $zone, $domain) = @_; + my $ze = app::zone::edit->new(zname => $domain, zdir => $self->zdir); + $ze->update_raw($zone); +} + sub update_domain { my ($self, $login, $zone, $domain) = @_; my $ze = app::zone::edit->new(zname => $domain, zdir => $self->zdir); diff --git a/app/zone/edit.pm b/app/zone/edit.pm index dfe5682..434a4ab 100644 --- a/app/zone/edit.pm +++ b/app/zone/edit.pm @@ -70,6 +70,27 @@ sub update { $rndc->reload($self->zname); } +=pod + udpate via the raw content of the zonefile +=cut + +sub update_raw { + my ($self, $zonetext) = @_; + + my $file = '/tmp/'.$self->zname; + + # write the updated zone file to disk + my $newzone; + open($newzone, '>', $file) or die "error"; + print $newzone $zonetext; + close $newzone; + + my $zonefile = DNS::ZoneParse->new($file, $self->zname); + unlink($file); + + $self->update($zonefile); +} + # sera utile plus tard, pour l'interface sub new_tmp { my ($self) = @_; diff --git a/www/lib/DNSManager.pm b/www/lib/DNSManager.pm index 10a4c17..6214e94 100644 --- a/www/lib/DNSManager.pm +++ b/www/lib/DNSManager.pm @@ -108,7 +108,8 @@ get '/mapage' => sub { } }; -get '/details' => sub { +any ['post', 'get'] => '/domainupdate/:domain' => sub { + # check if user is logged & if domain parameter is set unless( session('login') && param('domain')) { @@ -117,30 +118,41 @@ get '/details' => sub { else { my $app = initco(); - my ($auth_ok, $user, $isadmin) = $app->auth( param('login') ); - my @zones = (); - my $zone_properties; - #say 'dump : ' . dump $user->get_zone( param('domain') ); + my ($auth_ok, $user, $isadmin) = $app->auth(param('login'), + param('password') ); - for( $user->get_zone( param('domain') ) ) - { + $app->update_domain_raw(session('login') + , param('zoneupdated') + , param('domain')); - if( ref($_) eq 'HASH' and exists $_->{addr} ) { - push( @zones, $_ ) when $_->{addr} ne '@'; - $zone_properties = $_ when $_->{addr} eq '@'; - } - - } - - template details => { - login => session('login') - , domain => param('domain') - , zones => \@zones - , zone_properties => $zone_properties }; + redirect '/mapage'; } }; +get '/details/:domain' => sub { + + # check if user is logged & if domain parameter is set + unless( session('login') && param('domain')) + { + redirect '/'; + } + else + { + my $app = initco(); + my ($auth_ok, $user, $isadmin) = $app->auth(param('login'), + param('password') ); + + my $zone = $app->get_domain(session('login') , param('domain')); + + template details => { + login => session('login') + , domain => param('domain') + , domain_zone => $zone->output() }; + + } + +}; any ['get', 'post'] => '/administration' => sub { unless( session('login') ) diff --git a/www/views/details.tt b/www/views/details.tt index a32ed3d..f049e86 100644 --- a/www/views/details.tt +++ b/www/views/details.tt @@ -1,105 +1,25 @@
Host | -Adress | -Type | -Domain | -
---|---|---|---|
- <% IF zone.host %> - <% zone.host %> - <%END%> - | -- <% IF zone.addr %> - <% zone.addr %> - <% END %> - | -- <% IF zone.type %> - <% zone.type %> - <%END%> - | -- <% IF zone.domain %> - <% zone.domain %> - <%END%> - | -
Admin de la zone | -Serial | -Primary | -Retry | -Domain | -Refresh | -Address | -Expire | -
---|---|---|---|---|---|---|---|
- <% IF zone_properties.admin %>
- <%zone_properties.admin%> - <%END%> - | - <% IF zone_properties.serial %> - <%zone_properties.serial%> - <%END%> - | -- <% IF zone_properties.primary %> - <%zone_properties.primary%> - <%END%> - | -- <% IF zone_properties.retry %> - <%zone_properties.retry%> - <%END%> - | -- <% IF zone_properties.domain %> - <%zone_properties.domain%> - <%END%> - | -- <% IF zone_properties.refresh %> - <%zone_properties.refresh%> - <%END%> - | -- <% IF zone_properties.addr %> - <%zone_properties.addr%> - <%END%> - | -- <% IF zone_properties.expire %> - <%zone_properties.expire%> - <%END%> - | -
Netlib.re est un projet qui permettra à tout un chacun d'obtenir un sous-domaine de netlib.re, gratuitement et simplement.
+Une bande d'informaticiens passionnés, voulant aider la communauté.
+En résumé : cherchez votre nom de domaine, réservez-le, on s'occupe du reste !
+ +