Handle hostnames with upper-case letters
[webmin.git] / apache / mod_cache.pl
1 # mod_cache.pl
2 # Functions that have been moved out of mod_proxy in apache 2.0
3
4 sub mod_cache_directives
5 {
6 local $rv;
7 $rv = [ [ 'CacheDefaultExpire', 0, 13.1, 'virtual', 2.0 ],
8         [ 'CacheEnable CacheDisable', 1, 13.1, 'virtual', 2.0 ],
9 #       [ 'CacheIgnoreCacheControl', 0, 13.1, 'virtual', 2.0 ],
10 #       [ 'CacheIgnoreNoLastMod', 0, 13.1, 'virtual', 2.0 ],
11         [ 'CacheLastModifiedFactor', 0, 13.1, 'virtual', 2.0 ],
12         [ 'CacheMaxExpire', 0, 13.1, 'virtual', 2.0 ] ];
13 return &make_directives($rv, $_[0], "mod_cache");
14 }
15
16 require 'cache.pl';
17
18 sub edit_CacheEnable_CacheDisable
19 {
20 local $rv = "<table border>\n".
21             "<tr $tb> <td><b>$text{'cache_enable'}</b></td>\n".
22             "<td><b>$text{'cache_type'}</b></td>\n".
23             "<td><b>$text{'cache_url'}</b></td> </tr>\n";
24 local ($c, $i = 0);
25 foreach $c (@{$_[0]}, @{$_[1]}, { }) {
26         $rv .= "<tr $cb>\n";
27         $rv .= "<td><select name=CacheEnable_e_$i>\n";
28         $rv .= sprintf "<option value=0 %s>&nbsp;\n",
29                         $c ? "" : "selected";
30         $rv .= sprintf "<option value=1 %s>%s\n",
31                         $c->{'name'} eq 'CacheEnable' ? 'selected' : '',
32                         $text{'yes'};
33         $rv .= sprintf "<option value=2 %s>%s\n",
34                         $c->{'name'} eq 'CacheDisable' ? 'selected' : '',
35                         $text{'no'};
36         $rv .= "</select></td> <td><select name=CacheEnable_t_$i>\n";
37         $rv .= sprintf "<option value=disk %s> %s\n",
38                         $c->{'words'}->[0] eq 'disk' ? 'selected' : '',
39                         $text{'cache_disk'};
40         $rv .= sprintf "<option value=mem %s> %s\n",
41                         $c->{'words'}->[0] eq 'mem' ? 'selected' : '',
42                         $text{'cache_mem'};
43         $rv .= "</select></td>\n";
44         $rv .= sprintf "<td><input name=CacheEnable_u_$i size=20 value='%s'></td>\n", $c->{'name'} eq 'CacheEnable' ? $c->{'words'}->[1] : $c->{'words'}->[0];
45         $rv .= "</tr>\n";
46         $i++;
47         }
48 $rv .= "</table>\n";
49 return (2, $text{'cache_endis'}, $rv);
50 }
51 sub save_CacheEnable_CacheDisable
52 {
53 local ($i, @en, @dis);
54 for($i=0; defined($in{"CacheEnable_e_$i"}); $i++) {
55         next if (!$in{"CacheEnable_e_$i"});
56         $in{"CacheEnable_u_$i"} =~ /^\S+$/ || &error($text{'cache_eurl'});
57         if ($in{"CacheEnable_e_$i"} == 1) {
58                 push(@en, $in{"CacheEnable_t_$i"}." ".$in{"CacheEnable_u_$i"});
59                 }
60         else {
61                 push(@dis, $in{"CacheEnable_u_$i"});
62                 }
63         }
64 return ( \@en, \@dis );
65 }
66
67 sub edit_CacheIgnoreCacheControl
68 {
69 return (1, $text{'cache_control'},
70         &choice_input($_[0]->{'value'}, "CacheIgnoreCacheControl", "off",
71                       "$text{'yes'},on", "$text{'no'},off"));
72 }
73 sub save_CacheIgnoreCacheControl
74 {
75 return &parse_choice("CacheIgnoreCacheControl", "off");
76 }
77
78 sub edit_CacheIgnoreNoLastMod
79 {
80 return (1, $text{'cache_lastmod'},
81         &choice_input($_[0]->{'value'}, "CacheIgnoreNoLastMod", "off",
82                       "$text{'yes'},on", "$text{'no'},off"));
83 }
84 sub save_CacheIgnoreNoLastMod
85 {
86 return &parse_choice("CacheIgnoreNoLastMod", "off");
87 }
88