Handle hostnames with upper-case letters
[webmin.git] / proftpd / create_virt.cgi
1 #!/usr/local/bin/perl
2 # create_virt.cgi
3 # Create a new virtual server
4
5 require './proftpd-lib.pl';
6 &ReadParse();
7 $conf = &get_config();
8 &error_setup($text{'vserv_err'});
9
10 # Validate inputs
11 $in{'addr_def'} || &to_ipaddress($in{'addr'}) ||
12     &to_ip6address($in{'addr'}) ||
13         &error($text{'vserv_eaddr'});
14 $in{'Port_def'} || $in{'Port'} =~ /^\d+$/ ||
15         &error($text{'vserv_eport'});
16 $in{'ServerName_def'} || $in{'ServerName'} =~ /\S/ ||
17         &error($text{'vserv_ename'});
18
19 # Add the virtual host
20 $l = $conf->[@$conf - 1];
21 $addfile = $config{'add_file'} || $l->{'file'};
22 &lock_file($addfile);
23 &before_changing();
24 $lref = &read_file_lines($addfile);
25 @lines = ( "<VirtualHost $in{'addr'}>" );
26 push(@lines, "Port $in{'Port'}") if (!$in{'Port_def'});
27 push(@lines, "ServerName \"$in{'ServerName'}\"") if (!$in{'ServerName_def'});
28 push(@lines, "</VirtualHost>");
29 push(@$lref, @lines);
30 &flush_file_lines($addfile);
31 &after_changing();
32 &unlock_file($addfile);
33 &webmin_log("virt", "create", $in{'addr'}, \%in);
34
35 &redirect("virt_index.cgi?virt=".scalar(@$conf));
36