Handle hostnames with upper-case letters
[webmin.git] / apache / create_dir.cgi
1 #!/usr/local/bin/perl
2 # create_dir.cgi
3 # Create an empty <Directory>, <Files> or <Location> clause
4
5 require './apache-lib.pl';
6 &ReadParse();
7 &error_setup($text{'cdir_err'});
8 ($vconf, $v) = &get_virtual_config($in{'virt'});
9 &can_edit_virt($v) || &error($text{'virt_ecannot'});
10
11 &lock_file($vconf->[0]->{'file'});
12 &before_changing();
13
14 # Validate inputs
15 $in{'path'} || &error($text{'cdir_epath'});
16 $in{'type'} eq 'Proxy' || $in{'type'} eq 'Location' ||
17    &allowed_doc_dir($in{'path'}) || &error($text{'cdir_ecannot'});
18
19 # Create the file structure
20 $dir = { 'type' => 1 };
21 if ($in{'regexp'}) {
22         $in{'type'} eq 'Proxy' && &error($text{'cdir_eproxy'});
23         if ($httpd_modules{'core'} >= 1.3) {
24                 $dir->{'name'} = $in{'type'}."Match";
25                 $dir->{'value'} = "\"$in{'path'}\"";
26                 }
27         else {
28                 $dir->{'name'} = $in{'type'};
29                 $dir->{'value'} = "~ \"$in{'path'}\"";
30                 }
31         }
32 else {
33         $dir->{'name'} = $in{'type'};
34         $dir->{'value'} = "\"$in{'path'}\"";
35         }
36
37 # Add to file
38 &save_directive_struct(undef, $dir, $vconf, $conf);
39 &flush_file_lines();
40 &unlock_file($vconf->[0]->{'file'});
41
42 &after_changing();
43 &webmin_log("dir", "create", &virtual_name($v, 1).":$in{'path'}", \%in);
44 &redirect("virt_index.cgi?virt=$in{'virt'}");
45