Handle hostnames with upper-case letters
[webmin.git] / apache / change_files.cgi
1 #!/usr/local/bin/perl
2 # change_files.cgi
3 # Modify or delete a <Files> clause in a .htaccess file
4
5 require './apache-lib.pl';
6 &ReadParse();
7 $access{'global'} || &error($text{'htaccess_ecannot'});
8 &allowed_auth_file($in{'file'}) ||
9         &error($text{'htindex_ecannot'});
10 $hconf = &get_htaccess_config($in{'file'});
11 $d = $hconf->[$in{'idx'}];
12 &lock_file($d->{'file'});
13 &before_changing();
14
15 if ($in{'delete'}) {
16         # deleting a directive
17         &save_directive_struct($d, undef, $hconf, $hconf);
18         }
19 else {
20         # changing a directive
21         if ($in{'regexp'}) {
22                 if ($httpd_modules{'core'} >= 1.3) {
23                         $d->{'name'} = 'FilesMatch';
24                         $d->{'value'} = "\"$in{'path'}\"";
25                         }
26                 else {
27                         $d->{'name'} = 'Files';
28                         $d->{'value'} = "~ \"$in{'path'}\"";
29                         }
30                 }
31         else {
32                 $d->{'name'} = 'Files';
33                 $d->{'value'} = "\"$in{'path'}\"";
34                 }
35         &save_directive_struct($d, $d, $hconf, $hconf, 1);
36         }
37 &flush_file_lines();
38 &unlock_file($d->{'file'});
39 &after_changing();
40
41 &webmin_log("files", $in{'delete'} ? 'delete' : 'save',
42             "$in{'file'}:$d->{'words'}->[0]", \%in);
43 &redirect("htaccess_index.cgi?file=".&urlize($in{'file'}));
44