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