Handle hostnames with upper-case letters
[webmin.git] / proftpd / create_dir.cgi
1 #!/usr/local/bin/perl
2 # create_dir.cgi
3 # Add a new <Directory> section to a virtual server
4
5 require './proftpd-lib.pl';
6 &ReadParse();
7 if ($in{'global'}) {
8         $conf = &get_config();
9         $conf = &get_or_create_global($conf);
10         }
11 else {
12         ($conf, $v) = &get_virtual_config($in{'virt'});
13         }
14 if ($in{'anon'}) {
15         $anon = &find_directive_struct("Anonymous", $conf);
16         $conf = $anon->{'members'};
17         }
18 &error_setup($text{'dserv_err'});
19
20 # Validate inputs
21 $in{'dir'} =~ /^\S+$/ || &error($text{'dserv_edir'});
22 !$anon || $in{'dir'} !~ /^\// || $anon->{'value'} =~ /^\~/ ||
23         &is_under_directory($anon->{'value'}, $in{'dir'}) ||
24                 &error($text{'dserv_eanondir'});
25
26 # Add the directory
27 $l = $conf->[@$conf - 1];
28 &lock_file($l->{'file'});
29 &before_changing();
30 $lref = &read_file_lines($l->{'file'});
31 @lines = ( "<Directory $in{'dir'}>", "</Directory>" );
32 splice(@$lref, $l->{'eline'}+1, 0, @lines);
33 &flush_file_lines();
34 &after_changing();
35 &unlock_file($l->{'file'});
36 &webmin_log("dir", "create", "$v->{'value'}:$in{'dir'}", \%in);
37 &redirect("dir_index.cgi?virt=$in{'virt'}&anon=$in{'anon'}&global=$in{'global'}&idx=".scalar(@$conf));
38