Merge branch 'features/domainModification'
This commit is contained in:
commit
483b6fed53
@ -106,7 +106,7 @@ get '/home' => sub {
|
|||||||
|
|
||||||
prefix '/domain' => sub {
|
prefix '/domain' => sub {
|
||||||
|
|
||||||
any ['post', 'get'] => '/update/:domain' => sub {
|
any ['post', 'get'] => '/updateraw/:domain' => sub {
|
||||||
|
|
||||||
# check if user is logged & if domain parameter is set
|
# check if user is logged & if domain parameter is set
|
||||||
unless( session('login') && param('domain'))
|
unless( session('login') && param('domain'))
|
||||||
@ -124,9 +124,86 @@ prefix '/domain' => sub {
|
|||||||
, param('domain'));
|
, param('domain'));
|
||||||
|
|
||||||
redirect '/domain/details/' . param('domain');
|
redirect '/domain/details/' . param('domain');
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
any ['post', 'get'] => '/update/:domain' => sub {
|
||||||
|
unless( session('login') && param('domain') )
|
||||||
|
{
|
||||||
|
redirect '/';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
my $type = param('type');
|
||||||
|
my $name = param('name');
|
||||||
|
my $value = param('value');
|
||||||
|
my $ttl = param('ttl');
|
||||||
|
|
||||||
|
my $app = initco();
|
||||||
|
my ($auth_ok, $user, $isadmin) = $app->auth(param('login'),
|
||||||
|
param('password') );
|
||||||
|
my $zone = $app->get_domain( session('login') , param('domain') );
|
||||||
|
given( $type )
|
||||||
|
{
|
||||||
|
|
||||||
|
when ('A') { my $a=$zone->a();
|
||||||
|
push( @$a, {name => $name,
|
||||||
|
class => "IN",
|
||||||
|
host => $value,
|
||||||
|
ttl => $ttl,
|
||||||
|
ORIGIN => $zone->origin} );
|
||||||
|
}
|
||||||
|
|
||||||
|
when ('AAAA') { my $aaaa=$zone->aaaa;
|
||||||
|
push(@$aaaa, {name => $name,
|
||||||
|
class => "IN",
|
||||||
|
host => $value,
|
||||||
|
ttl => $ttl,
|
||||||
|
ORIGIN => $zone->origin} );
|
||||||
|
}
|
||||||
|
|
||||||
|
when ('CNAME') { my $cname=$zone->cname;
|
||||||
|
push(@$cname,
|
||||||
|
{name => $name,
|
||||||
|
class => "IN",
|
||||||
|
host => $value,
|
||||||
|
ttl => $ttl,
|
||||||
|
ORIGIN => $zone->origin} );
|
||||||
|
}
|
||||||
|
|
||||||
|
when ('MX') { my $ptr=$zone->ptr;
|
||||||
|
push(@$ptr, {name => $name,
|
||||||
|
class => "IN",
|
||||||
|
host => $value,
|
||||||
|
ttl => $ttl,
|
||||||
|
ORIGIN => $zone->origin} );
|
||||||
|
}
|
||||||
|
|
||||||
|
when ('PTR') { my $ptr=$zone->ptr;
|
||||||
|
push(@$ptr, {name => $name,
|
||||||
|
class => "IN",
|
||||||
|
host => $value,
|
||||||
|
ttl => $ttl,
|
||||||
|
ORIGIN => $zone->origin} );
|
||||||
|
}
|
||||||
|
|
||||||
|
when ('NS') { my $ns=$zone->ns;
|
||||||
|
push(@$ns, {name => $name,
|
||||||
|
class => "IN",
|
||||||
|
host => $value,
|
||||||
|
ttl => $ttl,
|
||||||
|
ORIGIN => $zone->origin} );
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
$zone->new_serial();
|
||||||
|
my $cfg = new Config::Simple(dirname(__FILE__).'/../conf/config.ini');
|
||||||
|
my $ed = app::zone::edit->new(zdir=>$cfg->param('zones_path'), zname => param('domain'));
|
||||||
|
$ed->update($zone);
|
||||||
|
redirect '/domain/details/'.param('domain');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
get '/details/:domain' => sub {
|
get '/details/:domain' => sub {
|
||||||
|
|
||||||
@ -143,10 +220,28 @@ prefix '/domain' => sub {
|
|||||||
|
|
||||||
my $zone = $app->get_domain(session('login') , param('domain'));
|
my $zone = $app->get_domain(session('login') , param('domain'));
|
||||||
|
|
||||||
template details => {
|
if( param( 'expert' ) )
|
||||||
login => session('login')
|
{
|
||||||
, domain => param('domain')
|
template details => {
|
||||||
, domain_zone => $zone->output() };
|
login => session('login')
|
||||||
|
, domain => param('domain')
|
||||||
|
, domain_zone => $zone->output()
|
||||||
|
, expert => true };
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
# say dump( $zone->cname());
|
||||||
|
template details => {
|
||||||
|
login => session('login')
|
||||||
|
, domain => param('domain')
|
||||||
|
, domain_zone => $zone->output()
|
||||||
|
, a => $zone->a()
|
||||||
|
, aaaa => $zone->aaaa()
|
||||||
|
, cname => $zone->cname()
|
||||||
|
, ptr => $zone->ptr()
|
||||||
|
, mx => $zone->mx()
|
||||||
|
, ns => $zone->ns() };
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,11 +5,107 @@
|
|||||||
|
|
||||||
<h3>Fichier de zone de <% domain %></h3>
|
<h3>Fichier de zone de <% domain %></h3>
|
||||||
|
|
||||||
<form class="form" action='/domain/update/<% domain %>' method="post" >
|
<% IF expert %>
|
||||||
<textarea name="zoneupdated" rows="20" cols="100"><% domain_zone %></textarea>
|
<form class="form" action='/domain/updateraw/<% domain %>' method="post" >
|
||||||
<br />
|
<textarea name="zoneupdated" rows="20" cols="100"><% domain_zone %></textarea>
|
||||||
<input type="submit" value="Mettre à jour la zone" />
|
<br />
|
||||||
</form>
|
<input type="submit" value="Mettre à jour la zone" />
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<a href='/domain/details/<% domain %>' >Easy Mode</a>
|
||||||
|
<% ELSE %>
|
||||||
|
|
||||||
|
<table border=1 >
|
||||||
|
<caption>
|
||||||
|
<td>Name</td>
|
||||||
|
<td>Class</td>
|
||||||
|
<td>Type</td>
|
||||||
|
<td>Host</td>
|
||||||
|
<td>TTL</td>
|
||||||
|
</caption>
|
||||||
|
|
||||||
|
<% FOREACH address in ns %>
|
||||||
|
<tr>
|
||||||
|
<td><% address.name %></td>
|
||||||
|
<td><% address.class %></td>
|
||||||
|
<td>NS</td>
|
||||||
|
<td><% address.host %></td>
|
||||||
|
<td><% address.ttl %></td>
|
||||||
|
</tr>
|
||||||
|
<% END %>
|
||||||
|
|
||||||
|
<% FOREACH address in a %>
|
||||||
|
<tr>
|
||||||
|
<td><% address.name %></td>
|
||||||
|
<td><% address.class %></td>
|
||||||
|
<td>A</td>
|
||||||
|
<td><% address.host %></td>
|
||||||
|
<td><% address.ttl %></td>
|
||||||
|
</tr>
|
||||||
|
<% END %>
|
||||||
|
|
||||||
|
<% FOREACH address in aaaa %>
|
||||||
|
<tr>
|
||||||
|
<td><% address.name %></td>
|
||||||
|
<td><% address.class %></td>
|
||||||
|
<td>AAAA</td>
|
||||||
|
<td><% address.host %></td>
|
||||||
|
<td><% address.ttl %></td>
|
||||||
|
</tr>
|
||||||
|
<% END %>
|
||||||
|
|
||||||
|
<% FOREACH address in cname %>
|
||||||
|
<tr>
|
||||||
|
<td><% address.name %></td>
|
||||||
|
<td><% address.class %></td>
|
||||||
|
<td>CNAME</td>
|
||||||
|
<td><% address.host %></td>
|
||||||
|
<td><% address.ttl %></td>
|
||||||
|
</tr>
|
||||||
|
<% END %>
|
||||||
|
|
||||||
|
<% FOREACH address in ptr %>
|
||||||
|
<tr>
|
||||||
|
<td><% address.name %></td>
|
||||||
|
<td><% address.class %></td>
|
||||||
|
<td>PTR</td>
|
||||||
|
<td><% address.host %></td>
|
||||||
|
<td><% address.ttl %></td>
|
||||||
|
</tr>
|
||||||
|
<% END %>
|
||||||
|
|
||||||
|
<% FOREACH address in mx %>
|
||||||
|
<tr>
|
||||||
|
<td><% address.name %></td>
|
||||||
|
<td><% address.class %></td>
|
||||||
|
<td>MX</td>
|
||||||
|
<td><% address.host %> (<% address.priority %>)</td>
|
||||||
|
<td><% address.ttl %></td>
|
||||||
|
</tr>
|
||||||
|
<% END %>
|
||||||
|
|
||||||
|
</table>
|
||||||
|
<a href='/domain/details/<% domain %>?expert=1'>Expert Mode</a>
|
||||||
|
|
||||||
|
<br /><br />
|
||||||
|
|
||||||
|
Ajouter un enregistrement : <br />
|
||||||
|
<form action='/domain/update/<% domain %>' method='post' >
|
||||||
|
<label for="name">Nom : </label><input type="text" name="name" />
|
||||||
|
<label for="type">Type : </label><select name="type" id="type" >
|
||||||
|
<option value="A">A</option>
|
||||||
|
<option value="AAAA">AAAA</option>
|
||||||
|
<option value="CNAME">CNAME</option>
|
||||||
|
<option value="MX">MX</option>
|
||||||
|
<option value="NS">NS</option>
|
||||||
|
<option value="PTR">PTR</option>
|
||||||
|
</select>
|
||||||
|
<label for="value">Valeur : </label><input type="text" id="value" name="value" />
|
||||||
|
<label for="input_ttl">TTL</label><input type="number" id="input_ttl" name="ttl" min='1' value="3"/>
|
||||||
|
<input type="submit">Valider</input>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<% END %>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user