Handle hostnames with upper-case letters
[webmin.git] / dnsadmin / change_soa.cgi
1 #!/usr/local/bin/perl
2 # change_soa.cgi
3 # Saves changes to the SOA record from edit_primary.cgi
4
5 require './dns-lib.pl';
6 $whatfailed = "Failed to save domain";
7 &ReadParse();
8 $d = $in{domain};
9
10 # Get the domain being edited
11 &get_primary($d);
12 for($i=0; $i<@name; $i++) {
13         if ($type[$i] eq "SOA") { $soa = $i; last; }
14         }
15
16 # Check user inputs
17 $in{serv} =~ /^[A-Za-z0-9\-\_\.]+$/ ||
18         &error("$in{serv} is not a valid server hostname");
19 $in{serv} = &make_full($in{serv}, "$d.");
20 $in{mail} =~ /^[A-Za-z0-9\-\_\.]+\@[A-Za-z0-9\-\_\.]+$/ ||
21         &error("$in{mail} doesn't look like a valid email address");
22 $in{mail} =~ s/\@/\./g; $in{mail} .= ".";
23 $in{refresh} =~ /^[0-9]+$/ ||
24         &error("$in{refresh} is not a valid refresh period");
25 $in{retry} =~ /^[0-9]+$/ ||
26         &error("$in{retry} is not a valid retry period");
27 $in{expire} =~ /^[0-9]+$/ ||
28         &error("$in{expire} is not a valid expire time");
29 $in{min} =~ /^[0-9]+$/ ||
30         &error("$in{min} is not a valid minumum TTL");
31
32 # Save and bounce back
33 $data[$soa] = "$in{serv} $in{mail} $in{serial} $in{refresh} $in{retry} $in{expire} $in{min}";
34 &save_primary($d);
35 &redirect("edit_primary.cgi?$d");
36