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