3
0

Merge branch 'features/ajoutTld'

This commit is contained in:
Julien Simonet 2014-01-21 21:50:19 +01:00
commit 33305b7901
3 changed files with 74 additions and 12 deletions

View File

@ -1,11 +1,18 @@
# TLD
# Must contains the first "."
tld = ".netlib.re"
# Database Options
sgbd = mysql
dbname = dnsmanager dbname = dnsmanager
host = localhost host = localhost
# other options : see DBI module
sgbd = mysql
# default port for mysql # default port for mysql
port = 3306 port = 3306
user = bla user = bla
passwd = HardPass4bla passwd = HardPass4bla
# other options : see DBI module
# possible options for dnsserver : bind rndc # possible options for dnsserver : bind rndc
dnsapp = rndc dnsapp = rndc
zones_path = "/srv/named/" zones_path = "/srv/named/"

View File

@ -67,15 +67,35 @@ get '/home' => sub {
my %domains = (); my %domains = ();
my %zone_properties = (); my %zone_properties = ();
my @d = @{$app->get_domains( session('login') )}; # my @d = @{$app->get_domains( session('login') )};
template home => {
login => session('login')
, domains => $app->get_domains(session('login'))
, zones_domains => \%domains
, zone_properties => \%zone_properties
, admin => session('admin') };
if( session('creationSuccess') || session('creationFailure') )
{
my $cs = session('creationSuccess');
session 'creationSuccess' => '';
my $cf = session('creationFailure');
session 'creationFailure' => '';
my $dn = session('domainName');
session 'domainName' => '';
template home =>
{ 'login' => session('login'),
'domains' => $app->get_domains(session('login')),
'zones_domains' => \%domains,
'zone_properties' => \%zone_properties,
'admin' => session('admin'),
'creationSuccess' => $cs,
'creationFailure' => $cf,
'domainName' => $dn };
}
else
{
template home =>
{ 'login' => session('login'),
'domains' => $app->get_domains(session('login')),
'zones_domains' => \%domains,
'zone_properties' => \%zone_properties,
'admin' => session('admin') };
}
} }
}; };
@ -137,8 +157,32 @@ prefix '/domain' => sub {
else else
{ {
my $app = initco(); my $creationSuccess = false;
$app->add_domain( session('login'), param('domain') ); my $creationFailure = false;
if( param('domain') =~ /^[a-zA-Z0-9]+[a-zA-Z0-9-]+[a-zA-Z0-9]+$|^[a-zA-Z0-9]+$/ )
{
my $cfg = new Config::Simple(dirname(__FILE__).'/../conf/config.ini');
my $domain = param('domain').$cfg->param('tld');
# $domain =~ s/\.{2,}/\./g;
# say "domain after sed : $domain";
# create domain
my $app = initco();
# Add tld
# create domain
$app->add_domain( session('login'), $domain );
$creationSuccess = true;
}
else
{
# say param('domain')." contains a char not valid";
$creationFailure = true;
}
session 'creationSuccess' => $creationSuccess;
session 'creationFailure' => $creationFailure;
session 'domainName' => param('domain');
redirect '/home'; redirect '/home';
} }

View File

@ -16,6 +16,17 @@
<div id="page"> <div id="page">
<!-- Permettra une mise en forme plus propre. -->
<% IF creationSuccess == 1 %>
<p>
Le domaine "<% domainName %>" a bien été créée.
</p>
<% ELSIF creationFailure == 1 %>
<p>
Le domaine "<% domainName %>" n'a pas été créée.
</p>
<% END %>
<% IF domains && domains.size %> <% IF domains && domains.size %>
<h3>Vos domaines :</h3> <h3>Vos domaines :</h3>
<br /> <br />