From 8ebd61261f182098f67299fbf376889922c154ac Mon Sep 17 00:00:00 2001 From: Julien Simonet Date: Mon, 20 Jan 2014 19:45:48 +0100 Subject: [PATCH 1/2] Ajout du TLD contenu dans le fichier de configuration. Suppression des possibles "point" doublons. - si l'utilisateur entre "mondomaine." par exempe. --- www/conf/config.ini | 11 +++++++++-- www/lib/DNSManager.pm | 4 ++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/www/conf/config.ini b/www/conf/config.ini index f4d9df0..3772c75 100644 --- a/www/conf/config.ini +++ b/www/conf/config.ini @@ -1,11 +1,18 @@ +# TLD +# Must contains the first "." +tld = ".netlib.re" + +# Database Options +sgbd = mysql dbname = dnsmanager host = localhost -# other options : see DBI module -sgbd = mysql + # default port for mysql port = 3306 user = bla passwd = HardPass4bla +# other options : see DBI module + # possible options for dnsserver : bind rndc dnsapp = rndc zones_path = "/srv/named/" diff --git a/www/lib/DNSManager.pm b/www/lib/DNSManager.pm index 193e9a6..592a196 100644 --- a/www/lib/DNSManager.pm +++ b/www/lib/DNSManager.pm @@ -137,6 +137,10 @@ prefix '/domain' => sub { else { + # Add tld + my $domain = param('domain').$cfg->param('tld'); + $domain =~ s/\.{2,}/\./g; + # create domain my $app = initco(); $app->add_domain( session('login'), param('domain') ); redirect '/home'; From c44fb8653b10cb4c168c5ae77294bf0f302fde14 Mon Sep 17 00:00:00 2001 From: Julien Simonet Date: Tue, 21 Jan 2014 00:16:26 +0100 Subject: [PATCH 2/2] =?UTF-8?q?Nouvel=20affichage=20concernant=20la=20cr?= =?UTF-8?q?=C3=A9ation=20d'une=20zone.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Un message indique si la zone a été créée ou non. - Le if/else de la page mapage.tt n'a pas beaucoup d'intérêt dans l'état actuel des choses. Il servira lorsqu'on qu'on voudra faire la mise en page (avec une mise en page différente en case de succès ou d'échec). Suppression de mapage.tt --- www/lib/DNSManager.pm | 68 ++++++++++++++++++++++++++++++++++--------- www/views/home.tt | 11 +++++++ 2 files changed, 65 insertions(+), 14 deletions(-) diff --git a/www/lib/DNSManager.pm b/www/lib/DNSManager.pm index 592a196..ece6160 100644 --- a/www/lib/DNSManager.pm +++ b/www/lib/DNSManager.pm @@ -67,15 +67,35 @@ get '/home' => sub { my %domains = (); my %zone_properties = (); - 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') }; + # my @d = @{$app->get_domains( session('login') )}; + 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,12 +157,32 @@ prefix '/domain' => sub { else { - # Add tld - my $domain = param('domain').$cfg->param('tld'); - $domain =~ s/\.{2,}/\./g; - # create domain - my $app = initco(); - $app->add_domain( session('login'), param('domain') ); + my $creationSuccess = false; + 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'; } diff --git a/www/views/home.tt b/www/views/home.tt index 6de350c..896488f 100644 --- a/www/views/home.tt +++ b/www/views/home.tt @@ -16,6 +16,17 @@
+ + <% IF creationSuccess == 1 %> +

+ Le domaine "<% domainName %>" a bien été créée. +

+ <% ELSIF creationFailure == 1 %> +

+ Le domaine "<% domainName %>" n'a pas été créée. +

+ <% END %> + <% IF domains && domains.size %>

Vos domaines :