Handle hostnames with upper-case letters
[webmin.git] / apache / htaccess_index.cgi
1 #!/usr/local/bin/perl
2 # htaccess_index.cgi
3 # Display a menu of icons for a per-directory options 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 $conf = &get_htaccess_config($in{'file'});
11 $desc = &html_escape($in{'file'});
12 &ui_print_header($desc, $text{'htindex_title'}, "",
13         undef, undef, undef, undef, "<a href=\"delete_htaccess.cgi?file=".
14         &urlize($in{'file'})."\">$text{'htindex_delete'}</a>");
15
16 $sw_icon = { "icon" => "images/show.gif",
17              "name" => $text{'htindex_show'},
18              "link" => "show.cgi?file=".&urlize($in{'file'}) };
19 if ($access{'types'} eq '*') {
20         $ed_icon = { "icon" => "images/edit.gif",
21                      "name" => $text{'htindex_edit'},
22                      "link" => "manual_form.cgi?file=".&urlize($in{'file'}) };
23         }
24 &config_icons("htaccess", "edit_htaccess.cgi?file=".&urlize($in{'file'})."&",
25               $sw_icon, $ed_icon ? ( $ed_icon ) : ( ));
26
27 @file = ( &find_directive_struct("Files", $conf),
28           &find_directive_struct("FilesMatch", $conf) );
29 if (@file && $httpd_modules{'core'} >= 1.2) {
30         # Files sub-directives
31         print &ui_hr();
32         print &ui_subheading($text{'htindex_file'});
33         foreach $f (@file) {
34                 $what = &dir_name($f);
35                 substr($what, 0, 1) = uc(substr($what, 0, 1));
36                 push(@links, "files_index.cgi?idx=".&indexof($f, @$conf).
37                              "&file=".&urlize($in{'file'}));
38                 push(@titles, $what);
39                 push(@icons, "images/dir.gif");
40                 push(@types, $f->{'name'});
41                 }
42         if ($config{'show_list'}) {
43                 # Show as list
44                 print &ui_columns_start([ $text{'virt_path'},
45                                           $text{'virt_type'} ]);
46                 for($i=0; $i<@links; $i++) {
47                         print &ui_columns_row([
48                           "<a href='$links[$i]'>$titles[$i]</a>",
49                           $text{'virt_'.$types[$i]} ]);
50                         }
51                 print &ui_columns_end();
52                 }
53         else {
54                 &icons_table(\@links, \@titles, \@icons, 3);
55                 }
56         print "<p>\n";
57         }
58
59 if ($httpd_modules{'core'} >= 1.2) {
60         print &ui_form_start("create_files.cgi");
61         print &ui_hidden("file", $in{'file'});
62         print &ui_table_start($text{'htindex_create'}, undef, 2);
63
64         print &ui_table_row($text{'htindex_regexp'},
65                 &ui_radio("regexp", 0,
66                           [ [ 0, $text{'htindex_exact'} ],
67                             [ 1, $text{'htindex_re'} ] ]));
68
69         print &ui_table_row($text{'htindex_path'},
70                 &ui_textbox("path", undef, 50));
71
72         print &ui_table_end();
73         print &ui_form_end([ [ undef, $text{'create'} ] ]);
74         }
75
76 &ui_print_footer("htaccess.cgi", $text{'htaccess_return'});
77
78