From d24074fdc92e940eca10341092e4dd5b811d661f Mon Sep 17 00:00:00 2001 From: Philippe Pittoli Date: Thu, 8 May 2014 19:42:38 +0200 Subject: [PATCH] reserved zones --- www/lib/DNSManager.pm | 22 +++++++++++++++++++++- www/lib/reserved.zone | 1 + 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 www/lib/reserved.zone diff --git a/www/lib/DNSManager.pm b/www/lib/DNSManager.pm index 56ae0e0..2c9509b 100755 --- a/www/lib/DNSManager.pm +++ b/www/lib/DNSManager.pm @@ -28,6 +28,22 @@ sub is_domain_name { return $dn =~ $ndd; } +sub is_reserved { + my ($domain) = @_; + + my $filename = "reserved.zone"; + open my $entree, '<:encoding(UTF-8)', $filename or + die "Impossible d'ouvrir '$filename' en lecture : $!"; + + while(<$entree>) { + if(m/^$domain$/) { + return 1; + } + } + + return 0; +} + # eventually change place sub initco { @@ -301,7 +317,11 @@ prefix '/domain' => sub { my $creationSuccess = ''; - if( param('domain') =~ /^[a-zA-Z0-9]+[a-zA-Z0-9-]+[a-zA-Z0-9]+$|^[a-zA-Z0-9]+$/ ) + if(is_reserved(param('domain'))) { + session errmsg => + q{Le nom de domaine est réservé}; + } + elsif( 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'); diff --git a/www/lib/reserved.zone b/www/lib/reserved.zone new file mode 100644 index 0000000..f8d728c --- /dev/null +++ b/www/lib/reserved.zone @@ -0,0 +1 @@ +www