Handle hostnames with upper-case letters
[webmin.git] / webalizer / edit_global.cgi
1 #!/usr/local/bin/perl
2 # edit_global.cgi
3 # Display options from a webalizer.conf file
4
5 require './webalizer-lib.pl';
6 &ReadParse();
7 $access{'view'} && &error($text{'edit_ecannot'});
8 if ($in{'file'}) {
9         &can_edit_log($in{'file'}) || &error($text{'edit_ecannot'});
10         &ui_print_header(undef, $text{'global_title2'}, "");
11         print "<center>",&text('global_for', "<tt>$in{'file'}</tt>"),
12               "</center>\n";
13         }
14 else {
15         $access{'global'} || &error($text{'edit_ecannot'});
16         &ui_print_header(undef, $text{'global_title'}, "");
17         }
18 $conf = &get_config($in{'file'});
19
20 $cfile = &config_file_name($in{'file'}) if ($in{'file'});
21
22 print "<form action=save_global.cgi method=post>\n";
23 print "<input type=hidden name=file value='$in{'file'}'>\n";
24 print "<input type=hidden name=type value='$in{'type'}'>\n";
25 print "<input type=hidden name=custom value='$in{'custom'}'>\n";
26 print "<table border width=100%>\n";
27 print "<tr $tb> <td><b>$text{'global_header'}</b></td> </tr>\n";
28 print "<tr $cb> <td><table width=100%>\n";
29
30 $report = &find_value("ReportTitle", $conf);
31 print "<tr> <td><b>$text{'global_report'}</b></td> <td colspan=3>\n";
32 printf "<input type=radio name=report_def value=1 %s> %s\n",
33         $report ? "" : "checked", $text{'default'};
34 printf "<input type=radio name=report_def value=0 %s>\n",
35         $report ? "checked" : "";
36 printf "<input name=report size=40 value='%s'></td> </tr>\n",
37         &html_escape($report);
38
39 if ($in{'file'}) {
40         $host = &find_value("HostName", $conf);
41         print "<tr> <td><b>$text{'global_host'}</b></td> <td colspan=3>\n";
42         printf "<input type=radio name=host_def value=1 %s> %s\n",
43                 $host ? "" : "checked", $text{'default'};
44         printf "<input type=radio name=host_def value=0 %s>\n",
45                 $host ? "checked" : "";
46         print "<input name=host size=30 value='$host'></td> </tr>\n";
47         }
48
49 @page = &find_value("PageType", $conf);
50 print "<tr> <td><b>$text{'global_page'}</b></td> <td colspan=3>\n";
51 printf "<input name=page size=50 value='%s'></td> </tr>\n",
52         join(" ", @page);
53
54 @index = &find_value("IndexAlias", $conf);
55 print "<tr> <td><b>$text{'global_index'}</b></td> <td colspan=3>\n";
56 printf "<input name=index size=50 value='%s'></td> </tr>\n",
57         join(" ", @index);
58
59 $gmt = &find_value("GMTTime", $conf);
60 print "<tr> <td><b>$text{'global_gmt'}</b></td>\n";
61 printf "<td><input type=radio name=gmt value=1 %s> %s\n",
62         $gmt =~ /^y/i ? "checked" : "", $text{'yes'};
63 printf "<input type=radio name=gmt value=0 %s> %s</td>\n",
64         $gmt =~ /^y/i ? "" : "checked", $text{'no'};
65
66 $fold = &find_value("FoldSeqErr", $conf);
67 print "<td><b>$text{'global_fold'}</b></td>\n";
68 printf "<td><input type=radio name=fold value=1 %s> %s\n",
69         $fold =~ /^y/i ? "checked" : "", $text{'yes'};
70 printf "<input type=radio name=fold value=0 %s> %s</td> </tr>\n",
71         $fold =~ /^y/i ? "" : "checked", $text{'no'};
72
73 $visit = &find_value("VisitTimeout", $conf);
74 print "<tr> <td><b>$text{'global_visit'}</b></td>\n";
75 printf "<td><input type=radio name=visit_def value=1 %s> %s\n",
76         $visit ? "" : "checked", $text{'default'};
77 printf "<input type=radio name=visit_def value=0 %s>\n",
78         $visit ? "checked" : "";
79 printf "<input name=visit size=6 value='%s'> %s</td>\n",
80         $visit, $text{'global_secs'};
81
82 $dns = &find_value("DNSChildren", $conf);
83 print "<td><b>$text{'global_dns'}</b></td>\n";
84 printf "<td><input type=radio name=dns_def value=1 %s> %s\n",
85         $dns ? "" : "checked", $text{'global_none'};
86 printf "<input type=radio name=dns_def value=0 %s>\n",
87         $dns ? "checked" : "";
88 printf "<input name=dns size=6 value='%s'></td> </tr>\n", $dns;
89
90 print "<tr> <td colspan=4><hr></td> </tr>\n";
91
92 $history = &find_value("HistoryName", $conf);
93 print "<tr> <td><b>$text{'global_history'}</b></td> <td colspan=3>\n";
94 printf "<input type=radio name=history_def value=1 %s> %s\n",
95         $history ? "" : "checked", $text{'default'};
96 printf "<input type=radio name=history_def value=0 %s>\n",
97         $history ? "checked" : "";
98 printf "<input name=history size=40 value='%s'></td> </tr>\n",
99         &html_escape($history);
100
101 $current = &find_value("IncrementalName", $conf);
102 print "<tr> <td><b>$text{'global_current'}</b></td> <td colspan=3>\n";
103 printf "<input type=radio name=current_def value=1 %s> %s\n",
104         $current ? "" : "checked", $text{'default'};
105 printf "<input type=radio name=current_def value=0 %s>\n",
106         $current ? "checked" : "";
107 printf "<input name=current size=40 value='%s'></td> </tr>\n",
108         &html_escape($current);
109
110 $cache = &find_value("DNSCache", $conf);
111 print "<tr> <td><b>$text{'global_cache'}</b></td> <td colspan=3>\n";
112 printf "<input type=radio name=cache_def value=1 %s> %s\n",
113         $cache ? "" : "checked", $text{'default'};
114 printf "<input type=radio name=cache_def value=0 %s>\n",
115         $cache ? "checked" : "";
116 printf "<input name=cache size=40 value='%s'></td> </tr>\n",
117         &html_escape($cache);
118
119 print "<tr> <td colspan=4><hr></td> </tr>\n";
120
121 print "<tr> <td valign=top><b>$text{'global_display'}</b></td>\n";
122 print "<td colspan=3><table>\n";
123 $i = 0;
124 foreach $g ('DailyGraph', 'DailyStats', 'HourlyGraph',
125             'HourlyStats', 'CountryGraph', 'GraphLegend') {
126         $v = &find_value($g, $conf);
127         print "<tr>\n" if ($i%2 == 0);
128         printf "<td><input type=checkbox name=%s value=1 %s>%s</td>\n",
129                 $g, $v =~ /^n/i ? "" : "checked", $text{"global_$g"};
130         print "</tr>\n" if ($i++%2 == 1);
131         }
132 print "</table></td> </tr>\n";
133
134 print "<tr> <td valign=top><b>$text{'global_tables'}</b></td>\n";
135 print "<td colspan=3><table width=100%>\n";
136 $i = 0;
137 foreach $t ('TopSites', 'TopKSites', 'TopURLs', 'TopKURLs', 'TopReferrers',
138             'TopAgents', 'TopCountries', 'TopEntry', 'TopExit',
139             'TopSearch', 'TopUsers') {
140         $v = &find_value($t, $conf);
141         print "<tr>\n" if ($i%2 == 0);
142         printf "<td><b>%s</b></td>", $text{"global_$t"};
143         printf "<td nowrap><input type=radio name=%s_def value=1 %s> %s\n",
144                 $t, $v eq "" ? "checked" : "", $text{'default'};
145         printf "<input type=radio name=%s_def value=2 %s> %s\n",
146                 $t, $v eq "0" ? "checked" : "", $text{'global_none'};
147         printf "<input type=radio name=%s_def value=0 %s>\n",
148                 $t, $v ? "checked" : "";
149         printf "<input name=%s size=4 value='%s'></td>\n",
150                 $t, $v ? $v : "";
151         print "</tr>\n" if ($i++%2 == 1);
152         }
153 print "</table></td> </tr>\n";
154
155 print "<tr> <td valign=top><b>$text{'global_all'}</b></td>\n";
156 print "<td colspan=3><table>\n";
157 $i = 0;
158 foreach $a ('AllSites', 'AllURLs', 'AllReferrers', 'AllAgents',
159             'AllSearchStr', 'AllUsers') {
160         $v = &find_value($a, $conf);
161         print "<tr>\n" if ($i%3 == 0);
162         printf "<td><input type=checkbox name=%s value=1 %s>%s</td>\n",
163                 $a, $v =~ /^y/i ? "checked" : "", $text{"global_$a"};
164         print "</tr>\n" if ($i++%3 == 2);
165         }
166 print "</table></td> </tr>\n";
167
168 print "<tr> <td colspan=4><hr></td> </tr>\n";
169
170 foreach $hid ("HideURL", "HideSite", "HideReferrer",
171               "HideUser", "HideAgent") {
172         @hidv = &find_value($hid, $conf);
173         print "<tr> <td><b>",$text{'global_'.lc($hid)},"</b></td> <td colspan=3>\n";
174         printf "<input name=%s size=60 value='%s'></td> </tr>\n",
175                 lc($hid), join(" ", @hidv);
176         }
177
178 print "<tr> <td colspan=4><hr></td> </tr>\n";
179
180 foreach $ign ("IgnoreURL", "IgnoreSite", "IgnoreReferrer",
181               "IgnoreUser", "IgnoreAgent") {
182         @ignv = &find_value($ign, $conf);
183         print "<tr> <td><b>",$text{'global_'.lc($ign)},"</b></td> <td colspan=3>\n";
184         printf "<input name=%s size=60 value='%s'></td> </tr>\n",
185                 lc($ign), join(" ", @ignv);
186         }
187
188 print "<tr> <td colspan=4><hr></td> </tr>\n";
189
190 foreach $inc ("IncludeURL", "IncludeSite", "IncludeReferrer",
191               "IncludeUser", "IncludeAgent") {
192         @incv = &find_value($inc, $conf);
193         print "<tr> <td><b>",$text{'global_'.lc($inc)},"</b></td> <td colspan=3>\n";
194         printf "<input name=%s size=60 value='%s'></td> </tr>\n",
195                 lc($inc), join(" ", @incv);
196         }
197
198 print "</table></td></tr></table>\n";
199 push(@b, "<input type=submit value='$text{'save'}'>");
200 push(@b, "<input type=submit name=delete value='$text{'global_delete'}'>")
201         if ($in{'file'} && -r $cfile);
202 &spaced_buttons(@b);
203 print "</form>\n";
204
205 &ui_print_footer("", $text{'index_return'});
206